diff --git a/.gitignore b/.gitignore index aa4a3a5c4..a2acf29c3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ tags # Project-specific ignores *.z64 +*.sra *.bin *.elf archive/ diff --git a/Jenkinsfile b/Jenkinsfile index cf5d8f3b6..3ebfd3614 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,10 @@ pipeline { label 'mm' } + options { + ansiColor('xterm') + } + stages { stage('Check formatting') { steps { @@ -10,6 +14,12 @@ pipeline { sh 'bash -c "tools/check_format.sh 2>&1 >(tee tools/check_format.txt)"' } } + stage('Check relocs') { + steps { + echo 'Checking relocs on spec...' + sh 'bash -c "tools/reloc_spec_check.sh"' + } + } stage('Copy ROM') { steps { echo 'Setting up ROM...' diff --git a/Makefile b/Makefile index 98aa5b1b4..7326b88a7 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,9 @@ ifeq ($(NON_MATCHING),1) COMPARE := 0 endif +DISASM_FLAGS := --reg-names=o32 ifneq ($(FULL_DISASM), 0) - DISASM_FLAGS += --full + DISASM_FLAGS += --all endif PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -72,6 +73,9 @@ AS := $(MIPS_BINUTILS_PREFIX)as LD := $(MIPS_BINUTILS_PREFIX)ld 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 IINC := -Iinclude -Isrc -Iassets -Ibuild -I. @@ -98,6 +102,9 @@ MIPS_VERSION := -mips2 # we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff. CFLAGS += -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINC) -nostdinc -Wab,-r4300_mul -woff 624,649,838,712 +# Use relocations and abi fpr names in the dump +OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 + ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU export QEMU_GUEST_BASE := 1 @@ -133,6 +140,8 @@ ASM_DIRS := $(shell find asm -type d -not -path "asm/non_matchings*") $(shell fi ## Assets binaries (PNGs, JPGs, etc) ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*") +# Prevents building C files that will be #include'd +ASSET_BIN_DIRS_C_FILES := $(shell find assets/* -type d -not -path "assets/xml*" -not -path "assets/code*" -not -path "assets/overlays*") ASSET_FILES_XML := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.xml)) ASSET_FILES_BIN := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.bin)) @@ -144,7 +153,7 @@ TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg)) TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \ $(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),build/$f) \ -C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS),$(wildcard $(dir)/*.c)) +C_FILES := $(foreach dir,$(SRC_DIRS) $(ASSET_BIN_DIRS_C_FILES),$(wildcard $(dir)/*.c)) S_FILES := $(shell grep -F "build/asm" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') \ $(shell grep -F "build/data" spec | sed 's/.*build\/// ; s/\.o\".*/.s/') BASEROM_FILES := $(shell grep -F "build/baserom" spec | sed 's/.*build\/// ; s/\.o\".*//') @@ -174,7 +183,8 @@ build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 build/src/code/audio/%.o: OPTFLAGS := -O2 -build/assets/%.o: OPTFLAGS := +build/assets/%.o: OPTFLAGS := -O1 +build/assets/%.o: ASM_PROC_FLAGS := # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv @@ -191,19 +201,19 @@ build/src/libultra/libc/llcvt.o: OPTFLAGS := -O1 build/src/libultra/libc/llcvt.o: MIPS_VERSION := -mips3 -32 # cc & asm-processor -build/src/boot_O2/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- +build/src/boot_O2_g3/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- -build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- +build/src/libultra/%.o: CC := $(CC_OLD) +# Needed at least until voice is decompiled +build/src/libultra/voice/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC_OLD) -- $(AS) $(ASFLAGS) -- -build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/code/audio/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/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/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/fbdemos/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/gamestates/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- -build/src/overlays/kaleido_scope/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/overlays/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- + +build/assets/%.o: CC := $(ASM_PROC) $(ASM_PROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) -- #### Main Targets ### @@ -298,7 +308,7 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) # TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if # the following is moved to a separate rule that is only run once when all the required objects have been compiled. $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s @@ -308,21 +318,21 @@ build/src/overlays/%.o: src/overlays/%.c build/src/%.o: src/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/ll.o: src/libultra/libc/ll.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) build/src/libultra/libc/llcvt.o: src/libultra/libc/llcvt.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< python3 tools/set_o32abi_bit.py $@ - @$(OBJDUMP) -d $@ > $(@:.o=.s) + @$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(RM_MDEBUG) # Build C files from assets diff --git a/README.md b/README.md index 845a10cc6..c3ce27e97 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ We recommend using Debian or Ubuntu 20.04 Linux distributions. ### MacOS -Preparation is covered in a [separate document](docsBUILDING_MACOS.md). +Preparation is covered in a [separate document](docs/BUILDING_MACOS.md). ### Linux (Native or under WSL / VM) @@ -74,13 +74,7 @@ sudo apt update sudo apt install make git build-essential binutils-mips-linux-gnu python3 python3-pip libpng-dev ``` -To install the Python dependencies simply run in a terminal: - -```bash -python3 -m pip install -r requirements.txt -``` - -#### 2. Fork the repository +#### 2. Clone the repository Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then clone your fork where you wish to have the project, with the command: @@ -88,11 +82,27 @@ Create your own fork of the repository at `https://github.com/zeldaret/mm`. Then git clone https://github.com//mm.git ``` -#### 3. Prepare a base ROM +This will copy the GitHub repository contents into a new folder in the current directory called `mm`. Change into this directory before doing anything else: + +```bash +cd mm +``` + +#### 3. Install python dependencies + +The build process has a few python packages required that are located in `requirements.txt`. + +To install them simply run in a terminal: + +```bash +python3 -m pip install -r requirements.txt +``` + +#### 4. Prepare a base ROM Copy your ROM to inside the root of this new project directory, and rename the file of the baserom to reflect the version of ROM you are using. ex: `baserom.mm.us.rev1.z64` -#### 4. Make and Build the ROM +#### 5. Make and Build the ROM To start the extraction/build process, run the following command: diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml new file mode 100644 index 000000000..d48335ec7 --- /dev/null +++ b/assets/xml/code/sub_s.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 70f9d606b..9d5a9901a 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -14,20 +14,20 @@ - - + + - - + + - - - - - - - + + + + + + + @@ -59,15 +59,15 @@ - + - + - - - - - + + + + + @@ -75,15 +75,19 @@ + + - - - - + + + + + + diff --git a/assets/xml/objects/gameplay_field_keep.xml b/assets/xml/objects/gameplay_field_keep.xml index 537d596a6..45fa3eccd 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -12,26 +12,26 @@ - - - - - - - - + + + + + + + + - - - + + + - + @@ -40,8 +40,8 @@ - - + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index 4ca6f2c4f..86f48d61d 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -38,7 +38,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -838,8 +838,11 @@ - - + + + + + @@ -870,9 +873,9 @@ - - - + + + @@ -882,8 +885,8 @@ - - + + @@ -892,23 +895,23 @@ - + - + - - - - - - + + + + + + @@ -935,7 +938,7 @@ - + @@ -1000,7 +1003,7 @@ - + @@ -1082,7 +1085,7 @@ - + @@ -1108,13 +1111,13 @@ - - + + - - + + @@ -1169,8 +1172,8 @@ - - + + @@ -1259,7 +1262,8 @@ - + + @@ -1268,7 +1272,8 @@ - + + @@ -1316,15 +1321,18 @@ - - - - - - + + + + + + + + + - + @@ -1350,7 +1358,8 @@ - + + @@ -1381,7 +1390,8 @@ - + + @@ -1402,23 +1412,28 @@ - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_ah.xml b/assets/xml/objects/object_ah.xml index 296347dac..3644f2a90 100644 --- a/assets/xml/objects/object_ah.xml +++ b/assets/xml/objects/object_ah.xml @@ -37,22 +37,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ahg.xml b/assets/xml/objects/object_ahg.xml index c636f0baa..7d4c2c741 100644 --- a/assets/xml/objects/object_ahg.xml +++ b/assets/xml/objects/object_ahg.xml @@ -33,21 +33,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_al.xml b/assets/xml/objects/object_al.xml index 7a2ff1a52..d0f6a6cbb 100644 --- a/assets/xml/objects/object_al.xml +++ b/assets/xml/objects/object_al.xml @@ -39,33 +39,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_am.xml b/assets/xml/objects/object_am.xml index c135b7b0b..b0737cb50 100644 --- a/assets/xml/objects/object_am.xml +++ b/assets/xml/objects/object_am.xml @@ -1,8 +1,8 @@  - - + + @@ -21,21 +21,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_an1.xml b/assets/xml/objects/object_an1.xml index c2ae65d8b..2c212923d 100644 --- a/assets/xml/objects/object_an1.xml +++ b/assets/xml/objects/object_an1.xml @@ -35,15 +35,22 @@ - + - + - + + + + + + + + @@ -54,27 +61,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_and.xml b/assets/xml/objects/object_and.xml index 269e2a73f..17cff4597 100644 --- a/assets/xml/objects/object_and.xml +++ b/assets/xml/objects/object_and.xml @@ -42,32 +42,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ani.xml b/assets/xml/objects/object_ani.xml index f9915c880..f039e0114 100644 --- a/assets/xml/objects/object_ani.xml +++ b/assets/xml/objects/object_ani.xml @@ -1,62 +1,67 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_aob.xml b/assets/xml/objects/object_aob.xml index dcdb75748..3325e9b53 100644 --- a/assets/xml/objects/object_aob.xml +++ b/assets/xml/objects/object_aob.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_az.xml b/assets/xml/objects/object_az.xml index c192f6914..d4382673f 100644 --- a/assets/xml/objects/object_az.xml +++ b/assets/xml/objects/object_az.xml @@ -27,30 +27,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -98,30 +98,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bai.xml b/assets/xml/objects/object_bai.xml index ad8d8445b..4225bec84 100644 --- a/assets/xml/objects/object_bai.xml +++ b/assets/xml/objects/object_bai.xml @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bal.xml b/assets/xml/objects/object_bal.xml index e564a4798..a16e2fb1f 100644 --- a/assets/xml/objects/object_bal.xml +++ b/assets/xml/objects/object_bal.xml @@ -36,39 +36,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bb.xml b/assets/xml/objects/object_bb.xml index ba3e4cb94..3bd04c90e 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -1,37 +1,47 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bba.xml b/assets/xml/objects/object_bba.xml index b172e9f77..144c685e4 100644 --- a/assets/xml/objects/object_bba.xml +++ b/assets/xml/objects/object_bba.xml @@ -1,56 +1,82 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bdoor.xml b/assets/xml/objects/object_bdoor.xml index d74f4aa57..a57339f3b 100644 --- a/assets/xml/objects/object_bdoor.xml +++ b/assets/xml/objects/object_bdoor.xml @@ -3,7 +3,7 @@ - + diff --git a/assets/xml/objects/object_bee.xml b/assets/xml/objects/object_bee.xml index b2c90324b..8f1d704cf 100644 --- a/assets/xml/objects/object_bee.xml +++ b/assets/xml/objects/object_bee.xml @@ -14,15 +14,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_bg.xml b/assets/xml/objects/object_bg.xml index 554047b44..0602f987d 100644 --- a/assets/xml/objects/object_bg.xml +++ b/assets/xml/objects/object_bg.xml @@ -28,30 +28,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -84,29 +84,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bh.xml b/assets/xml/objects/object_bh.xml index d54e99e23..84f3050c0 100644 --- a/assets/xml/objects/object_bh.xml +++ b/assets/xml/objects/object_bh.xml @@ -8,11 +8,11 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_bigokuta.xml b/assets/xml/objects/object_bigokuta.xml index 653853c92..21ead0501 100644 --- a/assets/xml/objects/object_bigokuta.xml +++ b/assets/xml/objects/object_bigokuta.xml @@ -34,25 +34,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bji.xml b/assets/xml/objects/object_bji.xml index cd953541c..b41ac1546 100644 --- a/assets/xml/objects/object_bji.xml +++ b/assets/xml/objects/object_bji.xml @@ -36,22 +36,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bjt.xml b/assets/xml/objects/object_bjt.xml index 9f0c0edc2..6266711ab 100644 --- a/assets/xml/objects/object_bjt.xml +++ b/assets/xml/objects/object_bjt.xml @@ -12,12 +12,12 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_bob.xml b/assets/xml/objects/object_bob.xml index 968a838d2..f942c84db 100644 --- a/assets/xml/objects/object_bob.xml +++ b/assets/xml/objects/object_bob.xml @@ -1,21 +1,21 @@  - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boj.xml b/assets/xml/objects/object_boj.xml index f0272cdc0..ed42d9031 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -20,7 +20,9 @@ - + + + @@ -58,22 +60,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss01.xml b/assets/xml/objects/object_boss01.xml index a9865a096..6a10080a3 100644 --- a/assets/xml/objects/object_boss01.xml +++ b/assets/xml/objects/object_boss01.xml @@ -62,58 +62,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -163,27 +163,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index fee15d4a0..0370e1ae2 100644 --- a/assets/xml/objects/object_boss02.xml +++ b/assets/xml/objects/object_boss02.xml @@ -34,19 +34,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -71,29 +71,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss03.xml b/assets/xml/objects/object_boss03.xml index 5cf4ad2b8..75ce1d3c9 100644 --- a/assets/xml/objects/object_boss03.xml +++ b/assets/xml/objects/object_boss03.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + diff --git a/assets/xml/objects/object_boss04.xml b/assets/xml/objects/object_boss04.xml index d24ad986a..d5d0f728a 100644 --- a/assets/xml/objects/object_boss04.xml +++ b/assets/xml/objects/object_boss04.xml @@ -17,14 +17,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_boss05.xml b/assets/xml/objects/object_boss05.xml index ec994d824..b401ae2be 100644 --- a/assets/xml/objects/object_boss05.xml +++ b/assets/xml/objects/object_boss05.xml @@ -15,16 +15,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -53,26 +53,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss07.xml b/assets/xml/objects/object_boss07.xml index aa0ef8c88..15a2e162d 100644 --- a/assets/xml/objects/object_boss07.xml +++ b/assets/xml/objects/object_boss07.xml @@ -23,31 +23,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -98,25 +98,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -157,34 +157,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss_hakugin.xml b/assets/xml/objects/object_boss_hakugin.xml index 52a124fec..62d6fb91f 100644 --- a/assets/xml/objects/object_boss_hakugin.xml +++ b/assets/xml/objects/object_boss_hakugin.xml @@ -41,39 +41,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index 39d21765f..fb1fb3fd5 100644 --- a/assets/xml/objects/object_box.xml +++ b/assets/xml/objects/object_box.xml @@ -17,11 +17,11 @@ - - - - - + + + + + @@ -29,21 +29,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bsb.xml b/assets/xml/objects/object_bsb.xml index ddaadc33d..7ccf12bce 100644 --- a/assets/xml/objects/object_bsb.xml +++ b/assets/xml/objects/object_bsb.xml @@ -52,27 +52,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cne.xml b/assets/xml/objects/object_cne.xml index 72447ceec..fccbf539f 100644 --- a/assets/xml/objects/object_cne.xml +++ b/assets/xml/objects/object_cne.xml @@ -1,47 +1,54 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cow.xml b/assets/xml/objects/object_cow.xml index 390c54b36..535d5dd85 100644 --- a/assets/xml/objects/object_cow.xml +++ b/assets/xml/objects/object_cow.xml @@ -1,38 +1,57 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index b3b004cd7..de51da580 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -1,24 +1,24 @@  - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 65cff1d46..803d2b02c 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -20,7 +20,7 @@ - + @@ -62,34 +62,34 @@ - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dai.xml b/assets/xml/objects/object_dai.xml index c39ef9a6d..f613a9ab8 100644 --- a/assets/xml/objects/object_dai.xml +++ b/assets/xml/objects/object_dai.xml @@ -63,24 +63,24 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_daiku.xml b/assets/xml/objects/object_daiku.xml index 0c42532ec..57124bd28 100644 --- a/assets/xml/objects/object_daiku.xml +++ b/assets/xml/objects/object_daiku.xml @@ -49,23 +49,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_death.xml b/assets/xml/objects/object_death.xml index 2aba9582d..7d3e1e596 100644 --- a/assets/xml/objects/object_death.xml +++ b/assets/xml/objects/object_death.xml @@ -54,28 +54,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dekubaba.xml b/assets/xml/objects/object_dekubaba.xml index bd59555c4..b82cfb94b 100644 --- a/assets/xml/objects/object_dekubaba.xml +++ b/assets/xml/objects/object_dekubaba.xml @@ -13,14 +13,14 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_dekunuts.xml b/assets/xml/objects/object_dekunuts.xml index 442dc756d..2e9529d4c 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -18,16 +18,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_dinofos.xml b/assets/xml/objects/object_dinofos.xml index 83eade0da..7b1ff8c20 100644 --- a/assets/xml/objects/object_dinofos.xml +++ b/assets/xml/objects/object_dinofos.xml @@ -41,27 +41,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dmask.xml b/assets/xml/objects/object_dmask.xml index f2411c147..a7b3874ec 100644 --- a/assets/xml/objects/object_dmask.xml +++ b/assets/xml/objects/object_dmask.xml @@ -2,15 +2,18 @@ - + + - + + - + + @@ -19,6 +22,7 @@ - + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index 0d290f19d..4e07a455c 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -1,50 +1,50 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dno.xml b/assets/xml/objects/object_dno.xml index 16fa904c5..a320be10f 100644 --- a/assets/xml/objects/object_dno.xml +++ b/assets/xml/objects/object_dno.xml @@ -54,33 +54,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnp.xml b/assets/xml/objects/object_dnp.xml index 575ae3d69..376368578 100644 --- a/assets/xml/objects/object_dnp.xml +++ b/assets/xml/objects/object_dnp.xml @@ -56,32 +56,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnq.xml b/assets/xml/objects/object_dnq.xml index d286082bf..830e6d8e4 100644 --- a/assets/xml/objects/object_dnq.xml +++ b/assets/xml/objects/object_dnq.xml @@ -56,39 +56,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dns.xml b/assets/xml/objects/object_dns.xml index 135dc6ab6..d42f68f54 100644 --- a/assets/xml/objects/object_dns.xml +++ b/assets/xml/objects/object_dns.xml @@ -1,44 +1,45 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + " Format="rgba16" Width="8" Height="8" Offset="0x28E8" /> + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnt.xml b/assets/xml/objects/object_dnt.xml index d2ff328d3..6a2b0058d 100644 --- a/assets/xml/objects/object_dnt.xml +++ b/assets/xml/objects/object_dnt.xml @@ -57,34 +57,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dodongo.xml b/assets/xml/objects/object_dodongo.xml index cf0fa3725..f63a27467 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -28,37 +28,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dog.xml b/assets/xml/objects/object_dog.xml index 7e9cd3e99..89eba9c96 100644 --- a/assets/xml/objects/object_dog.xml +++ b/assets/xml/objects/object_dog.xml @@ -1,53 +1,65 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dor02.xml b/assets/xml/objects/object_dor02.xml index 0b64a9b1b..c60fa9ba9 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 c374837ea..941fa6fcc 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 2d1ac5611..394f5a6fe 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_drs.xml b/assets/xml/objects/object_drs.xml index 35202d17b..c5f4ee726 100644 --- a/assets/xml/objects/object_drs.xml +++ b/assets/xml/objects/object_drs.xml @@ -1,20 +1,21 @@  + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ds2.xml b/assets/xml/objects/object_ds2.xml index 0745fad58..1f1fd9d20 100644 --- a/assets/xml/objects/object_ds2.xml +++ b/assets/xml/objects/object_ds2.xml @@ -19,14 +19,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_ds2n.xml b/assets/xml/objects/object_ds2n.xml index 63ccca136..8cee6b22e 100644 --- a/assets/xml/objects/object_ds2n.xml +++ b/assets/xml/objects/object_ds2n.xml @@ -31,25 +31,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dt.xml b/assets/xml/objects/object_dt.xml index a4df244ad..78ad8046e 100644 --- a/assets/xml/objects/object_dt.xml +++ b/assets/xml/objects/object_dt.xml @@ -47,21 +47,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dy_obj.xml b/assets/xml/objects/object_dy_obj.xml index 7de69f2ff..8dd90375a 100644 --- a/assets/xml/objects/object_dy_obj.xml +++ b/assets/xml/objects/object_dy_obj.xml @@ -64,33 +64,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_efc_tw.xml b/assets/xml/objects/object_efc_tw.xml index f251f9607..4d4c1029c 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -3,8 +3,8 @@ - - - + + + diff --git a/assets/xml/objects/object_eg.xml b/assets/xml/objects/object_eg.xml index 1458afaec..46d3e0089 100644 --- a/assets/xml/objects/object_eg.xml +++ b/assets/xml/objects/object_eg.xml @@ -47,30 +47,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_famos.xml b/assets/xml/objects/object_famos.xml index 7cec70be5..4466f9b30 100644 --- a/assets/xml/objects/object_famos.xml +++ b/assets/xml/objects/object_famos.xml @@ -15,12 +15,12 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_fb.xml b/assets/xml/objects/object_fb.xml index 101ddbc5a..f0d3b8111 100644 --- a/assets/xml/objects/object_fb.xml +++ b/assets/xml/objects/object_fb.xml @@ -32,30 +32,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_firefly.xml b/assets/xml/objects/object_firefly.xml index f6d8f1bc7..84018ddd8 100644 --- a/assets/xml/objects/object_firefly.xml +++ b/assets/xml/objects/object_firefly.xml @@ -22,33 +22,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fish.xml b/assets/xml/objects/object_fish.xml index c0cbd54c7..9da78b6ab 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -20,22 +20,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -65,15 +65,15 @@ - - - - - - - - - + + + + + + + + + @@ -120,18 +120,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fr.xml b/assets/xml/objects/object_fr.xml index cf65cc0ac..cb02087ba 100644 --- a/assets/xml/objects/object_fr.xml +++ b/assets/xml/objects/object_fr.xml @@ -39,29 +39,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fsn.xml b/assets/xml/objects/object_fsn.xml index 7c3d0beb2..f90bf4e4d 100644 --- a/assets/xml/objects/object_fsn.xml +++ b/assets/xml/objects/object_fsn.xml @@ -1,63 +1,111 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_fu.xml b/assets/xml/objects/object_fu.xml index fe847642e..4094355ae 100644 --- a/assets/xml/objects/object_fu.xml +++ b/assets/xml/objects/object_fu.xml @@ -32,21 +32,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ge1.xml b/assets/xml/objects/object_ge1.xml index e401fd088..2f6aac2dd 100644 --- a/assets/xml/objects/object_ge1.xml +++ b/assets/xml/objects/object_ge1.xml @@ -9,22 +9,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_geldb.xml b/assets/xml/objects/object_geldb.xml index 357b83284..6338b48d6 100644 --- a/assets/xml/objects/object_geldb.xml +++ b/assets/xml/objects/object_geldb.xml @@ -48,30 +48,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gg.xml b/assets/xml/objects/object_gg.xml index e1ac1c779..17c21c93a 100644 --- a/assets/xml/objects/object_gg.xml +++ b/assets/xml/objects/object_gg.xml @@ -52,26 +52,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_giant.xml b/assets/xml/objects/object_giant.xml index edaeee039..8698d176b 100644 --- a/assets/xml/objects/object_giant.xml +++ b/assets/xml/objects/object_giant.xml @@ -51,24 +51,24 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + diff --git a/assets/xml/objects/object_gk.xml b/assets/xml/objects/object_gk.xml index 420f544f1..3fde40f94 100644 --- a/assets/xml/objects/object_gk.xml +++ b/assets/xml/objects/object_gk.xml @@ -23,26 +23,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gla.xml b/assets/xml/objects/object_gla.xml index ee793c256..ae80c7dfc 100644 --- a/assets/xml/objects/object_gla.xml +++ b/assets/xml/objects/object_gla.xml @@ -44,28 +44,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_grasshopper.xml b/assets/xml/objects/object_grasshopper.xml index 5b8ee82af..35120e0c9 100644 --- a/assets/xml/objects/object_grasshopper.xml +++ b/assets/xml/objects/object_grasshopper.xml @@ -35,30 +35,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ha.xml b/assets/xml/objects/object_ha.xml index f3d3f1029..4f595b6be 100644 --- a/assets/xml/objects/object_ha.xml +++ b/assets/xml/objects/object_ha.xml @@ -38,32 +38,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -105,31 +105,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hakaisi.xml b/assets/xml/objects/object_hakaisi.xml index 82e80242e..227fc4cf8 100644 --- a/assets/xml/objects/object_hakaisi.xml +++ b/assets/xml/objects/object_hakaisi.xml @@ -10,6 +10,6 @@ - + diff --git a/assets/xml/objects/object_harfgibud.xml b/assets/xml/objects/object_harfgibud.xml index 9a9bf4745..a97e42c00 100644 --- a/assets/xml/objects/object_harfgibud.xml +++ b/assets/xml/objects/object_harfgibud.xml @@ -35,25 +35,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -91,25 +91,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hariko.xml b/assets/xml/objects/object_hariko.xml index e0f139b88..5cb2d8328 100644 --- a/assets/xml/objects/object_hariko.xml +++ b/assets/xml/objects/object_hariko.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/assets/xml/objects/object_hata.xml b/assets/xml/objects/object_hata.xml index 3131a6628..3f5e12a38 100644 --- a/assets/xml/objects/object_hata.xml +++ b/assets/xml/objects/object_hata.xml @@ -14,26 +14,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hintnuts.xml b/assets/xml/objects/object_hintnuts.xml index 655c8ae3c..a500981a7 100644 --- a/assets/xml/objects/object_hintnuts.xml +++ b/assets/xml/objects/object_hintnuts.xml @@ -18,16 +18,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_horse_link_child.xml b/assets/xml/objects/object_horse_link_child.xml index f844224fa..506135e0c 100644 --- a/assets/xml/objects/object_horse_link_child.xml +++ b/assets/xml/objects/object_horse_link_child.xml @@ -10,7 +10,9 @@ - + + + @@ -28,53 +30,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_hs.xml b/assets/xml/objects/object_hs.xml index 315128815..0d36c4ff1 100644 --- a/assets/xml/objects/object_hs.xml +++ b/assets/xml/objects/object_hs.xml @@ -27,21 +27,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ice_block.xml b/assets/xml/objects/object_ice_block.xml index 1e14ea5b5..ba755d100 100644 --- a/assets/xml/objects/object_ice_block.xml +++ b/assets/xml/objects/object_ice_block.xml @@ -1,15 +1,28 @@  - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ik.xml b/assets/xml/objects/object_ik.xml index 34dcac8f2..0b68303da 100644 --- a/assets/xml/objects/object_ik.xml +++ b/assets/xml/objects/object_ik.xml @@ -72,35 +72,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ikn_demo.xml b/assets/xml/objects/object_ikn_demo.xml index 69d225933..56f8fd0e9 100644 --- a/assets/xml/objects/object_ikn_demo.xml +++ b/assets/xml/objects/object_ikn_demo.xml @@ -27,23 +27,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -57,13 +57,13 @@ - - - - - - - + + + + + + + @@ -83,13 +83,13 @@ - - - - - - - + + + + + + + diff --git a/assets/xml/objects/object_in.xml b/assets/xml/objects/object_in.xml index 42bace14f..3874e4834 100644 --- a/assets/xml/objects/object_in.xml +++ b/assets/xml/objects/object_in.xml @@ -93,26 +93,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_in2.xml b/assets/xml/objects/object_in2.xml index a47c7613e..4457defae 100644 --- a/assets/xml/objects/object_in2.xml +++ b/assets/xml/objects/object_in2.xml @@ -47,26 +47,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_jg.xml b/assets/xml/objects/object_jg.xml index 03d7c3ce5..17889995f 100644 --- a/assets/xml/objects/object_jg.xml +++ b/assets/xml/objects/object_jg.xml @@ -1,100 +1,118 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_js.xml b/assets/xml/objects/object_js.xml index be9246ab6..92f14da0b 100644 --- a/assets/xml/objects/object_js.xml +++ b/assets/xml/objects/object_js.xml @@ -27,19 +27,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_jso.xml b/assets/xml/objects/object_jso.xml index 777c6e53c..33816a797 100644 --- a/assets/xml/objects/object_jso.xml +++ b/assets/xml/objects/object_jso.xml @@ -30,26 +30,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -95,26 +95,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ka.xml b/assets/xml/objects/object_ka.xml index 2944a00b2..36dceb0ca 100644 --- a/assets/xml/objects/object_ka.xml +++ b/assets/xml/objects/object_ka.xml @@ -31,34 +31,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kaizoku_obj.xml b/assets/xml/objects/object_kaizoku_obj.xml index a38d16827..8dd96770a 100644 --- a/assets/xml/objects/object_kaizoku_obj.xml +++ b/assets/xml/objects/object_kaizoku_obj.xml @@ -28,8 +28,8 @@ - - + + diff --git a/assets/xml/objects/object_kamejima.xml b/assets/xml/objects/object_kamejima.xml index 8bdb54d06..9b45ad478 100644 --- a/assets/xml/objects/object_kamejima.xml +++ b/assets/xml/objects/object_kamejima.xml @@ -43,30 +43,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kbt.xml b/assets/xml/objects/object_kbt.xml index b3ab0baaf..aad49e946 100644 --- a/assets/xml/objects/object_kbt.xml +++ b/assets/xml/objects/object_kbt.xml @@ -42,27 +42,33 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kgy.xml b/assets/xml/objects/object_kgy.xml index 856c5883d..0e2d3be2c 100644 --- a/assets/xml/objects/object_kgy.xml +++ b/assets/xml/objects/object_kgy.xml @@ -45,29 +45,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kitan.xml b/assets/xml/objects/object_kitan.xml index 3884470f9..05d090d93 100644 --- a/assets/xml/objects/object_kitan.xml +++ b/assets/xml/objects/object_kitan.xml @@ -29,26 +29,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_knight.xml b/assets/xml/objects/object_knight.xml index 67d87a0ff..0459cb062 100644 --- a/assets/xml/objects/object_knight.xml +++ b/assets/xml/objects/object_knight.xml @@ -143,64 +143,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kujiya.xml b/assets/xml/objects/object_kujiya.xml index 3b17d43c0..f657e8bd8 100644 --- a/assets/xml/objects/object_kujiya.xml +++ b/assets/xml/objects/object_kujiya.xml @@ -1,25 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_kusa.xml b/assets/xml/objects/object_kusa.xml index 0d36569a5..36c61f364 100644 --- a/assets/xml/objects/object_kusa.xml +++ b/assets/xml/objects/object_kusa.xml @@ -1,6 +1,6 @@  - - + + diff --git a/assets/xml/objects/object_kz.xml b/assets/xml/objects/object_kz.xml index 24c16e1fc..2b714be38 100644 --- a/assets/xml/objects/object_kz.xml +++ b/assets/xml/objects/object_kz.xml @@ -52,30 +52,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_boy.xml b/assets/xml/objects/object_link_boy.xml index 8bfd17e98..b0a85ece5 100644 --- a/assets/xml/objects/object_link_boy.xml +++ b/assets/xml/objects/object_link_boy.xml @@ -55,27 +55,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_child.xml b/assets/xml/objects/object_link_child.xml index 86c596909..51145033c 100644 --- a/assets/xml/objects/object_link_child.xml +++ b/assets/xml/objects/object_link_child.xml @@ -130,27 +130,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_goron.xml b/assets/xml/objects/object_link_goron.xml index 05336d6db..2fe3906fb 100644 --- a/assets/xml/objects/object_link_goron.xml +++ b/assets/xml/objects/object_link_goron.xml @@ -76,33 +76,33 @@ - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_nuts.xml b/assets/xml/objects/object_link_nuts.xml index 169dc848a..e3dab39da 100644 --- a/assets/xml/objects/object_link_nuts.xml +++ b/assets/xml/objects/object_link_nuts.xml @@ -53,27 +53,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_zora.xml b/assets/xml/objects/object_link_zora.xml index e3bbaba95..d36aaa420 100644 --- a/assets/xml/objects/object_link_zora.xml +++ b/assets/xml/objects/object_link_zora.xml @@ -63,27 +63,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ma1.xml b/assets/xml/objects/object_ma1.xml index 7001eb84a..3d0ea1fcc 100644 --- a/assets/xml/objects/object_ma1.xml +++ b/assets/xml/objects/object_ma1.xml @@ -63,29 +63,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ma2.xml b/assets/xml/objects/object_ma2.xml index a6554d387..a61eff4e0 100644 --- a/assets/xml/objects/object_ma2.xml +++ b/assets/xml/objects/object_ma2.xml @@ -58,28 +58,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mk.xml b/assets/xml/objects/object_mk.xml index c927f33de..1ee3741bb 100644 --- a/assets/xml/objects/object_mk.xml +++ b/assets/xml/objects/object_mk.xml @@ -28,18 +28,18 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mm.xml b/assets/xml/objects/object_mm.xml index 43c0e9b19..baac5425d 100644 --- a/assets/xml/objects/object_mm.xml +++ b/assets/xml/objects/object_mm.xml @@ -39,22 +39,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mnk.xml b/assets/xml/objects/object_mnk.xml index 8f813ba00..c6e23399d 100644 --- a/assets/xml/objects/object_mnk.xml +++ b/assets/xml/objects/object_mnk.xml @@ -19,11 +19,11 @@ - - - - - + + + + + @@ -82,29 +82,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -118,9 +118,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_ms.xml b/assets/xml/objects/object_ms.xml index 9d7df53ad..a4a36e149 100644 --- a/assets/xml/objects/object_ms.xml +++ b/assets/xml/objects/object_ms.xml @@ -19,14 +19,14 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_msmo.xml b/assets/xml/objects/object_msmo.xml index cb08f53ef..6bfd0e46d 100644 --- a/assets/xml/objects/object_msmo.xml +++ b/assets/xml/objects/object_msmo.xml @@ -1,9 +1,10 @@  + - - - - - + + + + + diff --git a/assets/xml/objects/object_mtoride.xml b/assets/xml/objects/object_mtoride.xml index ab0792839..a79547730 100644 --- a/assets/xml/objects/object_mtoride.xml +++ b/assets/xml/objects/object_mtoride.xml @@ -31,7 +31,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/assets/xml/objects/object_mu.xml b/assets/xml/objects/object_mu.xml index a1c11fed2..925cb74e9 100644 --- a/assets/xml/objects/object_mu.xml +++ b/assets/xml/objects/object_mu.xml @@ -36,27 +36,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_nb.xml b/assets/xml/objects/object_nb.xml index e0f557f98..e8a695b52 100644 --- a/assets/xml/objects/object_nb.xml +++ b/assets/xml/objects/object_nb.xml @@ -34,13 +34,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index b055a2740..e49426560 100644 --- a/assets/xml/objects/object_niw.xml +++ b/assets/xml/objects/object_niw.xml @@ -18,21 +18,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_numa_obj.xml b/assets/xml/objects/object_numa_obj.xml index cc36fa1b8..a450cf11a 100644 --- a/assets/xml/objects/object_numa_obj.xml +++ b/assets/xml/objects/object_numa_obj.xml @@ -1,4 +1,5 @@  + @@ -11,27 +12,30 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_oF1d_map.xml b/assets/xml/objects/object_oF1d_map.xml index 9557dc73e..6c3af0778 100644 --- a/assets/xml/objects/object_oF1d_map.xml +++ b/assets/xml/objects/object_oF1d_map.xml @@ -78,24 +78,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ob.xml b/assets/xml/objects/object_ob.xml index 7a75a59f2..0f79703b5 100644 --- a/assets/xml/objects/object_ob.xml +++ b/assets/xml/objects/object_ob.xml @@ -59,24 +59,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_okuta.xml b/assets/xml/objects/object_okuta.xml index 0eebb587e..e71f65a1c 100644 --- a/assets/xml/objects/object_okuta.xml +++ b/assets/xml/objects/object_okuta.xml @@ -34,22 +34,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_osn.xml b/assets/xml/objects/object_osn.xml index 0994d057f..b31660e6a 100644 --- a/assets/xml/objects/object_osn.xml +++ b/assets/xml/objects/object_osn.xml @@ -92,25 +92,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ot.xml b/assets/xml/objects/object_ot.xml index 1fb04a34a..49a8d89ce 100644 --- a/assets/xml/objects/object_ot.xml +++ b/assets/xml/objects/object_ot.xml @@ -30,25 +30,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_owl.xml b/assets/xml/objects/object_owl.xml index 381c0bfd0..6c9d79883 100644 --- a/assets/xml/objects/object_owl.xml +++ b/assets/xml/objects/object_owl.xml @@ -37,27 +37,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -75,21 +75,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pamera.xml b/assets/xml/objects/object_pamera.xml index 6ce4c5219..6b457ab8b 100644 --- a/assets/xml/objects/object_pamera.xml +++ b/assets/xml/objects/object_pamera.xml @@ -38,29 +38,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ph.xml b/assets/xml/objects/object_ph.xml index df0cff73d..2e8a8eb29 100644 --- a/assets/xml/objects/object_ph.xml +++ b/assets/xml/objects/object_ph.xml @@ -16,29 +16,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po.xml b/assets/xml/objects/object_po.xml index 5d66d380c..2cc6e5cbd 100644 --- a/assets/xml/objects/object_po.xml +++ b/assets/xml/objects/object_po.xml @@ -28,26 +28,26 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index 288dd41c3..ae8ef56e3 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -42,17 +42,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_po_fusen.xml b/assets/xml/objects/object_po_fusen.xml index 6dd6d1f9b..5885b89a3 100644 --- a/assets/xml/objects/object_po_fusen.xml +++ b/assets/xml/objects/object_po_fusen.xml @@ -18,15 +18,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_po_sisters.xml b/assets/xml/objects/object_po_sisters.xml index 6004d6cbf..f42fe1664 100644 --- a/assets/xml/objects/object_po_sisters.xml +++ b/assets/xml/objects/object_po_sisters.xml @@ -37,17 +37,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pp.xml b/assets/xml/objects/object_pp.xml index 63bf541cd..1ac690935 100644 --- a/assets/xml/objects/object_pp.xml +++ b/assets/xml/objects/object_pp.xml @@ -37,32 +37,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -100,32 +100,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pr.xml b/assets/xml/objects/object_pr.xml index 27a03fdcf..95fc4743c 100644 --- a/assets/xml/objects/object_pr.xml +++ b/assets/xml/objects/object_pr.xml @@ -31,16 +31,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -51,11 +51,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_ps.xml b/assets/xml/objects/object_ps.xml index 9febc5660..f341e95a4 100644 --- a/assets/xml/objects/object_ps.xml +++ b/assets/xml/objects/object_ps.xml @@ -22,18 +22,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_pst.xml b/assets/xml/objects/object_pst.xml index 9d62acba7..3649877ea 100644 --- a/assets/xml/objects/object_pst.xml +++ b/assets/xml/objects/object_pst.xml @@ -7,8 +7,8 @@ - - - + + + diff --git a/assets/xml/objects/object_raf.xml b/assets/xml/objects/object_raf.xml index df3d619d1..26c0741ec 100644 --- a/assets/xml/objects/object_raf.xml +++ b/assets/xml/objects/object_raf.xml @@ -26,17 +26,17 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rat.xml b/assets/xml/objects/object_rat.xml index 5c979b098..ce32e20cc 100644 --- a/assets/xml/objects/object_rat.xml +++ b/assets/xml/objects/object_rat.xml @@ -14,15 +14,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_rb.xml b/assets/xml/objects/object_rb.xml index 3898e8417..72b3e6cb6 100644 --- a/assets/xml/objects/object_rb.xml +++ b/assets/xml/objects/object_rb.xml @@ -1,44 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rd.xml b/assets/xml/objects/object_rd.xml index d9087282a..854ded388 100644 --- a/assets/xml/objects/object_rd.xml +++ b/assets/xml/objects/object_rd.xml @@ -1,114 +1,114 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rs.xml b/assets/xml/objects/object_rs.xml index 5019d9631..01099db47 100644 --- a/assets/xml/objects/object_rs.xml +++ b/assets/xml/objects/object_rs.xml @@ -33,21 +33,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_ru2.xml b/assets/xml/objects/object_ru2.xml index 016a610e8..f2d3fd2b0 100644 --- a/assets/xml/objects/object_ru2.xml +++ b/assets/xml/objects/object_ru2.xml @@ -46,29 +46,29 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rz.xml b/assets/xml/objects/object_rz.xml index 323393f87..a75e033f0 100644 --- a/assets/xml/objects/object_rz.xml +++ b/assets/xml/objects/object_rz.xml @@ -45,27 +45,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sb.xml b/assets/xml/objects/object_sb.xml index 9fcd76a8f..359cff20d 100644 --- a/assets/xml/objects/object_sb.xml +++ b/assets/xml/objects/object_sb.xml @@ -16,15 +16,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_sdn.xml b/assets/xml/objects/object_sdn.xml index 9cc607047..219436b02 100644 --- a/assets/xml/objects/object_sdn.xml +++ b/assets/xml/objects/object_sdn.xml @@ -1,66 +1,66 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_shn.xml b/assets/xml/objects/object_shn.xml index b322641a9..1b94600ab 100644 --- a/assets/xml/objects/object_shn.xml +++ b/assets/xml/objects/object_shn.xml @@ -50,7 +50,7 @@ - + @@ -66,22 +66,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sichitai_obj.xml b/assets/xml/objects/object_sichitai_obj.xml index f093778ab..d1179beab 100644 --- a/assets/xml/objects/object_sichitai_obj.xml +++ b/assets/xml/objects/object_sichitai_obj.xml @@ -1,9 +1,9 @@  - - - - + + + + diff --git a/assets/xml/objects/object_skb.xml b/assets/xml/objects/object_skb.xml index cafba559e..c9935b64f 100644 --- a/assets/xml/objects/object_skb.xml +++ b/assets/xml/objects/object_skb.xml @@ -36,26 +36,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_snowman.xml b/assets/xml/objects/object_snowman.xml index f92110b3e..91b650a75 100644 --- a/assets/xml/objects/object_snowman.xml +++ b/assets/xml/objects/object_snowman.xml @@ -18,25 +18,25 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + diff --git a/assets/xml/objects/object_ssh.xml b/assets/xml/objects/object_ssh.xml index a95597ae4..57599fdce 100644 --- a/assets/xml/objects/object_ssh.xml +++ b/assets/xml/objects/object_ssh.xml @@ -29,36 +29,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_st.xml b/assets/xml/objects/object_st.xml index 011d76449..2dabce2f8 100644 --- a/assets/xml/objects/object_st.xml +++ b/assets/xml/objects/object_st.xml @@ -35,36 +35,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_sth.xml b/assets/xml/objects/object_sth.xml index 7b6947b07..c7a0ffd25 100644 --- a/assets/xml/objects/object_sth.xml +++ b/assets/xml/objects/object_sth.xml @@ -22,21 +22,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_stk.xml b/assets/xml/objects/object_stk.xml index 44a311dfb..68e8ae26b 100644 --- a/assets/xml/objects/object_stk.xml +++ b/assets/xml/objects/object_stk.xml @@ -55,28 +55,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_syoten.xml b/assets/xml/objects/object_syoten.xml index 9802f7701..2e546f471 100644 --- a/assets/xml/objects/object_syoten.xml +++ b/assets/xml/objects/object_syoten.xml @@ -1,6 +1,7 @@  - + + @@ -12,12 +13,16 @@ - + + + + + diff --git a/assets/xml/objects/object_tab.xml b/assets/xml/objects/object_tab.xml index 52c3156a3..9a63c2ed3 100644 --- a/assets/xml/objects/object_tab.xml +++ b/assets/xml/objects/object_tab.xml @@ -24,9 +24,10 @@ - + - + + @@ -37,26 +38,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tanron4.xml b/assets/xml/objects/object_tanron4.xml index 7e48cdf0e..2c988e74b 100644 --- a/assets/xml/objects/object_tanron4.xml +++ b/assets/xml/objects/object_tanron4.xml @@ -1,24 +1,30 @@  + - - + + + + + - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_test3.xml b/assets/xml/objects/object_test3.xml index fc6e026a9..6b0a5349c 100644 --- a/assets/xml/objects/object_test3.xml +++ b/assets/xml/objects/object_test3.xml @@ -42,27 +42,27 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_thiefbird.xml b/assets/xml/objects/object_thiefbird.xml index 31f0213c5..e7cb3ac91 100644 --- a/assets/xml/objects/object_thiefbird.xml +++ b/assets/xml/objects/object_thiefbird.xml @@ -44,23 +44,23 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tite.xml b/assets/xml/objects/object_tite.xml index eec5b05d0..681b732e8 100644 --- a/assets/xml/objects/object_tite.xml +++ b/assets/xml/objects/object_tite.xml @@ -25,30 +25,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tk.xml b/assets/xml/objects/object_tk.xml index 813b0fb24..0c0ea3831 100644 --- a/assets/xml/objects/object_tk.xml +++ b/assets/xml/objects/object_tk.xml @@ -43,23 +43,23 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tl.xml b/assets/xml/objects/object_tl.xml index 656d70743..6397283af 100644 --- a/assets/xml/objects/object_tl.xml +++ b/assets/xml/objects/object_tl.xml @@ -7,10 +7,10 @@ - - - - + + + + @@ -43,19 +43,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_toryo.xml b/assets/xml/objects/object_toryo.xml index 101db5839..45d3da100 100644 --- a/assets/xml/objects/object_toryo.xml +++ b/assets/xml/objects/object_toryo.xml @@ -32,22 +32,22 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_trt.xml b/assets/xml/objects/object_trt.xml index ecde36e18..a0d83076e 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -63,32 +63,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tru.xml b/assets/xml/objects/object_tru.xml index 0ca1acff4..dd0e6d20c 100644 --- a/assets/xml/objects/object_tru.xml +++ b/assets/xml/objects/object_tru.xml @@ -76,33 +76,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tsn.xml b/assets/xml/objects/object_tsn.xml index 63c03c84c..761a6e0d7 100644 --- a/assets/xml/objects/object_tsn.xml +++ b/assets/xml/objects/object_tsn.xml @@ -26,28 +26,28 @@ - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_uch.xml b/assets/xml/objects/object_uch.xml index 86f2a4646..a58af5654 100644 --- a/assets/xml/objects/object_uch.xml +++ b/assets/xml/objects/object_uch.xml @@ -28,19 +28,19 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_um.xml b/assets/xml/objects/object_um.xml index 693c704d3..5717124a7 100644 --- a/assets/xml/objects/object_um.xml +++ b/assets/xml/objects/object_um.xml @@ -49,28 +49,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_utubo.xml b/assets/xml/objects/object_utubo.xml index 97a7095c9..a1f499eb6 100644 --- a/assets/xml/objects/object_utubo.xml +++ b/assets/xml/objects/object_utubo.xml @@ -1,42 +1,53 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_vm.xml b/assets/xml/objects/object_vm.xml index b07534c65..b6c1cdfa2 100644 --- a/assets/xml/objects/object_vm.xml +++ b/assets/xml/objects/object_vm.xml @@ -15,16 +15,16 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index 249af61ee..fba2bc246 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -1,63 +1,75 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_warp1.xml b/assets/xml/objects/object_warp1.xml index 50d4c527a..814334792 100644 --- a/assets/xml/objects/object_warp1.xml +++ b/assets/xml/objects/object_warp1.xml @@ -11,28 +11,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wdhand.xml b/assets/xml/objects/object_wdhand.xml index 22e12cfa0..bcd5b0ce3 100644 --- a/assets/xml/objects/object_wdhand.xml +++ b/assets/xml/objects/object_wdhand.xml @@ -16,13 +16,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_wdor04.xml b/assets/xml/objects/object_wdor04.xml index 040df1598..07ad601dd 100644 --- a/assets/xml/objects/object_wdor04.xml +++ b/assets/xml/objects/object_wdor04.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_wdor05.xml b/assets/xml/objects/object_wdor05.xml index f8fda2322..6eb0f4ed0 100644 --- a/assets/xml/objects/object_wdor05.xml +++ b/assets/xml/objects/object_wdor05.xml @@ -1,7 +1,7 @@  - - - + + + diff --git a/assets/xml/objects/object_wf.xml b/assets/xml/objects/object_wf.xml index 56c9e1621..4775552e2 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -27,28 +27,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -81,28 +81,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 7f41954cf..d9c8a1589 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -78,25 +78,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_yb.xml b/assets/xml/objects/object_yb.xml index 8cf61e347..1a8503a6e 100644 --- a/assets/xml/objects/object_yb.xml +++ b/assets/xml/objects/object_yb.xml @@ -1,57 +1,61 @@  + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zl1.xml b/assets/xml/objects/object_zl1.xml index 759b35867..04d4ae406 100644 --- a/assets/xml/objects/object_zl1.xml +++ b/assets/xml/objects/object_zl1.xml @@ -57,24 +57,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zl4.xml b/assets/xml/objects/object_zl4.xml index f13487f98..dafdef8cd 100644 --- a/assets/xml/objects/object_zl4.xml +++ b/assets/xml/objects/object_zl4.xml @@ -51,24 +51,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zm.xml b/assets/xml/objects/object_zm.xml index 022efcf27..f6f1b95e5 100644 --- a/assets/xml/objects/object_zm.xml +++ b/assets/xml/objects/object_zm.xml @@ -38,24 +38,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zo.xml b/assets/xml/objects/object_zo.xml index f0926dd2b..8fc22ae46 100644 --- a/assets/xml/objects/object_zo.xml +++ b/assets/xml/objects/object_zo.xml @@ -42,26 +42,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zob.xml b/assets/xml/objects/object_zob.xml index 22400d46e..bc4d61c6a 100644 --- a/assets/xml/objects/object_zob.xml +++ b/assets/xml/objects/object_zob.xml @@ -44,30 +44,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zod.xml b/assets/xml/objects/object_zod.xml index f1152e2ac..3e0b6567a 100644 --- a/assets/xml/objects/object_zod.xml +++ b/assets/xml/objects/object_zod.xml @@ -35,16 +35,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/assets/xml/objects/object_zog.xml b/assets/xml/objects/object_zog.xml index 55f169ad1..627bb676a 100644 --- a/assets/xml/objects/object_zog.xml +++ b/assets/xml/objects/object_zog.xml @@ -85,28 +85,28 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zoraegg.xml b/assets/xml/objects/object_zoraegg.xml index c527fe618..367d2df76 100644 --- a/assets/xml/objects/object_zoraegg.xml +++ b/assets/xml/objects/object_zoraegg.xml @@ -11,17 +11,18 @@ - + - - - - - - - - + + + + + + + + + diff --git a/assets/xml/objects/object_zos.xml b/assets/xml/objects/object_zos.xml index 5af477773..1f5a2a542 100644 --- a/assets/xml/objects/object_zos.xml +++ b/assets/xml/objects/object_zos.xml @@ -45,24 +45,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zov.xml b/assets/xml/objects/object_zov.xml index 17d6382a9..abbc52268 100644 --- a/assets/xml/objects/object_zov.xml +++ b/assets/xml/objects/object_zov.xml @@ -37,43 +37,45 @@ - + - + - + + - + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Arrow_Ice.xml b/assets/xml/overlays/ovl_Arrow_Ice.xml index 96c0f2522..bec512600 100644 --- a/assets/xml/overlays/ovl_Arrow_Ice.xml +++ b/assets/xml/overlays/ovl_Arrow_Ice.xml @@ -1,11 +1,12 @@ + - - - + + + - - + + diff --git a/assets/xml/overlays/ovl_Arrow_Light.xml b/assets/xml/overlays/ovl_Arrow_Light.xml new file mode 100644 index 000000000..3d5ae87b8 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_Light.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Arrow_fire.xml b/assets/xml/overlays/ovl_Arrow_fire.xml new file mode 100644 index 000000000..893f335d0 --- /dev/null +++ b/assets/xml/overlays/ovl_Arrow_fire.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Dm_Char01.xml b/assets/xml/overlays/ovl_Dm_Char01.xml new file mode 100644 index 000000000..3f855c376 --- /dev/null +++ b/assets/xml/overlays/ovl_Dm_Char01.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml b/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml new file mode 100644 index 000000000..7e0b6d08b --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bom_Bowl_Man.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Bombers.xml b/assets/xml/overlays/ovl_En_Bombers.xml new file mode 100644 index 000000000..c6fc64246 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Bombers.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Gakufu.xml b/assets/xml/overlays/ovl_En_Gakufu.xml new file mode 100644 index 000000000..92b2672d4 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Gakufu.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Horse_Game_Check.xml b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml new file mode 100644 index 000000000..bcb8ea695 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Horse_Game_Check.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/xml/overlays/ovl_En_Mm3.xml b/assets/xml/overlays/ovl_En_Mm3.xml new file mode 100644 index 000000000..207b5ec8f --- /dev/null +++ b/assets/xml/overlays/ovl_En_Mm3.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/xml/overlays/ovl_En_Sda.xml b/assets/xml/overlays/ovl_En_Sda.xml new file mode 100644 index 000000000..7e257ee20 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sda.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Sth.xml b/assets/xml/overlays/ovl_En_Sth.xml new file mode 100644 index 000000000..80393fc2d --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sth.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Syateki_Okuta.xml b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml new file mode 100644 index 000000000..0f4de7c4e --- /dev/null +++ b/assets/xml/overlays/ovl_En_Syateki_Okuta.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Tanron1.xml b/assets/xml/overlays/ovl_En_Tanron1.xml new file mode 100644 index 000000000..17cf5faf5 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Tanron1.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Entotu.xml b/assets/xml/overlays/ovl_Obj_Entotu.xml new file mode 100644 index 000000000..e6e6c64cf --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Entotu.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Grass.xml b/assets/xml/overlays/ovl_Obj_Grass.xml new file mode 100644 index 000000000..e1002b369 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Grass.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Smork.xml b/assets/xml/overlays/ovl_Obj_Smork.xml new file mode 100644 index 000000000..745c6b6af --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Smork.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe6.xml b/assets/xml/overlays/ovl_Oceff_Wipe6.xml new file mode 100644 index 000000000..e64c8cc71 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe6.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml b/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml index 066cbe10e..0c41a1b29 100644 --- a/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml +++ b/assets/xml/scenes/Z2_LOST_WOODS/Z2_LOST_WOODS.xml @@ -1,5 +1,5 @@ - + diff --git a/diff_settings.py b/diff_settings.py index a6cee9dc8..4eeb4989c 100755 --- a/diff_settings.py +++ b/diff_settings.py @@ -5,4 +5,5 @@ def apply(config, args): config['myimg'] = 'mm.us.rev1.rom_uncompressed.z64' config['mapfile'] = 'build/mm.map' config['source_directories'] = ['./src','./include'] + config['objdump_flags'] = ['-M','reg-names=32'] config['makeflags'] = ['KEEP_MDEBUG=1'] diff --git a/docs/BUILDING_MACOS.md b/docs/BUILDING_MACOS.md index 17b683442..77f1d839e 100644 --- a/docs/BUILDING_MACOS.md +++ b/docs/BUILDING_MACOS.md @@ -80,4 +80,4 @@ If this worked, you can now delete the temporary directory `~/binutils-tmp`. Apple's version of `make` is very out-of-date, so you should use the brew-installed `gmake` in place of `make` in this repo from now on. -You should now be able to continue from [step 2](README.md#2-clone-the-repository) of the Linux instructions. +You should now be able to continue from [step 2](../README.md#2-clone-the-repository) of the Linux instructions. diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index d01d3e347..81d62739d 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -159,14 +159,14 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -175,7 +175,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { // Duplicate return node #17. Try simplifying control flow for better match return; } - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { temp_v0_2 = globalCtx->msgCtx.choiceIndex; if (temp_v0_2 != 0) { if (temp_v0_2 != 1) { @@ -211,7 +211,7 @@ which is long, messy, and contains some rather nasty-looking control flow, inclu temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 != 4) { if (temp_v0 != 5) { - if ((temp_v0 == 6) && (func_80147624(globalCtx) != 0)) { + if ((temp_v0 == 6) && (Message_ShouldAdvance(globalCtx) != 0)) { this->actionFunc = func_80952734; return; } @@ -248,13 +248,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -262,7 +262,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -350,13 +350,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { goto block_17; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } func_801477B4(globalCtx); @@ -364,7 +364,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { goto block_17; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -420,13 +420,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -434,7 +434,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } temp_v0_2 = globalCtx->msgCtx.choiceIndex; @@ -557,7 +557,7 @@ There's a couple of other obvious things here: Well, at least the bottom half looks respectable now. Again, there is no code after the switch, so the next thing up, namely ```C - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } ``` @@ -578,13 +578,13 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { if (temp_v0 != 6) { return; } - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } this->actionFunc = func_80952734; return; block_5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -592,7 +592,7 @@ block_5: this->actionFunc = func_809529AC; return; block_7: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); @@ -647,7 +647,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) == 0) { + if (Message_ShouldAdvance(globalCtx) == 0) { return; } func_801477B4(globalCtx); @@ -656,11 +656,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); @@ -700,7 +699,7 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp((Actor *) this, globalCtx, 0x35, this->actor.xzDistToPlayer, this->actor.playerHeightRel); this->actionFunc = func_809529AC; @@ -708,11 +707,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_801477B4(globalCtx); - if (gSaveContext.save.playerData.rupees < 0xA) { play_sound(0x4806U); func_80151938(globalCtx, 0x935U); diff --git a/docs/tutorial/beginning_decomp.md b/docs/tutorial/beginning_decomp.md index 01cc21cf3..13e5941fc 100644 --- a/docs/tutorial/beginning_decomp.md +++ b/docs/tutorial/beginning_decomp.md @@ -1,6 +1,6 @@ # Beginning decompilation: the Init function and the Actor struct -Up: [Contents](contents.md) +- Up: [Contents](contents.md) Open the C file and the H file with your actor's name from the appropriate directory in `src/overlays/actors/`. These will be the main files we work with. We will be using EnRecepgirl (the rather forward Mayor's receptionist in the Mayor's residence in East Clock Town) as our example: it is a nice simple NPC with most of the common features of an NPC. @@ -96,9 +96,9 @@ It is currently divided into six sections as follows: 3. These are prototypes for the "main four" functions that almost every actor has. You add more functions here if they need to be declared above their first use. -5. `if`'d-out section containing the `InitVars` and a few other common pieces of data. This can be ignored until we import the data. +4. `if`'d-out section containing the `InitVars` and a few other common pieces of data. This can be ignored until we import the data. -4. A set of `extern`s. These refer to the data in the previous section, and, data that comes from other files, usually in the actor's corresponding object file. The latter point to addresses in the ROM where assets are stored (usually collision data, animations or display lists). Once the corresponding object files have been decompiled, these will simply be replaced by including the object file (see [Object Decompilation](object_decomp.md) for how this process works). These symbols have been automatically extracted from the MIPS code. There may turn out to be some that were not caught by the script, in which case they need to be placed in the file called `undefined_syms.txt` in the root directory of the project. Ask in Discord for how to do this: it is simple, but rare enough to not be worth covering here. +5. A set of `extern`s. These refer to the data in the previous section, and, data that comes from other files, usually in the actor's corresponding object file. The latter point to addresses in the ROM where assets are stored (usually collision data, animations or display lists). These can simply be replaced by including the object file (see [Object Decompilation](object_decomp.md) for how this process works). 6. List of functions. Each `#pragma GLOBAL_ASM` is letting the compiler use the corresponding assembly file while we do not have decompiled C code for that function. The majority of the decompilation work is converting these functions into C that it looks like a human wrote. @@ -397,7 +397,7 @@ An actor with SkelAnime has three structs in the Actor struct that handle it: on There are two different sorts of SkelAnime, although for decompilation purposes there is not much difference between them. Looking at the prototype of `SkelAnime_InitFlex` from `functions.h` (or even the definition in `z_skelanime.c`), ```C void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, - AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); + AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); ``` we can read off the types of the various arguments: - The `SkelAnime` struct is at `this + 0x144` diff --git a/docs/tutorial/contents.md b/docs/tutorial/contents.md index 227f4fc7d..0435becb4 100644 --- a/docs/tutorial/contents.md +++ b/docs/tutorial/contents.md @@ -32,7 +32,9 @@ - Fake symbols - Inlining -## [Object Decompilation](object_decomp.md) (TODO) +- [Documenting a decompiled file](documenting.md) + +## [Object Decompilation](object_decomp.md) - Object files - How we decompile objects diff --git a/docs/tutorial/data.md b/docs/tutorial/data.md index ae856123e..972451b07 100644 --- a/docs/tutorial/data.md +++ b/docs/tutorial/data.md @@ -1,13 +1,13 @@ # Data -Up: [Contents](contents.md) -Previous: [Draw functions](draw_functions.md) +- Up: [Contents](contents.md) +- Previous: [Draw functions](draw_functions.md) ## Table of Contents - [Data first](#data-first) - [Extern and data last](#extern-and-data-last) -- [Segmented pointers](#segmented-pointers) +- [Segmented pointers and object symbols](#segmented-pointers-and-object-symbols) - [Fake symbols](#fake-symbols) - [Inlining](#inlining) @@ -114,7 +114,7 @@ static s32 D_80C106C8 = 0; That should be everything, and we should now be able to `make` without the data file with no issues. -## Segmented pointers +## Segmented pointers and object symbols The game has a convenient system that allows it to sometimes effectively use offsets into a file instead of raw memory addresses to reference things. This is done by setting a file address to a *segment*. A segmented address is of the form `0x0XYYYYYY`, where `X` is the segment number. There are 16 available segments, and actors always set segment 6 to their object file, which is a file containing assets (skeleton, animations, textures, etc.) that they use. This is what all those `D_06...` are, and it is also what the entries in `D_80C106B0` are: they are currently raw numbers instead of symbols, though, and we would like to replace them. @@ -124,29 +124,23 @@ mips-linux-gnu-ld: build/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.o:( ```` As we'd expect, of course: we didn't fulfil our promise that they were defined elsewhere.) -This is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. If you find a segmented address that is not in already externed, `extern` it at the top of the file and add it to the actor's section in undefined_syms: -```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; -extern void* D_0600FCF0; +For actors which have yet to be decompiled, this is mitigated by use of the file `undefined_syms.txt`, which feeds the linker the raw addresses to use as the symbol definitions. However, we want to replace these segmented addresses with proper object symbols whenever possible. In `En_Recepgirl_InitVars`, we can see that this actor uses the object `OBJECT_BG`: +```c +const ActorInit En_Recepgirl_InitVars = { + ACTOR_EN_RECEPGIRL, + ACTORCAT_NPC, + FLAGS, + OBJECT_BG, +}; +``` -static void* D_80C106B0[4] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; -``` -and in undefined_syms.txt: -``` -// ovl_En_Recepgirl -D_06000968 = 0x06000968; -D_06001384 = 0x06001384; -D_06009890 = 0x06009890; -D_0600A280 = 0x0600A280; -D_0600AD98 = 0x0600AD98; -D_0600F8F0 = 0x0600F8F0; -D_0600FCF0 = 0x0600FCF0; -D_060100F0 = 0x060100F0; -D_06011B60 = 0x06011B60; +If we open up `assets/objects/object_bg.h`, we can see a bunch of different names corresponding to every asset in the object. You may notice that some of these names look a bit familiar; `object_bg_Tex_00F8F0` seems very close to the segmented address `(void*)0x600F8F0`. This is the proper object symbol for this segmented address, so we should `#include` this header in our actor and use these object symbols like so: +```c +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` +After replacing every segmented pointer with an object symbol, you should go ahead and delete every segmented pointer associated with this actor from `undefined_syms`. + We will come back and name these later when we do the object. diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index 7437c3550..a5e64d2a9 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -1,7 +1,7 @@ # Documenting -Up: [Contents](contents.md) -Previous: [Data](data.md) +- Up: [Contents](contents.md) +- Previous: [Data](data.md) Decompilation is only the first step: since the point of this project is to understand the game better than ever before, the code needs documentation. In this document, we will go through the basic stuff that it's good to do for any actor: we will not try to understand every single thing the actor does in full detail, but try to name the functions and variables usefully for a full documentation pass later to take advantage of. @@ -62,11 +62,7 @@ const ActorInit En_Recepgirl_InitVars = { (ActorFunc)EnRecepgirl_Draw, }; -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; - -static void* D_80C106B0[4] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; +static void* D_80C106B0[4] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; // static InitChainEntry sInitChain[] = { static InitChainEntry D_80C106C0[] = { @@ -76,14 +72,6 @@ static InitChainEntry D_80C106C0[] = { static s32 D_80C106C8 = 0; -extern AnimationHeader D_06000968; -extern AnimationHeader D_06001384; -extern AnimationHeader D_06009890; -extern AnimationHeader D_0600A280; -extern AnimationHeader D_0600AD98; -extern FlexSkeletonHeader D_06011B60; - - // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s") void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { EnRecepgirl* this = THIS; @@ -91,7 +79,7 @@ void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, D_80C106C0); ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bg_Skel_011B60, &object_bg_Anim_009890, this->jointTable, this->morphTable, 24); if (D_80C106C8 == 0) { for (i = 0; i < 4; i++) { @@ -132,8 +120,8 @@ void func_80C100DC(EnRecepgirl *this) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10148.s") void func_80C10148(EnRecepgirl *this) { - if (this->skelAnime.animation == &D_06001384) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_001384) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } this->actionFunc = func_80C1019C; } @@ -141,10 +129,10 @@ void func_80C10148(EnRecepgirl *this) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C1019C.s") void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, -4.0f); } } @@ -164,7 +152,7 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { // #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10290.s") void func_80C10290(EnRecepgirl *this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); this->actionFunc = func_80C102D4; } @@ -173,18 +161,18 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_ChangeDefaultRepeat(&this->skelAnime, &D_06001384); - } else if (this->skelAnime.animation == &D_0600AD98) { + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_ChangeDefaultRepeat(&this->skelAnime, &object_bg_Anim_001384); + } else if (this->skelAnime.animation == &object_bg_Anim_00AD98) { if (this->actor.textId == 0x2ADA) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } } else if (this->actor.textId == 0x2ADA) { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); } } @@ -194,21 +182,21 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - - if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + + if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); if ((gSaveContext.save.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; } else { this->actor.textId = 0x2ADA; } } else if (this->actor.textId == 0x2ADC) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); this->actor.textId = 0x2ADD; } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); if (this->actor.textId == 0x2ADD) { this->actor.textId = 0x2ADE; } else if (this->actor.textId == 0x2ADA) { @@ -349,11 +337,9 @@ Go to "Analysis -> Find Dlists" and press OK (the defaults are usually fine). Th We will talk about what all these types of data are next time, but for now, all we want to know is what ```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; +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 `extern FlexSkeletonHeader D_06011B60;` 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 `extern AnimationHeader D_06000968;`, 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, 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) @@ -389,11 +375,7 @@ But what sort of textures? This is an NPC, so what textures on the model would i **N.B.** static data should not be renamed in the assembly or `variables.txt`, since assembly has no notion of file locality and there can be symbol clashes. Therefore it should only be renamed in its respective file, not globally. ```C -extern void* D_0600F8F0; -extern void* D_0600FCF0; -extern void* D_060100F0; - -static TexturePtr sEyeTextures[] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; +static TexturePtr sEyeTextures[] = { object_bg_Tex_00F8F0, object_bg_Tex_00FCF0, object_bg_Tex_0100F0, object_bg_Tex_00FCF0 }; ``` And now it's rather more obvious what @@ -461,18 +443,18 @@ Finally, we have to name the rest of the functions. Setup functions are usually ```C void func_80C10148(EnRecepgirl* this) { - if (this->skelAnime.animation == &D_06001384) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_001384) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } this->actionFunc = func_80C1019C; } void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) != 0) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 5.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, -4.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, -4.0f); } } @@ -491,7 +473,7 @@ void func_80C1019C(EnRecepgirl* this, GlobalContext* globalCtx) { } void func_80C10290(EnRecepgirl* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); this->actionFunc = func_80C102D4; } @@ -499,18 +481,18 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { u8 temp_v0_2; if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &D_0600A280) { - Animation_ChangeDefaultRepeat(&this->skelAnime, &D_06001384); - } else if (this->skelAnime.animation == &D_0600AD98) { + if (this->skelAnime.animation == &object_bg_Anim_00A280) { + Animation_ChangeDefaultRepeat(&this->skelAnime, &object_bg_Anim_001384); + } else if (this->skelAnime.animation == &object_bg_Anim_00AD98) { if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); } else { - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } } else if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) - Animation_ChangeTransitionRepeat(&this->skelAnime, &D_06009890, 10.0f); + Animation_ChangeTransitionRepeat(&this->skelAnime, &object_bg_Anim_009890, 10.0f); } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00A280, -4.0f); } } @@ -518,20 +500,20 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) { if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? func_80C10148(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); if (gSaveContext.save.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) } } else if (this->actor.textId == 0x2ADC) { // hear directions again? - Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); this->actor.textId = 0x2ADD; // "So..." } else { - Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_000968, 10.0f); if (this->actor.textId == 0x2ADD) { // "So..." this->actor.textId = 0x2ADE; // Mayor's office is on the left, drawing room on the right @@ -568,7 +550,7 @@ We like to make macros for reading an actor's `params` (indeed, this is required } else { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); - CollisionHeader_GetVirtual(&D_06001B2C, &colHeader); + CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); } ``` @@ -588,7 +570,7 @@ Notice that we use `thisx`: this makes the form of every one of these macros the } else { Actor_SetScale(&this->dyna.actor, 0.1f); DynaPolyActor_Init(&this->dyna, 1); - CollisionHeader_GetVirtual(&D_06001B2C, &colHeader); + CollisionHeader_GetVirtual(&object_tree_Colheader_001B2C, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); } ``` diff --git a/docs/tutorial/draw_functions.md b/docs/tutorial/draw_functions.md index 5f9aa551d..eae1c121e 100644 --- a/docs/tutorial/draw_functions.md +++ b/docs/tutorial/draw_functions.md @@ -1,7 +1,7 @@ # Draw functions -Up: [Contents](contents.md) -Previous: [The rest of the functions in the actor](other_functions.md) +- Up: [Contents](contents.md) +- Previous: [The rest of the functions in the actor](other_functions.md) Draw functions behave completely differently from the other functions in an actor. They often use a lot of macros. diff --git a/docs/tutorial/images/broken_texture.png b/docs/tutorial/images/broken_texture.png new file mode 100644 index 000000000..6f79f1872 Binary files /dev/null and b/docs/tutorial/images/broken_texture.png differ diff --git a/docs/tutorial/images/custom_texture_in_game.png b/docs/tutorial/images/custom_texture_in_game.png new file mode 100644 index 000000000..92fa53811 Binary files /dev/null and b/docs/tutorial/images/custom_texture_in_game.png differ diff --git a/docs/tutorial/images/dns_custom_texture.png b/docs/tutorial/images/dns_custom_texture.png new file mode 100644 index 000000000..3b8cf4d57 Binary files /dev/null and b/docs/tutorial/images/dns_custom_texture.png differ diff --git a/docs/tutorial/images/z64utils_dns_deku_flower.png b/docs/tutorial/images/z64utils_dns_deku_flower.png new file mode 100644 index 000000000..66b40a3fd Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_deku_flower.png differ diff --git a/docs/tutorial/images/z64utils_dns_display_list.png b/docs/tutorial/images/z64utils_dns_display_list.png new file mode 100644 index 000000000..31cbd5794 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_display_list.png differ diff --git a/docs/tutorial/images/z64utils_dns_head_limb.png b/docs/tutorial/images/z64utils_dns_head_limb.png new file mode 100644 index 000000000..dcb658fe8 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_head_limb.png differ diff --git a/docs/tutorial/images/z64utils_dns_limb_dlist.png b/docs/tutorial/images/z64utils_dns_limb_dlist.png new file mode 100644 index 000000000..0f24d0225 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_limb_dlist.png differ diff --git a/docs/tutorial/images/z64utils_dns_skeletonheader.png b/docs/tutorial/images/z64utils_dns_skeletonheader.png new file mode 100644 index 000000000..4f0222673 Binary files /dev/null and b/docs/tutorial/images/z64utils_dns_skeletonheader.png differ diff --git a/docs/tutorial/images/z64utils_open_dns.png b/docs/tutorial/images/z64utils_open_dns.png new file mode 100644 index 000000000..84533270e Binary files /dev/null and b/docs/tutorial/images/z64utils_open_dns.png differ diff --git a/docs/tutorial/images/z64utils_set_segment_8.png b/docs/tutorial/images/z64utils_set_segment_8.png new file mode 100644 index 000000000..46b2f1cff Binary files /dev/null and b/docs/tutorial/images/z64utils_set_segment_8.png differ diff --git a/docs/tutorial/merging.md b/docs/tutorial/merging.md index 1d8c6ad1c..79e1386cc 100644 --- a/docs/tutorial/merging.md +++ b/docs/tutorial/merging.md @@ -1,7 +1,7 @@ # The merging process -Up: [Contents](contents.md) -Previous: [Documenting](documenting.md) +- Up: [Contents](contents.md) +- Previous: [Documenting](documenting.md) ## Preparing to PR diff --git a/docs/tutorial/object_decomp.md b/docs/tutorial/object_decomp.md index 88fe89eca..f210dd446 100644 --- a/docs/tutorial/object_decomp.md +++ b/docs/tutorial/object_decomp.md @@ -1,14 +1,160 @@ -# Analysing object files +# Object Decompilation -Up: [Contents](contents.md) -Previous: [Documenting](documenting.md) +- Up: [Contents](contents.md) +- Previous: [Documenting](documenting.md) -TODO: To be written once automated objects are present. +Object decompilation is the process of taking an object file and writing instructions to extract the various assets from it in the correct format, with appropriate labelling to distinguish their nature and/or use. -## Useful tools +## What is an object file? + +An object file is generally where most of the information used by overlays is stored. Its contents can include + +- Vertices (positional/normal/color data used by displaylists) +- Textures +- DisplayLists (instructions to the graphics processor on how to put together textures and vertices) +- Skeleton (The underlying structure of an actor's shape, that can be manipulated to change its "pose") +- Animations +- Texture Animations (instructions to scroll/cycle textures or change colors) + +## How we work with objects + +These objects are considered assets so they are not included in the repository directly. Instead we use the Zelda Asset Processor for Decompilation (ZAPD) to extract them from the ROM. As input, ZAPD takes an XML file that describes what and how to extract. Each object already has an autogenerated XML created in the `assets/xml/objects` directory, though they are incomplete with just autogenerated names. The goal of object decompilation is to complete these files by identifying any remaining blobs and giving everything proper names. + +## How to decomp an object + +Choose an object to decomp. As usual, some will be easier than others. For reasons explained shortly, it is much easier to decomp an object if all actors that use it are decompiled. + +### Files and folders + +Select the XML file of your selected object, which should be in `assets/xml/objects/object_name.xml`. + +The ZAPD output will go in the folder `assets/objects/object_name/`. You'll want this folder open later to check the output is correct. + +### Examining actor files + +All objects have had their XML generated in an automated way, so most constituent parts of each object are already identified, but will still need to be named and documented properly. Further, these objects usually have some blobs unreferenced by the object's own contents and hence not automatically extracted; most of the time these can be identified by looking at references in the actor which uses said object. + +### Extracting assets + +You can run `extract_assets.py` to extract the object's assets. Running it with no arguments extracts all files that have been updated since the last time it was run. You can also run it with `-s` (for single file), and give it the location of the object you want to extract relative to `assets`, i.e. + +```bash +./extract_assets.py -s objects/object_name +``` + +This should populate the folder you created earlier. ZAPD produces a C file containing the extracted object data, which will be `assets/objects/object_name/object_name.c`. Any data that you have not specified the type of, or is not referenced elsewhere in the object, is extracted as unknown blobs (usually named `unaccounted_XXXXXX`). Open the C file to see if there are any such blobs. (Some are just padding with 0s and can be ignored.) + +You now have to try and decipher these blobs using the [list of tools given below](#tools) to work out what they might be. In the case of unused parts of the object, this can be very difficult. + +### Naming + +You'll want to name everything that exists in the XML, but it helps to break it down into separate steps. After each step, extract the single asset again. + +1. First, name every piece of data that is directly accessed by another part of the repo (generally, but not always, actors). For most objects, this includes several of a skeleton, animations, some textures, and collision information. + +2. Then, name the limbs associated with each skeleton. This is usually straightforward, providing Z64Utils can show the skeleton properly. Note that when naming limbs, you should name them *from the object's perspective*, so the "left arm" is the one that is to the *object's* left. As part of this step, you should also replace the autogenerated enum values associated with each limb with an appropriate name. Another thing to note is that some limbs are considered "Root" limbs that are simply parents to other limbs and don't actually render anything themselves. In these cases, you can simply add `Root` to the limb name, e.g., `gGibdoRightLegRootLimb`. + +3. Next, name the display lists that are associated to limbs in the skeleton. Z64Utils can show you which display list is associated with a given limb. + +4. If any non-limb display lists still lack a name, try naming them now. + +5. Lastly, try to name every texture in the object. This can be a bit tricky just by looking at the textures, so it helps to see how they're used in the display lists. You can also try manipulating the textures, recompiling the game, and loading up the resulting ROM to see what your changes look like in-game. + +You'll notice that we didn't mention vertices in this list. This is because, for the most part, vertices are not used outside the object itself, and so are not required to have names. However, some actors have code that manipulates or otherwise interacts with vertices; in these cases, the vertices should be added to the XML and named. + +Current naming practice is to name each item in the xml using camelCase as usual, with the `g` prefix (for "global"), and the type of data last (`Skel`, `Anim`, `DL`, `Tex`, `TLUT`, `Vtx`, `TexAnim`, etc.), while output texture files are named in `snake_case`. TLUTs (texture look-up tables) should always have their output file end in `tlut`. For more info on which suffixes to use, check out the [ZAPD documentation on extraction XML](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/docs/zapd_extraction_xml_reference.md). + +### Textures + +Since all objects have an autogenerated XML, most textures in the game already have an entry in an XML file. However, some did not get automatically detected, and textures can be especially troublesome due to the abundance of formats they can be in. Some are simple RGBA textures, while others use external palettes, and can look meaningless without. If the texture is used in a displaylist, it will tell you the format, but if not, you have to use your best judgement based on anything you know about its context. + +The order of operations is that palettes are loaded first, then the texture, and then the vertices to which it is applied. + +The first argument of `gsDPLoadTextureBlock` tells you the offset, the second the format, the third the bit depth, fourth the width and fifth the height + +The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. + + +| Format name | Typing in `gsDPLoadTextureBlock` | "Format" in xml | +| ----------------------------------------------- | -------------------------------- | --------------- | +| 4-bit intensity (I) | `G_IM_FMT_I, G_IM_SIZ_4b` | i4 | +| 4-bit intensity with alpha (I/A) (3/1) | `G_IM_FMT_IA, G_IM_SIZ_4b` | ia4 | +| 4-bit color index (CI) | `G_IM_FMT_CI, G_IM_SIZ_4b` | ci4 | +| 8-bit I | `G_IM_FMT_I, G_IM_SIZ_8b` | i8 | +| 8-bit IA (4/4) | `G_IM_FMT_IA, G_IM_SIZ_8b` | ia8 | +| 8-bit CI | `G_IM_FMT_CI, G_IM_SIZ_8b` | ci8 | +| 16-bit red, green, blue, alpha (RGBA) (5/5/5/1) | `G_IM_FMT_RGBA, G_IM_SIZ_16b` | rgba16 | +| 16-bit IA (8/8) | `G_IM_FMT_IA, G_IM_SIZ_16b` | ia16 | +| 16-bit YUV (Luminance, Blue-Y, Red-Y) | `G_IM_FMT_YUV, G_IM_SIZ_16b` | (not used) | +| 32-bit RGBA (8/8/8/8) | `G_IM_FMT_RGBA, G_IM_SIZ_32b` | rgba32 | + +The 4-bit formats are loaded using `gDPLoadTextureBlock_4b`. The others use `gDPLoadTextureBlock`. + +For example, + +```c +gsDPLoadTextureBlock(D_06006110, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 4, 0, 0), +``` + +says that there is a texture at offset `0x6110`, its Format is `rgba16`, Width is `16` and Height is `16`, so we can declare + +```XML + +``` + +See [this web page](http://n64devkit.square7.ch/tutorial/graphics/3/3_3.htm) for more information about these formats, and [gSP functions](http://n64devkit.square7.ch/n64man/gsp/gSP_INDEX.htm) and [gDP functions](http://n64devkit.square7.ch/n64man/gdp/gDP_INDEX.htm) for more about the graphics functions used. + +The `ci` formats use palettes, which are declared separately. The shape you give the palette does not matter, but to avoid overlap errors it needs to fit into a rectangle; choose the one you think looks best, and if in doubt, just do height 1 and appropriate width. + +If in doubt, look at completed objects in the repo, and if still in doubt, ask. + +## Tools 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. - [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 + +Thankfully it is not necessary to do a full make from clean to check that a particular object file has been decompiled successfully. + +- With a valid xml file, run `extract_assets.py -s` on its object. +- `make` + +If you want to change a texture, for example to see precisely where it is used, the following steps ensure it will be used in the build + +- Change and save the texture. You can simply open the texture's PNG file in most image editors (e.g., Photoshop, GIMP, Paint, etc.) and edit it to your liking, though you'll need to keep the original palette in mind for palettized textures. +- Touch the object's main C file (in the same directory) +- make +- Ironically, ERROR 1 implies success (your new texture has changed the checksum). + +If you'd rather not have it tell you about the checksum, you can run `make COMPARE=0` instead. + +--- + +To revert to the original texture, you can just run `extract_assets.py -s` on the object again. + +N.B. doing this will overwrite every custom texture, as will running `make setup`. + +## Example + +An example of decompiling a particular object is given [here](object_decomp_example.md). + +## Tips and Tricks + +### Fixing improper-looking textures + +For CI4 and CI8 textures, you might see improper-looking textures like so: + +![An improper-looking CI8 texture](images/broken_texture.png) + +The reason this happens is because ZAPD couldn't determine the TLUT for the texture, so it couldn't use the proper palette. To fix this, you can supply a `TlutOffset` to the texture like so: +```xml + +``` + +### Understanding texture animations + +Texture animations are new to Majora's Mask, and they can be pretty tricky to understand. Luckily, there's some extensive documentation on how they're structured [here](https://github.com/zeldaret/mm/blob/master/tools/ZAPD/ZAPD/ZTextureAnimation.cpp). One useful thing to remember is that empty texture animations take the form of `00 00 00 06 00 00 00 00`. The process that automatically generated all the object XMLs sometimes failed to recognize this as an empty texture animation, so it puts it in various blobs or fails to account for it at all. + Next: [The merging process](merging.md) \ No newline at end of file diff --git a/docs/tutorial/object_decomp_example.md b/docs/tutorial/object_decomp_example.md new file mode 100644 index 000000000..798167e68 --- /dev/null +++ b/docs/tutorial/object_decomp_example.md @@ -0,0 +1,258 @@ +# Object Decompilation Example + +- Previous: [Object Decompilation](object_decomp.md) + +Let's take a look at `object_dns`, which is a pretty typical NPC object. It's used by one actor: `ovl_En_Dns`. + +## 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. + +![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": + +![Finding object_dns's SkeletonHeader in Z64Utils](images/z64utils_dns_skeletonheader.png) + +When you open the Skeleton Viewer, you'll see a list of animations off to the side. Selecting one of them will display an error that says something like `RENDER ERROR AT 0x06001A98! (Could not read 0x80 bytes at address 08000000)`. This is because one of the display lists in the skeleton is expecting something to be set at segment 8. From the actor, we know that it's expecting the eye textures to be loaded into segment 8 like so: +```c +static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; +[...] +gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); +``` + +Let's set segment 8 to be one of the eye textures listed here. Click on "Segments", then for segment 08, click "Edit" and select "Address" as the source. Input "060028E8" as the address, then hit OK. This should result in the window looking as follows: + +![Setting segment 8 to one of the eye textures in Z64Utils](images/z64utils_set_segment_8.png) + +Now that we've gotten around the error, we can see what each limb in the skeleton corresponds to by clicking on it in the Hierarchy. Clicking on any given limb will highlight what part of the model it represents in red. In the below example, this limb is clearly the head: + +![Showing the head limb in Z64Utils](images/z64utils_dns_head_limb.png) + +Note that some limbs don't actually render anything, so sometimes clicking on a limb will not turn anything red; this may indicate a "Root" limb that has no associated display list, or it may indicate something like an eye limb that doesn't have the right textures loaded to display anything in Z64Utils. It may be useful to skip ahead to [Step #5](#step-5-naming-limb-display-lists) to learn how to check if the limb has a display list. If it doesn't have a display list, then it's a "Root" limb that will never be highlighted. + +We can now start naming the skeleton and individual limbs. Since we know this particular skeleton is the King's Chamber Deku Guard, we can name the skeleton `gKingsChamberDekuGuardSkel`. For the LimbNone name, we can call it something like `KINGS_CHAMBER_DEKU_GUARD_LIMB_NONE`, and we can name the LimbMax similarly. For the EnumName, we can name it `KingsChamberDekuGuardLimbs`. For each individual limb, we can name them based on what we see in Z64Utils; just make sure to update both the Name and the EnumName. After naming everything, we have something that looks like this: +```xml + + + + + + + + + + + + + +``` + +Now we can run `./extract_assets.py -s objects/object_dns` to extract the object again, this time with our new names. What can we do with this? Quite a bit actually. In `z_en_dns.h`, we can add this to the top of the file to start using these new names in our code: +```c +#include "objects/object_dns/object_dns.h" +``` + +Now, we can redefine the `jointTable` and `morphTable` in terms of the limb enum we defined before, like so: +```c +/* 0x22A */ Vec3s jointTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; +/* 0x278 */ Vec3s morphTable[KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX]; +``` + +We can also use our new skeleton name and limb enum when initialization the skeleton like so: +```c +SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); +``` + +Lastly, we can use our limb enum in `EnDns_PostLimbDraw`. Where the code originally had: +```c +if (limbIndex == 2) { + [...] +} +``` + +We can instead write: +```c +if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { + [...] +} +``` + +## Step 2: Naming the animations + +Now that we have the skeleton figured out, it's time to name all the animations. In the Skeleton Viewer, you can hit the "play" button on any animation to see what it looks like. Note that some objects have multiple skeletons, and selecting an animation that is associated with a different skeleton than the one you're looking at can cause odd behavior. Try to give each animation a descriptive name based on what it looks like. If you're struggling; +- Try viewing the animation in game. In what contexts does this animation play? +- Try analyzing the code for the actor to see when the animation is used. Is this animation ever referenced? +- If you're still really struggling, Majora's Mask 3D contains the original animation names for the majority of animations in the game. These original names can help you figure out what the developers were originally intending. Explaining how to find these animations in MM3D is outside of the scope of this document, so just ask in Discord if you want to try this. + +After naming the animations, the end result will look something like this: +```xml + + + + + + +[...] + + +``` + +Once again, we can run `./extract_assets.py -s objects/object_dns` to extract the object, and we can update the animation names in `z_en_dns.c` to use our new names like so: +```c +static AnimationInfoS sAnimations[] = { + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardRunStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardRunLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardDanceAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardFlipAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, +}; +``` + +## Step 3: Identifying the blob + +In the XML, you may notice undefined blobs like this: +```xml + +``` + +You might already have an idea as to what this is based on what you've seen before. Recall that the eye textures are referenced in the actor's code like this: +```c +static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 }; +``` + +Do you notice how the "28E8" in `D_060028E8` also appears as the Offset in that blob? That's because the blob is just the eye textures; the process for automatically creating the XML wasn't able to figure it out on its own, so we'll need to do it ourselves. But how should we define these textures in the XML? Recall that the eye textures were loaded into segment 8; let's take a look in `object_dns.c` and see if we can find something that uses this segment. This display list has the answer: +```c +Gfx object_dns_DL_001A50[] = { + [...] + gsDPLoadTextureBlock(0x08000000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | + G_TX_CLAMP, 3, 3, G_TX_NOLOD, G_TX_NOLOD), + [...] +}; +``` + +Using `0x08000000` with `gsDPLoadTextureBlock` signals that this display list is expecting a texture in segment 8. What kind of texture is it expecting? We can look at the arguments after the `0x08000000`. It's looking for an RBGA16 texture with dimensions of 8x8, so we can define these textures in the XML like so: +```xml + + + +``` + +Now, we just have to name them. In [Step #1](#step-1-naming-the-skeleton-and-limbs), we set segment 8 to one of the eye textures; we can use that same technique with the other two eye textures to see what they are. Like most NPCs, these various eye textures are used for handling blinking, so we can name them based on how open the eye is: +```xml + + + +``` + +Like with previous steps, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new names: +```c +static TexturePtr sEyeTextures[] = { + gKingsChamberDekuGuardEyeOpenTex, + gKingsChamberDekuGuardEyeHalfTex, + gKingsChamberDekuGuardEyeClosedTex, + gKingsChamberDekuGuardEyeHalfTex, +}; +``` + +Note that this step might be tricky to do if multiple things in the actor use the same segment. It's okay to wait to do this until you've named all the display lists in the actor, since that will make it easier to find the display list associated with a given texture. + +## Step #4: Naming anything else in the actor + +For some actors, there may be a few other things left to name that are directly referenced in the actor's code. In our case, there is one display list that we still need to name: +```c +gSPDisplayList(POLY_OPA_DISP++, &D_06002C48); +``` + +In Z64Utils, scroll to find this display list, then right-click and select "Open in Dlist Viewer": + +![Opening dlist_00002C48 in Z64Utils](images/z64utils_dns_display_list.png) + +We can see this is the guard's Deku Flower: + +![Showing the guard's Deku Flower in Z64Utils](images/z64utils_dns_deku_flower.png) + +We can name the display list as such in the XML: +```xml + +``` + +Then, like all steps before, we can run `./extract_assets.py -s objects/object_dns` and then update `z_en_dns.c` with our new name: +```c +gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); +``` + +## Step #5: Naming limb display lists + +Now that we've named everything that's used externally by the actor, we just need to clean up the rest of the unnamed stuff in the XML. Let's start by naming the display lists for each limb. There are two ways you can determine which display list is associated with a given limb. One way is to click on the limb in Z64Utils; it will tell you what display list is used for that limb: + +![Showing the head limb's display list in Z64Utils](images/z64utils_dns_limb_dlist.png) + +Another way is to simply check `object_dns.c`. Each limb lists its own display list like this: +```c +StandardLimb gKingsChamberDekuGuardHeadLimb = { + { 0, 1300, 0 }, KINGS_CHAMBER_DEKU_GUARD_LIMB_STALK - 1, KINGS_CHAMBER_DEKU_GUARD_LIMB_LEFT_FOOT - 1, + object_dns_DL_0018B8 +}; +``` + +Either way you go about it, you should be able to name all the limb display lists like so: +```xml + + + + + + + + + + + + +``` + +Run `./extract_assets.py -s objects/object_dns` once again, since it will help in the next step to have all of our display lists named. + +### Step #6: Naming remaining textures + +With every display list named, it's now a lot easier to name the remaining textures. In the `assets/objects/object_dns/` folder, you can see all the textures in the object as various PNG files. For some of the textures, just looking at them will give you a good idea as to what they should be named. For other textures, it may help to see how the texture is used in the object's display lists. Let's take a look at `object_dns_Tex_002868`, which is only used in one display list: +```c +Gfx gKingsChamberDekuGuardSnoutDL[] = { + [...] + gsDPLoadTextureBlock(object_dns_Tex_002868, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_MIRROR | G_TX_CLAMP, + G_TX_MIRROR | G_TX_CLAMP, 3, 3, G_TX_NOLOD, G_TX_NOLOD), + [...] +}; +``` + +Since `tex_002868.rgba16.png` looks like the inside of the Deku Guard's mouth, and it's *only* used in the snout display list, you can probably name this something like `gKingsChamberDekuGuardMouthTex`. But rather than guessing, we can confirm it by editing the texture ourselves and then viewing it in-game. Using an image editor, let's change `tex_002868.rgba16.png` to this: + +![Our custom mouth texture](images/dns_custom_texture.png) + +Now, rebuild the game using [the steps described here](object_decomp.md#building-and-investigative-modding) and look at the guard in-game. You should see something like this: + +![Our custom mouth texture being shown in-game](images/custom_texture_in_game.png) + +This confirms our suspicion that this is indeed the mouth texture, so we can name it as such. We can use similar strategies to name all the other textures like so: +```xml + + + +``` + +### Step #7: Finishing up + +If you have any other unnamed assets, now's the time to identify them. Otherwise, finish up the file by putting a comment at the top above the `` node: +```xml + + + +``` + +And we're done! Hopefully, you found this example helpful when decompiling your own objects. \ No newline at end of file diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index 7a685458c..796939dd8 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -1,7 +1,7 @@ # The rest of the functions in the actor -Up: [Contents](contents.md) -Previous: [Beginning decompilation: the Init function and the Actor struct](beginning_decomp.md) +- Up: [Contents](contents.md) +- Previous: [Beginning decompilation: the Init function and the Actor struct](beginning_decomp.md) ## Now what? @@ -288,7 +288,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { func_80C10148(this); return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { temp_v0_3 = this->actor.textId; if (temp_v0_3 == 0x2AD9) { Flags_SetSwitch(globalCtx, (s32) this->actor.params); @@ -347,7 +347,7 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) { return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); @@ -397,7 +397,7 @@ somehow we skipped over `t0`. Where is this in the code? The `153` in the middle return; } - if (((temp_v0_2 & 0xFF) == 5) && (func_80147624(globalCtx) != 0)) { + if (((temp_v0_2 & 0xFF) == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { ``` If you look at the conditionals and the declaration of `temp_v0_2`, you may notice something odd: `temp_v0_2` is a `u8`. Therefore the `& 0xFF` does nothing! It's surprisingly common for this to happen, be it leaving out a `& 0xFF` or adding an extraneous one. If we remove it, we get a match: diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 2c04e570f..ace2cd2e8 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -2899,6 +2899,9 @@ _DW({ \ gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) #endif + #define gDPSetDither(pkt, mode) \ + gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 4, mode) + /* 'blendmask' is not supported anymore. * The bits are reserved for future use. * Fri May 26 13:45:55 PDT 1995 diff --git a/include/command_macros_base.h b/include/command_macros_base.h index bb5ce1648..4a866c29e 100644 --- a/include/command_macros_base.h +++ b/include/command_macros_base.h @@ -17,9 +17,9 @@ #define CMD_W(a) (a) #ifdef __GNUC__ -#define CMD_F(a) {.f = (a)} +#define CMD_F(a) .f = (a) #else -#define CMD_F(a) {(a)} +#define CMD_F(a) (a) #endif #define CMD_PTR(a) (uintptr_t)(a) diff --git a/include/functions.h b/include/functions.h index 201a7c5c7..8ad9b47b2 100644 --- a/include/functions.h +++ b/include/functions.h @@ -7,8 +7,8 @@ void bootproc(void); void Idle_ThreadEntry(void* arg); void ViConfig_UpdateVi(u32 arg0); void ViConfig_UpdateBlack(void); -s32 DmaMgr_DMARomToRam(u32 src, void* dst, size_t size); -void DmaMgr_DmaCallback0(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); +s32 DmaMgr_DmaRomToRam(u32 src, void* dst, size_t size); +s32 DmaMgr_DmaHandler(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); DmaEntry* DmaMgr_FindDmaEntry(u32 vromAddr); u32 DmaMgr_TranslateVromToRom(u32 vromAddr); s32 DmaMgr_FindDmaIndex(u32 vromAddr); @@ -153,14 +153,10 @@ void MtxConv_L2F(MtxF* m1, MatrixInternal* m2); void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); -void SystemArena_FreeNull(void* pvParm1); -void func_8008633C(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4); -void func_800863AC(u32 param_1, s32 param_2, s32 param_3, UNK_PTR param_4); -// void func_8008641C(void); -// void func_800864EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80086588(void); -void SystemArena_Init(u32 base, u32 size); -s32 PadSetup_Init(OSMesgQueue* mq, u8* outMask, OSContStatus* status); +void SystemArena_FreeNullCheck(void* ptr); +void SystemArena_RunInits(void); +void SystemArena_Init(void* start, size_t size); +s32 func_80086620(OSMesgQueue* param_1, PadMgr* param_2, OSContStatus* param_3); // void func_80086760(void); // void func_80086794(void); // void func_800867B4(void); @@ -576,10 +572,10 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca // void EffectSsStick_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE2 uParm3); // void EffectSsSibuki_Spawn(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos); -// void EffectSsStone1_Spawn(UNK_TYPE4 uParm1, UNK_PTR puParm2, UNK_TYPE4 uParm3); +void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* arg1, s32 arg2); // void EffectSsHitMark_Spawn(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, UNK_TYPE2 uParm3, Vec3f* pzParm4); void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos); -// void EffectSsHitMark_SpawnCustomScale(void); +void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos); // void EffectSsFhgFlash_SpawnShock(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE1 param_5); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); @@ -595,12 +591,12 @@ void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* // void EffectSsFireTail_SpawnFlameOnPlayer(void); void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, s16 bodyPart); // void EffectSsEnFire_SpawnVec3s(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); -// void EffectSsExtra_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); +void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx); void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk); void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s32 colorIndex); -// void EffectSsDeadDd_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE1* param_5, UNK_TYPE1* param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10); +void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life); // void EffectSsDeadDs_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE4 param_8); -// void func_800B31BC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); +void func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life); void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale); void FlagSet_Update(GameState* gameState); @@ -772,17 +768,17 @@ s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor); void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx); void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown); void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed); -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3); +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown); void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type); void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration); Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx); Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx); -void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 parm5); +void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop); s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)); void func_800BD888(Actor* actor, struct_800BD888_arg1* arg1, s16 arg2, s16 arg3); void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha); -void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index); +void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index); void Actor_Noop(Actor* actor, GlobalContext* globalCtx); void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist); @@ -799,7 +795,7 @@ void func_800BE504(Actor* actor, ColliderCylinder* collider); void func_800BE568(Actor* actor, ColliderSphere* collider); void func_800BE5CC(Actor* actor, ColliderJntSph* collider, s32 colliderIndex); s32 func_800BE63C(struct EnBox* chest); -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, f32 effectAlpha, u8 mode); +void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, f32 frozenSteamScale, f32 effectAlpha, u8 type); void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb, f32 scale, f32 scaleRange); void ActorOverlayTable_FaultPrint(void* arg0, void* arg1); @@ -979,7 +975,7 @@ s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor); -s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4); +s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, s16 startHeight); f32 Camera_fabsf(f32 f); f32 Camera_LengthVec3f(Vec3f* v); // void func_800CB270(void); @@ -1140,13 +1136,13 @@ s32 Camera_ChangeMode(Camera* camera, s16 mode); // void func_800DF86C(void); // void func_800DF8EC(void); s32 func_800DFAC8(Camera* camera, s16 param_2); -u32 func_800DFB14(Camera* camera, u32 param_2); +u32 Camera_ChangeDataIdx(Camera* camera, u32 camDataIdx); // void func_800DFC1C(void); // void func_800DFC40(void); -s32 func_800DFC68(Camera* camera); -// void func_800DFC90(void); -s16 func_800DFCB4(Camera* camera); -s16 func_800DFCDC(Camera* camera); +s32 Camera_GetInputDirYaw(Camera* camera); +void func_800DFC90(Vec3s* arg0, Camera* camera); +s16 Camera_GetCamDirPitch(Camera* camera); +s16 Camera_GetCamDirYaw(Camera* camera); void func_800DFD04(Camera* camera, s32 arg1, s32 arg2, s32 arg3); // void func_800DFD78(void); // UNK_TYPE4 func_800DFEF0(s32 param_1, u16 param_2); @@ -1155,16 +1151,16 @@ void func_800DFD04(Camera* camera, s32 arg1, s32 arg2, s32 arg3); // UNK_TYPE4 func_800DFF44(void); s16 Camera_SetFlags(Camera* iParm1, s16 flags); s16 Camera_ClearFlags(Camera* camera, s16 flags); -// void func_800DFFAC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); +s32 func_800DFFAC(Camera* camera, Actor* doorActor, s16 bgCamDataId, f32 arg3, s16 timer1, s16 timer2, s16 timer3); // UNK_TYPE4 func_800E007C(Camera* param_1, Camera* param_2); // UNK_TYPE4 func_800E01AC(void); -// void func_800E01B8(void); +Vec3f* Camera_GetQuakeOffset(Vec3f* dst, Camera* camera); // void func_800E01DC(s32 param_1, u32 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); // UNK_TYPE4 func_800E0228(void); // void func_800E0238(void); -void func_800E02AC(Camera* camera, Actor* actor); -void func_800E0308(Camera* camera, Actor* actor); -f32 func_800E031C(Camera* camera); +void Camera_SetToTrackActor(Camera* camera, Actor* actor); +void Camera_SetTargetActor(Camera* camera, Actor* actor); +f32 Camera_GetWaterYPos(Camera* camera); void func_800E0348(Camera* camera); DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* damageTable); @@ -1388,7 +1384,7 @@ s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); void SaveContext_Init(void); void GameInfo_Init(void); -// void func_800E9470(void); +// void DebugDisplay_Init(void); 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, GraphicsContext* gfxCtx); // void func_800E9C90(void); // void func_800E9CA0(s32 param_1, UNK_TYPE1 param_2, s8* param_3); @@ -1396,55 +1392,24 @@ DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, // void func_800E9DBC(void); // void func_800E9E94(void); void func_800E9F78(GraphicsContext* gfxCtx); + void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA0D4(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA0EC(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_StepCutscene1(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_StepCutscene2(GlobalContext* globalCtx, CutsceneContext* csCtx); -void Cutscene_Nop800EA210(GlobalContext* globalCtx, CutsceneContext* csCtx); -s32 func_800EA220(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target); -void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EA324(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EABAC(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd); -void func_800EAC08(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicChange* cmd); -void func_800EAC44(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicChange* cmd); -void func_800EAC94(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicFade* cmd); -void func_800EAD14(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAECC(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EAF20(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdUnk190* cmd); -void func_800EAFE0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdUnk9B* cmd); -void func_800EB1DC(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd); -void func_800EB364(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EB4B4(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EB6F8(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EBB68(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EBCD0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -void func_800EBD60(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd); -s32 func_800EC678(GlobalContext* globalCtx, CsCmdUnk5A* cmd); -// u32 func_800EC6D4(void); -void func_800EC924(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd); -void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index); -void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr, u16* commandReadHead); -void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx); +void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx); void func_800EDBE0(GlobalContext* globalCtx); -void nop_800EDDB0(GlobalContext* globalCtx); -// void func_800EDDBC(void); -void func_800EDDCC(GlobalContext* globalCtx, u32 uParm2); -void func_800EDE34(Actor* actor, GlobalContext* globalCtx, s32 param_3); -void func_800EDF24(Actor* actor, GlobalContext* globalCtx, u32 arg2); -void func_800EDF78(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -void func_800EE0CC(Actor* actor, GlobalContext* globalCtx, s32 iParm3); -s32 func_800EE1D8(GlobalContext* globalCtx); -u32 func_800EE200(GlobalContext* globalCtx, u16 uParm2); -u32 func_800EE29C(GlobalContext* globalCtx, u16 uParm2); -u32 func_800EE2F4(GlobalContext* globalCtx); +void func_800EDDB0(GlobalContext* globalCtx); +void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex); +void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex); +s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx); +s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd); +s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd); +u8 Cutscene_IsPlaying(GlobalContext* globalCtx); + void GetItem_Draw(GlobalContext* globalCtx, s16 index); void func_800EE364(GlobalContext* globalCtx, s16 index); void func_800EE400(GlobalContext* globalCtx, s16 index); @@ -1478,21 +1443,7 @@ void SoundSource_UpdateAll(GlobalContext* globalCtx); void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId); void SoundSource_PlaySfxEachFrameAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId); u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx); -s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); -Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); -void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); -s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx); -void EnHy_Blink(EnHy* enHy, s32 arg1); -s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* arg2, s16 arg3, s16 arg4); -s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); -s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3); -s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex); -s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); -s32 EnHy_MoveForwards(EnHy* enHy, f32 arg1); -s32 EnHy_MoveBackwards(EnHy* enHy, f32 arg1); -void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx); -s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 arg2); + u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet); void EnvFlags_UnsetAll(GlobalContext* globalCtx); void EnvFlags_Set(GlobalContext* globalCtx, s16 flag); @@ -1517,10 +1468,10 @@ s16 ActorCutscene_GetCurrentIndex(void); ActorCutscene* ActorCutscene_GetCutscene(s16 index); s16 ActorCutscene_GetAdditionalCutscene(s16 index); s16 ActorCutscene_GetLength(s16 index); -// void func_800F2138(void); +s32 func_800F2138(s8 arg0); s32 func_800F2178(s16 arg0); s16 ActorCutscene_GetCurrentCamera(s16 index); -// void func_800F21CC(void); +s16 func_800F21CC(void); s32 func_800F22C4(s16 param_1, Actor* actor); void ActorCutscene_SetReturnCamera(s16 index); // void func_800F23E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); @@ -1537,21 +1488,22 @@ void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* in void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire); void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState); void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor); -// void func_800F3940(void); +s32 func_800F3940(GlobalContext* globalCtx); // void func_800F39B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_800F3A64(void); -// void func_800F3B2C(void); +void func_800F3B2C(GlobalContext* globalCtx); // void func_800F3B68(void); // void func_800F3C44(void); // void func_800F3ED4(void); void func_800F40A0(GameState* gameState, Player* player); -// void func_800F415C(void); +void func_800F415C(Actor* actor, Vec3f* arg1, s16 arg2); UNK_TYPE func_800F41E4(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800F4A10(GlobalContext* globalCtx); -void func_800F4C0C(GlobalContext* globalCtx); +void KaleidoSetup_Update(GlobalContext* globalCtx); void KaleidoSetup_Init(GlobalContext* globalCtx); void KaleidoSetup_Destroy(GlobalContext* globalCtx); + void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset); void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset); void Font_LoadMessageBoxEndIcon(Font* font, u16 icon); @@ -1560,7 +1512,7 @@ void Font_LoadOrderedFont(Font* font); // void func_800F50D4(void); void Kankyo_Init(GlobalContext* globalCtx, EnvironmentContext* envCtx); u32 func_800F5954(u8* param_1, u32 param_2, u32 param_3, u8 param_4, u8 param_5); -f32 func_800F5A8C(u16 arg0, u16 arg1, u16 arg2, GlobalContext* globalContext); +f32 Environment_LerpWeight(u16 max, u16 min, u16 val); // void func_800F5B10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void func_800F5CD0(void); void func_800F6834(GlobalContext* globalCtx, s32 waterLightsIndex); @@ -1588,7 +1540,7 @@ void func_800FAAB4(GlobalContext* globalCtx, u8 arg1); // void func_800FAC20(void); // void func_800FAF74(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_800FB010(void); -void func_800FB320(GlobalContext* globalCtx, u8 param_2); +void Environment_AddLightningBolts(GlobalContext* globalCtx, u8 num); // void func_800FB388(void); void func_800FB758(GlobalContext* globalCtx); // void func_800FB9B4(void); @@ -1604,7 +1556,7 @@ void func_800FD538(Color_RGB8* param_1, Color_RGB8* param_2, f32 param_3, Vec3s* void func_800FD59C(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD5E0(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); -// void func_800FD698(void); +void func_800FD698(GlobalContext* globalCtx, s16 arg1, s16 arg2, f32 arg3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); @@ -1631,9 +1583,9 @@ void func_800FE658(f32 arg0); // void func_800FE778(void); // void func_800FE788(void); // void func_800FE798(void); -// void func_800FE7A8(void); +void func_800FE7A8(Color_RGBA8* inColor, Color_RGBA8* outColor); s32 func_800FE9B4(GlobalContext* globalCtx); -// void func_800FEA50(void); +void func_800FEA50(GlobalContext* globalCtx); void func_800FEAB0(void); // void func_800FEAC0(void); void func_800FEAF4(EnvironmentContext* envCtx); @@ -1692,7 +1644,7 @@ void Actor_ProcessInitChain(Actor* actor, InitChainEntry* ichain); f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, f32 step, f32 minStep); void Math_ApproachF(f32* pValue, f32 target, f32 scale, f32 maxStep); void Math_ApproachZeroF(f32* pValue, f32 scale, f32 maxStep); -s32 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep); void Math_ApproachS(s16* pValue, s16 target, s16 scale, s16 maxStep); void Color_RGBA8_Copy(Color_RGBA8* dst, Color_RGBA8* src); void func_801000A4(u16 sfxId); @@ -1846,7 +1798,7 @@ void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* p // void func_80109F78(void); s32 func_8010A000(GlobalContext* globalCtx); s32 func_8010A074(GlobalContext* globalCtx); -// void func_8010A0A4(void); +s32 func_8010A0A4(GlobalContext* globalCtx); // void func_8010A0F0(void); // void func_8010A164(void); // void func_8010A194(void); @@ -1945,7 +1897,7 @@ void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); // void Interface_InitVertices(void); // void func_8010E968(void); void func_8010E9F0(s16 arg0, s16 arg1); -// void func_8010EA9C(void); +void func_8010EA9C(s16 timeLimit, s16 arg1); // void func_8010EB50(void); // void func_8010EBA0(void); // void func_8010EC54(void); @@ -2022,7 +1974,7 @@ f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); void Path_CopyLastPoint(Path* path, Vec3f* dest); void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); -// void func_801226E0(void); +void func_801226E0(GlobalContext* globalCtx, s8 arg1); void func_80122744(GlobalContext* globalCtx, UNK_PTR arg1, u32 arg2, Vec3s* arg3); s32 func_80122760(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); void func_80122868(GlobalContext* globalCtx, Player* player); @@ -2034,12 +1986,12 @@ void func_801229A0(GlobalContext* globalCtx, Player* player); // void func_80122D44(void); // void func_80122ED8(void); // void func_80122EEC(void); -void func_80122F28(Player* player, GlobalContext* globalCtx, Actor* actor); -// void func_80122F9C(void); -// void func_80122FCC(void); -// void func_8012300C(void); +void func_80122F28(Player* player); +s32 func_80122F9C(GlobalContext* globalCtx); +s32 func_80122FCC(GlobalContext* globalCtx); +void func_8012300C(GlobalContext* globalCtx, s32 arg1); void func_8012301C(s32 iParm1, GlobalContext* globalCtx); -void func_80123140(GlobalContext* globalCtx, Player* param_2); +void func_80123140(GlobalContext* globalCtx, Player* player); u32 func_80123358(GlobalContext* globalCtx, Player* player); s32 Player_InCsMode(GameState* gameState); // void func_80123420(void); @@ -2066,13 +2018,13 @@ s32 func_80124020(void); u8 Player_GetMask(GlobalContext* globalCtx); void Player_RemoveMask(GlobalContext* globalCtx); s32 func_8012405C(GlobalContext* globalCtx); -// void func_80124088(void); +s32 func_80124088(GlobalContext* globalCtx); s32 func_801240C8(Player* player); // void func_801240DC(void); // void func_80124110(void); // void func_80124148(void); // void func_80124168(void); -// void func_80124190(void); +s32 func_80124190(Player* player); // void func_801241B4(void); // void func_801241E0(void); // void func_8012420C(void); @@ -2099,7 +2051,7 @@ s32 func_801242B4(Player* player); // void func_80125D4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801262C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801263FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_80126440(GlobalContext* globalCtx, Collider* param_2, s32* param_3, Vec3f* param_4, Vec3f* param_5); +s32 func_80126440(GlobalContext* globalCtx, Collider* param_2, s32* param_3, Vec3f* param_4, Vec3f* param_5); // void func_801265C8(void); // void func_8012669C(void); // void func_80126808(void); @@ -2377,7 +2329,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor, Mtx** mtx); void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, TransformLimbDrawOpa transformLimbDraw, Actor* actor); -void SkelAnime_GetFrameData(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); +void SkelAnime_GetFrameData(AnimationHeader* animation, s32 currentFrame, s32 limbCount, Vec3s* dst); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx); @@ -2395,7 +2347,7 @@ void AnimationContext_DisableQueue(GlobalContext* globalCtx); AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type); void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src); -void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4); +void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index); void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3); @@ -2413,25 +2365,25 @@ s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime); void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); -void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitionRate); -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); -void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg); -void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed); -void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg); -void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 playbackSpeed); +void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morphFrames); +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); +void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation); +void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); +void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation); +void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed); void LinkAnimation_CopyJointToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime); void LinkAnimation_CopyMorphToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime); -void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 frame); -void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 frame); +void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); +void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame); void LinkAnimation_InterpJointMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame); -void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 transitionFrame, LinkAnimationHeader* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate, Vec3s* jointTable); -void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, f32 transitionFrame, LinkAnimationHeader* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate, Vec3s* jointTable); +void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); +void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable); void LinkAnimation_EndLoop(SkelAnime* skelAnime); -s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 arg1, f32 updateRate); -s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 arg1); -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); +s32 Animation_OnFrameImpl(SkelAnime* skelAnime, f32 frame, f32 updateRate); +s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame); +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount); -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); s32 SkelAnime_Morph(SkelAnime* skelAnime); @@ -2440,39 +2392,22 @@ void SkelAnime_AnimateFrame(SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); -void Animation_ChangeImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationType, f32 transitionRate, s8 unk2); -void Animation_Change(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 mode, f32 transitionRate); -void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg); -void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); -void Animation_PlayOnceSetSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); -void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg); -void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate); -void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed); +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* index); -void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3); +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* pos, s16 angle); -s32 Animation_OnFrame(SkelAnime* skelAnime, f32 arg1); +s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame); void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); -// void func_80137970(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80137B34(void); -// void func_80137EBC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80137F58(void); -// void func_80138050(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80138228(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80138258(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8013828C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_801382C4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_80138300(void); -// void func_8013835C(void); -// void func_80138410(void); -// void func_80138424(void); -// void func_8013859C(void); -// void func_80138700(void); -// void func_801387D4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801388E4(void); void SkinMatrix_Vec3fMtxFMultXYZW(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest); void SkinMatrix_Vec3fMtxFMultXYZ(MtxF* mf, Vec3f* src, Vec3f* dest); void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); @@ -2497,59 +2432,61 @@ void SkinMatrix_MulXRotation(MtxF* mf, s16 a); void SkinMatrix_SetYRotation(MtxF* mf, s16 a); void SkinMatrix_MulYRotation(MtxF* mf, s16 a); void SkinMatrix_SetZRotation(MtxF* mf, s16 a); + s32 func_8013A240(GlobalContext* globalCtx); void func_8013A41C(s32 flag); void func_8013A46C(s32 flag); u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); +Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); -void func_8013AED4(u16* arg0, u16 arg1, u16 arg2); +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); -Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); -s32 func_8013BC6C(SkelAnime* skelAnime, ActorAnimationEntryS* arg1, s32 arg2); -s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); -Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); -s32 func_8013C8B8(Path* path, s32 arg1, Vec3f* arg2); +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); -s32 func_8013D5E8(s16 arg0, s16 arg1, s16 arg2); -Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s16 arg2); -s32 func_8013D68C(Path* path, s32 arg1, Vec3f* arg2); -s16 func_8013D720(Vec3f* arg0, Vec3f* arg1, f32* arg2); -s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); -s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -s8 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); -s8 func_8013D924(s16 arg0, GlobalContext* globalCtx); +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); +s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -s32 func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3); -s32 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); -s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); -void func_8013DCE0(GlobalContext* globalCtx, Vec3f* arg1, Actor* arg2, struct_8013DF3C_arg1* arg3, Path* arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, u8 arg9); -s32 func_8013DE04(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1, struct_8013DF3C_arg1_unk_func1 arg2, struct_8013DF3C_arg1_unk_func2 arg3, struct_8013DF3C_arg1_unk_func2 arg4, struct_8013DF3C_arg1_unk_func2 arg5); -void func_8013DF3C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E054(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E07C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -s32 func_8013E0A4(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); -void func_8013E1C8(SkelAnime* skelAnime, struct_80B8E1A8 animations[], s32 animationIndex, s32* actorAnimationIndex); -s32 func_8013E2D4(Actor* actor, s16 arg1, s16 arg2, s32 arg3); -s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s16 len); +s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCount(Path* paths, s32 index); +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath); +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); @@ -2634,45 +2571,13 @@ Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); void SkyboxDraw_Noop(SkyboxContext* skyboxCtx); -void func_80143A10(u8 owlId); -// void func_80143A54(void); -void func_80143AC4(void); -void func_80143B0C(GlobalContext* globalCtx); -void Sram_IncrementDay(void); -u32 Sram_CalcChecksum(u8* data, u32 length); -// void func_80144628(void); -// void Sram_GenerateRandomSaveFields(void); -void func_80144890(void); -void Sram_InitDebugSave(void); -// void func_80144A94(void); -// void func_80144E78(void); -// void func_8014546C(void); -// void func_80145698(void); -void func_801457CC(GameState* gameState, SramContext* param_2); -void func_80146580(s32 param_1, SramContext* param_2, s32 param_3); -// void func_80146628(void); -// void func_80146AA0(void); -// void func_80146DF8(void); -void func_80146E40(GameState* gameState, SramContext* sramCtx); -void Sram_Alloc(GameState* gameState, SramContext* sramCtx); -// void func_80146EBC(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); -// void func_80146EE8(void); -// void func_80146F5C(void); -// void func_80147008(void); -void func_80147020(SramContext* param_1); -void func_80147068(SramContext* param_1); -// void func_80147138(SramContext* param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3); -void func_80147150(SramContext* param_1); -void func_80147198(SramContext* param_1); -// void func_80147314(void); -// void func_80147414(void); -// void Sram_nop8014750C(UNK_TYPE4 param_1); + // void func_80147520(void); void func_80147564(GlobalContext* globalCtx); -u32 func_80147624(GlobalContext* globalCtx); -u32 func_80147734(GlobalContext* globalCtx); +s32 Message_ShouldAdvance(GlobalContext* globalCtx); +s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx); void func_801477B4(GlobalContext* globalCtx); -// void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); +void func_80147818(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80147F18(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); // void func_80148558(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE4 uParm3, UNK_TYPE4 uParm4); void func_80148B98(GlobalContext* globalCtx, u8 bParm2); @@ -2683,28 +2588,28 @@ void func_80148B98(GlobalContext* globalCtx, u8 bParm2); // void func_80149454(void); // void func_801496C8(void); // void func_8014995C(void); -// void func_80149C18(void); -// void func_80149EBC(void); +void func_80149C18(GlobalContext* globalCtx); +// void Message_FindMessage(void); void func_80149F74(GlobalContext* globalCtx, u32** ppuParm2); // void func_8014AAD0(void); void func_8014ADBC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_8014C70C(void); -// void func_8014CC14(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 arg4); // void func_8014CCB4(void); // void func_8014CDF0(void); // void func_8014CFDC(void); -// void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8014D62C(void); // void func_8014D7B4(void); -// void func_80150A84(void); +void func_80150A84(GlobalContext* globalCtx); void func_80150D08(GlobalContext* globalCtx, u32 uParm2); // void func_801514B0(void); -void func_801518B0(GlobalContext* globalCtx, u16 textId, Actor* Actor); +void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor); void func_80151938(GlobalContext* globalCtx, u16 textId); void func_80151A68(GlobalContext* globalCtx, u16 textId); -void func_80151BB4(GlobalContext* globalCtx, u32 uParm2); +void func_80151BB4(GlobalContext* globalCtx, u8 uParm2); // void func_80151C9C(void); -// void func_80151DA4(void); +void func_80151DA4(GlobalContext* globalCtx, u16 arg2); void func_80152434(GlobalContext* globalCtx, u16 arg2); // void func_80152464(void); u8 Message_GetState(MessageContext* msgCtx); @@ -2716,30 +2621,26 @@ u8 Message_GetState(MessageContext* msgCtx); // void func_80153750(void); // void func_80153E7C(void); // void func_80153EF0(void); -// void func_801541D4(void); +void func_801541D4(GlobalContext* globalCtx, Gfx** gfxp); // void func_80156758(void); void func_8015680C(GlobalContext* globalCtx); void func_801586A4(GlobalContext* globalCtx); void Message_Init(GlobalContext* globalCtx); -void func_801588D0(GlobalContext* globalCtx, s16 param_2); -// void func_80158988(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_80158A24(void); -// void func_80158C04(void); -// void func_80158D98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_80158FB0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8015926C(void); +void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId); +// void Message_LoadCharNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +// void Message_LoadPluralRupeesNES(void); +// void Message_LoadLocalizedRupeesNES(void); +// void Message_LoadRupeesNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); +// void Message_LoadTimeNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); +// void Message_LoadAreaTextNES(void); // void func_80159438(void); -// void func_8015966C(void); +void func_8015966C(GlobalContext* globalCtx, UNK_PTR puParm2, UNK_TYPE arg3); // void func_8015A144(void); -// void func_8015B198(void); -// void func_8015E750(void); +void func_8015B198(GlobalContext* globalCtx); +void Message_FindCreditsMessage(GlobalContext *globalCtx, u16 textId); void func_8015E7EC(GlobalContext* globalCtx, UNK_PTR puParm2); // void func_8015F8A8(UNK_TYPE4 ctxt); -// void func_80160A90(void); -// void func_80160AF8(void); -// void func_80160B40(void); -// void func_80160B80(void); -// void func_80160BC0(void); + void ShrinkWindow_SetLetterboxTarget(s32 target); s32 ShrinkWindow_GetLetterboxTarget(void); void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude); @@ -2753,13 +2654,13 @@ void ShrinkWindow_Destroy(void); void ShrinkWindow_Update(s32 framerateDivisor); void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); -// void func_8016119C(void); +s32 func_8016119C(Camera* camera, DbCameraUnkStruct* arg1); // void func_8016122C(void); // void func_801612B8(void); -// void func_80161998(void); +s32 func_80161998(u8* cmd, DbCameraUnkStruct* arg1); // s32 func_80161BAC(void); -// void func_80161BE0(void); -// void func_80161C0C(void); +void func_80161BE0(s16 arg0); +void func_80161C0C(void); // void func_80161C20(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_80161E4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801620CC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); @@ -2844,7 +2745,7 @@ void func_80167DE4(GlobalContext* globalCtx); void Play_Draw(GlobalContext* globalCtx); void func_80168DAC(GlobalContext* globalCtx); void Play_Update(GlobalContext* globalCtx); -s32 func_801690CC(GlobalContext* globalCtx); +s32 Play_InCsMode(GlobalContext* globalCtx); f32 func_80169100(GlobalContext* globalCtx, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); // void func_801691F0(void); void* Play_LoadScene(GlobalContext* globalCtx, RomFile* entry); @@ -2852,37 +2753,35 @@ void func_8016927C(GlobalContext* globalCtx, s16 sParm2); // void func_801692C4(GlobalContext* globalCtx, UNK_TYPE1 uParm2); // void Play_SceneInit(GlobalContext* globalCtx, s32 sceneIndex, UNK_TYPE1 param_3); UNK_RET func_80169474(GlobalContext* globalCtx, Vec3f* v1, Vec3f* v2); -s32 func_801694DC(GlobalContext* globalCtx); -s32 Play_GetActiveCameraIndex(GlobalContext* globalCtx); -void func_80169590(GlobalContext* globalCtx, s16 param_2, s16 param_3); -void func_80169600(GlobalContext* globalCtx, s16 param_2); -// void func_80169668(void); +s32 Play_CreateSubCamera(GlobalContext* globalCtx); +s32 Play_GetActiveCamId(GlobalContext* globalCtx); +void Play_CameraChangeStatus(GlobalContext* globalCtx, s16 camId, s16 status); +void Play_ClearCamera(GlobalContext* globalCtx, s16 camId); Camera* Play_GetCamera(GlobalContext* globalCtx, s16 index); s32 Play_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye); -void func_8016981C(GlobalContext* globalCtx, s16 arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4); -void func_80169940(GlobalContext* globalCtx, s16 camId, f32 arg2); -// void func_80169988(void); -void func_801699D4(GlobalContext* globalCtx, s16 arg1, s16 arg2); +void Play_CameraSetAtEyeUp(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); +void Play_CameraSetFov(GlobalContext* globalCtx, s16 camId, f32 fov); +void Play_CameraSetRoll(GlobalContext* globalCtx, s16 camId, s16 roll); +void Play_CopyCamera(GlobalContext* globalCtx, s16 dstCamId, s16 srcCamId); // void func_80169A50(void); -// void func_80169AC0(void); +void Play_CameraChangeSetting(GlobalContext* globalCtx, s16 camId, s16 setting); void func_80169AFC(GlobalContext* globalCtx, s16 camId, s16 arg2); -// void func_80169C64(void); -// void func_80169C84(void); -s16 convert_scene_number_among_shared_scenes(s16 arg0); -void func_80169D40(GlobalContext* globalCtx); -void func_80169DCC(GlobalContext* globalCtx, s32 arg1, u16 arg2, s32 arg3, s32 arg4, Vec3f* arg5, s16 arg6); -void func_80169E6C(GlobalContext* globalCtx, s32 param_1, s32 param_2); -// void func_80169ECC(void); -void func_80169EFC(GlobalContext* globalCtx); -void func_80169F78(GlobalContext* globalCtx); -void func_80169FDC(GlobalContext* globalCtx); -// void func_80169FFC(void); -s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx); -// UNK_TYPE4 func_8016A02C(s32 param_1, s32 param_2, s16* param_3); -// void func_8016A0AC(void); +s16 Play_GetCsCamDataSetting(GlobalContext* globalCtx, s32 camId); +Vec3s* Play_GetCsCamDataVec3s(GlobalContext* globalCtx, s32 camId); +s16 Play_GetOriginalSceneNumber(s16 sceneNum); +void Play_SaveCycleSceneFlags(GameState* gameState); +void Play_SetRespawnData(GameState* gameState, s32 respawnNumber, u16 sceneSetup, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw); +void Play_SetupRespawnPoint(GameState* gameState, s32 respawnNumber, s32 playerParams); +void func_80169EFC(GameState* gameState); +void func_80169F78(GameState* gameState); +void func_80169FDC(GameState* gameState); +s32 func_80169FFC(GameState* gameState); +s32 FrameAdvance_IsEnabled(GameState* gameState); +s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw); +s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos); s32 func_8016A168(void); -// void func_8016A178(void); -void func_8016A268(GlobalContext* globalCtx, s32 param_2, s32 param_3, s32 param_4, s32 param_5, s32 param_6); +void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 cutscene); +void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); void Play_Init(GameState* gameState); // void func_8016AC10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); // void func_8016AE1C(void); @@ -3163,12 +3062,12 @@ s32 Math3D_TriChkPointParaZIntersect(Vec3f* a, Vec3f* b, Vec3f* c, f32 nx, f32 n s32 Math3D_TriChkLineSegParaZIntersect(Vec3f* v0, Vec3f* v1, Vec3f* v2, f32 nx, f32 ny, f32 nz, f32 originDist, f32 x, f32 y, f32* zIntersect, f32 z0, f32 z1); // void func_8017D1AC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_8017D220(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8017D2FC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); +s32 Math3D_LineSegVsPlane(f32 nx, f32 ny, f32 nz, f32 originDist, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect, s32 fromFront); // void func_8017D404(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); void Math3D_TriSetCoords(TriNorm* tri, Vec3f* pointA, Vec3f* pointB, Vec3f* pointC); u32 Math3D_IsPointInSphere(Sphere16* sphere, Vec3f* point); s32 Math3D_PointDistToLine2D(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32* arg6, f32* arg7, f32* arg8); // returns boolean -// void func_8017D7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); +s32 func_8017D7C0(f32 x0, f32 y0, f32 x1, f32 y1, f32 x2, f32 y2, f32* lineLenSq); // void func_8017D814(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017D91C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8017DA24(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); @@ -3257,12 +3156,12 @@ void func_80183070(void); // void func_801832B0(void); // void func_8018332C(void); // void func_8018340C(void); -// void func_80183430(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8018349C(void); -// void func_801834A8(void); +void func_80183430(SkeletonInfo* skeletonInfo, void* arg1, void* arg2, Vec3s* arg3, s16* arg4, UnkKeyframeCallback* callbacks); +void func_8018349C(UNK_PTR arg0); +void func_801834A8(SkeletonInfo* skeletonInfo, void* arg1); // void func_80183510(void); // void func_80183580(void); -// void func_801835EC(void); +void func_801835EC(UNK_PTR arg0, UNK_PTR arg1); // void func_80183658(void); // void func_801836CC(void); // void func_8018373C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9); @@ -3272,9 +3171,11 @@ void func_80183070(void); // void func_80183A3C(void); // void func_80183B08(void); // void func_80183B68(void); -// void func_80183DE0(void); +s32 func_80183DE0(SkeletonInfo* skeletonInfo); // void func_8018410C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8018450C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +void func_8018450C(GlobalContext* globalCtx, SkeletonInfo* skeleton, Mtx* mtx, + OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, + Actor* actor); // void func_801845A4(void); // void func_801845C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80184638(void); @@ -3298,17 +3199,17 @@ void Slowly_Stop(SlowlyTask* slowly); // char* func_801857D0(void); // void func_80185864(void); u32 func_80185908(void); -// void func_80185968(void); +UNK_TYPE func_80185968(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2); // void func_801859F0(void); // void func_80185A2C(void); // void func_80185B1C(void); // void func_80185BE4(void); // void func_80185C24(void); void SysFlashrom_ThreadEntry(s80185D40* param_1); -// void func_80185DDC(void); -// void func_80185EC4(void); -// void func_80185F04(void); -// void func_80185F64(void); +void func_80185DDC(u8* arg0, u32 arg1, u32 arg2); +s32 func_80185EC4(void); +s32 func_80185F04(void); +void func_80185F64(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2); s32 func_80185F90(u32 param_1); u32 osFlashGetAddr(u32 pageNum); OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start); @@ -3367,130 +3268,53 @@ s32 osFlashReadArray(OSIoMesg* mb, s32 priority, u32 pageNum, void* dramAddr, u3 // void func_8018A808(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6); // void func_8018ACC4(void); // void func_8018AE34(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8018B0F0(void); -// void func_8018B10C(void); -// void func_8018B250(void); -// void func_8018B318(void); -// void func_8018B474(void); -// void func_8018B4F8(void); -// void func_8018B520(void); -// void func_8018B578(void); -void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, u32 size); -// void func_8018B608(void); -// void func_8018B640(void); -// void func_8018B69C(void); -// void func_8018B6E8(void); -// void func_8018B740(void); -// void func_8018B768(void); -// void func_8018B77C(void); -// void func_8018B7BC(void); -// void func_8018B8FC(void); -// void func_8018B95C(void); -// void func_8018B9E0(void); -// void func_8018BA64(void); -// void func_8018BB28(void); -// void func_8018BBEC(void); -// void func_8018C380(void); -// void func_8018C3D8(void); -// void func_8018C8E8(void); -// void func_8018C93C(void); -// void func_8018C994(void); -// void func_8018CB70(void); -// void func_8018CB78(void); -// void func_8018CC3C(void); -// void func_8018CCA8(void); -// void func_8018CFAC(void); -// void func_8018D57C(void); -// void func_8018D5D4(void); -// void func_8018D658(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018D6C8(void); -// void func_8018D760(void); -// void func_8018DA50(void); -// void func_8018DBC4(void); -// void func_8018DCB4(void); -// void func_8018DCF8(void); -// void func_8018DD98(void); -// void func_8018DDD4(void); -// void func_8018DF24(void); -// void func_8018DFE0(void); -// void func_8018E00C(void); -// void func_8018E03C(void); -// void func_8018E2A8(void); -// void func_8018E344(void); -// void func_8018E8C8(void); -// void func_8018EB60(void); -// void func_8018EC4C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018EF88(void); -s32 AudioLoad_IsFontLoadComplete(s32 bankId); -// void func_8018F298(void); -// void func_8018F310(void); -// void func_8018F388(void); -// void func_8018F3B8(void); -// void func_8018F3E8(void); -// void func_8018F448(void); -// void func_8018F478(void); -// void func_8018F4D8(void); -// void func_8018F588(void); -// void func_8018F604(void); -// void func_8018F6F0(void); -// void func_8018F7C0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8018F7F8(void); -// void func_8018F83C(void); -// void func_8018F880(void); -// void func_8018F8C4(void); -// void func_8018F908(void); -// void func_8018F9B8(void); -// void func_8018FA60(void); -// void func_8018FAD0(void); -// void func_8018FB20(void); -// void func_8018FB78(void); -// void func_8018FCCC(void); -// void func_8018FD20(void); -// void func_8018FD40(void); -// void func_8018FE5C(void); -// void func_8018FF60(void); -// void func_80190204(void); -// void func_80190240(void); -// void func_80190294(void); -// void func_801902D8(void); -// void func_80190544(void); -// void func_80190668(void); -// void func_8019067C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_8019075C(void); -// void func_8019077C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80190B08(void); -void func_80190B38(void* callback); -// void func_80190B50(void); -// void func_80190BB0(void); -// void func_80190F50(void); -// void func_80190F64(void); -// void func_80191134(void); -// void func_801911CC(void); -// void func_80191240(void); -// void func_801913C8(void); -// void func_8019144C(void); -// void func_80191460(void); -// void func_80191568(void); -// void func_80191598(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8); -// void func_8019161C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_80191740(void); -// void func_80191864(void); -// void func_80191870(void); -// void func_801919AC(void); -// void func_80191B40(void); -// void func_80191BD0(void); -// void func_80191C40(void); -// void func_80191C54(void); -// void func_80191D94(void); -// void func_8019218C(void); -// void func_80192340(void); -// void func_80192388(void); -// void func_801924BC(void); -// void func_80192514(void); -// void func_80192990(void); -// void func_80192AE8(void); -// void func_80192B54(void); -// void func_80192BAC(void); +void AudioHeap_DiscardFont(s32 fontId); +void* AudioHeap_WritebackDCache(void* addr, size_t size); +void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size); +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size); +void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size); +void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size); +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size); +void AudioHeap_PopCache(s32 tableType); +void AudioHeap_InitMainPool(size_t initPoolSize); +void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id); +void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id); +void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff); +s32 AudioHeap_ResetStep(void); +void AudioHeap_Init(void); +void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); +void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size); +void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache); +void AudioHeap_ApplySampleBankCache(s32 sampleBankId); +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags); +void AudioLoad_DecreaseSampleDmaTtls(void); +void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); +void AudioLoad_InitSampleDmaBuffers(s32 numNotes); +s32 AudioLoad_IsFontLoadComplete(s32 fontId); +s32 AudioLoad_IsSeqLoadComplete(s32 seqId); +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status); +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 status); +void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3); +s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); +void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue); +u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts); +void AudioLoad_DiscardSeqFonts(s32 seqId); +void func_8018FA60(u32 tableType, u32 id, s32 arg2, s32 arg3); +s32 AudioLoad_SyncIniPlayer(s32 playerIdx, s32 seqId, s32 arg2); +s32 AudioLoad_SyncInitSetSeqqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks); +void AudioLoad_ProcessLoads(s32 resetStatus); +void AudioLoad_SetDmaHandler(DmaHandler callback); +void AudioLoad_Init(void* heap, u32 heapSize); +void AudioLoad_InitSlowLoads(void); +s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone); +s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone); +void AudioLoad_InitAsyncLoads(void); +void AudioLoad_LoadPermanentSamples(void); +void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone); +void AudioLoad_ProcessScriptLoads(void); +void AudioLoad_InitScriptLoads(void); AudioTask* func_80192BE0(void); // void func_80192C00(void); // void func_8019319C(void); @@ -3500,7 +3324,7 @@ AudioTask* func_80192BE0(void); // void func_8019380C(void); // void func_80193858(void); // void func_8019387C(void); -// void func_801938A0(void); +void Audio_QueueCmdS8(u32 opArgs, s8 data); // void func_801938D0(void); // void func_80193900(void); // void func_80193990(void); @@ -3524,8 +3348,8 @@ AudioTask* func_80192BE0(void); // void func_80194528(void); // void func_80194548(void); // void func_80194568(void); -// void func_80194668(void); -// void func_801946E4(void); +u32 Audio_NextRandom(void); +void Audio_InitMesgQueues(void); void Audio_InvalDCache(void* buf, size_t size); void Audio_WritebackDCache(void* buf, size_t size); // void func_80194790(void); @@ -3564,7 +3388,7 @@ void AudioSeq_SequenceChannelDisable(SequenceChannel* channel); // void func_80197B14(void); // void func_80197C0C(void); // void func_80197C8C(void); -// void func_80197D24(void); +void AudioSeq_SequencePlayerDisableAsFinished(SequencePlayer* seqPlayer); void AudioSeq_SequencePlayerDisable(SequencePlayer* seqPlayer); void AudioSeq_AudioListPushBack(AudioListItem* list, AudioListItem* item); void* AudioSeq_AudioListPopBack(AudioListItem* list); @@ -3586,23 +3410,23 @@ void func_80199268(s32* param_1); // void func_8019A0BC(void); // void func_8019AA3C(void); // void func_8019AAF0(void); -// void func_8019AB40(void); -// void func_8019AC10(void); +void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer); +void AudioSeq_InitSequencePlayerChannels(s32 playerIdx); // void func_8019ACEC(void); -// void func_8019ADBC(void); +void AudioSeq_InitSequencePlayers(void); void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4); void func_8019AEC0(UNK_PTR param_1, UNK_PTR param_2); // void func_8019AF00(void); // void func_8019AF58(void); // void func_8019AFE8(void); // void func_8019B02C(void); -// void func_8019B074(void); +// void AudioOcarina_MapSongFromNotesToButtons(void); // void func_8019B144(void); // void func_8019B378(void); // void func_8019B38C(void); // void func_8019B3D0(void); // void func_8019B4B8(void); -void func_8019B544(u16 arg0); +void AudioOcarina_StartDefault(u32 arg0); // void func_8019B568(void); // void func_8019B5AC(void); // void func_8019B5EC(void); @@ -3614,7 +3438,7 @@ void func_8019B544(u16 arg0); // void func_8019C1D0(void); // void func_8019C268(void); // void func_8019C2E4(void); -void func_8019C300(s32 arg0); +u32 AudioOcarina_SetInstrumentId(u8 arg0); // void func_8019C398(void); // void func_8019C5A0(void); // void func_8019C8D8(void); @@ -3624,14 +3448,14 @@ void func_8019C300(s32 arg0); // void func_8019CEBC(void); // void func_8019CF6C(void); // void func_8019CF78(void); -// void func_8019CF9C(void); +OcarinaStaff* AudioOcarina_GetPlaybackStaff(void); // void func_8019CFA8(void); -// void func_8019D134(void); -// void func_8019D26C(void); -// void func_8019D488(void); -// void func_8019D4F8(void); +// void AudioOcarina_TerminaWallValidateNotes(void); +void AudioOcarina_TerminaWallGenerateNotes(void); +// void AudioOcarina_MemoryGameSetNumNotes(void); +// void AudioOcarina_MemoryGameGenerateNotes(void); // void func_8019D600(void); -// void func_8019D758(void); +void func_8019D758(void); // void func_8019D864(void); // void func_8019D8B4(void); // void func_8019D8E4(void); @@ -3658,7 +3482,7 @@ void func_8019F230(void); // cancel sfx // void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); void func_8019F4AC(Vec3f* pos, u16 sfxId); -void func_8019F540(u8 arg0); +void func_8019F540(s8 arg0); void func_8019F570(Vec3f* pos, s8 arg1); // void func_8019F5AC(void); // void func_8019F638(void); @@ -3669,8 +3493,8 @@ void func_8019F88C(Vec3f* arg0, u16 sfxId, UNK_TYPE arg2); // void func_8019F900(void); // void func_8019FA18(void); void func_8019FAD8(Vec3f* param_1, u16 sfxId, f32 param_3); -// void func_8019FB0C(void); -// void func_8019FC20(void); +void func_8019FB0C(Vec3f* arg0, u16 sfxId, f32 arg2, s32 arg3); +void func_8019FC20(Vec3f* pos, u16 sfxId); // void func_8019FCB8(void); // void func_8019FD90(void); void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); @@ -3678,24 +3502,24 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); void func_8019FE74(f32* arg0, f32 arg1, s32 arg2); // void func_8019FEDC(void); // void func_8019FF38(void); -// void func_8019FF9C(void); -// void func_801A0048(void); -// void func_801A00EC(void); +void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale); +// void Audio_PlaySfxForWaterfall(void); +// void Audio_StepFreqLerp(void); void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); void func_801A0204(s8 seqId); -// void func_801A0238(void); -// void func_801A026C(void); -// void func_801A0318(void); -// void func_801A046C(void); +void func_801A0238(s32 arg0, s32 arg1); +// void Audio_SetGanonsTowerBgmVolumeLevel(void); +// void Audio_SetGanonsTowerBgmVolume(void); +// void Audio_UpdateRiverSoundVolumes(void); // void func_801A0554(void); // void func_801A05F0(void); void func_801A0654(Vec3f* arg0, u16 sfxId, s32 arg2); void func_801A0810(Vec3f* arg0, u16 sfxId, u8 arg2); // void func_801A0868(void); // void func_801A09D4(void); -// void func_801A0CB0(void); +// void Audio_SplitBgmChannels(void); // void func_801A0E44(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); // void func_801A1290(void); // void func_801A1348(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); @@ -3715,7 +3539,7 @@ void func_801A1FB4(u8 playerIdx, Vec3f* pos, u16 seqId, f32 maxDist); void func_801A246C(u8 param_1, u8 param_2); // void func_801A2544(void); // void func_801A257C(void); -// void func_801A25E4(void); +void func_801A25E4(u16 seqId, u8 dayMinusOne); // void func_801A2670(void); // void func_801A2778(void); // void func_801A27E8(void); @@ -3724,10 +3548,10 @@ void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); -// void func_801A2C88(void); -// void func_801A2D54(void); +void func_801A2C88(u16 seqId); +void func_801A2D54(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); -void func_801A2E54(s32 param_1); +void func_801A2E54(s32 bgmId); void func_801A2ED8(void); // void func_801A2F88(void); // void func_801A3000(void); @@ -3738,24 +3562,24 @@ void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_801A32CC(void); // void func_801A3590(void); -// void func_801A3950(void); +u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); u8 func_801A39F8(void); -// void func_801A3A7C(void); +void func_801A3A7C(s32 arg0); // void func_801A3AC0(void); -// void func_801A3AEC(void); +void func_801A3AEC(s32 arg0); void func_801A3B48(UNK_TYPE arg0); // void func_801A3B90(void); void func_801A3CD8(s8 param_1); // void func_801A3CF4(void); -// void func_801A3D98(void); +void func_801A3D98(s8 audioSetting); // void func_801A3E38(void); // void func_801A3EC0(void); -void func_801A3F54(u8 flag); +void Audio_SetCutsceneFlag(u8 flag); // void func_801A3F6C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801A3FB4(void); // void func_801A3FFC(UNK_TYPE1 param_1); void audio_setBGM(u32 bgmID); -// void func_801A4058(void); +void func_801A4058(UNK_TYPE arg0); // void func_801A41C8(void); // void func_801A41F8(void); // void func_801A429C(void); @@ -3763,16 +3587,16 @@ void audio_setBGM(u32 bgmID); // void func_801A4324(void); // void func_801A4348(void); // void func_801A4380(void); -// void func_801A4428(void); +void func_801A4428(u8 reverbIndex); void Audio_PreNMI(void); // void func_801A44C4(void); // void func_801A44D4(void); s32 func_801A46F8(void); -// void func_801A4748(void); +void func_801A4748(Vec3f* pos, u16 sfxId); void func_801A479C(Vec3f* arg0, u16 sfxId, s32 arg2); -// void func_801A47DC(void); +void func_801A47DC(u8 channelIndexRange, u8 port, u8 val); // void func_801A48E0(void); -void func_801A4A28(s32 arg0); +void func_801A4A28(u8 natureSeqId); // void func_801A4B80(void); void func_801A4C30(void); // void func_801A4C54(void); @@ -3819,16 +3643,16 @@ void func_801A75E8(u16 sfxId); void func_801A7794(u32 param_1, u32 param_2, u32 param_3); // void func_801A7828(void); // void func_801A787C(void); -// void func_801A78E4(void); +u8 Audio_IsSfxPlaying(u32 sfxId); // void func_801A794C(void); // void func_801A7B10(void); // void func_801A7D04(void); // void func_801A7D84(void); -void Audio_QueueSeqCmd(u32 arg0); +void Audio_QueueSeqCmd(u32 cmd); // void func_801A89D0(void); s32 func_801A8A50(s32 param1); // void func_801A8ABC(void); -// void func_801A8BD0(void); +void Audio_SetVolumeScale(u8 playerIdx, u8 scaleIdx, u8 targetVol, u8 volFadeTimer); // void func_801A8D5C(void); // void func_801A8E90(void); // void func_801A9768(void); diff --git a/include/ichain.h b/include/ichain.h index f9131545c..07bd07313 100644 --- a/include/ichain.h +++ b/include/ichain.h @@ -1,5 +1,5 @@ -#ifndef _ICHAIN_H_ -#define _ICHAIN_H_ +#ifndef ICHAIN_H +#define ICHAIN_H #include "libc/stddef.h" diff --git a/include/initvars.h b/include/initvars.h index 797e73876..11a6719e9 100644 --- a/include/initvars.h +++ b/include/initvars.h @@ -34,6 +34,7 @@ extern EffectSsInit Effect_Ss_Ice_Smoke_InitVars; extern EffectSsInit Effect_En_Ice_Block_InitVars; extern EffectSsInit Effect_Ss_Sbn_InitVars; +extern ActorInit Player_InitVars; extern ActorInit Arms_Hook_InitVars; extern ActorInit Arrow_Fire_InitVars; extern ActorInit Arrow_Ice_InitVars; diff --git a/include/macro.inc b/include/macro.inc index 396a4cb68..d7a8da875 100644 --- a/include/macro.inc +++ b/include/macro.inc @@ -37,3 +37,39 @@ .set TagHi, $29 .set ErrorEPC, $30 .set Reserved31, $31 + + +# Float register aliases (o32 ABI, odd ones are rarely used) + +.set $fv0, $f0 +.set $fv0f, $f1 +.set $fv1, $f2 +.set $fv1f, $f3 +.set $ft0, $f4 +.set $ft0f, $f5 +.set $ft1, $f6 +.set $ft1f, $f7 +.set $ft2, $f8 +.set $ft2f, $f9 +.set $ft3, $f10 +.set $ft3f, $f11 +.set $fa0, $f12 +.set $fa0f, $f13 +.set $fa1, $f14 +.set $fa1f, $f15 +.set $ft4, $f16 +.set $ft4f, $f17 +.set $ft5, $f18 +.set $ft5f, $f19 +.set $fs0, $f20 +.set $fs0f, $f21 +.set $fs1, $f22 +.set $fs1f, $f23 +.set $fs2, $f24 +.set $fs2f, $f25 +.set $fs3, $f26 +.set $fs3f, $f27 +.set $fs4, $f28 +.set $fs4f, $f29 +.set $fs5, $f30 +.set $fs5f, $f31 diff --git a/include/macros.h b/include/macros.h index b19d87a68..bd76cd90e 100644 --- a/include/macros.h +++ b/include/macros.h @@ -1,5 +1,5 @@ -#ifndef _MACROS_H_ -#define _MACROS_H_ +#ifndef MACROS_H +#define MACROS_H #include "libc/stdint.h" #include "ultra64/convert.h" @@ -21,8 +21,7 @@ #define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr)) #define GET_ACTIVE_CAM(globalCtx) ((globalCtx)->cameraPtrs[(globalCtx)->activeCamera]) -#define MAIN_CAM 0 -#define SUBCAM_FREE 0 +#define CAM_ID_MAIN 0 #define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ (curState)->nextGameStateInit = (GameStateFunc)newInit; \ @@ -50,47 +49,70 @@ #define CURRENT_DAY (((void)0, gSaveContext.save.day) % 5) -#define CLOCK_TIME(hr, min) ((s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60))) +#define CLOCK_TIME(hr, min) (s32)(((hr) * 60 + (min)) * 0x10000 / (24 * 60)) #define CLOCK_TIME_MINUTE (CLOCK_TIME(0, 1)) +#define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f +#define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (0x10000 / (24.0f * 60.0f))) + +#define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) +#define CLOCK_TIME_ALT_F(hr, min) (((hr) * 60.0f + (min)) / (24.0f * 60.0f / 0x10000)) + #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 ALL_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.save.inventory.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE_VOID(equip) \ - ((((void)0, gSaveContext.save.equips.equipment) & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_UPG_VALUE_VOID(upg) \ - ((((void)0, gSaveContext.save.inventory.upgrades) & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define INV_CONTENT_VOID(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] +#define GET_INV_CONTENT(item) ((void)0, gSaveContext.save.inventory.items)[SLOT(item)] #define CUR_FORM ((gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) ? 0 : gSaveContext.save.playerForm) -#define GET_CUR_FORM_BTN_ITEM(btn) ((u8)((btn) == 0 ? gSaveContext.save.equips.buttonItems[CUR_FORM][btn] : gSaveContext.save.equips.buttonItems[0][btn])) -#define GET_CUR_FORM_BTN_SLOT(btn) ((u8)((btn) == 0 ? gSaveContext.save.equips.cButtonSlots[CUR_FORM][btn] : gSaveContext.save.equips.cButtonSlots[0][btn])) -#define SET_CUR_FORM_BTN_ITEM(btn, item) \ - if ((btn) == 0) { \ - gSaveContext.save.equips.buttonItems[CUR_FORM][btn] = (item); \ - } else { \ - gSaveContext.save.equips.buttonItems[0][btn] = (item); \ - } +#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 SET_CUR_FORM_BTN_SLOT(btn, slot) \ - if ((btn) == 0) { \ - gSaveContext.save.equips.cButtonSlots[CUR_FORM][btn] = (slot); \ - } else { \ - gSaveContext.save.equips.cButtonSlots[0][btn] = (slot); \ - } +#define GET_CUR_EQUIP_VALUE(equip) ((GET_SAVE_EQUIPS_EQUIPMENT & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define ALL_EQUIP_VALUE(equip) ((gSaveContext.save.inventory.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) -#define CUR_EQUIP_VALUE(equip) ((gSaveContext.save.equips.equipment & gEquipMasks[equip]) >> gEquipShifts[equip]) #define CUR_UPG_VALUE(upg) ((gSaveContext.save.inventory.upgrades & gUpgradeMasks[upg]) >> gUpgradeShifts[upg]) -#define TAKE_EQUIPPED_ITEM(equip) (gSaveContext.save.equips.equipment = ((((void)0, gSaveContext.save.equips.equipment) & (gEquipNegMasks[equip])) | (u16)(0 << gEquipShifts[equip]))) -#define CUR_FORM_EQUIP(button) (gSaveContext.save.equips.buttonItems[CUR_FORM][button]) -#define CHECK_QUEST_ITEM(item) (((void)0, gSaveContext.save.inventory.questItems) & gBitFlags[item]) -#define REMOVE_QUEST_ITEM(item) (gSaveContext.save.inventory.questItems = (((void)0, gSaveContext.save.inventory.questItems) & (-1 - gBitFlags[item]))) -#define SET_EQUIP_VALUE(equip, value) (gSaveContext.save.equips.equipment = ((((void)0, gSaveContext.save.equips.equipment) & (gEquipNegMasks[equip])) | (u16)((u16)(value) << gEquipShifts[equip]))) +#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 BUTTON_ITEM_EQUIP(form, button) (gSaveContext.save.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 CHECK_QUEST_ITEM(item) (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 CHECK_DUNGEON_ITEM(item, dungeonIndex) (gSaveContext.save.inventory.dungeonItems[(void)0, dungeonIndex] & gBitFlags[item]) +#define DUNGEON_KEY_COUNT(dungeonIndex) (gSaveContext.save.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))) + + +#define SET_CUR_FORM_BTN_ITEM(btn, item) \ + if ((btn) == EQUIP_SLOT_B) { \ + BUTTON_ITEM_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + BUTTON_ITEM_EQUIP(0, (btn)) = (item); \ + } \ + +#define SET_CUR_FORM_BTN_SLOT(btn, item) \ + if ((btn) == EQUIP_SLOT_B) { \ + C_SLOT_EQUIP(CUR_FORM, (btn)) = (item); \ + } else { \ + C_SLOT_EQUIP(0, (btn)) = (item); \ + } \ + +#define STOLEN_ITEM_NONE (0) + +#define STOLEN_ITEM_1 ((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) +#define STOLEN_ITEM_2 ((gSaveContext.save.stolenItems & 0x00FF0000) >> 0x10) + +#define SET_STOLEN_ITEM_1(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0xFF000000) | ((itemId & 0xFF) << 0x18)) +#define SET_STOLEN_ITEM_2(itemId) \ + (gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) @@ -162,6 +184,7 @@ extern GraphicsContext* __gfxCtx; #define ALIGN8(val) (((val) + 7) & ~7) #define ALIGN16(val) (((val) + 0xF) & ~0xF) #define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) @@ -190,4 +213,4 @@ extern GraphicsContext* __gfxCtx; #define ALIGNED8 #endif -#endif // _MACROS_H_ +#endif // MACROS_H diff --git a/include/message_data_static.h b/include/message_data_static.h new file mode 100644 index 000000000..f69e17232 --- /dev/null +++ b/include/message_data_static.h @@ -0,0 +1,12 @@ +#ifndef MESSAGE_DATA_STATIC_H +#define MESSAGE_DATA_STATIC_H + +#include "PR/ultratypes.h" + +typedef struct MessageTableEntry{ + /* 0x0 */ u16 textId; + /* 0x2 */ u8 typePos; + /* 0x4 */ const char* segment; +} MessageTableEntry; // size = 0x8; + +#endif diff --git a/include/regs.h b/include/regs.h index e39e53d69..9942242a7 100644 --- a/include/regs.h +++ b/include/regs.h @@ -1,8 +1,8 @@ /* Header taken as placeholder from OoT sister project */ /* Confirm as needed */ -#ifndef _REGS_H_ -#define _REGS_H_ +#ifndef REGS_H +#define REGS_H #define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc. #define REG_PAGES 6 diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 3f02baa5c..e133437cc 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1,7 +1,8 @@ -#ifndef _SEGMENT_SYMBOLS_H_ -#define _SEGMENT_SYMBOLS_H_ +#ifndef SEGMENT_SYMBOLS_H +#define SEGMENT_SYMBOLS_H -#include "z64.h" +#include "libc/stddef.h" +#include "PR/ultratypes.h" #define DECLARE_SEGMENT(name) \ extern u8 _##name##SegmentStart[]; \ diff --git a/include/bgm.h b/include/sequence.h similarity index 60% rename from include/bgm.h rename to include/sequence.h index c3ac3b1d1..d46e96aea 100644 --- a/include/bgm.h +++ b/include/sequence.h @@ -1,5 +1,5 @@ -#ifndef BGM_H -#define BGM_H +#ifndef SEQUENCE_H +#define SEQUENCE_H #define NA_BGM_STOP 0x100000FF @@ -133,4 +133,146 @@ #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF +typedef enum { + /* 0 */ SEQ_PLAYER_BGM_MAIN, + /* 1 */ SEQ_PLAYER_FANFARE, + /* 2 */ SEQ_PLAYER_SFX, + /* 3 */ SEQ_PLAYER_BGM_SUB, + /* 4 */ SEQ_PLAYER_NATURE +} SequencePlayerId; + +typedef enum { + /* 0 */ SEQ_MODE_DEFAULT, + /* 1 */ SEQ_MODE_ENEMY, + /* 2 */ SEQ_MODE_STILL, // Not moving or first-person view + /* 3 */ SEQ_MODE_IGNORE +} SequenceMode; + +typedef enum { + /* 0x0 */ CHANNEL_IO_PORT_0, + /* 0x1 */ CHANNEL_IO_PORT_1, + /* 0x2 */ CHANNEL_IO_PORT_2, + /* 0x3 */ CHANNEL_IO_PORT_3, + /* 0x4 */ CHANNEL_IO_PORT_4, + /* 0x5 */ CHANNEL_IO_PORT_5, + /* 0x6 */ CHANNEL_IO_PORT_6, + /* 0x7 */ CHANNEL_IO_PORT_7 +} ChannelIOPort; + +typedef enum { + /* 0x0 */ NATURE_CHANNEL_STREAM_0, + /* 0x1 */ NATURE_CHANNEL_CRITTER_0, + /* 0x2 */ NATURE_CHANNEL_CRITTER_1, + /* 0x3 */ NATURE_CHANNEL_CRITTER_2, + /* 0x4 */ NATURE_CHANNEL_CRITTER_3, + /* 0x5 */ NATURE_CHANNEL_CRITTER_4, + /* 0x6 */ NATURE_CHANNEL_CRITTER_5, + /* 0x7 */ NATURE_CHANNEL_CRITTER_6, + /* 0x8 */ NATURE_CHANNEL_CRITTER_7, + /* 0xC */ NATURE_CHANNEL_STREAM_1 = 12, + /* 0xD */ NATURE_CHANNEL_UNK, + /* 0xE */ NATURE_CHANNEL_RAIN, + /* 0xF */ NATURE_CHANNEL_LIGHTNING +} NatureChannelIdx; // playerIdx = 4 + +typedef enum { + /* 0x00 */ NATURE_AMBIENCE_0, + /* 0x01 */ NATURE_AMBIENCE_1, + /* 0x02 */ NATURE_AMBIENCE_2, + /* 0x03 */ NATURE_AMBIENCE_3, + /* 0x04 */ NATURE_AMBIENCE_4, + /* 0x05 */ NATURE_AMBIENCE_5, + /* 0x06 */ NATURE_AMBIENCE_6, + /* 0x07 */ NATURE_AMBIENCE_7, + /* 0x08 */ NATURE_AMBIENCE_8, + /* 0x09 */ NATURE_AMBIENCE_9, + /* 0x0A */ NATURE_AMBIENCE_A, + /* 0x0B */ NATURE_AMBIENCE_B, + /* 0x0C */ NATURE_AMBIENCE_C, + /* 0x0D */ NATURE_AMBIENCE_D, + /* 0x0E */ NATURE_AMBIENCE_E, + /* 0x0F */ NATURE_AMBIENCE_F, + /* 0x10 */ NATURE_AMBIENCE_10, + /* 0x11 */ NATURE_AMBIENCE_11, + /* 0x12 */ NATURE_AMBIENCE_12, + /* 0x13 */ NATURE_AMBIENCE_13 +} NatureAmbienceId; // playerIdx = 4 + +typedef enum { + /* 0x00 */ NATURE_STREAM_0, + /* 0x01 */ NATURE_STREAM_1, + /* 0x02 */ NATURE_STREAM_2, + /* 0x03 */ NATURE_STREAM_3 +} NatureStreamId; + +typedef enum { + /* 0x00 */ NATURE_CRITTER_00, + /* 0x01 */ NATURE_CRITTER_01, + /* 0x02 */ NATURE_CRITTER_02, + /* 0x03 */ NATURE_CRITTER_03, + /* 0x04 */ NATURE_CRITTER_04, + /* 0x05 */ NATURE_CRITTER_05, + /* 0x06 */ NATURE_CRITTER_06, + /* 0x07 */ NATURE_CRITTER_07, + /* 0x08 */ NATURE_CRITTER_08, + /* 0x09 */ NATURE_CRITTER_09, + /* 0x0A */ NATURE_CRITTER_10, + /* 0x0B */ NATURE_CRITTER_11, + /* 0x0C */ NATURE_CRITTER_12, + /* 0x0D */ NATURE_CRITTER_13, + /* 0x0E */ NATURE_CRITTER_14, + /* 0x0F */ NATURE_CRITTER_15, + /* 0x10 */ NATURE_CRITTER_16, + /* 0x11 */ NATURE_CRITTER_17, + /* 0x12 */ NATURE_CRITTER_18, + /* 0x13 */ NATURE_CRITTER_19 +} NatureAmimalId; + +#define NATURE_IO_CRITTER_0_TYPE(type) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_0_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_0_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_0_PORT5(reverb) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_1_TYPE(type) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_1_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_1_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_1_PORT5(reverb) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_2_TYPE(type) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_2_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_2_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_2_PORT5(reverb) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_3_TYPE(type) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_3_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_3_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_3_PORT5(reverb) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_4_TYPE(type) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_4_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_4_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_4_PORT5(reverb) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_5_TYPE(type) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_5_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_5_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_5_PORT5(reverb) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_CRITTER_6_TYPE(type) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type +#define NATURE_IO_CRITTER_6_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend +#define NATURE_IO_CRITTER_6_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num +#define NATURE_IO_CRITTER_6_PORT5(reverb) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_5, reverb + +#define NATURE_IO_STREAM_0_TYPE(type) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type +#define NATURE_IO_STREAM_0_PORT3(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data +#define NATURE_IO_STREAM_0_PORT4(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_STREAM_1_TYPE(type) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type +#define NATURE_IO_STREAM_1_PORT3(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data +#define NATURE_IO_STREAM_1_PORT4(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_RAIN_PORT4(data) NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data + +#define NATURE_IO_ENTRIES_END 0xFF + #endif diff --git a/include/unk.h b/include/unk.h index eb31a3874..0510fcd6a 100644 --- a/include/unk.h +++ b/include/unk.h @@ -1,5 +1,5 @@ -#ifndef _UNK_H_ -#define _UNK_H_ +#ifndef UNK_H +#define UNK_H #include "PR/ultratypes.h" diff --git a/include/variables.h b/include/variables.h index 55ab6f711..474a9e324 100644 --- a/include/variables.h +++ b/include/variables.h @@ -43,7 +43,6 @@ extern StackEntry* sStackInfoListEnd; // extern UNK_TYPE1 sGfxPrintUnkTLUT; // extern UNK_TYPE1 sGfxPrintUnkData; // extern UNK_TYPE1 sGfxPrintFontData; -// extern UNK_TYPE4 D_80097500; // extern UNK_TYPE4 D_80097524; // extern u32 sRandInt; extern OSViMode osViModeNtscHpf1; @@ -428,7 +427,6 @@ extern Color_RGBA8 actorDefaultHitColor; // extern UNK_TYPE2 D_801AEE4C; extern Gfx D_801AEF88[]; extern Gfx D_801AEFA0[]; -// extern UNK_TYPE1 D_801AEFA8; // extern UNK_TYPE1 D_801AEFB8; // extern UNK_TYPE1 D_801AEFBC; // extern UNK_TYPE1 D_801AEFC0; @@ -869,21 +867,13 @@ extern EffectShieldParticleInit shieldParticleInitWood; // extern UNK_TYPE1 D_801BB0DC; // extern UNK_TYPE2 D_801BB0FC; // extern UNK_TYPE1 D_801BB100; -// extern UNK_TYPE2 D_801BB124; -// extern UNK_TYPE2 D_801BB128; + extern u8 D_801BB12C; -// extern UNK_TYPE1 D_801BB130; -extern cutscene_update_func sCsStateHandlers1[5]; -extern cutscene_update_func sCsStateHandlers2[5]; -// extern UNK_TYPE2 D_801BB15C; -// extern UNK_TYPE4 D_801BB160; + extern s801BB170 D_801BB170[118]; // extern UNK_TYPE1 D_801BC210; extern Gfx D_801BC240[9]; extern Gfx D_801BC288[3]; -// extern UNK_TYPE1 D_801BC3F0; -// extern UNK_TYPE1 D_801BC400; -// extern UNK_TYPE1 D_801BC410; // extern UNK_TYPE1 D_801BC41E; extern ActorCutscene actorCutscenesGlobalCutscenes[8]; extern s16 actorCutsceneCurrent; @@ -903,7 +893,7 @@ extern s32 graphNumGameStates; // extern UNK_TYPE2 D_801BDA7C; extern s32 D_801BDA9C; extern UNK_TYPE4 D_801BDAA0; -extern UNK_TYPE4 D_801BDAA4; +extern s32 D_801BDAA4; // extern UNK_TYPE2 D_801BDAA8; // extern UNK_TYPE2 D_801BDAAA; // extern UNK_TYPE2 D_801BDAAC; @@ -918,9 +908,7 @@ extern UNK_TYPE4 D_801BDAA4; // extern UNK_TYPE4 D_801BDACC; // extern UNK_TYPE4 D_801BDAF0; // extern UNK_TYPE4 D_801BDAF8; -// extern UNK_TYPE1 D_801BDB00; -// extern UNK_TYPE1 D_801BDB08; -// extern UNK_TYPE1 D_801BDB18; + extern u8 kanfontOrdering[92]; // extern UNK_TYPE4 D_801BDB90; // extern UNK_TYPE4 D_801BDB94; @@ -1378,36 +1366,7 @@ extern s32 D_801C5E9C[]; // D_801C5E9C extern s32 D_801C5EB0[]; // D_801C5EB0 extern s16 D_801C5EC4[]; // D_801C5EC4 extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 -// extern UNK_TYPE4 D_801C5FC0; -// extern UNK_TYPE4 D_801C5FC4; -// extern UNK_TYPE4 D_801C5FC8; -// extern UNK_TYPE4 D_801C5FCC; -// extern UNK_TYPE4 D_801C5FD0; -// extern UNK_TYPE2 D_801C66D0; -// extern UNK_TYPE4 D_801C6798; -// extern UNK_TYPE1 D_801C67B0; -// extern UNK_TYPE4 D_801C67C8; -// extern UNK_TYPE4 D_801C67CC; -// extern UNK_TYPE4 D_801C67E8; -// extern UNK_TYPE4 D_801C67F0; -// extern UNK_TYPE4 D_801C67F4; -// extern UNK_TYPE1 D_801C6818; -// extern UNK_TYPE4 D_801C6838; -// extern UNK_TYPE1 D_801C6840; -// extern UNK_TYPE1 D_801C6850; -// extern UNK_TYPE1 D_801C6870; -// extern UNK_TYPE1 D_801C6890; -// extern UNK_TYPE1 D_801C6898; -// extern UNK_TYPE1 D_801C68C0; -extern Inventory gSaveDefaultInventory; -extern u16 gSaveDefaultChecksum; -// extern UNK_TYPE1 D_801C6970; -// extern UNK_TYPE1 D_801C6998; -extern Inventory D_801C69BC; -extern u16 D_801C6A44; -// extern UNK_TYPE1 D_801C6A48; -// extern UNK_TYPE1 D_801C6A50; -// extern UNK_TYPE1 D_801C6A58; + // extern UNK_TYPE1 D_801C6A70; // extern UNK_TYPE2 D_801C6A74; // extern UNK_TYPE2 D_801C6A78; @@ -1421,9 +1380,7 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801C6A98; // extern UNK_TYPE1 D_801C6AB8; // extern UNK_TYPE1 D_801C6B28; -// extern UNK_TYPE1 D_801C6B98; // extern UNK_TYPE1 D_801CED40; -// extern UNK_TYPE1 D_801CFB08; // extern UNK_TYPE2 D_801CFC78; // extern UNK_TYPE1 D_801CFC7A; // extern UNK_TYPE1 D_801CFC7C; @@ -1433,8 +1390,8 @@ extern u16 D_801C6A44; // extern UNK_TYPE1 D_801CFC8C; // extern UNK_TYPE1 D_801CFC8E; // extern UNK_TYPE1 D_801CFC92; -// extern UNK_TYPE1 D_801CFC98; -// extern UNK_TYPE2 D_801CFCA4; +extern u8 D_801CFC98; +extern s16 D_801CFCA4[9]; // extern UNK_TYPE2 D_801CFCAC; // extern UNK_TYPE1 D_801CFCB8; // extern UNK_TYPE2 D_801CFCD8; @@ -1526,11 +1483,11 @@ extern char D_801D039C[]; // extern UNK_TYPE1 D_801D0428; // extern UNK_TYPE1 D_801D045A; // extern UNK_TYPE1 D_801D0462; -// extern UNK_TYPE1 D_801D0468; +//extern UNK_TYPE1 D_801D0468; // extern UNK_TYPE1 D_801D0470; -extern char D_801D06F0[]; +// extern char D_801D06F0[]; // extern UNK_TYPE1 D_801D0710; -extern char D_801D0714[]; +// extern char D_801D0714[]; // extern UNK_TYPE1 D_801D07C4; // extern UNK_TYPE1 D_801D07DC; // extern UNK_TYPE1 D_801D080C; @@ -1543,7 +1500,6 @@ extern char D_801D0714[]; // extern UNK_TYPE1 D_801D08E4; // extern UNK_TYPE1 D_801D08E8; // extern UNK_TYPE1 D_801D0900; -extern ActorInit Player_InitVars; extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[2]; // extern UNK_TYPE1 D_801D0B8C; extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; @@ -1626,21 +1582,11 @@ extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; extern Mtx gIdentityMtx; extern MtxF gIdentityMtxF; -// extern u64* initialgspUcodeText; -// extern u64* initialgspUcodeData; // extern UNK_TYPE1 D_801D1E70; -// extern UNK_TYPE1 gLowPassFilterData; -// extern UNK_TYPE1 gHighPassFilterData; -// extern UNK_TYPE1 gBandStopFilterData; -// extern UNK_TYPE1 gBandPassFilterData; -// extern UNK_TYPE1 gSawtoothWaveSample; -// extern UNK_TYPE1 gTriangleWaveSample; -// extern UNK_TYPE1 gSineWaveSample; -// extern UNK_TYPE1 gSquareWaveSample; -// extern UNK_TYPE1 gWhiteNoiseSample; -// extern UNK_TYPE1 D_801D4790; -// extern UNK_TYPE1 gEighthPulseWaveSample; -// extern UNK_TYPE1 gQuarterPulseWaveSample; +extern s16 gLowPassFilterData[]; +extern s16 gHighPassFilterData[]; +extern s16 gBandStopFilterData[]; +extern s16 gBandPassFilterData[]; extern s16* gWaveSamples[9]; extern UNK_PTR D_801D4D98; extern UNK_PTR D_801D4DB0; @@ -1668,7 +1614,7 @@ extern f32 gDefaultPanVolume[]; // extern UNK_TYPE1 D_801D5FD4; extern UNK_PTR D_801D5FE0; // extern UNK_TYPE1 D_801D5FE4; -// extern UNK_TYPE4 D_801D5FE8; +extern s32 gAudioContextInitalized; // extern UNK_TYPE4 D_801D5FEC; // extern UNK_TYPE4 D_801D5FF0; // extern UNK_TYPE4 D_801D5FF4; @@ -1692,7 +1638,7 @@ extern UNK_PTR D_801D618C; // extern UNK_TYPE1 D_801D6648; // extern UNK_TYPE1 D_801D664C; // extern UNK_TYPE1 D_801D6650; -extern f32 D_801D6654; +extern f32 gSfxVolume; // extern UNK_TYPE1 D_801D6658; // extern UNK_TYPE1 D_801D665C; // extern UNK_TYPE1 D_801D6660; @@ -1790,11 +1736,11 @@ extern UNK_PTR D_801D84F0; // extern UNK_TYPE2 D_801D853E; // extern UNK_TYPE1 D_801D8544; extern UNK_PTR D_801D889C; -extern UNK_PTR D_801D88A0; +extern u8* gScarecrowSpawnSongPtr; extern UNK_PTR D_801D88A4; // extern UNK_TYPE1 D_801D88A8; // extern UNK_TYPE1 D_801D88B8; -// extern UNK_TYPE1 D_801D8A48; +extern OcarinaSongButtons gOcarinaSongButtons[24]; // extern UNK_TYPE1 D_801D8B20; extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8B28; @@ -1849,7 +1795,7 @@ extern s8 D_801DB4B8; // extern UNK_TYPE1 D_801DB8B8; // extern UNK_TYPE1 D_801DB900; extern UNK_PTR D_801DB930; -extern AudioSpec D_801DB958[21]; +extern AudioSpec gAudioSpecs[21]; // rodata extern f32 D_801DBDF0; @@ -3028,7 +2974,7 @@ extern f32 D_801E05B4; extern f32 D_801E05B8; extern f32 D_801E05D0; extern f32 D_801E05D4; -// extern UNK_TYPE1 D_801E0BD0; +extern const u16 gAudioEnvironmentalSfx[]; // extern UNK_TYPE1 D_801E0BFC; extern f32 D_801E0CEC; extern f32 D_801E0CF0; @@ -3082,10 +3028,10 @@ extern const s16 gAudioTatumInit[]; extern const AudioContextInitSizes gAudioContextInitSizes; // extern UNK_TYPE4 D_801E1108; // extern UNK_TYPE4 D_801E110C; -// extern UNK_TYPE2 gSoundFontTable; -// extern UNK_TYPE1 gSequenceFontTable; -// extern UNK_TYPE2 gSequenceTable; -// extern UNK_TYPE1 gSampleBankTable; +extern u8 gSoundFontTable[]; +extern u8 gSequenceFontTable[]; +extern u8 gSequenceTable[]; +extern u8 gSampleBankTable[]; extern u64 aspMainDataStart[]; // bss @@ -3196,15 +3142,11 @@ extern GameInfo* gGameInfo; // extern UNK_TYPE1 D_801F3F80; // extern UNK_TYPE1 D_801F3F83; // extern UNK_TYPE1 D_801F48C8; -// extern UNK_TYPE1 D_801F4D40; -// extern UNK_TYPE2 D_801F4D42; -// extern UNK_TYPE1 D_801F4D48; -// extern UNK_TYPE1 D_801F4DC8; -// extern UNK_TYPE1 D_801F4DCA; -// extern UNK_TYPE2 D_801F4DCC[8]; -// extern UNK_TYPE1 D_801F4DDC; -// extern UNK_TYPE1 D_801F4DE0; + +extern UNK_TYPE D_801F4DDC; +extern u8 D_801F4DE0; extern s16 D_801F4DE2; + extern ActorCutscene* actorCutscenes; extern s16 actorCutsceneCount; extern u8 actorCutsceneWaiting[16]; @@ -3223,7 +3165,7 @@ extern Vec3f D_801F4E50; extern f32 D_801F4E5C; extern f32 D_801F4E60; extern s16 D_801F4E64; -// extern UNK_TYPE1 D_801F4E68; +extern u8 D_801F4E68; extern f32 D_801F4E70; // extern UNK_TYPE1 D_801F4E74; extern u16 D_801F4E78; @@ -3258,7 +3200,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F4F66; // extern UNK_TYPE1 D_801F4F68; // extern UNK_TYPE1 D_801F4F6A; -extern LightsBuffer sLightsBuffer; +// extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; // extern UNK_TYPE1 D_801F528E; @@ -3282,7 +3224,6 @@ extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F59F0; // extern UNK_TYPE1 D_801F59F4; // extern UNK_TYPE1 D_801F59F8; -// extern UNK_TYPE1 D_801F5AC0; // extern UNK_TYPE1 D_801F69D0; // extern UNK_TYPE1 D_801F6A10; // extern UNK_TYPE1 D_801F6AD4; @@ -3306,17 +3247,13 @@ extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F6B1E; // extern UNK_TYPE1 D_801F6B20; // extern UNK_TYPE1 D_801F6B22; -// extern UNK_TYPE1 D_801F6B30; -// extern UNK_TYPE1 D_801F6B34; -// extern UNK_TYPE1 D_801F6B38; -// extern UNK_TYPE1 D_801F6B3C; extern ShrinkWindowContext gShrinkWindowContext; extern ShrinkWindowContext* gShrinkWindowContextPtr; // extern UNK_TYPE4 D_801F6B50; // extern UNK_TYPE1 D_801F6B58; -extern FaultAddrConvClient sKaleidoAreaFaultClient; extern void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); extern void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +extern FaultAddrConvClient sKaleidoAreaFaultClient; // extern UNK_TYPE1 D_801F6C10; extern Input D_801F6C18; // extern UNK_TYPE1 D_801F6C30; @@ -3487,7 +3424,7 @@ extern StackEntry sys_flashromStackEntry; extern OSThread sys_flashromOSThread; extern s80185D40 D_801FD008; extern OSMesg D_801FD034; -// extern UNK_TYPE1 D_801FD120; +extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD140; // extern UNK_TYPE1 D_801FD158; // extern UNK_TYPE1 D_801FD198; @@ -3614,10 +3551,10 @@ extern SoundRequest D_801FE7C0[1]; // extern UNK_TYPE1 D_80200BCE; // extern UNK_TYPE1 D_80200BD0; extern AudioContext gAudioContext; // at 0x80200C70 -// extern UNK_TYPE4 D_80208E68; -// extern UNK_TYPE4 D_80208E6C; -// extern UNK_TYPE4 D_80208E70; -// extern UNK_TYPE4 D_80208E74; +extern void (*D_80208E68)(void); +extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); +extern s32 (*D_80208E70)(SoundFontSample*, s32, s8, s32); +extern Acmd* (*D_80208E74)(Acmd*, s32, s32); // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; diff --git a/include/z64.h b/include/z64.h index 1a9770b1c..5ae6f0636 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1,5 +1,5 @@ -#ifndef _Z64_H_ -#define _Z64_H_ +#ifndef Z64_H +#define Z64_H #include "libc/math.h" #include "libc/stdarg.h" @@ -17,10 +17,11 @@ #include "scheduler.h" #include "xstdio.h" -#include "bgm.h" #include "color.h" #include "ichain.h" +#include "sequence.h" #include "sfx.h" +#include "message_data_static.h" #include "z64actor.h" #include "z64animation.h" @@ -34,9 +35,12 @@ #include "z64light.h" #include "z64math.h" #include "z64object.h" +#include "z64ocarina.h" #include "z64player.h" -#include "z64scene.h" #include "z64save.h" +#include "z64scene.h" +#include "z64skin.h" +#include "z64subs.h" #include "z64transition.h" #include "regs.h" @@ -66,7 +70,7 @@ typedef struct { /* 0x0 */ s16 priority; // Lower means higher priority. -1 means it ignores priority /* 0x2 */ s16 length; - /* 0x4 */ s16 unk4; + /* 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; @@ -107,24 +111,6 @@ typedef struct { /* 0x8 */ CameraModeParams* modes; } CameraStateParams; // size = 0xC -typedef struct { - /* 0x00 */ u8 sceneCsCount; - /* 0x04 */ void* segment; - /* 0x08 */ u8 state; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ u16 frames; - /* 0x12 */ u16 unk_12; - /* 0x14 */ s32 unk_14; - /* 0x18 */ u16 unk_18; - /* 0x1A */ u8 unk_1A; - /* 0x1B */ u8 unk_1B; - /* 0x1C */ CutsceneCameraPoint* cameraFocus; - /* 0x20 */ CutsceneCameraPoint* cameraPosition; - /* 0x24 */ CsCmdActorAction* linkAction; - /* 0x28 */ CsCmdActorAction* npcActions[10]; // "npcdemopnt" - /* 0x50 */ CutsceneEntry* sceneCsList; -} CutsceneContext; // size = 0x54 - typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; @@ -156,15 +142,21 @@ typedef struct { /* 0x4 */ f32 dynamicSizeStep; /* 0x8 */ u8 state; /* 0x9 */ u8 sizeGrowsCos2; - /* 0xA */ u8 unkA; + /* 0xA */ u8 colorsIndex; /* 0xB */ u8 flags; - /* 0xC */ u8 unkC; + /* 0xC */ u8 lightParamsIndex; } FireObjInitParams; // size = 0xD -typedef struct { +typedef struct FireObjColors { /* 0x0 */ Color_RGBA8 primColor; - /* 0x4 */ u8 unk4; + /* 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 #define FONT_CHAR_TEX_WIDTH 16 @@ -183,7 +175,7 @@ typedef struct { } msgBuf; /* 0x11D80 */ u8* messageStart; /* 0x11D84 */ u8* messageEnd; - /* 0x11D88 */ u8 unk_11D88; + /* 0x11D88 */ u8 unk_11D88; // current Char Buffer ? } Font; // size = 0x11D8C // Game Info aka. Static Context @@ -323,19 +315,6 @@ typedef struct { /* 0x3 */ s8 pillarboxMagnitude; } ShrinkWindowContext; // size = 0x4 -typedef struct { - /* 0x00 */ u8* readBuff; - /* 0x04 */ u32* flashReadBuff; - /* 0x08 */ char unk_08[4]; - /* 0x0C */ s16 status; - /* 0x10 */ u32 curPage; - /* 0x14 */ u32 numPages; - /* 0x18 */ OSTime unk_18; - /* 0x20 */ s16 unk_20; - /* 0x22 */ s16 unk_22; - /* 0x24 */ s16 unk_24; -} SramContext; // size = 0x28 - typedef struct { /* 0x0 */ s32 topY; /* 0x4 */ s32 bottomY; @@ -763,8 +742,8 @@ typedef struct { /* 0x12 */ u8 unk_12; /* 0x13 */ u8 unk_13; /* 0x14 */ u8 unk_14; - /* 0x15 */ u8 unk_15; - /* 0x16 */ u8 unk_16; + /* 0x15 */ u8 skyboxDisabled; + /* 0x16 */ u8 sunMoonDisabled; /* 0x17 */ u8 unk_17; /* 0x18 */ u8 unk_18; /* 0x19 */ u8 unk_19; @@ -785,7 +764,7 @@ typedef struct { /* 0x80 */ OSMesg unk_80; /* 0x84 */ f32 unk_84; /* 0x88 */ f32 unk_88; - /* 0x8C */ LightSettings2 unk_8C; + /* 0x8C */ EnvLightSettings lightSettings; /* 0xA8 */ f32 unk_A8; /* 0xAC */ Vec3s windDir; /* 0xB4 */ f32 windSpeed; @@ -794,18 +773,18 @@ typedef struct { /* 0xC0 */ u8 unk_C0; /* 0xC1 */ u8 unk_C1; /* 0xC2 */ u8 unk_C2; - /* 0xC3 */ u8 unk_C3; + /* 0xC3 */ u8 lightSettingOverride; /* 0xC4 */ LightSettings unk_C4; /* 0xDA */ u16 unk_DA; - /* 0xDC */ f32 unk_DC; + /* 0xDC */ f32 lightBlend; /* 0xE0 */ u8 unk_E0; /* 0xE1 */ u8 unk_E1; /* 0xE2 */ s8 unk_E2; /* 0xE3 */ u8 unk_E3; // modified by unused func in EnWeatherTag /* 0xE4 */ u8 unk_E4; - /* 0xE5 */ u8 unk_E5; - /* 0xE6 */ u8 unk_E6[4]; - /* 0xEA */ u8 unk_EA; + /* 0xE5 */ u8 fillScreen; + /* 0xE6 */ u8 screenFillColor[4]; + /* 0xEA */ u8 sandstormState; /* 0xEB */ u8 unk_EB; /* 0xEC */ u8 unk_EC; /* 0xED */ u8 unk_ED; @@ -894,46 +873,91 @@ typedef struct { typedef struct { /* 0x00000 */ View view; /* 0x00168 */ Font font; - /* 0x11EF4 */ char unk_11EF4[0x10]; - /* 0x11F04 */ u16 unk11F04; + /* 0x11EF4 */ char unk_11EF4[0x4]; + /* 0x11EF8 */ UNK_PTR unk11EF8; + /* 0x11EFC */ UNK_TYPE1 unk11EFC[0x8]; + /* 0x11F04 */ u16 currentTextId; /* 0x11F06 */ UNK_TYPE1 pad11F06[0x4]; /* 0x11F0A */ u8 unk11F0A; /* 0x11F0B */ UNK_TYPE1 pad11F0B[0x5]; /* 0x11F10 */ s32 unk11F10; - /* 0x11F14 */ UNK_TYPE1 pad11F14[0xE]; + /* 0x11F14 */ UNK_TYPE1 pad11F14[0x6]; + /* 0x11F1A */ s16 unk11F1A[3]; + /* 0x11F20 */ UNK_TYPE1 pad11F20[0x2]; /* 0x11F22 */ u8 msgMode; - /* 0x11F23 */ UNK_TYPE1 pad11F23[0xE3]; + /* 0x11F23 */ UNK_TYPE1 pad11F23; + /* 0x11F24 */ union { + u8 schar[206]; + u16 wchar[103]; + } decodedBuffer; + /* 0x11FF2 */ u16 unk11FF2; + /* 0x11FF4 */ s16 unk11FF4; + /* 0x11FF6 */ s16 unk11FF6; + /* 0x11FF8 */ UNK_TYPE1 unk11FF8[0x6]; + /* 0x11FFE */ s16 unk11FFE[0x3]; + /* 0x12004 */ s16 unk12004; /* 0x12006 */ s16 unk12006; - /* 0x12007 */ UNK_TYPE1 pad12007[0x18]; + /* 0x12008 */ u8 unk12008[0x16]; + /* 0x1201E */ s16 unk1201E; /* 0x12020 */ u8 unk12020; /* 0x12021 */ u8 choiceIndex; /* 0x12022 */ u8 unk12022; /* 0x12023 */ u8 unk12023; - /* 0x12024 */ UNK_TYPE1 unk12024[0x6]; + /* 0x12024 */ s16 unk12024; + /* 0x12026 */ u16 unk12026; + /* 0x12028 */ u16 songPlayed; /* 0x1202A */ u16 ocarinaMode; /* 0x1202C */ u16 ocarinaAction; /* 0x1202E */ u16 unk1202E; /* 0x12030 */ s16 unk_12030; /* 0x12032 */ UNK_TYPE1 unk_12032[0x2]; - /* 0x12034 */ UNK_TYPE1 pad12034[0x10]; + /* 0x12034 */ UNK_TYPE1 pad12034[0x6]; + /* 0x1203A */ s16 unk1203A; + /* 0x1203C */ s16 unk1203C; + /* 0x1203E */ s16 pad1203E; + /* 0x12040 */ Actor* unkActor; /* 0x12044 */ s16 unk12044; - /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; + /* 0x12046 */ s16 unk12046; /* 0x12048 */ u8 unk12048; // EnKakasi - /* 0x12049 */ UNK_TYPE1 pad12049[0xB]; - /* 0x12054 */ s16 unk12054; // First digit in lottery code guess - /* 0x12056 */ s16 unk12056; // Second digit lottery code guess - /* 0x12058 */ s16 unk12058; // Third digit lottery code guess - /* 0x1205A */ UNK_TYPE1 pad1205A[0x10]; + /* 0x12049 */ UNK_TYPE1 pad12049[0x1]; + /* 0x1204A */ s16 unk1204A[0x5]; + /* 0x12054 */ s16 unk12054[3]; // First, second and third digits in lottery code guess + /* 0x1205A */ UNK_TYPE1 pad1205A[0xE]; + /* 0x12068 */ s16 unk12068; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; - /* 0x12070 */ UNK_TYPE1 pad12070[0x8]; + /* 0x12070 */ s32 unk12070; + /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; /* 0x1207C */ s32 bankRupees; - /* 0x12080 */ UNK_TYPE1 pad12080[0x31]; + /* 0x12080 */ MessageTableEntry* messageEntryTable; + /* 0x12084 */ MessageTableEntry* messageEntryTableNes; + /* 0x12088 */ UNK_TYPE4 unk12088; + /* 0x1208C */ MessageTableEntry* messageTableStaff; + /* 0x12090 */ s16 unk12090; + /* 0x12092 */ s16 unk12092; + /* 0x12094 */ s8 unk12094; + /* 0x12095 */ UNK_TYPE1 unk12095[0x3]; + /* 0x12098 */ f32 unk12098; // Text_Scale? + /* 0x1209C */ s16 unk1209C; + /* 0x1209E */ UNK_TYPE1 unk1209E[0x2]; + /* 0x120A0 */ s32 unk120A0; + /* 0x120A4 */ UNK_TYPE1 unk120A4[0xC]; + /* 0x120B0 */ u8 unk120B0; /* 0x120B1 */ u8 unk120B1; - /* 0x120B2 */ UNK_TYPE1 pad120B2[0x22]; - /* 0x120D4 */ UNK_TYPE2 unk120D4; - /* 0x120D6 */ UNK_TYPE2 unk120D6; + /* 0x120B2 */ u8 unk120B2[0xC]; + /* 0x120BE */ s16 unk120BE; + /* 0x120C0 */ s16 unk120C0; + /* 0x120C2 */ s16 unk120C2; + /* 0x120C4 */ s32 unk120C4; + /* 0x120C8 */ s16 unk120C8; + /* 0x120CA */ s16 unk120CA; + /* 0x120CC */ s16 unk120CC; + /* 0x120CE */ s16 unk120CE; + /* 0x120D0 */ s16 unk120D0; + /* 0x120D2 */ s16 unk120D2; + /* 0x120D4 */ s16 unk120D4; + /* 0x120D6 */ s16 unk120D6; /* 0x120D8 */ UNK_TYPE1 pad120D8[0x8]; } MessageContext; // size = 0x120E0 @@ -1041,8 +1065,6 @@ typedef void (*ColChkApplyFunc)(GlobalContext*, CollisionCheckContext*, Collider typedef void (*ColChkVsFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Collider*); typedef s32 (*ColChkLineFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); -typedef void(*cutscene_update_func)(GlobalContext* globalCtx, CutsceneContext* cCtxt); - typedef void(*draw_func)(GlobalContext* globalCtx, s16 index); typedef void(*room_draw_func)(GlobalContext* globalCtx, Room* room, u32 flags); @@ -1117,7 +1139,7 @@ typedef struct Camera { /* 0x15E */ s16 animState; /* 0x160 */ s16 unk160; /* 0x162 */ s16 timer; - /* 0x164 */ s16 thisIdx; + /* 0x164 */ s16 camId; /* 0x166 */ s16 prevCamDataIdx; /* 0x168 */ s16 unk168; /* 0x16A */ s16 unk16A; @@ -1146,7 +1168,7 @@ typedef struct { /* 0x1A */ s16 speed; /* 0x1C */ s16 isShakePerpendicular; /* 0x1E */ s16 countdown; - /* 0x20 */ s16 cameraPtrsIdx; + /* 0x20 */ s16 camId; } QuakeRequest; // size = 0x24 typedef struct { @@ -1180,7 +1202,7 @@ typedef struct { typedef enum { /* 0 */ DISTORTION_INACTIVE, /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP, + /* 2 */ DISTORTION_SETUP } DistortionState; typedef struct { @@ -1224,8 +1246,8 @@ typedef enum { struct FireObjLight { /* 0x00 */ LightNode* light; - /* 0x04 */ LightInfoPositional lightInfo; - /* 0x12 */ u8 unk12; + /* 0x04 */ LightInfo lightInfo; + /* 0x12 */ u8 lightParamsIndex; }; // size = 0x13 #define OS_SC_RETRACE_MSG 1 @@ -1276,7 +1298,7 @@ struct FireObj { /* 0x24 */ u8 state; // 0 - growing, 1 - shrinking, 2 - fully lit, 3 - not lit /* 0x25 */ u8 sizeGrowsCos2; /* 0x26 */ u8 unk26; - /* 0x27 */ u8 unk27; + /* 0x27 */ u8 colorsIndex; /* 0x28 */ u8 flags; // bit 0 - ?, bit 1 - ? /* 0x29 */ UNK_TYPE1 pad29[0x1]; /* 0x2A */ s16 ignitionDelay; @@ -1346,7 +1368,7 @@ struct GlobalContext { /* 0x18760 */ DoorContext doorCtx; /* 0x18768 */ void (*playerInit)(Player* player, struct GlobalContext* globalCtx, FlexSkeletonHeader* skelHeader); /* 0x1876C */ void (*playerUpdate)(Player* player, struct GlobalContext* globalCtx, Input* input); - /* 0x18770 */ void* unk_18770; //! @TODO: Determine function prototype + /* 0x18770 */ void (*unk_18770)(struct GlobalContext* globalCtx, Player* player); /* 0x18774 */ s32 (*startPlayerFishing)(struct GlobalContext* globalCtx); /* 0x18778 */ s32 (*grabPlayer)(struct GlobalContext* globalCtx, Player* player); /* 0x1877C */ s32 (*startPlayerCutscene)(struct GlobalContext* globalCtx, Player* player, s32 mode); @@ -1357,7 +1379,7 @@ struct GlobalContext { /* 0x18790 */ void (*unk_18790)(struct GlobalContext* globalCtx, s16 arg1, Actor* actor); /* 0x18794 */ void* unk_18794; //! @TODO: Determine function prototype /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct GlobalContext* globalCtx, void* talkAnim, s32 arg2); - /* 0x1879C */ s16 unk_1879C[10]; + /* 0x1879C */ s16 playerActorCsIds[10]; /* 0x187B0 */ MtxF viewProjectionMtxF; /* 0x187F0 */ Vec3f unk_187F0; /* 0x187FC */ MtxF billboardMtxF; @@ -1370,7 +1392,7 @@ struct GlobalContext { /* 0x1884C */ RomFile* roomList; /* 0x18850 */ ActorEntry* linkActorEntry; /* 0x18854 */ ActorEntry* setupActorList; - /* 0x18858 */ void* unk_18858; + /* 0x18858 */ CsCamData* csCamData; /* 0x1885C */ EntranceEntry* setupEntranceList; /* 0x18860 */ u16* setupExitList; /* 0x18864 */ Path* setupPathList; @@ -1385,7 +1407,7 @@ struct GlobalContext { /* 0x1887C */ s8 unk_1887C; /* 0x1887D */ s8 unk_1887D; /* 0x1887E */ s8 unk_1887E; - /* 0x1887F */ u8 unk_1887F; + /* 0x1887F */ u8 unk_1887F; // fadeTransition /* 0x18880 */ u8 unk_18880; /* 0x18884 */ CollisionCheckContext colChkCtx; /* 0x18B20 */ u16 envFlags[20]; @@ -1423,68 +1445,12 @@ typedef struct { /* 0x24 */ s16 unk_24; } struct_800BD888_arg1; // size = 0x28 -typedef struct EnHy { - /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk_144[0x8]; - /* 0x14C */ SkelAnime skelAnime; - /* 0x190 */ s8 unk190; - /* 0x191 */ s8 unk191; - /* 0x192 */ s8 unk192; - /* 0x193 */ s8 animObjIndex; - /* 0x194 */ ColliderCylinder collider; - /* 0x1E0 */ UNK_TYPE1 unk_1E0[0x4]; - /* 0x1E4 */ Path* path; - /* 0x1E8 */ s16 curPoint; - /* 0x1EA */ UNK_TYPE1 unk_1EA[0x2]; - /* 0x1EC */ Vec3f leftFootPos; - /* 0x1F8 */ Vec3f rightFootPos; - /* 0x204 */ u8 isLeftFootOnGround; - /* 0x205 */ u8 isRightFootOnGround; - /* 0x206 */ Vec3s jointTable[16]; - /* 0x266 */ Vec3s morphTable[16]; - /* 0x2C6 */ UNK_TYPE1 unk_2C6[0x120]; - /* 0x3E6 */ s16 eyeTexIndex; - /* 0x3E8 */ s16 blinkTimer; -} EnHy; - typedef struct { /* 0x0 */ u8 unk0; /* 0x4 */ s32 unk4; /* 0x8 */ s32 unk8; // game script pointer? } struct_80133038_arg2; // size = 0xC -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); - -typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); - -struct struct_8013DF3C_arg1; -typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); -typedef s32 (*struct_8013DF3C_arg1_unk_func2)(struct GlobalContext*, struct struct_8013DF3C_arg1*); - -typedef struct struct_8013DF3C_arg1 { - /* 0x00 */ Path* setupPathList; - /* 0x04 */ s32 pathIndex; - /* 0x08 */ Vec3s* points; - /* 0x0C */ s32 count; - /* 0x10 */ s32 unk_10; - /* 0x14 */ s32 unk_14; - /* 0x18 */ s32 unk_18; - /* 0x1C */ u8 unk_1C; - /* 0x1D */ u8 unk_1D; - /* 0x20 */ Vec3f unk_20; - /* 0x2C */ Vec3f unk_2C; - /* 0x38 */ Vec3f unk_38; - /* 0x44 */ Vec3f* unk_44; - /* 0x48 */ Actor* actor; - /* 0x4C */ f32 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ Vec3s unk_54; - /* 0x5C */ struct_8013DF3C_arg1_unk_func1 unk_5C; - /* 0x60 */ struct_8013DF3C_arg1_unk_func2 unk_60; - /* 0x64 */ struct_8013DF3C_arg1_unk_func2 unk_64; - /* 0x68 */ struct_8013DF3C_arg1_unk_func2 unk_68; -} struct_8013DF3C_arg1; // size = 0x6C - typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; @@ -1577,4 +1543,35 @@ 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 8c6992f49..ee73ae8af 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -297,24 +297,6 @@ typedef enum { /* 0x0C */ ACTORCAT_MAX } ActorType; -typedef struct { - /* 0x00 */ AnimationHeader* animation; - /* 0x04 */ f32 playSpeed; - /* 0x08 */ f32 startFrame; - /* 0x0C */ f32 frameCount; - /* 0x10 */ u8 mode; - /* 0x14 */ f32 morphFrames; -} ActorAnimationEntry; // size = 0x18 - -typedef struct { - /* 0x00 */ AnimationHeader* animationSeg; - /* 0x04 */ f32 playbackSpeed; - /* 0x08 */ s16 frame; - /* 0x0A */ s16 frameCount; - /* 0x0C */ u8 mode; - /* 0x0E */ s16 transitionRate; -} ActorAnimationEntryS; // size = 0x10 - typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ f32 unkC; @@ -405,6 +387,18 @@ typedef struct ActorContext { /* 0x26C */ Input unk_26C; } ActorContext; // size = 0x284 +typedef enum { + /* 00 */ ACTOR_DRAW_DMGEFF_FIRE, + /* 01 */ ACTOR_DRAW_DMGEFF_BLUE_FIRE, + /* 10 */ ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX = 10, + /* 11 */ ACTOR_DRAW_DMGEFF_FROZEN_SFX, + /* 20 */ ACTOR_DRAW_DMGEFF_LIGHT_ORBS = 20, + /* 21 */ ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS, + /* 30 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL = 30, + /* 31 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM, + /* 32 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE +} ActorDrawDamageEffectType; + typedef enum { /* 0x000 */ ACTOR_PLAYER, /* 0x001 */ ACTOR_EN_TEST, @@ -1178,7 +1172,7 @@ typedef enum { /* 0x03 */ CLEAR_TAG_SMALL_LIGHT_RAYS, /* 0x04 */ CLEAR_TAG_LARGE_LIGHT_RAYS, /* 0x23 */ CLEAR_TAG_SPLASH = 35, - /* 0xC8 */ CLEAR_TAG_SMOKE = 200, + /* 0xC8 */ CLEAR_TAG_SMOKE = 200 } ClearTagType; #endif diff --git a/include/z64animation.h b/include/z64animation.h index 2aa97e2ec..974b8bea0 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -1,5 +1,5 @@ -#ifndef _Z64_ANIMATION_H -#define _Z64_ANIMATION_H +#ifndef Z64_ANIMATION_H +#define Z64_ANIMATION_H #include "PR/ultratypes.h" #include "PR/gbi.h" @@ -28,7 +28,7 @@ typedef enum { } AnimationModes; typedef enum { - /* -1 */ ANIMTAPER_DECEL = -1, + /* -1 */ ANIMTAPER_DECEL = -1, /* 0 */ ANIMTAPER_NONE, /* 1 */ ANIMTAPER_ACCEL } AnimationTapers; @@ -49,14 +49,6 @@ typedef struct { /* 0x08 */ Gfx* dLists[2]; // Near and far } LodLimb; // size = 0x10 -typedef struct { - /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent - /* 0x06 */ u8 child; - /* 0x07 */ u8 sibling; - /* 0x08 */ s32 unk_8; // Type of data contained in segment - /* 0x0C */ void* segment; // Segment address of data. Currently unclear what. -} SkinLimb; // size = 0x10 - // Model has limbs with only rigid meshes typedef struct { /* 0x00 */ void** segment; @@ -279,48 +271,98 @@ typedef s32 (*OverrideCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeC typedef void (*PostCurveLimbDraw)(struct GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, struct Actor* actor); -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ s16 unk_2; - /* 0x004 */ s16 unk_4; - /* 0x006 */ s8 unk_6; - /* 0x007 */ s8 unk_7; - /* 0x008 */ s8 unk_8; - /* 0x009 */ u8 unk_9; -} Struct_800A57C0; // size = 0xA + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; + /* 0x08 */ f32 startFrame; + /* 0x0C */ f32 frameCount; + /* 0x10 */ u8 mode; + /* 0x14 */ f32 morphFrames; +} AnimationInfo; // size = 0x18 -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes typedef struct { - /* 0x000 */ u8 unk_0; - /* 0x002 */ s16 x; - /* 0x004 */ s16 y; - /* 0x006 */ s16 z; - /* 0x008 */ u8 unk_8; -} Struct_800A598C_2; // size = 0xA + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; + /* 0x08 */ s16 startFrame; + /* 0x0A */ s16 frameCount; + /* 0x0C */ u8 mode; + /* 0x0E */ s16 morphFrames; +} AnimationInfoS; // size = 0x10 -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ u16 unk_4; - /* 0x008 */ Struct_800A57C0* unk_8; - /* 0x00C */ Struct_800A598C_2* unk_C; -} Struct_800A598C; // size = 0x10 - -// TODO the name of this struct is imported from OoT and cannot change until the ZAPD name also changes -typedef struct { - /* 0x000 */ u16 unk_0; - /* 0x002 */ u16 unk_2; - /* 0x004 */ Struct_800A598C* unk_4; - /* 0x008 */ Gfx* unk_8; -} Struct_800A5E28; // size = 0xC - -typedef struct struct_80B8E1A8 { - /* 0x00 */ AnimationHeader* animationSeg; - /* 0x04 */ f32 playbackSpeed; +typedef struct AnimationSpeedInfo { + /* 0x00 */ AnimationHeader* animation; + /* 0x04 */ f32 playSpeed; /* 0x08 */ u8 mode; - /* 0x0C */ f32 transitionRate; -} struct_80B8E1A8; // size = 0x10 + /* 0x0C */ f32 morphFrames; +} AnimationSpeedInfo; // size = 0x10 + +struct SkeletonInfo; + +typedef s32 (*UnkKeyframeCallback)(struct GlobalContext* globalCtx, struct SkeletonInfo* skeletonInfo, s32* arg2, Gfx** dList, + u8* arg4, void* arg5); + +// Keyframe limb? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ Vec3s root; +} Struct_801BFA14_Arg1_Field4; // size = 0xC + +// Other limb type? +typedef struct { + /* 0x00 */ Gfx* dList; + /* 0x04 */ u8 unk_4; + /* 0x05 */ u8 flags; + /* 0x06 */ u8 unk_6; // transform limb draw index +} Struct_801BFA14_Arg1_Field4_2; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 limbCount; + /* 0x01 */ u8 unk_1; // non-zero in object files, number of non-null-dlist limbs? + /* 0x04 */ union { + Struct_801BFA14_Arg1_Field4* unk_4; // arrays + Struct_801BFA14_Arg1_Field4_2* unk_4_2; + }; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} Struct_801BFA14_Arg1; + +typedef struct { + /* 0x00 */ u16* unk_0; + /* 0x04 */ s16* unk_4; + /* 0x08 */ s16* unk_8; + /* 0x0C */ s16* unk_C; + /* 0x0C */ char unk_10[0x2]; + /* 0x12 */ s16 unk_12; +} SkeletonInfo_1C; + +typedef struct { + /* 0x00 */ f32 unk_0; + /* 0x04 */ f32 unk_4; + /* 0x08 */ f32 unk_8; + /* 0x0C */ f32 unk_C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s32 unk_14; +} FrameControl; + +// FlexKeyframeSkeleton ? +typedef struct SkeletonInfo { + /* 0x00 */ FrameControl frameCtrl; + /* 0x18 */ Struct_801BFA14_Arg1* unk_18; // array + /* 0x1C */ SkeletonInfo_1C* unk_1C; + /* 0x20 */ UnkKeyframeCallback* unk_20; // pointer to array of functions + /* 0x24 */ f32 unk_24; // duration? current time? + /* 0x28 */ Vec3s* frameData; // array of 3 Vec3s + /* 0x2C */ s16* unk_2C; +} SkeletonInfo; + +typedef s32 (*OverrideKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); + +typedef void (*PostKeyframeDrawScaled)(struct GlobalContext* globalCtx, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, + u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); #endif diff --git a/include/z64audio.h b/include/z64audio.h index 89fff01c7..5dd78f73a 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -20,12 +20,19 @@ #define AIBUF_LEN 0x580 +typedef enum { + /* 0 */ AUDIO_FS_STEREO, + /* 1 */ AUDIO_FS_HEADSET, + /* 2 */ AUDIO_FS_SURROUND, + /* 3 */ AUDIO_FS_MONO +} AudioFileSelectOption; + typedef enum { /* 0 */ AUDIO_MODE_STEREO, /* 1 */ AUDIO_MODE_HEADSET, /* 2 */ AUDIO_MODE_UNK, /* 3 */ AUDIO_MODE_MONO, - /* 4 */ AUDIO_MODE_SURROUND, + /* 4 */ AUDIO_MODE_SURROUND } AudioSoundMode; typedef enum { @@ -42,11 +49,10 @@ typedef enum { typedef enum { /* 0 */ MEDIUM_RAM, - /* 1 */ MEDIUM_UNK1, + /* 1 */ MEDIUM_UNK, /* 2 */ MEDIUM_CART, /* 3 */ MEDIUM_DISK_DRIVE, - /* 4 */ MEDIUM_UNK4, - /* 5 */ MEDIUM_UNK5 + /* 5 */ MEDIUM_RAM_UNLOADED = 5 } SampleMedium; typedef enum { @@ -64,6 +70,14 @@ typedef enum { /* 2 */ SAMPLE_TABLE } SampleBankTableType; +typedef enum { + /* 0 */ CACHE_LOAD_PERMANENT, + /* 1 */ CACHE_LOAD_PERSISTENT, + /* 2 */ CACHE_LOAD_TEMPORARY, + /* 3 */ CACHE_LOAD_EITHER, + /* 4 */ CACHE_LOAD_EITHER_NOSYNC +} AudioCacheLoadType; + typedef enum { /* 0 */ CACHE_TEMPORARY, /* 1 */ CACHE_PERSISTENT, @@ -72,61 +86,13 @@ typedef enum { } AudioCacheType; typedef enum { - /* 0 */ OCARINA_SONG_SONATA, - /* 1 */ OCARINA_SONG_GORON_LULLABY, - /* 2 */ OCARINA_SONG_NEW_WAVE, - /* 3 */ OCARINA_SONG_ELEGY, - /* 4 */ OCARINA_SONG_OATH, - /* 5 */ OCARINA_SONG_SARIAS, - /* 6 */ OCARINA_SONG_TIME, - /* 7 */ OCARINA_SONG_HEALING, - /* 8 */ OCARINA_SONG_EPONAS, - /* 9 */ OCARINA_SONG_SOARING, - /* 10 */ OCARINA_SONG_STORMS, - /* 11 */ OCARINA_SONG_SUNS, - /* 12 */ OCARINA_SONG_INVERTED_TIME, - /* 13 */ OCARINA_SONG_DOUBLE_TIME, - /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, - /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" - /* 16 */ OCARINA_SONG_WIND_FISH_GORON, - /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, - /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, - /* 19 */ OCARINA_SONG_EVAN_PART1, - /* 20 */ OCARINA_SONG_EVAN_PART2, - /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, - /* 22 */ OCARINA_SONG_SCARECROW, - /* 23 */ OCARINA_SONG_TERMINA_WALL, - /* 24 */ OCARINA_SONG_MAX, -} OcarinaSongId; - -typedef enum { - /* 0 */ OCARINA_BTN_A, - /* 1 */ OCARINA_BTN_C_DOWN, - /* 2 */ OCARINA_BTN_C_RIGHT, - /* 3 */ OCARINA_BTN_C_LEFT, - /* 4 */ OCARINA_BTN_C_UP, - /* -1 */ OCARINA_BTN_INVALID = 0xFF -} OcarinaButtonIdx; - -typedef enum { - /* 0x0 */ OCARINA_PITCH_C4, - /* 0x1 */ OCARINA_PITCH_DFLAT4, - /* 0x2 */ OCARINA_PITCH_D4, - /* 0x3 */ OCARINA_PITCH_EFLAT4, - /* 0x4 */ OCARINA_PITCH_E4, - /* 0x5 */ OCARINA_PITCH_F4, - /* 0x6 */ OCARINA_PITCH_GFLAT4, - /* 0x7 */ OCARINA_PITCH_G4, - /* 0x8 */ OCARINA_PITCH_AFLAT4, - /* 0x9 */ OCARINA_PITCH_A4, - /* 0xA */ OCARINA_PITCH_BFLAT4, - /* 0xB */ OCARINA_PITCH_B4, - /* 0xC */ OCARINA_PITCH_C5, - /* 0xD */ OCARINA_PITCH_DFLAT5, - /* 0xE */ OCARINA_PITCH_D5, - /* 0xF */ OCARINA_PITCH_EFLAT5, - /* -1 */ OCARINA_PITCH_NONE = 0xFF -} OcarinaNoteIdx; + /* 0 */ LOAD_STATUS_0, + /* 1 */ LOAD_STATUS_1, + /* 2 */ LOAD_STATUS_2, // Samples/Seqplayer + /* 3 */ LOAD_STATUS_3, // Sequences + /* 4 */ LOAD_STATUS_4, // SoundFonts + /* 5 */ LOAD_STATUS_5 // Permanent +} AudioLoadStatus; typedef s32 (*DmaHandler)(OSPiHandle* handle, OSIoMesg* mb, s32 direction); @@ -292,9 +258,9 @@ typedef struct { } SoundFont; // size = 0x14 typedef struct { - /* 0x00 */ u8* pc; + /* 0x00 */ u8* pc; // program counter /* 0x04 */ u8* stack[4]; - /* 0x14 */ u8 remLoopIters[4]; + /* 0x14 */ u8 remLoopIters[4]; // remaining loop iterations /* 0x18 */ u8 depth; /* 0x19 */ s8 value; } SeqScriptState; // size = 0x1C @@ -449,7 +415,7 @@ typedef struct SequenceChannel { /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; /* 0x22 */ u16 unk_20; - /* 0x24 */ u16 unk_22; + /* 0x24 */ u16 unk_22; // Used for indexing data /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or // 0x80..0x83 for sawtooth/triangle/sine/square waves. /* 0x28 */ s16 transposition; @@ -673,32 +639,41 @@ typedef struct { /* 0x16 */ s16 lowPassFilterCutoffRight; } ReverbSettings; // size = 0x18 +/** + * The high-level audio specifications requested when initializing or resetting the audio heap. + * Most often resets during scene transitions, but will highly depend on game play. + */ typedef struct { - /* 0x00 */ u32 frequency; + /* 0x00 */ u32 samplingFreq; // Target sampling rate in Hz /* 0x04 */ u8 unk_04; /* 0x05 */ u8 numNotes; /* 0x06 */ u8 numSequencePlayers; /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero /* 0x09 */ u8 numReverbs; - /* 0x0A */ u8 unk_0A[0x2]; /* 0x0C */ ReverbSettings* reverbSettings; /* 0x10 */ u16 sampleDmaBufSize1; /* 0x12 */ u16 sampleDmaBufSize2; /* 0x14 */ u16 unk_14; - /* 0x18 */ u32 persistentSeqMem; - /* 0x1C */ u32 persistentFontMem; - /* 0x20 */ u32 persistentSampleMem; - /* 0x24 */ u32 temporarySeqMem; - /* 0x28 */ u32 temporaryFontMem; - /* 0x2C */ u32 temporarySampleMem; - /* 0x30 */ s32 persistentSampleCacheMem; - /* 0x34 */ s32 temporarySampleCacheMem; + /* 0x18 */ size_t persistentSeqCacheSize; // size of cache on audio pool to store sequences persistently + /* 0x1C */ size_t persistentFontCacheSize; // size of cache on audio pool to store soundFonts persistently + /* 0x20 */ size_t persistentSampleBankCacheSize; // size of cache on audio pool to store entire sample banks persistently + /* 0x24 */ size_t temporarySeqCacheSize; // size of cache on audio pool to store sequences temporarily + /* 0x28 */ size_t temporaryFontCacheSize; // size of cache on audio pool to store soundFonts temporarily + /* 0x2C */ size_t temporarySampleBankCacheSize; // size of cache on audio pool to store entire sample banks temporarily + /* 0x30 */ size_t persistentSampleCacheSize; // size of cache on audio pool to store individual samples persistently + /* 0x34 */ size_t temporarySampleCacheSize; // size of cache on audio pool to store individual samples temporarily } AudioSpec; // size = 0x38 +/** + * The audio buffer stores the fully processed digital audio before it is sent to the audio interface (AI), then to the + * digital-analog converter (DAC), then to play on the speakers. The audio buffer is written to by the rsp after + * processing audio commands, and the audio buffer is read by AI which sends the data to the DAC. + * This struct parameterizes that buffer. + */ typedef struct { /* 0x00 */ s16 specUnk4; - /* 0x02 */ u16 frequency; - /* 0x04 */ u16 aiFrequency; + /* 0x02 */ u16 samplingFreq; // Target sampling rate in Hz + /* 0x04 */ u16 aiSamplingFreq; // True sampling rate set to the audio interface (AI) for the audio digital-analog converter (DAC) /* 0x06 */ s16 samplesPerFrameTarget; /* 0x08 */ s16 maxAiBufferLength; /* 0x0A */ s16 minAiBufferLength; @@ -713,20 +688,29 @@ typedef struct { /* 0x24 */ f32 unk_24; } AudioBufferParameters; // size = 0x28 +/** + * Meta-data associated with a pool (contain withing the Audio Heap) + */ typedef struct { - /* 0x0 */ u8* start; - /* 0x4 */ u8* cur; - /* 0x8 */ s32 size; - /* 0xC */ s32 count; + /* 0x0 */ u8* startAddr; // start addr of the pool + /* 0x4 */ u8* curAddr; // address of the next available memory for allocation + /* 0x8 */ size_t size; // size of the pool + /* 0xC */ s32 count; // number of entries allocated to the pool } AudioAllocPool; // size = 0x10 +/** + * Audio cache entry data to store a single entry containing either a sequence, soundfont, or entire sample banks + */ typedef struct { - /* 0x0 */ u8* ptr; - /* 0x4 */ u32 size; + /* 0x0 */ u8* addr; + /* 0x4 */ size_t size; /* 0x8 */ s16 tableType; /* 0xA */ s16 id; } AudioCacheEntry; // size = 0xC +/** + * Audio cache entry data to store a single entry containing an individual sample + */ typedef struct { /* 0x00 */ s8 inUse; /* 0x01 */ s8 origMedium; @@ -734,13 +718,16 @@ typedef struct { /* 0x03 */ char unk_03[0x5]; /* 0x08 */ u8* allocatedAddr; /* 0x0C */ void* sampleAddr; - /* 0x10 */ u32 size; + /* 0x10 */ size_t size; } SampleCacheEntry; // size = 0x14 +/** + * Audio cache entry data to store individual samples + */ typedef struct { /* 0x000 */ AudioAllocPool pool; /* 0x010 */ SampleCacheEntry entries[128]; - /* 0xA10 */ s32 size; + /* 0xA10 */ s32 numEntries; } AudioSampleCache; // size = 0xA14 typedef struct { @@ -762,22 +749,21 @@ typedef struct { } AudioCache; // size = 0x110 typedef struct { - /* 0x0 */ u32 wantPersistent; - /* 0x4 */ u32 wantTemporary; -} AudioPoolSplit2; // size = 0x8 + /* 0x0 */ size_t persistentCommonPoolSize; + /* 0x4 */ size_t temporaryCommonPoolSize; +} AudioCachePoolSplit; // size = 0x8 typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; -} AudioPoolSplit3; // size = 0xC + /* 0x0 */ size_t seqCacheSize; + /* 0x4 */ size_t fontCacheSize; + /* 0x8 */ size_t sampleBankCacheSize; +} AudioCommonPoolSplit; // size = 0xC typedef struct { - /* 0x0 */ u32 wantSeq; - /* 0x4 */ u32 wantFont; - /* 0x8 */ u32 wantSample; - /* 0xC */ u32 wantCustom; -} AudioPoolSplit4; // size = 0x10 + /* 0x0 */ size_t miscPoolSize; + /* 0x4 */ u32 unkSizes[2]; + /* 0xC */ size_t cachePoolSize; +} AudioSessionPoolSplit; // size = 0x10 typedef struct { /* 0x00 */ u32 endAndMediumKey; @@ -813,10 +799,10 @@ typedef struct { /* 0x01 */ s8 delay; /* 0x02 */ s8 medium; /* 0x04 */ u8* ramAddr; - /* 0x08 */ u32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; - /* 0x10 */ u32 bytesRemaining; - /* 0x14 */ u32 chunkSize; + /* 0x10 */ size_t bytesRemaining; + /* 0x14 */ size_t chunkSize; /* 0x18 */ s32 unkMediumParam; /* 0x1C */ u32 retMsg; /* 0x20 */ OSMesgQueue* retQueue; @@ -830,12 +816,12 @@ typedef struct { /* 0x01 */ u8 seqOrFontId; /* 0x02 */ u16 instId; /* 0x04 */ s32 unkMediumParam; - /* 0x08 */ s32 curDevAddr; + /* 0x08 */ uintptr_t curDevAddr; /* 0x0C */ u8* curRamAddr; /* 0x10 */ u8* ramAddr; /* 0x14 */ s32 status; - /* 0x18 */ s32 bytesRemaining; - /* 0x1C */ s8* isDone; + /* 0x18 */ size_t bytesRemaining; + /* 0x1C */ s8* isDone; // TODO: rename in OoT and sync up here. This is an external status while (s32 status) is an internal status /* 0x20 */ SoundFontSample sample; /* 0x30 */ OSMesgQueue msgqueue; /* 0x48 */ OSMesg msg; @@ -843,8 +829,8 @@ typedef struct { } AudioSlowLoad; // size = 0x64 typedef struct { - /* 0x00 */ u32 romAddr; - /* 0x04 */ u32 size; + /* 0x00 */ uintptr_t romAddr; + /* 0x04 */ size_t size; /* 0x08 */ s8 medium; /* 0x09 */ s8 cachePolicy; /* 0x0A */ s16 shortData1; @@ -855,7 +841,7 @@ typedef struct { typedef struct { /* 0x00 */ s16 numEntries; /* 0x02 */ s16 unkMediumParam; - /* 0x04 */ u32 romAddr; + /* 0x04 */ uintptr_t romAddr; /* 0x08 */ char pad[0x8]; /* 0x10 */ AudioTableEntry entries[1]; // (dynamic size) } AudioTable; // size >= 0x20 @@ -869,18 +855,18 @@ typedef struct { typedef struct { /* 0x00 */ u8* ramAddr; - /* 0x04 */ u32 devAddr; + /* 0x04 */ uintptr_t devAddr; /* 0x08 */ u16 sizeUnused; /* 0x0A */ u16 size; /* 0x0C */ u8 unused; /* 0x0D */ u8 reuseIndex; // position in sSampleDmaReuseQueue1/2, if ttl == 0 - /* 0x0E */ u8 ttl; // duration after which the DMA can be discarded + /* 0x0E */ u8 ttl; // Time To Live: duration after which the DMA can be discarded } SampleDma; // size = 0x10 typedef struct { /* 0x0000 */ char unk_0000; /* 0x0001 */ s8 numSynthesisReverbs; - /* 0x0002 */ u16 unk_2; + /* 0x0002 */ u16 unk_2; // reads from audio spec unk_14, never used, always set to 0x7FFF /* 0x0004 */ u16 unk_4; /* 0x0006 */ char unk_0006[0xA]; /* 0x0010 */ s16* curLoadedBook; @@ -912,13 +898,13 @@ typedef struct { /* 0x263C */ SampleDma* sampleDmas; /* 0x2640 */ u32 sampleDmaCount; /* 0x2644 */ u32 sampleDmaListSize1; - /* 0x2648 */ s32 unused2628; + /* 0x2648 */ s32 unused2648; /* 0x264C */ u8 sampleDmaReuseQueue1[0x100]; // read pos <= write pos, wrapping mod 256 /* 0x274C */ u8 sampleDmaReuseQueue2[0x100]; - /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; - /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; - /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; - /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; + /* 0x284C */ u8 sampleDmaReuseQueue1RdPos; // Read position for dma 1 + /* 0x284D */ u8 sampleDmaReuseQueue2RdPos; // Read position for dma 2 + /* 0x284E */ u8 sampleDmaReuseQueue1WrPos; // Write position for dma 1 + /* 0x284F */ u8 sampleDmaReuseQueue2WrPos; // Write position for dma 2 /* 0x2850 */ AudioTable* sequenceTable; /* 0x2854 */ AudioTable* soundFontTable; /* 0x2858 */ AudioTable* sampleBankTable; @@ -936,52 +922,52 @@ typedef struct { /* 0x28B8 */ s32 numNotes; /* 0x2898 */ s16 tempoInternalToExternal; /* 0x28BE */ s8 soundMode; - /* 0x28C0 */ s32 totalTaskCnt; + /* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset /* 0x28C4 */ s32 curAudioFrameDmaCount; - /* 0x28C8 */ s32 rspTaskIdx; - /* 0x28CC */ s32 curAIBufIdx; - /* 0x28AC */ Acmd* abiCmdBufs[2]; + /* 0x28C8 */ s32 rspTaskIndex; + /* 0x28CC */ s32 curAiBuffferIndex; + /* 0x28AC */ Acmd* abiCmdBufs[2]; // Pointer to audio heap where the audio binary interface command lists are stored. Two lists that alternative every frame /* 0x28B4 */ Acmd* curAbiCmdBuf; - /* 0x28DC */ AudioTask* currTask; + /* 0x28DC */ AudioTask* curTask; /* 0x28C0 */ AudioTask rspTask[2]; /* 0x2980 */ f32 unk_2960; /* 0x2984*/ s32 refreshRate; - /* 0x2988 */ s16* aiBuffers[3]; - /* 0x2994 */ s16 aiBufLengths[3]; + /* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI) + /* 0x2994 */ s16 aiBufLengths[3]; // Number of bytes to transfer to the audio interface buffer /* 0x299C */ u32 audioRandom; /* 0x29A0 */ s32 audioErrorFlags; /* 0x29A4 */ volatile u32 resetTimer; /* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel); /* 0x29B8 */ s8 unk_29B8; /* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt - /* 0x29C0 */ AudioAllocPool audioSessionPool; - /* 0x29D0 */ AudioAllocPool externalPool; - /* 0x29E0 */ AudioAllocPool audioInitPool; - /* 0x29F0 */ AudioAllocPool notesAndBuffersPool; + /* 0x29C0 */ AudioAllocPool audioSessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset + /* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game + /* 0x29E0 */ AudioAllocPool audioInitPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset + /* 0x29F0 */ AudioAllocPool miscPool; // A sub-pool to the session pool, /* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools - /* 0x2A20 */ AudioAllocPool cachePool; - /* 0x2A30 */ AudioAllocPool persistentCommonPool; - /* 0x2A40 */ AudioAllocPool temporaryCommonPool; - /* 0x2A50 */ AudioCache seqCache; - /* 0x2B60 */ AudioCache fontCache; - /* 0x2C70 */ AudioCache sampleBankCache; - /* 0x2D80 */ AudioAllocPool permanentPool; - /* 0x2D90 */ AudioCacheEntry permanentCache[32]; - /* 0x3690 */ AudioSampleCache persistentSampleCache; - /* 0x40A4 */ AudioSampleCache temporarySampleCache; - /* 0x4338 */ AudioPoolSplit4 sessionPoolSplit; - /* 0x4348 */ AudioPoolSplit2 cachePoolSplit; - /* 0x4350 */ AudioPoolSplit3 persistentCommonPoolSplit; - /* 0x435C */ AudioPoolSplit3 temporaryCommonPoolSplit; + /* 0x2A20 */ AudioAllocPool cachePool; // The common pool for all cache entries + /* 0x2A30 */ AudioAllocPool persistentCommonPool; // A sub-pool to the cache pool, contains all caches for data stored persistently + /* 0x2A40 */ AudioAllocPool temporaryCommonPool; // A sub-pool to the cache pool, contains all caches for data stored temporarily + /* 0x2A50 */ AudioCache seqCache; // Cache to store sequences + /* 0x2B60 */ AudioCache fontCache; // Cache to store soundFonts + /* 0x2C70 */ AudioCache sampleBankCache; // Cache for loading entire sample banks + /* 0x2D80 */ AudioAllocPool permanentPool; // Pool to stores audio data that is always loaded in. Primarily used for sfxs + /* 0x2D90 */ AudioCacheEntry permanentEntries[32]; // indificual entries to the permanent pool + /* 0x3690 */ AudioSampleCache persistentSampleCache; // Stores individual samples persistently + /* 0x40A4 */ AudioSampleCache temporarySampleCache; // Stores individual samples temporarily + /* 0x4338 */ AudioSessionPoolSplit sessionPoolSplit; // splits session pool into the cache pool and misc pool + /* 0x4348 */ AudioCachePoolSplit cachePoolSplit; // splits cache pool into the persistent & temporary common pools + /* 0x4350 */ AudioCommonPoolSplit persistentCommonPoolSplit; // splits persistent common pool into caches for sequences, soundFonts, sample banks + /* 0x435C */ AudioCommonPoolSplit temporaryCommonPoolSplit; // splits temporary common pool into caches for sequences, soundFonts, sample banks /* 0x4368 */ u8 sampleFontLoadStatus[0x30]; /* 0x4398 */ u8 fontLoadStatus[0x30]; /* 0x43C8 */ u8 seqLoadStatus[0x80]; /* 0x4448 */ volatile u8 resetStatus; /* 0x4449 */ u8 audioResetSpecIdToLoad; /* 0x444C */ s32 audioResetFadeOutFramesLeft; - /* 0x4450 */ f32* unk_3520; + /* 0x4450 */ f32* unk_3520; // fadeOutVelocities for ADSR /* 0x4454 */ u8* audioHeap; - /* 0x4458 */ u32 audioHeapSize; + /* 0x4458 */ size_t audioHeapSize; /* 0x445C */ Note* notes; /* 0x4460 */ SequencePlayer seqPlayers[5]; /* 0x4B40 */ SequenceLayer sequenceLayers[80]; @@ -989,11 +975,10 @@ typedef struct { /* 0x7924 */ s32 noteSubEuOffset; /* 0x7928 */ AudioListItem layerFreeList; /* 0x7938 */ NotePool noteFreeLists; - /* 0x7978 */ u8 cmdWrPos; - /* 0x7979 */ u8 cmdRdPos; + /* 0x7978 */ u8 cmdWritePos; + /* 0x7979 */ u8 cmdReadPos; /* 0x797A */ u8 cmdQueueFinished; - /* 0x797C */ u16 unk_5BDC[4]; - /* 0x7984 */ char unk_7984[4]; + /* 0x797C */ u16 activeChannelsFlags[5]; // bitwise flag for 16 channels. Only channels with bit turned on will be processed /* 0x7988 */ OSMesgQueue* audioResetQueueP; /* 0x798C */ OSMesgQueue* taskStartQueueP; /* 0x7990 */ OSMesgQueue* cmdProcQueueP; @@ -1003,7 +988,7 @@ typedef struct { /* 0x79DC */ OSMesg taskStartMsgs[1]; /* 0x79E0 */ OSMesg audioResetMesgs[1]; /* 0x79E4 */ OSMesg cmdProcMsgs[4]; - /* 0x79F4 */ AudioCmd cmdBuf[0x100]; + /* 0x79F4 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread /* 0x81F4 */ char unk_81F4[4]; } AudioContext; // size = 0x81F8 @@ -1022,9 +1007,9 @@ typedef struct { } NoteSubAttributes; // size = 0x1A typedef struct { - /* 0x0 */ u32 heapSize; - /* 0x4 */ u32 initPoolSize; - /* 0x8 */ u32 permanentPoolSize; + /* 0x0 */ size_t heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` (ideally about the same size) + /* 0x4 */ size_t mainPoolSplitSize; // The entire audio heap is split into two pools. + /* 0x8 */ size_t permanentPoolSize; } AudioContextInitSizes; // size = 0xC typedef struct { @@ -1155,31 +1140,4 @@ typedef struct { /* 0x10 */ f32* vol; } SoundRequest; // size = 0x14 -/** - * Note: - * Flag for resolving C_RIGHT and C_LEFT only being two semitones apart - * 0x40 - BTN_Z is pressed to lower note by a semitone - * 0x80 - BTN_R is pressed to raise note by a semitone - */ - -typedef struct { - /* 0x0 */ u8 noteIdx; - /* 0x2 */ u16 length; // number of frames the note is sustained - /* 0x4 */ u8 volume; - /* 0x5 */ u8 vibrato; - /* 0x6 */ s8 bend; - /* 0x7 */ u8 BFlat4Flag; // BFlat4Flag See note above -} OcarinaNote; // size = 0x8 - -typedef struct { - /* 0x0 */ u8 numButtons; - /* 0x1 */ u8 buttonIdx[8]; -} OcarinaSongButtons; // size = 0x9 - -typedef struct { - /* 0x0 */ u8 buttonIdx; - /* 0x1 */ u8 state; - /* 0x2 */ u8 pos; -} OcarinaStaff; // size = 0x3 - #endif diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 55429a433..0a5afb3d9 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -89,10 +89,10 @@ typedef struct CollisionPoly { } CollisionPoly; // size = 0x10 typedef struct { - /* 0x00 */ u16 cameraSType; - /* 0x02 */ s16 unk_02; - /* 0x04 */ Vec3s* camPosData; -} CamData; + /* 0x0 */ u16 setting; + /* 0x2 */ s16 numData; + /* 0x4 */ Vec3s* data; +} CamData; // size = 0x8 (BgCamData) typedef struct { /* 0x0 */ Vec3s minPos; diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 0f2a6e678..84150a527 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -1,5 +1,5 @@ -#ifndef _Z64CUTSCENE_H_ -#define _Z64CUTSCENE_H_ +#ifndef Z64CUTSCENE_H +#define Z64CUTSCENE_H #include "ultra64.h" #include "unk.h" @@ -26,21 +26,24 @@ typedef struct { } CutsceneCameraMove; // size = 0xC typedef struct { - /* 0x00 */ u16 unk0; // action; // "dousa" + /* 0x00 */ u16 action; // "dousa" /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; - /* 0x06 */ u16 unk6; - /* 0x08 */ u16 unk8; - /* 0x0C */ Vec3i unk0C; - /* 0x18 */ Vec3i unk18; - /* 0x24 */ UNK_TYPE1 unk24[0xC]; + union { + /* 0x06 */ Vec3s rot; + /* 0x06 */ Vec3us urot; + }; + /* 0x0C */ Vec3i startPos; + /* 0x18 */ Vec3i endPos; + /* 0x24 */ Vec3f normal; } CsCmdActorAction; // size = 0x30 typedef struct { /* 0x0 */ u16 base; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdBase; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdBase; // size = 0x8 typedef struct { /* 0x0 */ u16 unk0; @@ -48,25 +51,30 @@ typedef struct { /* 0x4 */ u16 endFrame; /* 0x6 */ u8 hour; /* 0x7 */ u8 minute; -} CsCmdDayTime; // size = 0x8 + /* 0x8 */ UNK_TYPE1 unk_08[0x04]; +} CsCmdDayTime; // size = 0xC typedef struct { /* 0x0 */ u16 setting; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdEnvLighting; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdEnvLighting; // size = 0x8 typedef struct { /* 0x0 */ u16 sequence; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdMusicChange; // size = 0x6 + /* 0x6 */ u16 unk_06; +} CsCmdSequenceChange; // size = 0x8 typedef struct { /* 0x0 */ u16 type; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; -} CsCmdMusicFade; // size = 0x6 + /* 0x6 */ u16 unk_06; + /* 0x8 */ u32 unk_08; +} CsCmdSequenceFade; // size = 0xC typedef struct { /* 0x0 */ u16 base; @@ -77,30 +85,77 @@ typedef struct { /* 0xA */ u16 textId2; } CsCmdTextbox; // size = 0xC +typedef enum { + /* 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, + /* 0xFFFF */ CS_TEXTBOX_TYPE_NONE = 0xFFFF +} CutsceneTextboxType; + typedef struct { - /* 0x0 */ u16 unk0; + /* 0x0 */ u16 type; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; /* 0x6 */ u8 unk6; /* 0x7 */ u8 unk7; /* 0x8 */ u8 unk8; /* 0x9 */ UNK_TYPE1 pad9[0x3]; -} CsCmdUnk190; // size = 0xC - -typedef struct { - /* 0x0 */ UNK_TYPE4 unk0; - /* 0x4 */ UNK_TYPE4 unk4; -} CsCmdUnk5A; // size = 0x8 +} CsCmdRumble; // size = 0xC typedef struct { /* 0x0 */ u16 unk0; /* 0x2 */ u16 startFrame; /* 0x4 */ u16 endFrame; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; - /* 0x8 */ u8 unk8; + /* 0x6 */ Color_RGB8 color; /* 0x9 */ UNK_TYPE1 pad9[0x3]; -} CsCmdUnk9B; // size = 0xC +} CsCmdFadeScreen; // size = 0xC + +typedef enum { + /* 0 */ CS_STATE_0, + /* 1 */ CS_STATE_1, + /* 2 */ CS_STATE_2, + /* 3 */ CS_STATE_3, + /* 4 */ CS_STATE_4 +} CutsceneState; + +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_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131, + /* 0x132 */ CS_CMD_132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190 +} CutsceneCmd; typedef union CutsceneData { s32 i; @@ -109,4 +164,29 @@ typedef union CutsceneData { s8 b[4]; } CutsceneData; +typedef struct { + /* 0x0 */ CutsceneData* segmentedData; + /* 0x4 */ s16 nextEntranceIndex; + /* 0x6 */ u8 unk6; + /* 0x7 */ u8 unk7; // a weekEventReg bitpack? +} CutsceneEntry; // size = 0x8 + +typedef struct { + /* 0x00 */ u8 sceneCsCount; + /* 0x04 */ CutsceneData* csData; + /* 0x08 */ u8 state; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ u16 frames; + /* 0x12 */ u16 currentCsIndex; + /* 0x14 */ s32 csCamId; + /* 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; +} CutsceneContext; // size = 0x54 + #endif diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index 99000eec2..b487b49b1 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -1,5 +1,5 @@ -#ifndef _Z64CUTSCENE_COMMANDS_H_ -#define _Z64CUTSCENE_COMMANDS_H_ +#ifndef Z64CUTSCENE_COMMANDS_H +#define Z64CUTSCENE_COMMANDS_H #include "command_macros_base.h" #include "z64cutscene.h" @@ -11,11 +11,571 @@ * eeeeeeee nnnnnnnn * size = 0x8 */ -#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) CMD_W(totalEntries), CMD_W(endFrame) +#define CS_BEGIN_CUTSCENE(totalEntries, endFrame) { CMD_W(totalEntries) }, { CMD_W(endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000000A eeeeeeee + * size = 0x8 + */ +#define CS_TEXT_LIST(entries) { CS_CMD_TEXTBOX }, { CMD_W(entries) } + +/** + * ARGS + * s16 messageId (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) } + +/** + * ARGS + * s16 messageId (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) + +/** + * ARGS + * s16 messageId (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) + +/** + * ARGS + * s16 ocarinaSongAction (o), s16 startFrame (s), s16 endFrame (e), s16 messageId (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) + +/** + * ARGS + * s16 messageId (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) + +/** + * If Player has all 4 bosses' remains then alternativeMessageId is used, otherwise defaultMessageId is used + * ARGS + * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (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) + +/** + * If Player has every non-transformation mask then alternativeMessageId is used, otherwise defaultMessageId is used + * ARGS + * s16 defaultMessageId (d), s16 startFrame (s), s16 endFrame (e), s16 alternativeMessageId (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) + +/** + * ARGS + * s16 startFrame (s), s16 endFrame (e) + * FORMAT + * FFFFssss eeeeFFFF FFFFFFFF + * size = 0xC + */ +#define CS_TEXT_NONE(startFrame, endFrame) \ + CS_TEXT_DISPLAY_TEXTBOX(0xFFFF, startFrame, endFrame, CS_TEXTBOX_TYPE_NONE, 0xFFFF, 0xFFFF) + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000005A eeeeeeee + * size = 0x8 + */ +#define CS_CAMERA_LIST(entries) { CS_CMD_CAMERA }, { CMD_W(entries) } + +// TODO: Camera command macros. Requieres func_80161998 being decomped + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000096 eeeeeeee + * size = 0x8 + */ +#define CS_MISC_LIST(entries) { CS_CMD_MISC }, { CMD_W(entries) } + +/** + * ARGS + * s16 unk (u), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * uuuussss eeeeUUUU + * size = 0x08 + */ +#define CS_MISC(unk, startFrame, endFrame, unk_06) \ + { CMD_HH(unk, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000097 eeeeeeee + * size = 0x8 + */ +#define CS_LIGHTING_LIST(entries) { CS_CMD_SET_LIGHTING }, { CMD_W(entries) } + +/** + * ARGS + * s16 setting (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_LIGHTING(setting, startFrame, endFrame) \ + { CMD_HH(setting, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000098 eeeeeeee + * size = 0x8 + */ +#define CS_SCENE_TRANS_FX_LIST(entries) { CS_CMD_SCENE_TRANS_FX }, { CMD_W(entries) } + +/** + * ARGS + * s16 transitionType (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_SCENE_TRANS_FX(transitionType, startFrame, endFrame) \ + { CMD_HH(transitionType, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000099 eeeeeeee + * size = 0x08 + */ +#define CS_MOTIONBLUR_LIST(entries) { CS_CMD_MOTIONBLUR }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_MOTIONBLUR(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009A eeeeeeee + * size = 0x8 + */ +#define CS_GIVETATL_LIST(entries) { CS_CMD_GIVETATL }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_GIVETATL(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009B eeeeeeee + * size = 0x8 + */ +#define CS_FADESCREEN_LIST(entries) { CS_CMD_FADESCREEN }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e), + * u8 red (r), u8 green (g), blue (b) + * FORMAT + * Capital U is Unused + * mmmmssss 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) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000009D eeeeeeee + * size = 0x8 + */ +#define CS_TIME_LIST(entries) { CS_CMD_SETTIME }, { CMD_W(entries) } + +/** + * ARGS + * s16 unk (u), s16 startFrame (s), s16 endFrame (e), s8 hour (h), s8 min (m) + * FORMAT + * Capital U is Unused + * 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) } + + +/** + * 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) } + +/** + * ARGS + * s16 npcAction (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), + * f32 normX (x), f32 normY (y), f32 normZ (z), + * FORMAT + * 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) }, \ + { 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) } + + +/** + * 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) } + +/** + * ARGS + * s16 playerAction (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), + * f32 normX (x), f32 normY (y), f32 normZ (z), + * FORMAT + * 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) + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000012C eeeeeeee + * size = 0x8 + */ +#define CS_PLAYSEQ_LIST(entries) { CS_CMD_PLAYSEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), 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 + * 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) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000133 eeeeeeee + * size = 0x8 + */ +#define CS_STOPSEQ_LIST(entries) { CS_CMD_STOPSEQ }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_STOPSEQ(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000134 eeeeeeee + * size = 0x8 + */ +#define CS_PLAYAMBIENCE_LIST(entries) { CS_CMD_PLAYAMBIENCE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_PLAYAMBIENCE(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000135 eeeeeeee + * size = 0x8 + */ +#define CS_FADEAMBIENCE_LIST(entries) { CS_CMD_FADEAMBIENCE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_FADEAMBIENCE(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000015E eeeeeeee + * size = 0x8 + */ +#define CS_TERMINATOR_LIST(entries) { CS_CMD_TERMINATOR }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_TERMINATOR(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 0000015F eeeeeeee + * size = 0x8 + */ +#define CS_CHOOSE_CREDITS_SCENES_LIST(entries) { CS_CMD_CHOOSE_CREDITS_SCENES }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_CHOOSE_CREDITS_SCENES(base, startFrame, endFrame) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, endFrame) } + + +/** + * ARGS + * s32 entries (e) + * FORMAT + * 00000004 eeeeeeee + * size = 0x8 + */ +#define CS_RUMBLE_LIST(entries) { CS_CMD_RUMBLE }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_RUMBLE(base, startFrame, endFrame, unk6, unk7, unk8) \ + { CMD_HH(base, startFrame) }, { CMD_HBB(endFrame, unk6, unk7) }, { CMD_BBBB(unk8, 0, 0, 0) } + + +/** + * ARGS + * s32 cmd (c), s32 entries (e) + * FORMAT + * cccccccc eeeeeeee + * size = 0x8 + */ +#define CS_UNK_DATA_LIST(cmd, entries) { CMD_W(cmd) }, { CMD_W(entries) } + +/** + * ARGS + * s16 base (m), s16 startFrame (s), s16 endFrame (e) + * FORMAT + * Capital U is Unused + * mmmmssss eeeeUUUU + * size = 0x08 + */ +#define CS_UNK_DATA(base, startFrame, endFrame, unk_06) \ + { CMD_HH(base, startFrame) }, { CMD_HH(endFrame, unk_06) } + /** * Marks the end of a cutscene */ -#define CS_END() 0xFFFFFFFF +#define CS_END() { CMD_W(0xFFFFFFFF) } #endif diff --git a/include/z64item.h b/include/z64item.h index c8d7b0d1e..f8b2cbf92 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -32,7 +32,7 @@ typedef enum { /* 0x05 */ QUEST_SWORD, /* 0x06 */ QUEST_SONG_SONATA, /* 0x07 */ QUEST_SONG_LULLABY, - /* 0x08 */ QUEST_SONG_NOVA, + /* 0x08 */ QUEST_SONG_BOSSA_NOVA, /* 0x09 */ QUEST_SONG_ELEGY, /* 0x0A */ QUEST_SONG_OATH, /* 0x0B */ QUEST_SONG_SARIA, @@ -265,6 +265,7 @@ typedef enum { /* 0xA1 */ ITEM_GOLD_DUST_2, /* 0xA2 */ ITEM_HYLIAN_LOACH_2, /* 0xA3 */ ITEM_SEA_HORSE_CAUGHT, + /* 0xFD */ ITEM_UNK_FD = 0xFD, /* 0xFF */ ITEM_NONE = 0xFF } ItemID; @@ -303,6 +304,7 @@ typedef enum { /* 0x3C */ GI_KEY_SMALL = 0x3C, /* 0x3E */ GI_MAP = 0x3E, /* 0x3F */ GI_COMPASS, + /* 0x50 */ GI_50 = 0x50, /* 0x52 */ GI_SCALE_GOLD = 0x52, // Assumed, used in En_Fishing /* 0x59 */ GI_BOTTLE_POTION_RED = 0x59, /* 0x5B */ GI_POTION_RED = 0x5B, @@ -335,7 +337,8 @@ typedef enum { /* 0x8E */ GI_MASK_SCENTS, /* 0x8F */ GI_MASK_GIANT, /* 0x92 */ GI_MILK = 0x92, - /* 0x96 */ GI_MOON_TEAR = 0x96, + /* 0x95 */ GI_95 = 0x95, + /* 0x96 */ GI_MOON_TEAR, /* 0x97 */ GI_DEED_LAND, /* 0x98 */ GI_DEED_SWAMP, /* 0x99 */ GI_DEED_MOUNTAIN, @@ -353,7 +356,11 @@ typedef enum { typedef enum { /* 0x00 */ GID_BOTTLE, + /* 0x02 */ GID_02 = 0x02, + /* 0x03 */ GID_03, /* 0x0A */ GID_COMPASS = 0x0A, + /* 0x0E */ GID_0E = 0x0E, + /* 0x0F */ GID_0F, /* 0x10 */ GID_MASK_ALL_NIGHT = 0x10, /* 0x11 */ GID_NUTS, /* 0x17 */ GID_BOMB_BAG_20 = 0x17, @@ -371,17 +378,26 @@ typedef enum { /* 0x31 */ GID_POTION_RED, /* 0x32 */ GID_POTION_BLUE, /* 0x33 */ GID_SHIELD_MIRROR, - /* 0x3B */ GID_FAIRY = 0x3B, + /* 0x3A */ GID_3A = 0x3A, + /* 0x3B */ GID_FAIRY, + /* 0x3E */ GID_3E = 0x3E, + /* 0x44 */ GID_44 = 0x44, + /* 0x45 */ GID_45, /* 0x55 */ GID_SWORD_KOKIRI = 0x55, /* 0x66 */ GID_SWORD_RAZOR = 0x66, /* 0x67 */ GID_SWORD_GILDED, - /* 0x68 */ GID_SWORD_GREAT_FAIRY + /* 0x68 */ GID_SWORD_GREAT_FAIRY, + /* 0x6A */ GID_6A = 0x6A, + /* 0x6B */ GID_6B, + /* 0x70 */ GID_70 = 0x70, + /* 0x71 */ GID_71 } GetItemDrawID; // TODO: fill typedef enum { /* -1 */ EXCH_ITEM_MINUS1 = -1, // Unknown usage or function /* 0x00 */ EXCH_ITEM_NONE, + /* 0x13 */ EXCH_ITEM_13 = 0x13, /* 0x1E */ EXCH_ITEM_1E = 0x1E, // BOTTLE_MUSHROOM /* 0x2A */ EXCH_ITEM_2A = 0x2A, // MOON_TEAR? /* 0x2E */ EXCH_ITEM_2E = 0x2E diff --git a/include/z64light.h b/include/z64light.h index 90ee01fb0..0c90be713 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -23,7 +23,7 @@ typedef struct { /* 0x12 */ s16 fogColor[3]; /* 0x18 */ s16 fogNear; /* 0x1A */ s16 fogFar; -} LightSettings2; // size = 0x1C +} EnvLightSettings; // size = 0x1C typedef struct { /* 0x0 */ s16 x; @@ -57,18 +57,12 @@ typedef struct Lights { /* 0x08 */ Lightsn l; } Lights; // size = 0x80 -typedef struct LightInfoPositional { - /* 0x0 */ u8 type; - /* 0x2 */ LightPoint params; -} LightInfoPositional; // size = 0xE - typedef struct LightNode { /* 0x0 */ LightInfo* info; /* 0x4 */ struct LightNode* prev; /* 0x8 */ struct LightNode* next; } LightNode; // size = 0xC -// TODO move LightsBuffer to .c file once .bss has been split #define LIGHTS_BUFFER_SIZE 32 typedef struct LightsBuffer { diff --git a/include/z64math.h b/include/z64math.h index dff669976..de0285e6c 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -5,9 +5,14 @@ #define VEC_SET(V,X,Y,Z) V.x=X;V.y=Y;V.z=Z +typedef struct { + /* 0x00 */ s16 x; + /* 0x02 */ s16 z; +} Vec2s; // size = 0x04 + typedef struct { /* 0x00 */ f32 x; - /* 0x04 */ f32 y; + /* 0x04 */ f32 z; } Vec2f; // size = 0x08 typedef struct { diff --git a/include/z64ocarina.h b/include/z64ocarina.h new file mode 100644 index 000000000..56ab48312 --- /dev/null +++ b/include/z64ocarina.h @@ -0,0 +1,125 @@ +#ifndef Z64OCARINA_H +#define Z64OCARINA_H + +#include "ultra64.h" + +typedef enum { + /* 0 */ OCARINA_SONG_SONATA, + /* 1 */ OCARINA_SONG_GORON_LULLABY, + /* 2 */ OCARINA_SONG_NEW_WAVE, + /* 3 */ OCARINA_SONG_ELEGY, + /* 4 */ OCARINA_SONG_OATH, + /* 5 */ OCARINA_SONG_SARIAS, + /* 6 */ OCARINA_SONG_TIME, + /* 7 */ OCARINA_SONG_HEALING, + /* 8 */ OCARINA_SONG_EPONAS, + /* 9 */ OCARINA_SONG_SOARING, + /* 10 */ OCARINA_SONG_STORMS, + /* 11 */ OCARINA_SONG_SUNS, + /* 12 */ OCARINA_SONG_INVERTED_TIME, + /* 13 */ OCARINA_SONG_DOUBLE_TIME, + /* 14 */ OCARINA_SONG_GORON_LULLABY_INTRO, + /* 15 */ OCARINA_SONG_WIND_FISH_HUMAN, // "Ballad of the Wind Fish" + /* 16 */ OCARINA_SONG_WIND_FISH_GORON, + /* 17 */ OCARINA_SONG_WIND_FISH_ZORA, + /* 18 */ OCARINA_SONG_WIND_FISH_DEKU, + /* 19 */ OCARINA_SONG_EVAN_PART1, + /* 20 */ OCARINA_SONG_EVAN_PART2, + /* 21 */ OCARINA_SONG_ZELDAS_LULLABY, + /* 22 */ OCARINA_SONG_SCARECROW, + /* 23 */ OCARINA_SONG_TERMINA_WALL, + /* 24 */ OCARINA_SONG_MAX, + /* 24 */ OCARINA_SONG_SCARECROW_LONG = OCARINA_SONG_MAX +} OcarinaSongId; + +typedef enum { + /* 0 */ OCARINA_BTN_A, + /* 1 */ OCARINA_BTN_C_DOWN, + /* 2 */ OCARINA_BTN_C_RIGHT, + /* 3 */ OCARINA_BTN_C_LEFT, + /* 4 */ OCARINA_BTN_C_UP, + /* -1 */ OCARINA_BTN_INVALID = 0xFF +} OcarinaButtonIndex; + +// Uses scientific pitch notation relative to middle C +// https://en.wikipedia.org/wiki/Scientific_pitch_notation +typedef enum { + /* 0x0 */ OCARINA_PITCH_C4, + /* 0x1 */ OCARINA_PITCH_DFLAT4, + /* 0x2 */ OCARINA_PITCH_D4, + /* 0x3 */ OCARINA_PITCH_EFLAT4, + /* 0x4 */ OCARINA_PITCH_E4, + /* 0x5 */ OCARINA_PITCH_F4, + /* 0x6 */ OCARINA_PITCH_GFLAT4, + /* 0x7 */ OCARINA_PITCH_G4, + /* 0x8 */ OCARINA_PITCH_AFLAT4, + /* 0x9 */ OCARINA_PITCH_A4, + /* 0xA */ OCARINA_PITCH_BFLAT4, + /* 0xB */ OCARINA_PITCH_B4, + /* 0xC */ OCARINA_PITCH_C5, + /* 0xD */ OCARINA_PITCH_DFLAT5, + /* 0xE */ OCARINA_PITCH_D5, + /* 0xF */ OCARINA_PITCH_EFLAT5, + /* -1 */ OCARINA_PITCH_NONE = 0xFF +} OcarinaPitch; + +// Mainly set by func_80152CAC in z_message.c +typedef enum { + /* 0 */ OCARINA_INSTRUMENT_OFF, + /* 1 */ OCARINA_INSTRUMENT_DEFAULT, + /* 2 */ OCARINA_INSTRUMENT_FEMALE_VOICE, + /* 3 */ OCARINA_INSTRUMENT_WHISTLING_FLUTE, + /* 4 */ OCARINA_INSTRUMENT_HARP, + /* 5 */ OCARINA_INSTRUMENT_IKANA_KING, + /* 6 */ OCARINA_INSTRUMENT_TATL, + /* 7 */ OCARINA_INSTRUMENT_GORON_DRUMS, + /* 8 */ OCARINA_INSTRUMENT_ZORA_GUITAR, + /* 9 */ OCARINA_INSTRUMENT_DEKU_PIPES, + /* 10 */ OCARINA_INSTRUMENT_MONKEY, + /* 11 */ OCARINA_INSTRUMENT_DEKU_TRUMPET, // Pull out ocarina for captured monkey + /* 12 */ OCARINA_INSTRUMENT_ELDER_GORON_DRUMS, + /* 13 */ OCARINA_INSTRUMENT_PIANO, + /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, + /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR // Related to (gSaveContext.weekEventReg[41] & 0x20) +} OcarinaInstrumentId; + +typedef enum { + /* 0 */ OCARINA_RECORD_OFF, + /* 1 */ OCARINA_RECORD_SCARECROW_LONG, + /* 2 */ OCARINA_RECORD_SCARECROW_SPAWN, + /* -1 */ OCARINA_RECORD_REJECTED = 0xFF +} OcarinaRecordingState; + +/** + * BFlat4Flag Note: + * Flag for resolving whether (pitch = OCARINA_PITCH_BFLAT4) + * gets mapped to either C_RIGHT and C_LEFT + * + * This is required as C_RIGHT and C_LEFT are the only notes + * that map to two semitones apart (NOTE_A4 and NOTE_B4) + * 0x40 - BTN_Z is pressed to lower note by a semitone + * 0x80 - BTN_R is pressed to raise note by a semitone + */ + +typedef struct { + /* 0x0 */ u8 pitch; // number of semitones above middle C + /* 0x2 */ u16 length; // number of frames the note is sustained + /* 0x4 */ u8 volume; + /* 0x5 */ u8 vibrato; + /* 0x6 */ s8 bend; // frequency multiplicative offset from the pitch defined by pitch + /* 0x7 */ u8 BFlat4Flag; // See note above +} OcarinaNote; // size = 0x8 + +typedef struct { + /* 0x0 */ u8 numButtons; + /* 0x1 */ u8 buttonIndex[8]; +} OcarinaSongButtons; // size = 0x9 + +typedef struct { + /* 0x0 */ u8 buttonIndex; + /* 0x1 */ u8 state; // original name: "status" + /* 0x2 */ u8 pos; // original name: "locate" +} OcarinaStaff; // size = 0x3 + +#endif diff --git a/include/z64save.h b/include/z64save.h index 61d217544..32822a8b3 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1,111 +1,140 @@ -#ifndef _Z64SAVE_H_ -#define _Z64SAVE_H_ +#ifndef Z64SAVE_H +#define Z64SAVE_H #include "ultra64.h" #include "z64math.h" #include "os.h" -#define DAY_SPEED_INVERTED -2 +struct GameState; +struct GlobalContext; +struct FileChooseContext; -typedef struct { - /* 0x00 */ u8 buttonItems[4][4]; - /* 0x10 */ u8 cButtonSlots[4][4]; +// TODO: properly name DOWN, RETURN and TOP +typedef enum RespawnMode { + /* 0 */ RESTART_MODE_DOWN, // "RESTART_MODE_DOWN" + /* 1 */ RESTART_MODE_RETURN, // "RESTART_MODE_RETURN" + /* 2 */ RESTART_MODE_TOP, // "RESTART_MODE_TOP" + /* 3 */ RESPAWN_MODE_UNK_3, // Maybe related to grottos + /* 4 */ RESPAWN_MODE_GORON, // "RESTART_MODE_GORON" + /* 5 */ RESPAWN_MODE_ZORA, // "RESTART_MODE_ZORA" + /* 6 */ RESPAWN_MODE_DEKU, // "RESTART_MODE_NUTS" + /* 7 */ RESPAWN_MODE_HUMAN, // "RESTART_MODE_CHILD" + /* 8 */ RESPAWN_MODE_MAX +} RespawnMode; + +#define SAVE_BUFFER_SIZE 0x4000 + +typedef struct SramContext { + /* 0x00 */ u8* readBuff; + /* 0x04 */ u8 *saveBuf; + /* 0x08 */ char unk_08[4]; + /* 0x0C */ s16 status; + /* 0x10 */ u32 curPage; + /* 0x14 */ u32 numPages; + /* 0x18 */ OSTime unk_18; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; +} SramContext; // size = 0x28 + +typedef struct ItemEquips { + /* 0x00 */ u8 buttonItems[4][4]; // "register_item" + /* 0x10 */ u8 cButtonSlots[4][4]; // "register_item_pt" /* 0x20 */ u16 equipment; } ItemEquips; // size = 0x22 -typedef struct { - /* 0x00 */ u8 items[24]; - /* 0x18 */ u8 masks[24]; - /* 0x30 */ s8 ammo[24]; - /* 0x48 */ u32 upgrades; // some bits are wallet upgrades - /* 0x4C */ u32 questItems; - /* 0x50 */ u8 dungeonItems[10]; - /* 0x5A */ s8 dungeonKeys[10]; - /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" - /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // Stores playerName (8 char) over (3 days) when getting a new high score. original name: degnuts_memory_name +typedef struct Inventory { + /* 0x00 */ u8 items[48]; // "item_register", first 24 elements are normal items and the other 24 are masks + /* 0x30 */ s8 ammo[24]; // "item_count" + /* 0x48 */ u32 upgrades; // "non_equip_register" some bits are wallet upgrades + /* 0x4C */ u32 questItems; // "collect_register" + /* 0x50 */ u8 dungeonItems[10]; // "key_compass_map" + /* 0x5A */ s8 dungeonKeys[10]; // "key_register" + /* 0x64 */ s8 strayFairies[10]; // "orange_fairy" + /* 0x6E */ char dekuPlaygroundPlayerName[3][8]; // "degnuts_memory_name" Stores playerName (8 char) over (3 days) when getting a new high score } Inventory; // size = 0x88 -typedef struct { - /* 0x00 */ s16 scene; - /* 0x02 */ Vec3s pos; - /* 0x08 */ s16 angle; +typedef struct HorseData { + /* 0x00 */ s16 scene; // "spot_no" + /* 0x02 */ Vec3s pos; // "horse_x", "horse_y" and "horse_z" + /* 0x08 */ s16 yaw; // "horse_a" } HorseData; // size = 0x0A -typedef struct { +typedef struct RespawnData { /* 0x00 */ Vec3f pos; /* 0x0C */ s16 yaw; /* 0x0E */ s16 playerParams; /* 0x10 */ u16 entranceIndex; /* 0x12 */ u8 roomIndex; /* 0x13 */ s8 data; - /* 0x14 */ u32 tempSwchFlags; + /* 0x14 */ u32 tempSwitchFlags; /* 0x18 */ u32 unk_18; /* 0x1C */ u32 tempCollectFlags; } RespawnData; // size = 0x20 -typedef struct { +typedef struct PermanentSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; /* 0x14 */ u32 unk_14; /* 0x18 */ u32 unk_18; } PermanentSceneFlags; // size = 0x1C -typedef struct { - /* 0x00 */ u16 optionId; // original name: option_id - /* 0x02 */ u8 language; // original name: j_n - /* 0x03 */ s8 audioSetting; // original name: s_sound - /* 0x04 */ u8 languageSetting; // original name: language - /* 0x05 */ u8 zTargetSetting; // 0: Switch; 1: Hold -} SaveOptions; // size = 0x06 - -typedef struct { - /* 0x0000 */ char newf[6]; // "newf" Will always be "ZELDA3 for a valid save - /* 0x0006 */ u16 deaths; // "savect" - /* 0x0008 */ char playerName[8]; // "player_name" - /* 0x0010 */ s16 healthCapacity; // "max_life" - /* 0x0012 */ s16 health; // "now_life" - /* 0x0014 */ s8 magicLevel; // "magic_max" - /* 0x0015 */ s8 magic; // "magic_now" - /* 0x0016 */ s16 rupees; // "lupy_count" - /* 0x0018 */ u16 swordHealth; // "long_sword_hp" - /* 0x001A */ u16 tatlTimer; // "navi_timer" - /* 0x001C */ u8 magicAcquired; // "magic_mode" - /* 0x001D */ u8 doubleMagic; // "magic_ability" - /* 0x001E */ u8 doubleDefense; // "life_ability" - /* 0x001F */ u8 unk_1F; // "ocarina_round" - /* 0x0020 */ u8 unk_20; // "first_memory" - /* 0x0022 */ u16 owlActivationFlags; // "memory_warp_point" - /* 0x0024 */ u8 unk_24; // "last_warp_pt" - /* 0x0026 */ s16 savedSceneNum; // "scene_data_ID" -} SavePlayerData; // size = 0x28 - -typedef struct { +typedef struct CycleSceneFlags { /* 0x00 */ u32 chest; - /* 0x04 */ u32 swch0; - /* 0x08 */ u32 swch1; + /* 0x04 */ u32 switch0; + /* 0x08 */ u32 switch1; /* 0x0C */ u32 clearedRoom; /* 0x10 */ u32 collectible; } CycleSceneFlags; // size = 0x14 -typedef struct { - /* 0x0000 */ u32 entranceIndex; // "scene_no" - /* 0x0004 */ u8 equippedMask; // "player_mask" - /* 0x0005 */ u8 unk_05; // "opening_flag" +typedef struct SaveOptions { + /* 0x00 */ u16 optionId; // "option_id" + /* 0x02 */ u8 language; // "j_n" + /* 0x03 */ s8 audioSetting; // "s_sound" + /* 0x04 */ u8 languageSetting; // "language" + /* 0x05 */ u8 zTargetSetting; // "z_attention", 0: Switch; 1: Hold +} SaveOptions; // size = 0x06 + +typedef struct SavePlayerData { + /* 0x0000 */ char newf[6]; // "newf" Will always be "ZELDA3 for a valid save + /* 0x0006 */ u16 deaths; // "savect" + /* 0x0008 */ char playerName[8]; // "player_name" + /* 0x0010 */ s16 healthCapacity; // "max_life" + /* 0x0012 */ s16 health; // "now_life" + /* 0x0014 */ s8 magicLevel; // "magic_max" + /* 0x0015 */ s8 magic; // "magic_now" + /* 0x0016 */ s16 rupees; // "lupy_count" + /* 0x0018 */ u16 swordHealth; // "long_sword_hp" + /* 0x001A */ u16 tatlTimer; // "navi_timer" + /* 0x001C */ u8 magicAcquired; // "magic_mode" + /* 0x001D */ u8 doubleMagic; // "magic_ability" + /* 0x001E */ u8 doubleDefense; // "life_ability" + /* 0x001F */ u8 unk_1F; // "ocarina_round" + /* 0x0020 */ u8 unk_20; // "first_memory" + /* 0x0022 */ u16 owlActivationFlags; // "memory_warp_point" + /* 0x0024 */ u8 unk_24; // "last_warp_pt" + /* 0x0026 */ s16 savedSceneNum; // "scene_data_ID" +} SavePlayerData; // size = 0x28 + +typedef struct Save { + /* 0x0000 */ u32 entranceIndex; // "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" + /* 0x0007 */ u8 linkAge; // "link_age" + /* 0x0008 */ s32 cutscene; // "day_time" + /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; - /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ u32 daySpeed; // "change_zelda_time" - /* 0x0018 */ s32 day; // "totalday" - /* 0x001C */ u32 daysElapsed; // "eventday" - /* 0x0020 */ u8 playerForm; // "player_character" - /* 0x0021 */ u8 snowheadCleared; // "spring_flag" - /* 0x0022 */ u8 hasTatl; // "bell_flag" + /* 0x0010 */ s32 isNight; // "asahiru_fg" + /* 0x0014 */ u32 daySpeed; // "change_zelda_time" + /* 0x0018 */ s32 day; // "totalday" + /* 0x001C */ u32 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; @@ -117,144 +146,167 @@ typedef struct { /* 0x0E7C */ u32 pictoFlags1; /* 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 + /* 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 + /* 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 + /* 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 unk_EF4; // Shooting Gallery Man Flags - /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" - /* 0x0F5C */ u32 mapsVisited; // "area_arrival" - /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" - /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" - /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" - /* 0x0F66 */ u8 scarecrowsSong[128]; // "oca_rec_buff8" - /* 0x0FE6 */ s8 bombersCaughtNum; // "aikotoba_index" - /* 0x0FE7 */ s8 bombersCaughtOrder[5]; // "aikotoba_table" - /* 0x0FEC */ s8 lotteryCodes[3][3]; // Pre-set lottery codes "numbers_table" - /* 0x0FF5 */ s8 spiderHouseMaskOrder[6]; // "kinsta_color_table" - /* 0x0FFB */ s8 bomberCode[5]; // "bombers_aikotoba_table" + /* 0x0EF0 */ u32 lotteryCodeGuess; // Lottery code chosen by player (only uses lower three hex digits) + /* 0x0EF4 */ u32 unk_EF4; // Shooting Gallery Man Flags + /* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg" + /* 0x0F5C */ u32 mapsVisited; // "area_arrival" + /* 0x0F60 */ u32 mapsVisible; // "cloud_clear" + /* 0x0F64 */ u8 unk_F64; // "oca_rec_flag" has scarecrows song + /* 0x0F65 */ u8 unk_F65; // "oca_rec_flag8" scarecrows song set? + /* 0x0F66 */ u8 scarecrowsSong[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" + /* 0x100A */ u16 checksum; // "check_sum" } Save; // size = 0x100C -typedef struct { +typedef struct SaveContext { /* 0x0000 */ Save save; - /* 0x100C */ u8 eventInf[8]; - /* 0x1014 */ u8 unk_1014; // "stone_set_flag" + /* 0x100C */ u8 eventInf[8]; // "event_inf" + /* 0x1014 */ u8 unk_1014; // "stone_set_flag" /* 0x1015 */ u8 unk_1015; /* 0x1016 */ u16 jinxTimer; - /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" - /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle - /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle - /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle - /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle - /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle - /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo - /* 0x3CA0 */ s32 fileNum; // "file_no" - /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" + /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" + /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle + /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle + /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle + /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle + /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle + /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo + /* 0x3CA0 */ s32 fileNum; // "file_no" + /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" /* 0x3CA6 */ u8 unk_3CA6; - /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" - /* 0x3CA8 */ s32 gameMode; // "mode" - /* 0x3CAC */ s32 sceneSetupIndex; // "counter" - /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" - /* 0x3CB4 */ RespawnData respawn[8]; // "restart_data" - /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" - /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" - /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" - /* 0x3DBB */ u8 unk_3DBB; // "next_walk" - /* 0x3DBC */ u16 dogParams; // "dog_flag" - /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" - /* 0x3DBF */ u8 showTitleCard; // "name_display" - /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" - /* 0x3DC2 */ u8 unk_3DC2; // "pad1" - /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" - /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" - /* 0x3DD7 */ u8 timersNoTimeLimit[7]; // "calc_flag" - /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" - /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" - /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" - /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" - /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" - /* 0x3EF8 */ s16 timerX[7]; // "event_xp" - /* 0x3F06 */ s16 timerY[7]; // "event_yp" - /* 0x3F14 */ s16 unk_3F14; // "character_change" - /* 0x3F16 */ u8 seqIndex; // "old_bgm" - /* 0x3F17 */ u8 nightSeqIndex; // "old_env" - /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" - /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" - /* 0x3F20 */ u16 unk_3F20; // "alpha_type" - /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" - /* 0x3F24 */ u16 unk_3F24; // "alpha_count" - /* 0x3F26 */ u16 unk_3F26; // "last_time_type" - /* 0x3F28 */ s16 unk_3F28; // "magic_flag" - /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" - /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" - /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" - /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" - /* 0x3F32 */ s16 unk_3F32; // "magic_used" - /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" - /* 0x3F36 */ u16 mapIndex; // "scene_ID" - /* 0x3F38 */ u16 minigameState; // "yabusame_mode" - /* 0x3F3A */ u16 minigameScore; // "yabusame_total" - /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" - /* 0x3F3E */ u8 unk_3F3E; // "no_save" - /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" + /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" + /* 0x3CA8 */ s32 gameMode; // "mode" + /* 0x3CAC */ s32 sceneSetupIndex; // "counter" + /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" + /* 0x3CB4 */ RespawnData respawn[RESPAWN_MODE_MAX]; // "restart_data" + /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" + /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" + /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" + /* 0x3DBB */ u8 unk_3DBB; // "next_walk" + /* 0x3DBC */ u16 dogParams; // "dog_flag" + /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" + /* 0x3DBF */ u8 showTitleCard; // "name_display" + /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" + /* 0x3DC2 */ u8 unk_3DC2; // "pad1" + /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" + /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" + /* 0x3DD7 */ u8 timersNoTimeLimit[7]; // "calc_flag" + /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" + /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" + /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" + /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" + /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" + /* 0x3EF8 */ s16 timerX[7]; // "event_xp" + /* 0x3F06 */ s16 timerY[7]; // "event_yp" + /* 0x3F14 */ s16 unk_3F14; // "character_change" + /* 0x3F16 */ u8 seqIndex; // "old_bgm" + /* 0x3F17 */ u8 nightSeqIndex; // "old_env" + /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" + /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" + /* 0x3F20 */ u16 unk_3F20; // "alpha_type" + /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" + /* 0x3F24 */ u16 unk_3F24; // "alpha_count" + /* 0x3F26 */ u16 unk_3F26; // "last_time_type" + /* 0x3F28 */ s16 unk_3F28; // "magic_flag" + /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" + /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" + /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" + /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" + /* 0x3F32 */ s16 unk_3F32; // "magic_used" + /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" + /* 0x3F36 */ u16 mapIndex; // "scene_ID" + /* 0x3F38 */ u16 minigameState; // "yabusame_mode" + /* 0x3F3A */ u16 minigameScore; // "yabusame_total" + /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" + /* 0x3F3E */ u8 unk_3F3E; // "no_save" + /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" /* 0x3F40 */ SaveOptions options; - /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" - /* 0x3F48 */ u8 unk_3F48; // "fade_go" - /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" - /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" - /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" - /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" - /* 0x3F50 */ u8 fadeDuration; // "fade_speed" - /* 0x3F51 */ u8 fadeSpeed; // "wipe_speed" - /* 0x3F52 */ u16 environmentTime; // "kankyo_time" - /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" - /* 0x3F55 */ u8 nextTransition; // "next_wipe" - /* 0x3F56 */ s16 worldMapArea; // "area_type" - /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" - /* 0x3F5A */ s16 healthAccumulator; // "life_mode" - /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" - /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" - /* 0x3F64 */ f32 screenScale; // "framescale_scale" - /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle - /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" - /* 0x48CA */ u8 maskMaskBit[3]; // masks given away on the Moon - /* 0x48CD */ u8 unk_48CD[24]; + /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" + /* 0x3F48 */ u8 unk_3F48; // "fade_go" + /* 0x3F4A */ u16 nextCutsceneIndex; // "next_daytime" + /* 0x3F4C */ u8 cutsceneTrigger; // "doukidemo" + /* 0x3F4D */ u8 unk_3F4D; // "Kenjya_no" + /* 0x3F4E */ u16 nextDayTime; // "next_zelda_time" + /* 0x3F50 */ u8 fadeDuration; // "fade_speed" + /* 0x3F51 */ u8 fadeSpeed; // "wipe_speed" transition related + /* 0x3F52 */ u16 environmentTime; // "kankyo_time" + /* 0x3F54 */ u8 dogIsLost; // "dog_event_flag" + /* 0x3F55 */ u8 nextTransition; // "next_wipe" + /* 0x3F56 */ s16 worldMapArea; // "area_type" + /* 0x3F58 */ s16 sunsSongState; // "sunmoon_flag" + /* 0x3F5A */ s16 healthAccumulator; // "life_mode" + /* 0x3F5C */ s32 unk_3F5C; // "bet_rupees" + /* 0x3F60 */ u8 screenScaleFlag; // "framescale_flag" + /* 0x3F64 */ f32 screenScale; // "framescale_scale" + /* 0x3F68 */ CycleSceneFlags cycleSceneFlags[120]; // Scene flags that are temporarily stored over the duration of a single 3-day cycle + /* 0x48C8 */ u16 unk_48C8; // "scene_id_mix" + /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon } SaveContext; // size = 0x48C8 -typedef enum { - /* 0x00 */ RESPAWN_MODE_VOID_OUT, - /* 0x01 */ RESPAWN_MODE_GROTTO, // Exiting a grotto - /* 0x02 */ RESPAWN_MODE_FARORES_WIND, // Unused in MM - /* 0x03 */ RESPAWN_MODE_GORON, - /* 0x04 */ RESPAWN_MODE_ZORA, - /* 0x05 */ RESPAWN_MODE_DEKU, - /* 0x06 */ RESPAWN_MODE_CHILD_LINK, - /* 0x07 */ RESPAWN_MODE_UNK_7, - /* 0x07 */ RESPAWN_MODE_UNK_8 -} RespawnMode; - -typedef enum { +typedef enum ButtonStatus { /* 0x00 */ BTN_ENABLED, /* 0xFF */ BTN_DISABLED = 0xFF } ButtonStatus; -typedef enum { +typedef enum SunsSongState { /* 0 */ SUNSSONG_INACTIVE, /* 1 */ SUNSSONG_START, // the suns ocarina effect signals that the song has finished playing /* 2 */ SUNSSONG_SPEED_TIME, // suns was played where time passes, speed up the advancement of time /* 3 */ SUNSSONG_SPECIAL // time does not advance, but signals the song was played. used for freezing redeads } SunsSongState; +void Sram_ActivateOwl(u8 owlId); +void Sram_ClearFlagsAtDawnOfTheFirstDay(void); +void Sram_SaveEndOfCycle(struct GlobalContext* globalCtx); +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_OpenSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_8014546C(SramContext* sramCtx); +void func_801457CC(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146580(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx, s32 fileNum); +void func_80146628(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void Sram_InitSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_80146DF8(SramContext* sramCtx); +void Sram_InitSram(struct GameState* gameState, SramContext* sramCtx); +void Sram_Alloc(struct GameState* gamestate, SramContext* sramCtx); +void Sram_SaveSpecialEnterClockTown(struct GlobalContext* globalCtx); +void Sram_SaveSpecialNewDay(struct GlobalContext* globalCtx); +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages); +void func_80147020(SramContext* sramCtx); +void func_80147068(SramContext* sramCtx); +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147150(SramContext* sramCtx); +void func_80147198(SramContext* sramCtx); + +extern s32 D_801C6798[]; +extern u8 D_801C67B0[24]; +extern s32 D_801C67C8[]; +extern s32 D_801C67E8[]; +extern s32 D_801C67F0[]; +extern s32 D_801C6818[]; +extern s32 D_801C6838[]; +extern s32 D_801C6840[]; +extern s32 D_801C6850[]; + #endif diff --git a/include/z64scene.h b/include/z64scene.h index 8d301d1d1..5a1c39e16 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -1,15 +1,16 @@ -#ifndef _Z64SCENE_H_ -#define _Z64SCENE_H_ +#ifndef Z64SCENE_H +#define Z64SCENE_H #include "ultra64.h" #include "z64dma.h" +#include "z64cutscene.h" #include "unk.h" #define SPAWN_ROT_FLAGS(rotation, flags) (((rotation) << 7) | (flags)) typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; } RomFile; // size = 0x8 typedef struct { @@ -290,7 +291,7 @@ typedef struct { typedef struct { struct { s8 room; // Room to switch to - s8 effects; // How the camera reacts during the transition + s8 bgCamDataId; // How the camera reacts during the transition. -2 for spiral staircase. -1 for generic door. 0+ will index scene CamData } /* 0x00 */ sides[2]; // 0 = front, 1 = back /* 0x04 */ s16 id; /* 0x06 */ Vec3s pos; @@ -310,13 +311,6 @@ typedef struct { /* 0xE */ s16 params; } ActorEntry; // size = 0x10 -typedef struct { - /* 0x0 */ u32 data; - /* 0x4 */ s16 unk4; - /* 0x6 */ u8 unk6; - /* 0x7 */ u8 unk7; -} CutsceneEntry; // size = 0x8 - typedef struct { /* 0x0 */ u8 spawn; /* 0x1 */ u8 room; @@ -496,10 +490,12 @@ typedef struct { } MinimapChest; // size = 0xA typedef struct { - /* 0x00 */ s16 type; - /* 0x00 */ s16 numPoints; - /* 0x00 */ Vec3s* points; -} CsCameraEntry; + /* 0x0 */ s16 setting; + /* 0x2 */ s16 numData; + /* 0x4 */ Vec3s* data; +} CsCamData; // size = 0x8 + +typedef CsCamData CsCameraEntry; // TODO: Remove once ZAPD updates its structs typedef union { /* Command: N/A */ SCmdBase base; @@ -649,7 +645,8 @@ typedef enum { /* 0x6D */ SCENE_ICHIBA, /* 0x6E */ SCENE_BACKTOWN, /* 0x6F */ SCENE_CLOCKTOWER, - /* 0x70 */ SCENE_ALLEY + /* 0x70 */ SCENE_ALLEY, + /* 0x71 */ SCENE_MAX } SceneID; // SceneTableEntry draw configs diff --git a/include/z64skin.h b/include/z64skin.h new file mode 100644 index 000000000..adb2f9b0f --- /dev/null +++ b/include/z64skin.h @@ -0,0 +1,106 @@ +#ifndef Z64_SKIN_H +#define Z64_SKIN_H + +#include "z64animation.h" + +struct GraphicsContext; +struct GameState; +struct GlobalContext; + +/** + * Holds a compact version of a vertex used in the Skin system (doesn't has the x, y, z positions or the flag member) + * It is used to initialise the Vtx used by an animated limb + */ +typedef struct { + /* 0x0 */ u16 index; + /* 0x2 */ s16 s; // s and t are texture coordinates (also known as u and v) + /* 0x4 */ s16 t; + /* 0x6 */ s8 normX; + /* 0x7 */ s8 normY; + /* 0x8 */ s8 normZ; + /* 0x9 */ u8 alpha; +} SkinVertex; // size = 0xA + +/** + * Describes a position displacement and a scale to be applied to a limb at index `limbIndex` + */ +typedef struct { + /* 0x0 */ u8 limbIndex; + /* 0x2 */ s16 x; + /* 0x4 */ s16 y; + /* 0x6 */ s16 z; + /* 0x8 */ u8 scale; +} SkinTransformation; // size = 0xA + +typedef struct { + /* 0x00 */ u16 vtxCount; // number of vertices in this modif entry + /* 0x02 */ u16 transformCount; + /* 0x04 */ u16 unk_04; // index of limbTransformations + /* 0x08 */ SkinVertex* skinVertices; + /* 0x0C */ SkinTransformation* limbTransformations; +} SkinLimbModif; // size = 0x10 + +typedef struct { + /* 0x00 */ u16 totalVtxCount; // total vertex count for all modif entries + /* 0x02 */ u16 limbModifCount; // count of limbModifCount + /* 0x04 */ SkinLimbModif* limbModifications; + /* 0x08 */ Gfx* dlist; +} SkinAnimatedLimbData; // size = 0xC + +// ZAPD compatibility typedefs +// TODO: Remove when ZAPD adds support for them +typedef SkinVertex Struct_800A57C0; +typedef SkinTransformation Struct_800A598C_2; +typedef SkinAnimatedLimbData Struct_800A5E28; +typedef SkinLimbModif Struct_800A598C; + +#define SKIN_LIMB_TYPE_ANIMATED 4 +#define SKIN_LIMB_TYPE_NORMAL 11 + +typedef struct { + /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent + /* 0x06 */ u8 child; + /* 0x07 */ u8 sibling; + /* 0x08 */ s32 segmentType; // Type of data contained in segment + /* 0x0C */ void* segment; // Gfx* if segmentType is SKIN_LIMB_TYPE_NORMAL, SkinAnimatedLimbData if segmentType is SKIN_LIMB_TYPE_ANIMATED, NULL otherwise +} SkinLimb; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 index; // alternates every draw cycle + /* 0x4 */ Vtx* buf[2]; // number of vertices in buffer determined by `totalVtxCount` +} SkinLimbVtx; // size = 0xC + +typedef struct { + /* 0x000 */ SkeletonHeader* skeletonHeader; + /* 0x004 */ MtxF mtx; + /* 0x044 */ s32 limbCount; + /* 0x048 */ SkinLimbVtx* vtxTable; // double buffered list of vertices for each limb + /* 0x04C */ SkelAnime skelAnime; +} Skin; // size = 0x90 + +typedef void (*SkinPostDraw)(struct Actor*, struct GlobalContext*, Skin*); +typedef s32 (*SkinOverrideLimbDraw)(struct Actor*, struct GlobalContext*, s32, Skin*); + +#define SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS (1 << 0) +#define SKIN_DRAW_FLAG_CUSTOM_MATRIX (1 << 1) + + +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos); +void Skin_ApplyLimbModifications(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3); +void Skin_DrawAnimatedLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags); +void Skin_DrawLimb(struct GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags); +void func_80138228(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation); +void func_80138258(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation); +void func_8013828C(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6); +void func_801382C4(Actor* actor, struct GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags); +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst); +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst); + +void Skin_Setup(Skin* skin); +void Skin_InitAnimatedLimb(struct GameState* gameState, Skin* skin, s32 limbIndex); +void Skin_Init(struct GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader); +void Skin_Free(struct GameState* gameState, Skin* skin); +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex); +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation); + +#endif diff --git a/include/z64subs.h b/include/z64subs.h new file mode 100644 index 000000000..ca69e72cb --- /dev/null +++ b/include/z64subs.h @@ -0,0 +1,60 @@ +#ifndef Z64SUBS_H +#define Z64SUBS_H + +#include "z64actor.h" +#include "z64scene.h" + +typedef enum { + /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, + /* 1 */ SUBS_CUTSCENE_NORMAL, + /* 2 */ SUBS_CUTSCENE_SET_FLAG +} SubSCutsceneType; + +typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, void*); + +typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); + +#define ACTOR_PATHING_RETURN_TO_START (1 << 0) +#define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) +#define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) +#define ACTOR_PATHING_REACHED_POINT_PERMANENT (1 << 4) +#define ACTOR_PATHING_REACHED_END_PERMANENT (1 << 5) +#define ACTOR_PATHING_REACHED_POINT_TEMPORARY (1 << 6) +#define ACTOR_PATHING_REACHED_END_TEMPORARY (1 << 7) + +#define ACTOR_PATHING_REACHED_TEMPORARY \ + (ACTOR_PATHING_REACHED_POINT_TEMPORARY | ACTOR_PATHING_REACHED_END_TEMPORARY) +#define ACTOR_PATHING_REACHED_POINT \ + (ACTOR_PATHING_REACHED_POINT_PERMANENT | ACTOR_PATHING_REACHED_POINT_TEMPORARY) +#define ACTOR_PATHING_REACHED_END \ + (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) + +struct ActorPathing; +typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); +typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); + +typedef struct ActorPathing { + /* 0x00 */ Path* setupPathList; + /* 0x04 */ s32 pathIndex; + /* 0x08 */ Vec3s* points; + /* 0x0C */ s32 count; + /* 0x10 */ s32 curPointIndex; + /* 0x14 */ s32 begPointIndex; + /* 0x18 */ s32 endPointIndex; + /* 0x1C */ u8 flags; + /* 0x1D */ u8 prevFlags; + /* 0x20 */ Vec3f curPoint; + /* 0x2C */ Vec3f pointOffset; + /* 0x38 */ Vec3f prevPoint; + /* 0x44 */ Vec3f* worldPos; + /* 0x48 */ Actor* actor; + /* 0x4C */ f32 distSqToCurPointXZ; + /* 0x50 */ f32 distSqToCurPoint; + /* 0x54 */ Vec3s rotToCurPoint; + /* 0x5C */ ActorPathingComputeFunc computePointInfoFunc; + /* 0x60 */ ActorPathingUpdateFunc updateActorInfoFunc; // Return true if should setNextPoint, false if the actor should move forward + /* 0x64 */ ActorPathingUpdateFunc moveFunc; // Return true if should compute and update again + /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again +} ActorPathing; // size = 0x6C + +#endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h new file mode 100644 index 000000000..997a41233 --- /dev/null +++ b/include/z_en_hy_code.h @@ -0,0 +1,94 @@ +#ifndef Z_EN_HY_CODE_H +#define Z_EN_HY_CODE_H + +#include "global.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" + +struct EnHy; + +#define ENHY_LIMB_MAX 16 + +//! TODO: Better animaion enum names when animations are documented +typedef enum { + /* 0 */ ENHY_ANIMATION_AOB_0, + /* 1 */ ENHY_ANIMATION_BOJ_1, + /* 2 */ ENHY_ANIMATION_BOJ_2, + /* 3 */ ENHY_ANIMATION_BOJ_3, + /* 4 */ ENHY_ANIMATION_BOJ_4, + /* 5 */ ENHY_ANIMATION_BOJ_5, + /* 6 */ ENHY_ANIMATION_BBA_6, + /* 7 */ ENHY_ANIMATION_BJI_7, + /* 8 */ ENHY_ANIMATION_BJI_8, + /* 9 */ ENHY_ANIMATION_BJI_9, + /* 10 */ ENHY_ANIMATION_BOJ_10, + /* 11 */ ENHY_ANIMATION_OS_ANIME_11, + /* 12 */ ENHY_ANIMATION_BOJ_12, + /* 13 */ ENHY_ANIMATION_BOJ_13, + /* 14 */ ENHY_ANIMATION_BOJ_14, + /* 15 */ ENHY_ANIMATION_BOJ_15, + /* 16 */ ENHY_ANIMATION_BOJ_16, + /* 17 */ ENHY_ANIMATION_BOJ_17, + /* 18 */ ENHY_ANIMATION_BOJ_18, + /* 19 */ ENHY_ANIMATION_BOJ_19, + /* 20 */ ENHY_ANIMATION_BOJ_20, + /* 21 */ ENHY_ANIMATION_MAX +} EnHyAnimation; + +typedef void (*EnHyActionFunc)(struct EnHy*, GlobalContext*); + +typedef struct EnHy { + /* 0x000 */ Actor actor; + /* 0x144 */ EnHyActionFunc actionFunc; + /* 0x148 */ EnHyActionFunc tmpActionFunc; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ s8 headObjIndex; // Limb 15 + /* 0x191 */ s8 skelUpperObjIndex; // Limbs 8-14 + /* 0x192 */ s8 skelLowerObjIndex; // Limbs 1-7 + /* 0x193 */ s8 animObjIndex; + /* 0x194 */ ColliderCylinder collider; + /* 0x1E0 */ u16 textId; + /* 0x1E2 */ u8 waitingOnInit; + /* 0x1E3 */ u8 inMsgState3; + /* 0x1E4 */ Path* path; + /* 0x1E8 */ s16 curPoint; + /* 0x1EC */ Vec3f leftFootPos; + /* 0x1F8 */ Vec3f rightFootPos; + /* 0x204 */ u8 isLeftFootOnGround; + /* 0x205 */ u8 isRightFootOnGround; + /* 0x206 */ Vec3s jointTable[ENHY_LIMB_MAX]; + /* 0x266 */ Vec3s morphTable[ENHY_LIMB_MAX]; + /* 0x2C6 */ Vec3s focusTarget; + /* 0x2CC */ Vec3s headRot; + /* 0x2D2 */ Vec3s torsoRot; + /* 0x2D8 */ Vec3s tmpFocusTarget; + /* 0x2DE */ Vec3s tmpHeadRot; + /* 0x2E4 */ Vec3s tmpTorsoRot; + /* 0x2EA */ s16 limbRotTableY[16]; + /* 0x30A */ s16 limbRotTableZ[16]; + /* 0x32C */ Vec3f bodyPartsPos[15]; + /* 0x3E0 */ UNK_TYPE1 unk_3E0[0x6]; + /* 0x3E6 */ s16 eyeTexIndex; + /* 0x3E8 */ s16 blinkTimer; +} EnHy; // size = 0x3EC + +extern s8 gEnHyBodyParts[]; +extern s8 gEnHyBodyPartsIndex[]; +extern u8 gEnHyShadowSize[]; + +s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); +EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); +void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); +s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx); +void EnHy_Blink(EnHy* enHy, s32 arg1); +s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); +void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4); +s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); +s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3); +s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex); +s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); +s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget); +s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget); +void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx); +s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold); + +#endif // Z_EN_HY_CODE_H diff --git a/spec b/spec index 352e4fbd6..b28a7d628 100644 --- a/spec +++ b/spec @@ -38,7 +38,6 @@ beginseg include "build/src/boot_O2/mtxuty-cvt.o" include "build/src/boot_O2/assert.o" include "build/src/boot_O2/boot_800862E0.o" - include "build/data/boot/boot_800862E0.data.o" include "build/src/boot_O2/padsetup.o" include "build/src/boot_O2/boot_80086760.o" include "build/asm/boot/fp.text.o" @@ -460,14 +459,13 @@ beginseg 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/data/code/z_demo.bss.o" include "build/src/code/z_draw.o" include "build/data/code/z_draw.data.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.o" + include "build/src/code/z_en_hy_code.o" include "build/src/code/z_face_reaction.o" include "build/src/code/z_env_flags.o" include "build/src/code/z_eventmgr.o" @@ -481,7 +479,6 @@ beginseg include "build/data/code/z_horse.data.o" include "build/src/code/z_jpeg.o" include "build/src/code/z_kaleido_setup.o" - include "build/data/code/z_kaleido_setup.data.o" include "build/src/code/z_kanfont.o" include "build/src/code/z_kankyo.o" include "build/data/code/z_kankyo.data.o" @@ -489,7 +486,6 @@ beginseg include "build/src/code/z_lib.o" include "build/src/code/z_lifemeter.o" include "build/src/code/z_lights.o" - include "build/data/code/z_lights.bss.o" include "build/src/code/z_malloc.o" include "build/src/code/z_map_disp.o" include "build/data/code/z_map_disp.data.o" @@ -526,12 +522,10 @@ beginseg include "build/data/code/code_801C5C50.data.o" include "build/src/code/z_skelanime.o" include "build/src/code/z_skin.o" - include "build/data/code/z_skin.bss.o" include "build/src/code/z_skin_awb.o" include "build/src/code/z_skin_matrix.o" include "build/src/code/z_snap.o" include "build/src/code/z_sub_s.o" - include "build/data/code/z_sub_s.data.o" include "build/data/code/code_801DE890.rodata.o" include "build/src/code/code_8013EC10.o" include "build/data/code/code_8013EC10.bss.o" @@ -544,19 +538,16 @@ beginseg 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" - include "build/data/code/z_sram_NES.data.o" - include "build/data/code/z_sram_NES.bss.o" include "build/src/code/z_message.o" + include "build/data/code/z_message.data.o" include "build/data/code/z_message.bss.o" include "build/src/code/z_message_nes.o" include "build/data/code/z_message_nes.data.o" include "build/src/code/z_message_staff.o" include "build/src/code/z_player_call.o" - include "build/data/code/z_player_call.bss.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/data/code/code_801D0B50.data.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" @@ -625,8 +616,6 @@ beginseg include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" include "build/src/code/audio/audio_load.o" - include "build/data/code/audio_load.data.o" - include "build/data/code/audio_load.bss.o" include "build/src/code/audio/code_80192BE0.o" include "build/data/code/code_80192BE0.data.o" include "build/src/code/audio/audio_dcache.o" @@ -641,8 +630,6 @@ beginseg pad_text include "build/asm/code/code_8019AEC0.text.o" // handwritten include "build/src/code/audio/code_8019AF00.o" - include "build/data/code/code_8019AF00.data.o" - include "build/data/code/code_8019AF00.bss.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" @@ -744,8 +731,7 @@ beginseg name "ovl_En_Test" compress include "build/src/overlays/actors/ovl_En_Test/z_en_test.o" - include "build/data/ovl_En_Test/ovl_En_Test.data.o" - include "build/data/ovl_En_Test/ovl_En_Test.reloc.o" + include "build/src/overlays/actors/ovl_En_Test/ovl_En_Test_reloc.o" endseg beginseg @@ -767,17 +753,14 @@ beginseg name "ovl_En_Light" compress include "build/src/overlays/actors/ovl_En_Light/z_en_light.o" - include "build/data/ovl_En_Light/ovl_En_Light.data.o" - include "build/data/ovl_En_Light/ovl_En_Light.reloc.o" + include "build/src/overlays/actors/ovl_En_Light/ovl_En_Light_reloc.o" endseg beginseg name "ovl_En_Door" compress include "build/src/overlays/actors/ovl_En_Door/z_en_door.o" - include "build/data/ovl_En_Door/ovl_En_Door.data.o" - include "build/data/ovl_En_Door/ovl_En_Door.bss.o" - include "build/data/ovl_En_Door/ovl_En_Door.reloc.o" + include "build/src/overlays/actors/ovl_En_Door/ovl_En_Door_reloc.o" endseg beginseg @@ -814,8 +797,7 @@ beginseg name "ovl_En_Wallmas" compress include "build/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.data.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.reloc.o" + include "build/src/overlays/actors/ovl_En_Wallmas/ovl_En_Wallmas_reloc.o" endseg beginseg @@ -836,16 +818,22 @@ beginseg name "ovl_En_Horse" compress include "build/src/overlays/actors/ovl_En_Horse/z_en_horse.o" - include "build/data/ovl_En_Horse/ovl_En_Horse.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Horse/ovl_En_Horse_reloc.o" +#else include "build/data/ovl_En_Horse/ovl_En_Horse.reloc.o" +#endif endseg beginseg name "ovl_En_Arrow" compress include "build/src/overlays/actors/ovl_En_Arrow/z_en_arrow.o" - include "build/data/ovl_En_Arrow/ovl_En_Arrow.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_En_Arrow/ovl_En_Arrow_reloc.o" +#else include "build/data/ovl_En_Arrow/ovl_En_Arrow.reloc.o" +#endif endseg beginseg @@ -926,8 +914,7 @@ beginseg name "ovl_Door_Shutter" compress include "build/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.o" - include "build/data/ovl_Door_Shutter/ovl_Door_Shutter.data.o" - include "build/data/ovl_Door_Shutter/ovl_Door_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Door_Shutter/ovl_Door_Shutter_reloc.o" endseg beginseg @@ -963,16 +950,14 @@ beginseg name "ovl_Obj_Wturn" compress include "build/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.data.o" - include "build/data/ovl_Obj_Wturn/ovl_Obj_Wturn.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Wturn/ovl_Obj_Wturn_reloc.o" endseg beginseg name "ovl_En_River_Sound" compress include "build/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.data.o" - include "build/data/ovl_En_River_Sound/ovl_En_River_Sound.reloc.o" + include "build/src/overlays/actors/ovl_En_River_Sound/ovl_En_River_Sound_reloc.o" endseg beginseg @@ -994,16 +979,14 @@ beginseg name "ovl_En_Bombf" compress include "build/src/overlays/actors/ovl_En_Bombf/z_en_bombf.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.data.o" - include "build/data/ovl_En_Bombf/ovl_En_Bombf.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombf/ovl_En_Bombf_reloc.o" endseg beginseg name "ovl_En_Am" compress include "build/src/overlays/actors/ovl_En_Am/z_en_am.o" - include "build/data/ovl_En_Am/ovl_En_Am.data.o" - include "build/data/ovl_En_Am/ovl_En_Am.reloc.o" + include "build/src/overlays/actors/ovl_En_Am/ovl_En_Am_reloc.o" endseg beginseg @@ -1033,8 +1016,7 @@ beginseg name "ovl_Bg_Breakwall" compress include "build/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.data.o" - include "build/data/ovl_Bg_Breakwall/ovl_Bg_Breakwall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Breakwall/ovl_Bg_Breakwall_reloc.o" endseg beginseg @@ -1088,8 +1070,7 @@ beginseg name "ovl_En_Bb" compress include "build/src/overlays/actors/ovl_En_Bb/z_en_bb.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.data.o" - include "build/data/ovl_En_Bb/ovl_En_Bb.reloc.o" + include "build/src/overlays/actors/ovl_En_Bb/ovl_En_Bb_reloc.o" endseg beginseg @@ -1103,9 +1084,7 @@ beginseg name "ovl_En_Wood02" compress include "build/src/overlays/actors/ovl_En_Wood02/z_en_wood02.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.data.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.bss.o" - include "build/data/ovl_En_Wood02/ovl_En_Wood02.reloc.o" + include "build/src/overlays/actors/ovl_En_Wood02/ovl_En_Wood02_reloc.o" endseg beginseg @@ -1129,8 +1108,7 @@ beginseg name "ovl_En_Vm" compress include "build/src/overlays/actors/ovl_En_Vm/z_en_vm.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.data.o" - include "build/data/ovl_En_Vm/ovl_En_Vm.reloc.o" + include "build/src/overlays/actors/ovl_En_Vm/ovl_En_Vm_reloc.o" endseg beginseg @@ -1255,8 +1233,11 @@ beginseg name "ovl_Mir_Ray" compress include "build/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.o" - include "build/data/ovl_Mir_Ray/ovl_Mir_Ray.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Mir_Ray/ovl_Mir_Ray_reloc.o" +#else include "build/data/ovl_Mir_Ray/ovl_Mir_Ray.reloc.o" +#endif endseg beginseg @@ -1277,8 +1258,7 @@ beginseg name "ovl_En_Karebaba" compress include "build/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.o" - include "build/data/ovl_En_Karebaba/ovl_En_Karebaba.data.o" - include "build/data/ovl_En_Karebaba/ovl_En_Karebaba.reloc.o" + include "build/src/overlays/actors/ovl_En_Karebaba/ovl_En_Karebaba_reloc.o" endseg beginseg @@ -1292,16 +1272,14 @@ beginseg name "ovl_En_Bom_Chu" compress include "build/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.data.o" - include "build/data/ovl_En_Bom_Chu/ovl_En_Bom_Chu.reloc.o" + include "build/src/overlays/actors/ovl_En_Bom_Chu/ovl_En_Bom_Chu_reloc.o" endseg beginseg name "ovl_En_Horse_Game_Check" compress include "build/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.data.o" - include "build/data/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.reloc.o" + include "build/src/overlays/actors/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check_reloc.o" endseg beginseg @@ -1322,11 +1300,7 @@ beginseg name "ovl_En_Fishing" compress include "build/src/overlays/actors/ovl_En_Fishing/z_en_fishing.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_En_Fishing/ovl_En_Fishing_reloc.o" -#else - include "build/data/ovl_En_Fishing/ovl_En_Fishing.reloc.o" -#endif endseg beginseg @@ -1355,16 +1329,14 @@ beginseg name "ovl_En_Insect" compress include "build/src/overlays/actors/ovl_En_Insect/z_en_insect.o" - include "build/data/ovl_En_Insect/ovl_En_Insect.data.o" - include "build/data/ovl_En_Insect/ovl_En_Insect.reloc.o" + include "build/src/overlays/actors/ovl_En_Insect/ovl_En_Insect_reloc.o" endseg beginseg name "ovl_En_Butte" compress include "build/src/overlays/actors/ovl_En_Butte/z_en_butte.o" - include "build/data/ovl_En_Butte/ovl_En_Butte.data.o" - include "build/data/ovl_En_Butte/ovl_En_Butte.reloc.o" + include "build/src/overlays/actors/ovl_En_Butte/ovl_En_Butte_reloc.o" endseg beginseg @@ -1386,9 +1358,7 @@ beginseg name "ovl_Arrow_Fire" compress include "build/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.data.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.bss.o" - include "build/data/ovl_Arrow_Fire/ovl_Arrow_Fire.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Fire/ovl_Arrow_Fire_reloc.o" endseg beginseg @@ -1402,9 +1372,7 @@ beginseg name "ovl_Arrow_Light" compress include "build/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.data.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.bss.o" - include "build/data/ovl_Arrow_Light/ovl_Arrow_Light.reloc.o" + include "build/src/overlays/actors/ovl_Arrow_Light/ovl_Arrow_Light_reloc.o" endseg beginseg @@ -1485,9 +1453,7 @@ beginseg name "ovl_En_Kusa" compress include "build/src/overlays/actors/ovl_En_Kusa/z_en_kusa.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.data.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.bss.o" - include "build/data/ovl_En_Kusa/ovl_En_Kusa.reloc.o" + include "build/src/overlays/actors/ovl_En_Kusa/ovl_En_Kusa_reloc.o" endseg beginseg @@ -1501,17 +1467,14 @@ beginseg name "ovl_Obj_Bombiwa" compress include "build/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.o" - include "build/data/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa.data.o" - include "build/data/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Bombiwa/ovl_Obj_Bombiwa_reloc.o" endseg beginseg name "ovl_Obj_Switch" compress include "build/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.data.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.bss.o" - include "build/data/ovl_Obj_Switch/ovl_Obj_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Switch/ovl_Obj_Switch_reloc.o" endseg beginseg @@ -1591,9 +1554,7 @@ beginseg name "ovl_En_Sda" compress include "build/src/overlays/actors/ovl_En_Sda/z_en_sda.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.data.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.bss.o" - include "build/data/ovl_En_Sda/ovl_En_Sda.reloc.o" + include "build/src/overlays/actors/ovl_En_Sda/ovl_En_Sda_reloc.o" endseg beginseg @@ -1621,16 +1582,14 @@ beginseg name "ovl_En_Hs" compress include "build/src/overlays/actors/ovl_En_Hs/z_en_hs.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.data.o" - include "build/data/ovl_En_Hs/ovl_En_Hs.reloc.o" + include "build/src/overlays/actors/ovl_En_Hs/ovl_En_Hs_reloc.o" endseg beginseg name "ovl_Bg_Ingate" compress include "build/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.o" - include "build/data/ovl_Bg_Ingate/ovl_Bg_Ingate.data.o" - include "build/data/ovl_Bg_Ingate/ovl_Bg_Ingate.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ingate/ovl_Bg_Ingate_reloc.o" endseg beginseg @@ -1648,16 +1607,14 @@ beginseg name "ovl_En_Attack_Niw" compress include "build/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.data.o" - include "build/data/ovl_En_Attack_Niw/ovl_En_Attack_Niw.reloc.o" + include "build/src/overlays/actors/ovl_En_Attack_Niw/ovl_En_Attack_Niw_reloc.o" endseg beginseg name "ovl_En_Mk" compress include "build/src/overlays/actors/ovl_En_Mk/z_en_mk.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.data.o" - include "build/data/ovl_En_Mk/ovl_En_Mk.reloc.o" + include "build/src/overlays/actors/ovl_En_Mk/ovl_En_Mk_reloc.o" endseg beginseg @@ -1728,8 +1685,7 @@ beginseg name "ovl_En_Ani" compress include "build/src/overlays/actors/ovl_En_Ani/z_en_ani.o" - include "build/data/ovl_En_Ani/ovl_En_Ani.data.o" - include "build/data/ovl_En_Ani/ovl_En_Ani.reloc.o" + include "build/src/overlays/actors/ovl_En_Ani/ovl_En_Ani_reloc.o" endseg beginseg @@ -1883,8 +1839,7 @@ beginseg name "ovl_Effect_Ss_Bubble" compress include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/z_eff_ss_bubble.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.data.o" - include "build/data/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Bubble/ovl_Effect_Ss_Bubble_reloc.o" endseg beginseg @@ -1946,8 +1901,7 @@ beginseg name "ovl_Effect_Ss_Sibuki" compress include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/z_eff_ss_sibuki.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.data.o" - include "build/data/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Sibuki/ovl_Effect_Ss_Sibuki_reloc.o" endseg beginseg @@ -2128,8 +2082,7 @@ beginseg name "ovl_Obj_Comb" compress include "build/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.o" - include "build/data/ovl_Obj_Comb/ovl_Obj_Comb.data.o" - include "build/data/ovl_Obj_Comb/ovl_Obj_Comb.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Comb/ovl_Obj_Comb_reloc.o" endseg beginseg @@ -2195,8 +2148,7 @@ beginseg name "ovl_En_Crow" compress include "build/src/overlays/actors/ovl_En_Crow/z_en_crow.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.data.o" - include "build/data/ovl_En_Crow/ovl_En_Crow.reloc.o" + include "build/src/overlays/actors/ovl_En_Crow/ovl_En_Crow_reloc.o" endseg beginseg @@ -2250,8 +2202,7 @@ beginseg name "ovl_Obj_Hamishi" compress include "build/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.data.o" - include "build/data/ovl_Obj_Hamishi/ovl_Obj_Hamishi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hamishi/ovl_Obj_Hamishi_reloc.o" endseg beginseg @@ -2280,8 +2231,7 @@ beginseg name "ovl_Obj_Pzlblock" compress include "build/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.data.o" - include "build/data/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Pzlblock/ovl_Obj_Pzlblock_reloc.o" endseg beginseg @@ -2296,8 +2246,7 @@ beginseg name "ovl_Obj_Armos" compress include "build/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.data.o" - include "build/data/ovl_Obj_Armos/ovl_Obj_Armos.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Armos/ovl_Obj_Armos_reloc.o" endseg beginseg @@ -2319,17 +2268,14 @@ beginseg name "ovl_Obj_Grass" compress include "build/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.data.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.bss.o" - include "build/data/ovl_Obj_Grass/ovl_Obj_Grass.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass/ovl_Obj_Grass_reloc.o" endseg beginseg name "ovl_Obj_Grass_Carry" compress include "build/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.data.o" - include "build/data/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Grass_Carry/ovl_Obj_Grass_Carry_reloc.o" endseg beginseg @@ -2392,8 +2338,7 @@ beginseg name "ovl_En_Warp_tag" compress include "build/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.data.o" - include "build/data/ovl_En_Warp_tag/ovl_En_Warp_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Warp_tag/ovl_En_Warp_tag_reloc.o" endseg beginseg @@ -2436,8 +2381,7 @@ beginseg name "ovl_En_Bom_Bowl_Man" compress include "build/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.o" - include "build/data/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.data.o" - include "build/data/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.reloc.o" + include "build/src/overlays/actors/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man_reloc.o" endseg beginseg @@ -2458,8 +2402,7 @@ beginseg name "ovl_En_Syateki_Crow" compress include "build/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.o" - include "build/data/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow.data.o" - include "build/data/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Crow/ovl_En_Syateki_Crow_reloc.o" endseg beginseg @@ -2473,16 +2416,14 @@ beginseg name "ovl_En_Cne_01" compress include "build/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.o" - include "build/data/ovl_En_Cne_01/ovl_En_Cne_01.data.o" - include "build/data/ovl_En_Cne_01/ovl_En_Cne_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Cne_01/ovl_En_Cne_01_reloc.o" endseg beginseg name "ovl_En_Bba_01" compress include "build/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.o" - include "build/data/ovl_En_Bba_01/ovl_En_Bba_01.data.o" - include "build/data/ovl_En_Bba_01/ovl_En_Bba_01.reloc.o" + include "build/src/overlays/actors/ovl_En_Bba_01/ovl_En_Bba_01_reloc.o" endseg beginseg @@ -2496,16 +2437,18 @@ beginseg name "ovl_Bg_Spdweb" compress include "build/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.o" - include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Spdweb/ovl_Bg_Spdweb_reloc.o" +#else include "build/data/ovl_Bg_Spdweb/ovl_Bg_Spdweb.reloc.o" +#endif endseg beginseg name "ovl_En_Mt_tag" compress include "build/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.data.o" - include "build/data/ovl_En_Mt_tag/ovl_En_Mt_tag.reloc.o" + include "build/src/overlays/actors/ovl_En_Mt_tag/ovl_En_Mt_tag_reloc.o" endseg beginseg @@ -2521,20 +2464,14 @@ beginseg name "ovl_Boss_02" compress include "build/src/overlays/actors/ovl_Boss_02/z_boss_02.o" - #ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" - #else - include "build/data/ovl_Boss_02/ovl_Boss_02.reloc.o" - #endif + include "build/src/overlays/actors/ovl_Boss_02/ovl_Boss_02_reloc.o" endseg beginseg name "ovl_Boss_03" compress include "build/src/overlays/actors/ovl_Boss_03/z_boss_03.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.data.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.bss.o" - include "build/data/ovl_Boss_03/ovl_Boss_03.reloc.o" + include "build/src/overlays/actors/ovl_Boss_03/ovl_Boss_03_reloc.o" endseg beginseg @@ -2632,8 +2569,7 @@ beginseg name "ovl_Bg_Numa_Hana" compress include "build/src/overlays/actors/ovl_Bg_Numa_Hana/z_bg_numa_hana.o" - include "build/data/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana.data.o" - include "build/data/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Numa_Hana/ovl_Bg_Numa_Hana_reloc.o" endseg beginseg @@ -2647,8 +2583,11 @@ beginseg name "ovl_Obj_Spinyroll" compress include "build/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.o" - include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll_reloc.o" +#else include "build/data/ovl_Obj_Spinyroll/ovl_Obj_Spinyroll.reloc.o" +#endif endseg beginseg @@ -2663,24 +2602,21 @@ beginseg name "ovl_En_Syateki_Wf" compress include "build/src/overlays/actors/ovl_En_Syateki_Wf/z_en_syateki_wf.o" - include "build/data/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf.data.o" - include "build/data/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Wf/ovl_En_Syateki_Wf_reloc.o" endseg beginseg name "ovl_Obj_Skateblock" compress include "build/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.data.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Skateblock/ovl_Obj_Skateblock_reloc.o" endseg beginseg name "ovl_Effect_En_Ice_Block" compress include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.data.o" - include "build/data/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block.reloc.o" + include "build/src/overlays/effects/ovl_Effect_En_Ice_Block/ovl_Effect_En_Ice_Block_reloc.o" endseg beginseg @@ -2702,17 +2638,14 @@ beginseg name "ovl_Bg_Dblue_Movebg" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.data.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.bss.o" - include "build/data/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Movebg/ovl_Bg_Dblue_Movebg_reloc.o" endseg beginseg name "ovl_En_Syateki_Dekunuts" compress include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.data.o" - include "build/data/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Dekunuts/ovl_En_Syateki_Dekunuts_reloc.o" endseg beginseg @@ -2757,8 +2690,7 @@ beginseg name "ovl_En_Pr" compress include "build/src/overlays/actors/ovl_En_Pr/z_en_pr.o" - include "build/data/ovl_En_Pr/ovl_En_Pr.data.o" - include "build/data/ovl_En_Pr/ovl_En_Pr.reloc.o" + include "build/src/overlays/actors/ovl_En_Pr/ovl_En_Pr_reloc.o" endseg beginseg @@ -2773,8 +2705,7 @@ beginseg name "ovl_Obj_Entotu" compress include "build/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.data.o" - include "build/data/ovl_Obj_Entotu/ovl_Obj_Entotu.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Entotu/ovl_Obj_Entotu_reloc.o" endseg beginseg @@ -2788,8 +2719,7 @@ beginseg name "ovl_En_Syateki_Okuta" compress include "build/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.data.o" - include "build/data/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.reloc.o" + include "build/src/overlays/actors/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta_reloc.o" endseg beginseg @@ -2820,8 +2750,7 @@ beginseg name "ovl_En_Elfgrp" compress include "build/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.data.o" - include "build/data/ovl_En_Elfgrp/ovl_En_Elfgrp.reloc.o" + include "build/src/overlays/actors/ovl_En_Elfgrp/ovl_En_Elfgrp_reloc.o" endseg beginseg @@ -2843,16 +2772,18 @@ beginseg name "ovl_Obj_Vspinyroll" compress include "build/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.o" - include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll_reloc.o" +#else include "build/data/ovl_Obj_Vspinyroll/ovl_Obj_Vspinyroll.reloc.o" +#endif endseg beginseg name "ovl_Obj_Smork" compress include "build/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.data.o" - include "build/data/ovl_Obj_Smork/ovl_Obj_Smork.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Smork/ovl_Obj_Smork_reloc.o" endseg beginseg @@ -2938,8 +2869,7 @@ beginseg name "ovl_Obj_Fireshield" compress include "build/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.data.o" - include "build/data/ovl_Obj_Fireshield/ovl_Obj_Fireshield.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Fireshield/ovl_Obj_Fireshield_reloc.o" endseg beginseg @@ -3079,16 +3009,18 @@ beginseg name "ovl_Obj_Driftice" compress include "build/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.o" - include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Driftice/ovl_Obj_Driftice_reloc.o" +#else include "build/data/ovl_Obj_Driftice/ovl_Obj_Driftice.reloc.o" +#endif endseg beginseg name "ovl_En_Look_Nuts" compress include "build/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.data.o" - include "build/data/ovl_En_Look_Nuts/ovl_En_Look_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Look_Nuts/ovl_En_Look_Nuts_reloc.o" endseg beginseg @@ -3109,8 +3041,7 @@ beginseg name "ovl_En_Mm3" compress include "build/src/overlays/actors/ovl_En_Mm3/z_en_mm3.o" - include "build/data/ovl_En_Mm3/ovl_En_Mm3.data.o" - include "build/data/ovl_En_Mm3/ovl_En_Mm3.reloc.o" + include "build/src/overlays/actors/ovl_En_Mm3/ovl_En_Mm3_reloc.o" endseg beginseg @@ -3133,16 +3064,14 @@ beginseg name "ovl_En_Pr2" compress include "build/src/overlays/actors/ovl_En_Pr2/z_en_pr2.o" - include "build/data/ovl_En_Pr2/ovl_En_Pr2.data.o" - include "build/data/ovl_En_Pr2/ovl_En_Pr2.reloc.o" + include "build/src/overlays/actors/ovl_En_Pr2/ovl_En_Pr2_reloc.o" endseg beginseg name "ovl_En_Prz" compress include "build/src/overlays/actors/ovl_En_Prz/z_en_prz.o" - include "build/data/ovl_En_Prz/ovl_En_Prz.data.o" - include "build/data/ovl_En_Prz/ovl_En_Prz.reloc.o" + include "build/src/overlays/actors/ovl_En_Prz/ovl_En_Prz_reloc.o" endseg beginseg @@ -3214,9 +3143,7 @@ beginseg name "ovl_En_Test6" compress include "build/src/overlays/actors/ovl_En_Test6/z_en_test6.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.data.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.bss.o" - include "build/data/ovl_En_Test6/ovl_En_Test6.reloc.o" + include "build/src/overlays/actors/ovl_En_Test6/ovl_En_Test6_reloc.o" endseg beginseg @@ -3262,17 +3189,14 @@ beginseg name "ovl_Dm_Char00" compress include "build/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.o" - include "build/data/ovl_Dm_Char00/ovl_Dm_Char00.data.o" - include "build/data/ovl_Dm_Char00/ovl_Dm_Char00.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char00/ovl_Dm_Char00_reloc.o" endseg beginseg name "ovl_Dm_Char01" compress include "build/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.data.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.bss.o" - include "build/data/ovl_Dm_Char01/ovl_Dm_Char01.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char01/ovl_Dm_Char01_reloc.o" endseg beginseg @@ -3303,8 +3227,7 @@ beginseg name "ovl_Dm_Char05" compress include "build/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.o" - include "build/data/ovl_Dm_Char05/ovl_Dm_Char05.data.o" - include "build/data/ovl_Dm_Char05/ovl_Dm_Char05.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char05/ovl_Dm_Char05_reloc.o" endseg beginseg @@ -3365,16 +3288,18 @@ beginseg name "ovl_En_Guard_Nuts" compress include "build/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.data.o" - include "build/data/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Guard_Nuts/ovl_En_Guard_Nuts_reloc.o" endseg beginseg name "ovl_Bg_Hakugin_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.o" - include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall_reloc.o" +#else include "build/data/ovl_Bg_Hakugin_Bombwall/ovl_Bg_Hakugin_Bombwall.reloc.o" +#endif endseg beginseg @@ -3552,24 +3477,21 @@ beginseg name "ovl_En_Fu_Mato" compress include "build/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.data.o" - include "build/data/ovl_En_Fu_Mato/ovl_En_Fu_Mato.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Mato/ovl_En_Fu_Mato_reloc.o" endseg beginseg name "ovl_En_Fu_Kago" compress include "build/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.data.o" - include "build/data/ovl_En_Fu_Kago/ovl_En_Fu_Kago.reloc.o" + include "build/src/overlays/actors/ovl_En_Fu_Kago/ovl_En_Fu_Kago_reloc.o" endseg beginseg name "ovl_En_Osn" compress include "build/src/overlays/actors/ovl_En_Osn/z_en_osn.o" - include "build/data/ovl_En_Osn/ovl_En_Osn.data.o" - include "build/data/ovl_En_Osn/ovl_En_Osn.reloc.o" + include "build/src/overlays/actors/ovl_En_Osn/ovl_En_Osn_reloc.o" endseg beginseg @@ -3658,8 +3580,7 @@ beginseg name "ovl_En_Tsn" compress include "build/src/overlays/actors/ovl_En_Tsn/z_en_tsn.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.data.o" - include "build/data/ovl_En_Tsn/ovl_En_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Tsn/ovl_En_Tsn_reloc.o" endseg beginseg @@ -3681,8 +3602,7 @@ beginseg name "ovl_En_Shn" compress include "build/src/overlays/actors/ovl_En_Shn/z_en_shn.o" - include "build/data/ovl_En_Shn/ovl_En_Shn.data.o" - include "build/data/ovl_En_Shn/ovl_En_Shn.reloc.o" + include "build/src/overlays/actors/ovl_En_Shn/ovl_En_Shn_reloc.o" endseg beginseg @@ -3697,8 +3617,7 @@ beginseg name "ovl_Obj_Bigicicle" compress include "build/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.data.o" - include "build/data/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Bigicicle/ovl_Obj_Bigicicle_reloc.o" endseg beginseg @@ -3735,9 +3654,7 @@ beginseg name "ovl_En_Test7" compress include "build/src/overlays/actors/ovl_En_Test7/z_en_test7.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.data.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.bss.o" - include "build/data/ovl_En_Test7/ovl_En_Test7.reloc.o" + include "build/src/overlays/actors/ovl_En_Test7/ovl_En_Test7_reloc.o" endseg beginseg @@ -3798,8 +3715,7 @@ beginseg name "ovl_En_Gakufu" compress include "build/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.data.o" - include "build/data/ovl_En_Gakufu/ovl_En_Gakufu.reloc.o" + include "build/src/overlays/actors/ovl_En_Gakufu/ovl_En_Gakufu_reloc.o" endseg beginseg @@ -3843,11 +3759,7 @@ beginseg name "ovl_Obj_Snowball" compress include "build/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.o" -#ifdef NON_MATCHING - include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_obj_Snowball_reloc.o" -#else - include "build/data/ovl_Obj_Snowball/ovl_Obj_Snowball.reloc.o" -#endif + include "build/src/overlays/actors/ovl_Obj_Snowball/ovl_Obj_Snowball_reloc.o" endseg beginseg @@ -3891,25 +3803,21 @@ beginseg name "ovl_Obj_Dhouse" compress include "build/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.o" - include "build/data/ovl_Obj_Dhouse/ovl_Obj_Dhouse.data.o" - include "build/data/ovl_Obj_Dhouse/ovl_Obj_Dhouse.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Dhouse/ovl_Obj_Dhouse_reloc.o" endseg beginseg name "ovl_Obj_Hakaisi" compress include "build/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.o" - include "build/data/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi.data.o" - include "build/data/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hakaisi/ovl_Obj_Hakaisi_reloc.o" endseg beginseg name "ovl_Bg_Hakugin_Switch" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Switch/z_bg_hakugin_switch.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.data.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.bss.o" - include "build/data/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Hakugin_Switch/ovl_Bg_Hakugin_Switch_reloc.o" endseg beginseg @@ -3953,8 +3861,7 @@ beginseg name "ovl_En_Hanabi" compress include "build/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.data.o" - include "build/data/ovl_En_Hanabi/ovl_En_Hanabi.reloc.o" + include "build/src/overlays/actors/ovl_En_Hanabi/ovl_En_Hanabi_reloc.o" endseg beginseg @@ -3976,16 +3883,14 @@ beginseg name "ovl_En_Racedog" compress include "build/src/overlays/actors/ovl_En_Racedog/z_en_racedog.o" - include "build/data/ovl_En_Racedog/ovl_En_Racedog.data.o" - include "build/data/ovl_En_Racedog/ovl_En_Racedog.reloc.o" + include "build/src/overlays/actors/ovl_En_Racedog/ovl_En_Racedog_reloc.o" endseg beginseg name "ovl_En_Kendo_Js" compress include "build/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.o" - include "build/data/ovl_En_Kendo_Js/ovl_En_Kendo_Js.data.o" - include "build/data/ovl_En_Kendo_Js/ovl_En_Kendo_Js.reloc.o" + include "build/src/overlays/actors/ovl_En_Kendo_Js/ovl_En_Kendo_Js_reloc.o" endseg beginseg @@ -4022,56 +3927,53 @@ beginseg name "ovl_Obj_Spidertent" compress include "build/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.o" - include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Spidertent/ovl_Obj_Spidertent_reloc.o" +#else include "build/data/ovl_Obj_Spidertent/ovl_Obj_Spidertent.reloc.o" +#endif endseg beginseg name "ovl_En_Zoraegg" compress include "build/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.o" - include "build/data/ovl_En_Zoraegg/ovl_En_Zoraegg.data.o" - include "build/data/ovl_En_Zoraegg/ovl_En_Zoraegg.reloc.o" + include "build/src/overlays/actors/ovl_En_Zoraegg/ovl_En_Zoraegg_reloc.o" endseg beginseg name "ovl_En_Kbt" compress include "build/src/overlays/actors/ovl_En_Kbt/z_en_kbt.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.data.o" - include "build/data/ovl_En_Kbt/ovl_En_Kbt.reloc.o" + include "build/src/overlays/actors/ovl_En_Kbt/ovl_En_Kbt_reloc.o" endseg beginseg name "ovl_En_Gg" compress include "build/src/overlays/actors/ovl_En_Gg/z_en_gg.o" - include "build/data/ovl_En_Gg/ovl_En_Gg.data.o" - include "build/data/ovl_En_Gg/ovl_En_Gg.reloc.o" + include "build/src/overlays/actors/ovl_En_Gg/ovl_En_Gg_reloc.o" endseg beginseg name "ovl_En_Maruta" compress include "build/src/overlays/actors/ovl_En_Maruta/z_en_maruta.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.data.o" - include "build/data/ovl_En_Maruta/ovl_En_Maruta.reloc.o" + include "build/src/overlays/actors/ovl_En_Maruta/ovl_En_Maruta_reloc.o" endseg beginseg name "ovl_Obj_Snowball2" compress include "build/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.o" - include "build/data/ovl_Obj_Snowball2/ovl_Obj_Snowball2.data.o" - include "build/data/ovl_Obj_Snowball2/ovl_Obj_Snowball2.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Snowball2/ovl_Obj_Snowball2_reloc.o" endseg beginseg name "ovl_En_Gg2" compress include "build/src/overlays/actors/ovl_En_Gg2/z_en_gg2.o" - include "build/data/ovl_En_Gg2/ovl_En_Gg2.data.o" - include "build/data/ovl_En_Gg2/ovl_En_Gg2.reloc.o" + include "build/src/overlays/actors/ovl_En_Gg2/ovl_En_Gg2_reloc.o" endseg beginseg @@ -4120,8 +4022,7 @@ beginseg name "ovl_En_Gk" compress include "build/src/overlays/actors/ovl_En_Gk/z_en_gk.o" - include "build/data/ovl_En_Gk/ovl_En_Gk.data.o" - include "build/data/ovl_En_Gk/ovl_En_Gk.reloc.o" + include "build/src/overlays/actors/ovl_En_Gk/ovl_En_Gk_reloc.o" endseg beginseg @@ -4151,8 +4052,7 @@ beginseg name "ovl_En_Dragon" compress include "build/src/overlays/actors/ovl_En_Dragon/z_en_dragon.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.data.o" - include "build/data/ovl_En_Dragon/ovl_En_Dragon.reloc.o" + include "build/src/overlays/actors/ovl_En_Dragon/ovl_En_Dragon_reloc.o" endseg beginseg @@ -4174,24 +4074,25 @@ beginseg name "ovl_Obj_Kendo_Kanban" compress include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.o" - include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban_reloc.o" +#else include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.reloc.o" +#endif endseg beginseg name "ovl_Obj_Hariko" compress include "build/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.data.o" - include "build/data/ovl_Obj_Hariko/ovl_Obj_Hariko.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hariko/ovl_Obj_Hariko_reloc.o" endseg beginseg name "ovl_En_Sth" compress include "build/src/overlays/actors/ovl_En_Sth/z_en_sth.o" - include "build/data/ovl_En_Sth/ovl_En_Sth.data.o" - include "build/data/ovl_En_Sth/ovl_En_Sth.reloc.o" + include "build/src/overlays/actors/ovl_En_Sth/ovl_En_Sth_reloc.o" endseg beginseg @@ -4251,16 +4152,14 @@ beginseg name "ovl_En_Jg" compress include "build/src/overlays/actors/ovl_En_Jg/z_en_jg.o" - include "build/data/ovl_En_Jg/ovl_En_Jg.data.o" - include "build/data/ovl_En_Jg/ovl_En_Jg.reloc.o" + include "build/src/overlays/actors/ovl_En_Jg/ovl_En_Jg_reloc.o" endseg beginseg name "ovl_En_Tru_Mt" compress include "build/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.data.o" - include "build/data/ovl_En_Tru_Mt/ovl_En_Tru_Mt.reloc.o" + include "build/src/overlays/actors/ovl_En_Tru_Mt/ovl_En_Tru_Mt_reloc.o" endseg beginseg @@ -4275,8 +4174,7 @@ beginseg name "ovl_En_Neo_Reeba" compress include "build/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.data.o" - include "build/data/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba.reloc.o" + include "build/src/overlays/actors/ovl_En_Neo_Reeba/ovl_En_Neo_Reeba_reloc.o" endseg beginseg @@ -4306,25 +4204,21 @@ beginseg name "ovl_Bg_Ikana_Rotaryroom" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.o" - include "build/data/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom.data.o" - include "build/data/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/ovl_Bg_Ikana_Rotaryroom_reloc.o" endseg beginseg name "ovl_Bg_Dblue_Balance" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.data.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.bss.o" - include "build/data/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Balance/ovl_Bg_Dblue_Balance_reloc.o" endseg beginseg name "ovl_Bg_Dblue_Waterfall" compress include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.data.o" - include "build/data/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dblue_Waterfall/ovl_Bg_Dblue_Waterfall_reloc.o" endseg beginseg @@ -4459,9 +4353,7 @@ beginseg name "ovl_Obj_Hunsui" compress include "build/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.data.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.bss.o" - include "build/data/ovl_Obj_Hunsui/ovl_Obj_Hunsui.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hunsui/ovl_Obj_Hunsui_reloc.o" endseg beginseg @@ -4475,24 +4367,25 @@ beginseg name "ovl_Mir_Ray3" compress include "build/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.o" - include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.data.o" +#ifdef NON_MATCHING + include "build/src/overlays/actors/ovl_Mir_Ray3/ovl_Mir_Ray3_reloc.o" +#else include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.reloc.o" +#endif endseg beginseg name "ovl_En_Zob" compress include "build/src/overlays/actors/ovl_En_Zob/z_en_zob.o" - include "build/data/ovl_En_Zob/ovl_En_Zob.data.o" - include "build/data/ovl_En_Zob/ovl_En_Zob.reloc.o" + include "build/src/overlays/actors/ovl_En_Zob/ovl_En_Zob_reloc.o" endseg beginseg name "ovl_Elf_Msg6" compress include "build/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.data.o" - include "build/data/ovl_Elf_Msg6/ovl_Elf_Msg6.reloc.o" + include "build/src/overlays/actors/ovl_Elf_Msg6/ovl_Elf_Msg6_reloc.o" endseg beginseg @@ -4522,8 +4415,7 @@ beginseg name "ovl_En_Baba" compress include "build/src/overlays/actors/ovl_En_Baba/z_en_baba.o" - include "build/data/ovl_En_Baba/ovl_En_Baba.data.o" - include "build/data/ovl_En_Baba/ovl_En_Baba.reloc.o" + include "build/src/overlays/actors/ovl_En_Baba/ovl_En_Baba_reloc.o" endseg beginseg @@ -4545,8 +4437,7 @@ beginseg name "ovl_En_Kujiya" compress include "build/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.data.o" - include "build/data/ovl_En_Kujiya/ovl_En_Kujiya.reloc.o" + include "build/src/overlays/actors/ovl_En_Kujiya/ovl_En_Kujiya_reloc.o" endseg beginseg @@ -4560,33 +4451,28 @@ beginseg name "ovl_Obj_Kinoko" compress include "build/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.o" - include "build/data/ovl_Obj_Kinoko/ovl_Obj_Kinoko.data.o" - include "build/data/ovl_Obj_Kinoko/ovl_Obj_Kinoko.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Kinoko/ovl_Obj_Kinoko_reloc.o" endseg beginseg name "ovl_Obj_Yasi" compress include "build/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.data.o" - include "build/data/ovl_Obj_Yasi/ovl_Obj_Yasi.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Yasi/ovl_Obj_Yasi_reloc.o" endseg beginseg name "ovl_En_Tanron1" compress include "build/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.data.o" - include "build/data/ovl_En_Tanron1/ovl_En_Tanron1.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron1/ovl_En_Tanron1_reloc.o" endseg beginseg name "ovl_En_Tanron2" compress include "build/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.data.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.bss.o" - include "build/data/ovl_En_Tanron2/ovl_En_Tanron2.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron2/ovl_En_Tanron2_reloc.o" endseg beginseg @@ -4600,9 +4486,7 @@ beginseg name "ovl_Obj_Chan" compress include "build/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.data.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.bss.o" - include "build/data/ovl_Obj_Chan/ovl_Obj_Chan.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Chan/ovl_Obj_Chan_reloc.o" endseg beginseg @@ -4632,25 +4516,21 @@ beginseg name "ovl_En_Ja" compress include "build/src/overlays/actors/ovl_En_Ja/z_en_ja.o" - include "build/data/ovl_En_Ja/ovl_En_Ja.data.o" - include "build/data/ovl_En_Ja/ovl_En_Ja.reloc.o" + include "build/src/overlays/actors/ovl_En_Ja/ovl_En_Ja_reloc.o" endseg beginseg name "ovl_Bg_F40_Block" compress include "build/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.data.o" - include "build/data/ovl_Bg_F40_Block/ovl_Bg_F40_Block.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Block/ovl_Bg_F40_Block_reloc.o" endseg beginseg name "ovl_Bg_F40_Switch" compress include "build/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.data.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.bss.o" - include "build/data/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Switch/ovl_Bg_F40_Switch_reloc.o" endseg beginseg @@ -4689,8 +4569,7 @@ beginseg name "ovl_Oceff_Wipe6" compress include "build/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.data.o" - include "build/data/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6_reloc.o" endseg beginseg @@ -4744,16 +4623,14 @@ beginseg name "ovl_En_Zov" compress include "build/src/overlays/actors/ovl_En_Zov/z_en_zov.o" - include "build/data/ovl_En_Zov/ovl_En_Zov.data.o" - include "build/data/ovl_En_Zov/ovl_En_Zov.reloc.o" + include "build/src/overlays/actors/ovl_En_Zov/ovl_En_Zov_reloc.o" endseg beginseg name "ovl_En_Ah" compress include "build/src/overlays/actors/ovl_En_Ah/z_en_ah.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.data.o" - include "build/data/ovl_En_Ah/ovl_En_Ah.reloc.o" + include "build/src/overlays/actors/ovl_En_Ah/ovl_En_Ah_reloc.o" endseg beginseg @@ -4841,16 +4718,14 @@ beginseg name "ovl_En_Hidden_Nuts" compress include "build/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.data.o" - include "build/data/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Hidden_Nuts/ovl_En_Hidden_Nuts_reloc.o" endseg beginseg name "ovl_En_Zow" compress include "build/src/overlays/actors/ovl_En_Zow/z_en_zow.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.data.o" - include "build/data/ovl_En_Zow/ovl_En_Zow.reloc.o" + include "build/src/overlays/actors/ovl_En_Zow/ovl_En_Zow_reloc.o" endseg beginseg @@ -4864,16 +4739,14 @@ beginseg name "ovl_En_Al" compress include "build/src/overlays/actors/ovl_En_Al/z_en_al.o" - include "build/data/ovl_En_Al/ovl_En_Al.data.o" - include "build/data/ovl_En_Al/ovl_En_Al.reloc.o" + include "build/src/overlays/actors/ovl_En_Al/ovl_En_Al_reloc.o" endseg beginseg name "ovl_En_Tab" compress include "build/src/overlays/actors/ovl_En_Tab/z_en_tab.o" - include "build/data/ovl_En_Tab/ovl_En_Tab.data.o" - include "build/data/ovl_En_Tab/ovl_En_Tab.reloc.o" + include "build/src/overlays/actors/ovl_En_Tab/ovl_En_Tab_reloc.o" endseg beginseg @@ -4902,16 +4775,14 @@ beginseg name "ovl_En_Tanron4" compress include "build/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.data.o" - include "build/data/ovl_En_Tanron4/ovl_En_Tanron4.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron4/ovl_En_Tanron4_reloc.o" endseg beginseg name "ovl_En_Tanron5" compress include "build/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.data.o" - include "build/data/ovl_En_Tanron5/ovl_En_Tanron5.reloc.o" + include "build/src/overlays/actors/ovl_En_Tanron5/ovl_En_Tanron5_reloc.o" endseg beginseg @@ -4946,16 +4817,14 @@ beginseg name "ovl_En_Heishi" compress include "build/src/overlays/actors/ovl_En_Heishi/z_en_heishi.o" - include "build/data/ovl_En_Heishi/ovl_En_Heishi.data.o" - include "build/data/ovl_En_Heishi/ovl_En_Heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Heishi/ovl_En_Heishi_reloc.o" endseg beginseg name "ovl_En_Demo_heishi" compress include "build/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.data.o" - include "build/data/ovl_En_Demo_heishi/ovl_En_Demo_heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Demo_heishi/ovl_En_Demo_heishi_reloc.o" endseg beginseg @@ -5034,8 +4903,7 @@ beginseg name "ovl_En_Osk" compress include "build/src/overlays/actors/ovl_En_Osk/z_en_osk.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.data.o" - include "build/data/ovl_En_Osk/ovl_En_Osk.reloc.o" + include "build/src/overlays/actors/ovl_En_Osk/ovl_En_Osk_reloc.o" endseg beginseg @@ -5050,8 +4918,7 @@ beginseg name "ovl_En_Yb" compress include "build/src/overlays/actors/ovl_En_Yb/z_en_yb.o" - include "build/data/ovl_En_Yb/ovl_En_Yb.data.o" - include "build/data/ovl_En_Yb/ovl_En_Yb.reloc.o" + include "build/src/overlays/actors/ovl_En_Yb/ovl_En_Yb_reloc.o" endseg beginseg @@ -5081,7 +4948,7 @@ beginseg name "ovl_En_Bomjima" compress include "build/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.o" - include "build/data/ovl_En_Bomjima/ovl_En_Bomjima.reloc.o" + include "build/src/overlays/actors/ovl_En_Bomjima/ovl_En_Bomjima_reloc.o" endseg beginseg @@ -5095,16 +4962,14 @@ beginseg name "ovl_En_Bombers" compress include "build/src/overlays/actors/ovl_En_Bombers/z_en_bombers.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.data.o" - include "build/data/ovl_En_Bombers/ovl_En_Bombers.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers/ovl_En_Bombers_reloc.o" endseg beginseg name "ovl_En_Bombers2" compress include "build/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.data.o" - include "build/data/ovl_En_Bombers2/ovl_En_Bombers2.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombers2/ovl_En_Bombers2_reloc.o" endseg beginseg @@ -5230,8 +5095,7 @@ beginseg name "ovl_En_Jgame_Tsn" compress include "build/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.data.o" - include "build/data/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn.reloc.o" + include "build/src/overlays/actors/ovl_En_Jgame_Tsn/ovl_En_Jgame_Tsn_reloc.o" endseg beginseg @@ -5253,8 +5117,7 @@ beginseg name "ovl_Demo_Syoten" compress include "build/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.data.o" - include "build/data/ovl_Demo_Syoten/ovl_Demo_Syoten.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Syoten/ovl_Demo_Syoten_reloc.o" endseg beginseg @@ -5325,8 +5188,7 @@ beginseg name "ovl_Dm_An" compress include "build/src/overlays/actors/ovl_Dm_An/z_dm_an.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.data.o" - include "build/data/ovl_Dm_An/ovl_Dm_An.reloc.o" + include "build/src/overlays/actors/ovl_Dm_An/ovl_Dm_An_reloc.o" endseg beginseg @@ -5348,8 +5210,7 @@ beginseg name "ovl_En_Drs" compress include "build/src/overlays/actors/ovl_En_Drs/z_en_drs.o" - include "build/data/ovl_En_Drs/ovl_En_Drs.data.o" - include "build/data/ovl_En_Drs/ovl_En_Drs.reloc.o" + include "build/src/overlays/actors/ovl_En_Drs/ovl_En_Drs_reloc.o" endseg beginseg @@ -5437,8 +5298,7 @@ beginseg name "ovl_Dm_Gm" compress include "build/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.data.o" - include "build/data/ovl_Dm_Gm/ovl_Dm_Gm.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Gm/ovl_Dm_Gm_reloc.o" endseg beginseg diff --git a/src/boot_O2/boot_800862E0.c b/src/boot_O2/boot_800862E0.c index 1055dfe1b..5774af9da 100644 --- a/src/boot_O2/boot_800862E0.c +++ b/src/boot_O2/boot_800862E0.c @@ -1,18 +1,116 @@ #include "global.h" -#include "os_malloc.h" +#include "system_malloc.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s") +typedef void (*BlockFunc)(void*); +typedef void (*BlockFunc1)(void*, u32); +typedef void (*BlockFunc8)(void*, u32, u32, u32, u32, u32, u32, u32, u32); -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s") +typedef struct InitFunc { + uintptr_t nextOffset; + void (*func)(void); +} InitFunc; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008633C.s") +void* sInitFuncs = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800863AC.s") +char sNew[] = { 0x00, 0x00, 0x00, 0x00 }; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_8008641C.s") +char D_80097508[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x00, 0x00, + 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, +}; -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_800864EC.s") +void* SystemArena_MallocMin1(size_t size) { + if (size == 0) { + size = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/func_80086588.s") + return __osMalloc(&gSystemArena, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s") +void SystemArena_FreeNullCheck(void* ptr) { + if (ptr != NULL) { + __osFree(&gSystemArena, ptr); + } +} + +void SystemArena_RunBlockFunc(void* blk, size_t nBlk, size_t blkSize, BlockFunc blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos); + } +} + +void SystemArena_RunBlockFunc1(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 2); + } +} + +void* SystemArena_RunBlockFunc8(void* blk, size_t nBlk, size_t blkSize, BlockFunc8 blockFunc) { + if (blk == NULL) { + blk = SystemArena_MallocMin1(nBlk * blkSize); + } + + if (blk != NULL && blockFunc != NULL) { + uintptr_t pos = blk; + + for (; pos < (uintptr_t)blk + (nBlk * blkSize); pos += (blkSize & ~0)) { + blockFunc(pos, 0, 0, 0, 0, 0, 0, 0, 0); + } + } + + return blk; +} + +void SystemArena_RunBlockFunc1Reverse(void* blk, size_t nBlk, size_t blkSize, BlockFunc1 blockFunc, s32 shouldFree) { + uintptr_t pos; + uintptr_t start; + size_t maskedBlkSize; + + if (blk == NULL) { + return; + } + + if (blockFunc != NULL) { + start = blk; + maskedBlkSize = (blkSize & ~0); + pos = (uintptr_t)start + (nBlk * blkSize); + + while (pos > start) { + pos -= maskedBlkSize; + blockFunc(pos, 2); + } + } + + if (shouldFree) { + SystemArena_FreeNullCheck(blk); + } +} + +void SystemArena_RunInits(void) { + InitFunc* initFunc = (InitFunc*)&sInitFuncs; + u32 nextOffset = initFunc->nextOffset; + InitFunc* prev = NULL; + + while (nextOffset != 0) { + initFunc = (InitFunc*)((uintptr_t)initFunc + nextOffset); + + if (initFunc->func != NULL) { + (*initFunc->func)(); + } + + nextOffset = initFunc->nextOffset; + initFunc->nextOffset = (uintptr_t)prev; + prev = initFunc; + } + + sInitFuncs = prev; +} + +void SystemArena_Init(void* start, size_t size) { + SystemArena_InitArena(start, size); + SystemArena_RunInits(); +} diff --git a/src/boot_O2_g3/CIC6105.c b/src/boot_O2_g3/CIC6105.c index 4745ad5c8..78eed1a77 100644 --- a/src/boot_O2_g3/CIC6105.c +++ b/src/boot_O2_g3/CIC6105.c @@ -1,4 +1,3 @@ -#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 87bee5da4..04bb9a33a 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" StackEntry sBootThreadInfo; diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index da93f13fd..942435fa7 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/boot_O2_g3/idle_extra_bss.c b/src/boot_O2_g3/idle_extra_bss.c index 7afa57250..24fc0083f 100644 --- a/src/boot_O2_g3/idle_extra_bss.c +++ b/src/boot_O2_g3/idle_extra_bss.c @@ -1,5 +1,5 @@ -#include "prevent_bss_reordering.h" -#include "global.h" +#include "PR/ultratypes.h" +#include "ultra64/vi.h" // This file is currently required to fix bss reordering in idle.c. It is not resolved by prevent_bss_reordering.h . // Hopefully it will not be permanent. diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 5fb32b8ea..80d819acc 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]; @@ -18,7 +17,7 @@ void* Yaz0_FirstDMA() { curSize = (u32)sYaz0CurDataEnd - (u32)sYaz0DataBuffer; dmaSize = (curSize > sYaz0CurSize) ? sYaz0CurSize : curSize; - DmaMgr_DMARomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; return sYaz0DataBuffer; @@ -41,7 +40,7 @@ void* Yaz0_NextDMA(void* curSrcPos) { } if (dmaSize != 0) { - DmaMgr_DMARomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); + DmaMgr_DmaRomToRam(sYaz0CurRomStart, dst + restSize, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; if (!sYaz0CurSize) { diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 9edc65e52..10d84dcb0 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -10,7 +10,7 @@ OSMesg sDmaMgrMsgs[32]; OSThread sDmaMgrThread; u8 sDmaMgrStack[0x500]; -s32 DmaMgr_DMARomToRam(uintptr_t rom, void* ram, size_t size) { +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg[1]; @@ -56,8 +56,8 @@ END: return ret; } -void DmaMgr_DmaCallback0(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { - osEPiStartDma(pihandle, mb, direction); +s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { + return osEPiStartDma(pihandle, mb, direction); } DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { @@ -130,7 +130,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { if (dmaEntry->vromEnd < (vrom + size)) { Fault_AddHungupAndCrash("../z_std_dma.c", 499); } - DmaMgr_DMARomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); + DmaMgr_DmaRomToRam((dmaEntry->romStart + vrom) - dmaEntry->vromStart, (u8*)ram, size); return; } @@ -211,7 +211,7 @@ s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size) { } void DmaMgr_Start(void) { - DmaMgr_DMARomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); + DmaMgr_DmaRomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); { DmaEntry* iter = dmadata; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index b3d83c1f9..b06f6a577 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -1,111 +1,1687 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B0F0.s") +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize); +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry); +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample); +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size); +void AudioHeap_DiscardSampleCaches(void); +void AudioHeap_DiscardSampleBank(s32 sampleBankId); +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId); +void AudioHeap_DiscardSampleBanks(void); +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B10C.s") +#define gTatumsPerBeat (gAudioTatumInit[1]) -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B250.s") +f32 func_8018B0F0(f32 arg0) { + return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B318.s") +void func_8018B10C(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B3FC.s") + gAudioContext.unk_3520[255] = func_8018B0F0(0.25f); + gAudioContext.unk_3520[254] = func_8018B0F0(0.33f); + gAudioContext.unk_3520[253] = func_8018B0F0(0.5f); + gAudioContext.unk_3520[252] = func_8018B0F0(0.66f); + gAudioContext.unk_3520[251] = func_8018B0F0(0.75f); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B474.s") + for (i = 128; i < 251; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(251 - i); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B4F8.s") + for (i = 16; i < 128; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B520.s") + for (i = 1; i < 16; i++) { + gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i)); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B578.s") + gAudioContext.unk_3520[0] = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s") +void AudioHeap_ResetLoadStatus(void) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B608.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.fontLoadStatus); i++) { + if (gAudioContext.fontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.fontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B640.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.sampleFontLoadStatus); i++) { + if (gAudioContext.sampleFontLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[i] = LOAD_STATUS_0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B69C.s") + for (i = 0; i < ARRAY_COUNT(gAudioContext.seqLoadStatus); i++) { + if (gAudioContext.seqLoadStatus[i] != LOAD_STATUS_5) { + gAudioContext.seqLoadStatus[i] = LOAD_STATUS_0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B6E8.s") +void AudioHeap_DiscardFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B740.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B768.s") + if (note->playbackState.fontId == fontId) { + if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) { + note->playbackState.parentLayer->enabled = false; + note->playbackState.parentLayer->finished = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B77C.s") + AudioPlayback_NoteDisable(note); + AudioPlayback_AudioListRemove(¬e->listItem); + AudioSeq_AudioListPushBack(&gAudioContext.noteFreeLists.disabled, ¬e->listItem); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7AC.s") +void AudioHeap_ReleaseNotesForFont(s32 fontId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B7BC.s") + for (i = 0; i < gAudioContext.numNotes; i++) { + Note* note = &gAudioContext.notes[i]; + NotePlaybackState* playbackState = ¬e->playbackState; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B8FC.s") + if (playbackState->fontId == fontId) { + if (playbackState->priority != 0) { + playbackState->priority = 1; + playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + playbackState->adsr.action.s.release = true; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B95C.s") +void AudioHeap_DiscardSequence(s32 seqId) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018B9E0.s") + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == seqId) { + AudioSeq_SequencePlayerDisable(&gAudioContext.seqPlayers[i]); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BA64.s") +/** + * Perform a writeback from the L1 data cache to the ram. + */ +void* AudioHeap_WritebackDCache(void* addr, size_t size) { + Audio_WritebackDCache(addr, size); + if (addr) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BB28.s") + // KSEG0 to KSEG1 (ensures data is written straight to ram instead of the data cache) + return OS_PHYSICAL_TO_K1(OS_K0_TO_PHYSICAL(addr)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018BBEC.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument. + * Afterwards, zero all data pool the new allocated space + */ +void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C380.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_AllocZeroed(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C3D8.s") + if (addr == NULL) { + addr = AudioHeap_AllocZeroed(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C4E4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8B8.s") +/** + * Attempt to allocated space on an external device. If no external device is available, + * then allocate space on the pool provided in the argument + */ +void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size) { + void* addr = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C8E8.s") + if (gAudioContext.externalPool.startAddr != NULL) { + addr = AudioHeap_Alloc(&gAudioContext.externalPool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C93C.s") + if (addr == NULL) { + addr = AudioHeap_Alloc(pool, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018C994.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB70.s") +void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CB78.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CC3C.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CCA8.s") +void* AudioHeap_AllocDmaMemoryZeroed(AudioAllocPool* pool, size_t size) { + void* addr = AudioHeap_AllocZeroed(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018CFAC.s") + if (addr != NULL) { + addr = AudioHeap_WritebackDCache(addr, size); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D57C.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D5D4.s") +/** + * Allocates space on a pool contained withing the heap and sets all the allocated space to 0 + */ +void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size) { + u8* addr = AudioHeap_Alloc(pool, size); + u8* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D658.s") + if (addr != NULL) { + for (ptr = addr; ptr < pool->curAddr; ptr++) { + *ptr = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D6C8.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018D760.s") +/** + * Tests the pool to see if the requested allocation would fit without actually allocating space. + * Returns NULL if there is not enough space on the pool. + * Else, return the address that would have been allocated + */ +void* AudioHeap_TestAlloc(AudioAllocPool* pool, size_t size) { + u8* oldAddr = pool->curAddr; + void* addr = AudioHeap_Alloc(pool, size); -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DA50.s") + // remove allocation from pool + if (addr != NULL) { + pool->curAddr = oldAddr; + pool->count--; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DBC4.s") + return addr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCB4.s") +/** + * Allocates space on the pool contained withing the heap. If there is not enough space on the pool, return NULL + */ +void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size) { + size_t alignedSize = ALIGN16(size); + u8* curAddr = pool->curAddr; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DCF8.s") + if ((pool->startAddr + pool->size) >= (pool->curAddr + alignedSize)) { + pool->curAddr += alignedSize; + } else { + return NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DD98.s") + pool->count++; + return curAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DDD4.s") +/** + * Initialize a pool at the requested address with the requested size. + * Store the metadata of this pool in AudioAllocPool* pool + */ +void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size) { + pool->curAddr = pool->startAddr = (u8*)ALIGN16((uintptr_t)addr); + pool->size = size - ((uintptr_t)addr & 0xF); + pool->count = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DF24.s") +void AudioHeap_ClearPersistentCache(AudioPersistentCache* persistent) { + persistent->pool.count = 0; + persistent->numEntries = 0; + persistent->pool.curAddr = persistent->pool.startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018DFE0.s") +void AudioHeap_ClearTemporaryCache(AudioTemporaryCache* temporary) { + temporary->pool.count = 0; + temporary->pool.curAddr = temporary->pool.startAddr; + temporary->nextSide = 0; + temporary->entries[0].addr = temporary->pool.startAddr; + temporary->entries[1].addr = temporary->pool.startAddr + temporary->pool.size; + temporary->entries[0].id = -1; + temporary->entries[1].id = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E00C.s") +void AudioHeap_ResetPool(AudioAllocPool* pool) { + pool->count = 0; + pool->curAddr = pool->startAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E03C.s") +void AudioHeap_PopCache(s32 tableType) { + AudioCache* loadedCache; + AudioAllocPool* persistentHeap; + AudioPersistentCache* persistent; + void* entryAddr; + u8* loadStatus; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E2A8.s") + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E344.s") + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_8018E8C8.s") + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + persistent = &loadedCache->persistent; + persistentHeap = &persistent->pool; + + if (persistent->numEntries == 0) { + return; + } + + entryAddr = persistent->entries[persistent->numEntries - 1].addr; + persistentHeap->curAddr = entryAddr; + persistentHeap->count--; + + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(persistent->entries[persistent->numEntries - 1].id); + } + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(persistent->entries[persistent->numEntries - 1].id); + } + + loadStatus[persistent->entries[persistent->numEntries - 1].id] = LOAD_STATUS_0; + persistent->numEntries--; +} + +void AudioHeap_InitMainPool(size_t mainPoolSplitSize) { + AudioHeap_AllocPoolInit(&gAudioContext.audioInitPool, gAudioContext.audioHeap, mainPoolSplitSize); + AudioHeap_AllocPoolInit(&gAudioContext.audioSessionPool, gAudioContext.audioHeap + mainPoolSplitSize, + gAudioContext.audioHeapSize - mainPoolSplitSize); + + gAudioContext.externalPool.startAddr = NULL; +} + +void AudioHeap_InitSessionPool(AudioSessionPoolSplit* split) { + gAudioContext.audioSessionPool.curAddr = gAudioContext.audioSessionPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.miscPool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->miscPoolSize), split->miscPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.cachePool, + AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->cachePoolSize), + split->cachePoolSize); +} + +void AudioHeap_InitCachePool(AudioCachePoolSplit* split) { + gAudioContext.cachePool.curAddr = gAudioContext.cachePool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.persistentCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize), + split->persistentCommonPoolSize); + AudioHeap_AllocPoolInit(&gAudioContext.temporaryCommonPool, + AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize), + split->temporaryCommonPoolSize); +} + +void AudioHeap_InitPersistentCache(AudioCommonPoolSplit* split) { + gAudioContext.persistentCommonPool.curAddr = gAudioContext.persistentCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.persistent.pool, + AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearPersistentCache(&gAudioContext.seqCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.fontCache.persistent); + AudioHeap_ClearPersistentCache(&gAudioContext.sampleBankCache.persistent); +} + +void AudioHeap_InitTemporaryCache(AudioCommonPoolSplit* split) { + gAudioContext.temporaryCommonPool.curAddr = gAudioContext.temporaryCommonPool.startAddr; + + AudioHeap_AllocPoolInit(&gAudioContext.seqCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize), + split->seqCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.fontCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize), + split->fontCacheSize); + AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.temporary.pool, + AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); + + AudioHeap_ClearTemporaryCache(&gAudioContext.seqCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.fontCache.temporary); + AudioHeap_ClearTemporaryCache(&gAudioContext.sampleBankCache.temporary); +} + +void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { + AudioCache* loadedCache; + AudioTemporaryCache* temporaryCache; + AudioAllocPool* temporaryPool; + void* persistentAddr; + void* temporaryAddr; + u8 loadStatusEntry0; + u8 loadStatusEntry1; + s32 i; + u8* loadStatus; + s32 side; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + loadStatus = gAudioContext.seqLoadStatus; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + loadStatus = gAudioContext.fontLoadStatus; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + loadStatus = gAudioContext.sampleFontLoadStatus; + break; + } + + if (cache == CACHE_TEMPORARY) { + temporaryCache = &loadedCache->temporary; + temporaryPool = &temporaryCache->pool; + + if ((s32)temporaryPool->size < (s32)size) { + return NULL; + } + + loadStatusEntry0 = + (temporaryCache->entries[0].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[0].id]; + loadStatusEntry1 = + (temporaryCache->entries[1].id == -1) ? LOAD_STATUS_0 : loadStatus[temporaryCache->entries[1].id]; + + if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3); + loadStatusEntry0 = LOAD_STATUS_3; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_4) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + + if (i == gAudioContext.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3); + loadStatusEntry1 = LOAD_STATUS_3; + } + } + } + + if (loadStatusEntry0 == LOAD_STATUS_0) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_0) { + temporaryCache->nextSide = 1; + } else if ((loadStatusEntry0 == LOAD_STATUS_3) && (loadStatusEntry1 == LOAD_STATUS_3)) { + // Use the opposite side from last time. + } else if (loadStatusEntry0 == LOAD_STATUS_3) { + temporaryCache->nextSide = 0; + } else if (loadStatusEntry1 == LOAD_STATUS_3) { + temporaryCache->nextSide = 1; + } else { + // Check if there is a side which isn't in active use, if so, evict that one. + if (tableType == SEQUENCE_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioContext.seqPlayers[i].enabled && + gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) { + break; + } + } + + if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + temporaryCache->nextSide = 1; + goto done; + } + } + } else if (tableType == FONT_TABLE) { + if (loadStatusEntry0 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 0; + goto done; + } + } + + if (loadStatusEntry1 == LOAD_STATUS_2) { + for (i = 0; i < gAudioContext.numNotes; i++) { + if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + break; + } + } + if (i == gAudioContext.numNotes) { + temporaryCache->nextSide = 1; + goto done; + } + } + } + + // No such luck. Evict the side that wasn't chosen last time, except + // if it is being loaded into. + if (temporaryCache->nextSide == 0) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + if (loadStatusEntry1 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 1; + } + } else { + if (loadStatusEntry1 == LOAD_STATUS_1) { + if (loadStatusEntry0 == LOAD_STATUS_1) { + goto fail; + } + temporaryCache->nextSide = 0; + } + } + + if (0) { + fail: + // Both sides are being loaded into. + return NULL; + } + } + done: + + side = temporaryCache->nextSide; + + if (temporaryCache->entries[side].id != -1) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[side].id); + } + + loadStatus[temporaryCache->entries[side].id] = LOAD_STATUS_0; + + if (tableType == FONT_TABLE) { + AudioHeap_DiscardFont(temporaryCache->entries[side].id); + } + } + + switch (side) { + case 0: + temporaryCache->entries[0].addr = temporaryPool->startAddr; + temporaryCache->entries[0].id = id; + temporaryCache->entries[0].size = size; + temporaryPool->curAddr = temporaryPool->startAddr + size; + + if ((temporaryCache->entries[1].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[1].id); + } + + loadStatus[temporaryCache->entries[1].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence((s32)temporaryCache->entries[1].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont((s32)temporaryCache->entries[1].id); + break; + } + + temporaryCache->entries[1].id = -1; + temporaryCache->entries[1].addr = temporaryPool->startAddr + temporaryPool->size; + } + + temporaryAddr = temporaryCache->entries[0].addr; + break; + + case 1: + temporaryCache->entries[1].addr = + (u8*)((uintptr_t)(temporaryPool->startAddr + temporaryPool->size - size) & ~0xF); + temporaryCache->entries[1].id = id; + temporaryCache->entries[1].size = size; + if ((temporaryCache->entries[0].id != -1) && + (temporaryCache->entries[1].addr < temporaryPool->curAddr)) { + if (tableType == SAMPLE_TABLE) { + AudioHeap_DiscardSampleBank(temporaryCache->entries[0].id); + } + + loadStatus[temporaryCache->entries[0].id] = LOAD_STATUS_0; + + switch (tableType) { + case SEQUENCE_TABLE: + AudioHeap_DiscardSequence(temporaryCache->entries[0].id); + break; + + case FONT_TABLE: + AudioHeap_DiscardFont(temporaryCache->entries[0].id); + break; + } + + temporaryCache->entries[0].id = -1; + temporaryPool->curAddr = temporaryPool->startAddr; + } + + temporaryAddr = temporaryCache->entries[1].addr; + break; + + default: + return NULL; + } + + temporaryCache->nextSide ^= 1; + return temporaryAddr; + } + + persistentAddr = AudioHeap_Alloc(&loadedCache->persistent.pool, size); + loadedCache->persistent.entries[loadedCache->persistent.numEntries].addr = persistentAddr; + + if (persistentAddr == NULL) { + switch (cache) { + case CACHE_EITHER: + return AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, id); + + case CACHE_TEMPORARY: + case CACHE_PERSISTENT: + return NULL; + } + } + + loadedCache->persistent.entries[loadedCache->persistent.numEntries].id = id; + loadedCache->persistent.entries[loadedCache->persistent.numEntries].size = size; + + return loadedCache->persistent.entries[loadedCache->persistent.numEntries++].addr; +} + +void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id) { + void* addr; + + // Always search the permanent cache in addition to the regular ones. + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + if (cache == CACHE_PERMANENT) { + return NULL; + } + return AudioHeap_SearchRegularCaches(tableType, cache, id); +} + +void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id) { + u32 i; + AudioCache* loadedCache; + AudioTemporaryCache* temporary; + AudioPersistentCache* persistent; + + switch (tableType) { + case SEQUENCE_TABLE: + loadedCache = &gAudioContext.seqCache; + break; + + case FONT_TABLE: + loadedCache = &gAudioContext.fontCache; + break; + + case SAMPLE_TABLE: + loadedCache = &gAudioContext.sampleBankCache; + break; + } + + temporary = &loadedCache->temporary; + + if (cache == CACHE_TEMPORARY) { + if (temporary->entries[0].id == id) { + temporary->nextSide = 1; + return temporary->entries[0].addr; + } else if (temporary->entries[1].id == id) { + temporary->nextSide = 0; + return temporary->entries[1].addr; + } else { + return NULL; + } + } + + persistent = &loadedCache->persistent; + + for (i = 0; i < persistent->numEntries; i++) { + if (persistent->entries[i].id == id) { + return persistent->entries[i].addr; + } + } + + if (cache == CACHE_EITHER) { + return AudioHeap_SearchCaches(tableType, CACHE_TEMPORARY, id); + } + return NULL; +} + +void func_8018C4E4(f32 p, f32 q, u16* out) { + // With the bug below fixed, this mysterious unused function computes two recurrences + // out[0..7] = a_i, out[8..15] = b_i, where + // a_{-2} = b_{-1} = 262159 = 2^18 + 15 + // a_{-1} = b_{-2} = 0 + // a_i = q * a_{i-1} + p * a_{i-2} + // b_i = q * b_{i-1} + p * b_{i-2} + // These grow exponentially if p < -1 or p + |q| > 1. + s32 i; + f32 tmp[16]; + + tmp[0] = (f32)(q * 262159.0f); + tmp[8] = (f32)(p * 262159.0f); + tmp[1] = (f32)((q * p) * 262159.0f); + tmp[9] = (f32)(((p * p) + q) * 262159.0f); + + for (i = 2; i < 8; i++) { + //! @bug value should be stored to tmp[i] and tmp[8 + i], otherwise we read + //! garbage in later loop iterations. + out[i] = q * tmp[i - 2] + p * tmp[i - 1]; + out[8 + i] = q * tmp[6 + i] + p * tmp[7 + i]; + } + + for (i = 0; i < 16; i++) { + out[i] = tmp[i]; + } +} + +void AudioHeap_ClearFilter(s16* filter) { + s32 i; + + for (i = 0; i < 8; i++) { + filter[i] = 0; + } +} + +void AudioHeap_LoadLowPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gLowPassFilterData[8 * cutoff]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadHighPassFilter(s16* filter, s32 cutoff) { + s32 i; + s16* ptr = &gHighPassFilterData[8 * (cutoff - 1)]; + + for (i = 0; i < 8; i++) { + filter[i] = ptr[i]; + } +} + +void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) { + s32 i; + s32 j; + s32 k; + s32 cutOff; + + //! @bug filter is never set if (lowPassCutoff == highPassCutoff) and does not equal 0 + if (lowPassCutoff == 0 && highPassCutoff == 0) { + // Identity filter + AudioHeap_LoadLowPassFilter(filter, 0); + } else if (highPassCutoff == 0) { + AudioHeap_LoadLowPassFilter(filter, lowPassCutoff); + } else if (lowPassCutoff == 0) { + AudioHeap_LoadHighPassFilter(filter, highPassCutoff); + } else { + k = 0; + j = 14; + + cutOff = lowPassCutoff; + if (lowPassCutoff < highPassCutoff) { + + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += highPassCutoff - lowPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandStopFilterData[8 * k + i]; + filter[i] = gBandStopFilterData[k + i]; + } + } else if (highPassCutoff < lowPassCutoff) { + + cutOff = highPassCutoff; + for (i = 1; i < cutOff; i++) { + k += j; + j--; + } + + k += lowPassCutoff - highPassCutoff - 1; + for (i = 0; i < 8; i++) { + //! @bug should be gBandPassFilterData[8 * k + i]; + filter[i] = gBandPassFilterData[k + i]; + } + } + } +} + +void AudioHeap_UpdateReverb(SynthesisReverb* reverb) { +} + +void AudioHeap_UpdateReverbs(void) { + s32 count; + s32 i; + s32 j; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + for (j = 0; j < count; j++) { + AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[i]); + } + } +} + +/** + * Clear the Audio Interface Buffers + */ +void AudioHeap_ClearAiBuffers(void) { + s32 curAiBuffferIndex = gAudioContext.curAiBuffferIndex; + s32 i; + + gAudioContext.aiBufLengths[curAiBuffferIndex] = gAudioContext.audioBufferParameters.minAiBufferLength; + + for (i = 0; i < AIBUF_LEN; i++) { + gAudioContext.aiBuffers[curAiBuffferIndex][i] = 0; + } +} + +s32 AudioHeap_ResetStep(void) { + s32 i; + s32 j; + s32 count; + + if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + count = 2; + } else { + count = 1; + } + + switch (gAudioContext.resetStatus) { + case 5: + for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_SequencePlayerDisableAsFinished(&gAudioContext.seqPlayers[i]); + } + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + break; + + case 4: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + for (i = 0; i < gAudioContext.numNotes; i++) { + if (gAudioContext.notes[i].noteSubEu.bitField0.enabled && + gAudioContext.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { + gAudioContext.notes[i].playbackState.adsr.fadeOutVel = + gAudioContext.audioBufferParameters.updatesPerFrameInv; + gAudioContext.notes[i].playbackState.adsr.action.s.release = true; + } + } + gAudioContext.audioResetFadeOutFramesLeft = 8 / count; + gAudioContext.resetStatus--; + } + break; + + case 3: + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + AudioHeap_UpdateReverbs(); + } else { + gAudioContext.audioResetFadeOutFramesLeft = 2 / count; + gAudioContext.resetStatus--; + } + break; + + case 2: + AudioHeap_ClearAiBuffers(); + if (gAudioContext.audioResetFadeOutFramesLeft != 0) { + gAudioContext.audioResetFadeOutFramesLeft--; + } else { + gAudioContext.resetStatus--; + AudioHeap_DiscardSampleCaches(); + AudioHeap_DiscardSampleBanks(); + } + break; + + case 1: + AudioHeap_Init(); + gAudioContext.resetStatus = 0; + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = gAudioContext.audioBufferParameters.maxAiBufferLength; + for (j = 0; j < AIBUF_LEN; j++) { + gAudioContext.aiBuffers[i][j] = 0; + } + } + break; + } + + if (gAudioContext.resetStatus < 3) { + return false; + } + + return true; +} + +void AudioHeap_Init(void) { + s32 pad1[4]; + s16* addr; + size_t persistentSize; + size_t temporarySize; + size_t cachePoolSize; + size_t miscPoolSize; + u32 intMask; + s32 i; + s32 j; + s32 pad2; + AudioSpec* spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad]; // Audio Specifications + + gAudioContext.sampleDmaCount = 0; + + // audio buffer parameters + gAudioContext.audioBufferParameters.samplingFreq = spec->samplingFreq; + gAudioContext.audioBufferParameters.aiSamplingFreq = + osAiSetFrequency(gAudioContext.audioBufferParameters.samplingFreq); + + gAudioContext.audioBufferParameters.samplesPerFrameTarget = + ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); + gAudioContext.audioBufferParameters.minAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; + gAudioContext.audioBufferParameters.maxAiBufferLength = + gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; + gAudioContext.audioBufferParameters.updatesPerFrame = + ((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1; + gAudioContext.audioBufferParameters.samplesPerUpdate = (gAudioContext.audioBufferParameters.samplesPerFrameTarget / + gAudioContext.audioBufferParameters.updatesPerFrame) & + ~7; + gAudioContext.audioBufferParameters.samplesPerUpdateMax = gAudioContext.audioBufferParameters.samplesPerUpdate + 8; + gAudioContext.audioBufferParameters.samplesPerUpdateMin = gAudioContext.audioBufferParameters.samplesPerUpdate - 8; + gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq; + gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled = + (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.audioBufferParameters.unk_24 = gAudioContext.audioBufferParameters.updatesPerFrame * 0.25f; + gAudioContext.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioContext.audioBufferParameters.updatesPerFrame; + + // sample dma size + gAudioContext.sampleDmaBufSize1 = spec->sampleDmaBufSize1; + gAudioContext.sampleDmaBufSize2 = spec->sampleDmaBufSize2; + + gAudioContext.numNotes = spec->numNotes; + gAudioContext.audioBufferParameters.numSequencePlayers = spec->numSequencePlayers; + + if (gAudioContext.audioBufferParameters.numSequencePlayers > 5) { + gAudioContext.audioBufferParameters.numSequencePlayers = 5; + } + + gAudioContext.unk_29BC = 8; + gAudioContext.unk_2 = spec->unk_14; + gAudioContext.tempoInternalToExternal = (u32)(gAudioContext.audioBufferParameters.updatesPerFrame * 2880000.0f / + gTatumsPerBeat / gAudioContext.unk_2960); + + gAudioContext.unk_2870 = gAudioContext.refreshRate; + gAudioContext.unk_2870 *= gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioContext.unk_2870 /= gAudioContext.audioBufferParameters.aiSamplingFreq; + gAudioContext.unk_2870 /= gAudioContext.tempoInternalToExternal; + + gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04; + gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.maxAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.minAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; + gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; + + if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { + gAudioContext.audioBufferParameters.maxAiBufferLength -= 0x10; + } + + // Determine the maximum allowable number of audio command list entries for the rsp microcode + gAudioContext.maxAudioCmds = + gAudioContext.numNotes * 20 * gAudioContext.audioBufferParameters.updatesPerFrame + spec->numReverbs * 30 + 800; + + // Calculate sizes for various caches on the audio heap + persistentSize = + spec->persistentSeqCacheSize + spec->persistentFontCacheSize + spec->persistentSampleBankCacheSize + 0x10; + temporarySize = + spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize + 0x10; + cachePoolSize = persistentSize + temporarySize; + miscPoolSize = gAudioContext.audioSessionPool.size - cachePoolSize - 0x100; + + if (gAudioContext.externalPool.startAddr != NULL) { + gAudioContext.externalPool.curAddr = gAudioContext.externalPool.startAddr; + } + + // Session Pool Split (split into Cache and Misc heaps) + gAudioContext.sessionPoolSplit.miscPoolSize = miscPoolSize; + gAudioContext.sessionPoolSplit.cachePoolSize = cachePoolSize; + AudioHeap_InitSessionPool(&gAudioContext.sessionPoolSplit); + + // Cache Pool Split (Split into Persistent and Temporary heaps) + gAudioContext.cachePoolSplit.persistentCommonPoolSize = persistentSize; + gAudioContext.cachePoolSplit.temporaryCommonPoolSize = temporarySize; + AudioHeap_InitCachePool(&gAudioContext.cachePoolSplit); + + // Persistent Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize; + gAudioContext.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize; + gAudioContext.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize; + AudioHeap_InitPersistentCache(&gAudioContext.persistentCommonPoolSplit); + + // Temporary Pool Split (Split into Sequences, SoundFonts, Samples) + gAudioContext.temporaryCommonPoolSplit.seqCacheSize = spec->temporarySeqCacheSize; + gAudioContext.temporaryCommonPoolSplit.fontCacheSize = spec->temporaryFontCacheSize; + gAudioContext.temporaryCommonPoolSplit.sampleBankCacheSize = spec->temporarySampleBankCacheSize; + AudioHeap_InitTemporaryCache(&gAudioContext.temporaryCommonPoolSplit); + + AudioHeap_ResetLoadStatus(); + + // Initialize notes + gAudioContext.notes = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.numNotes * sizeof(Note)); + AudioPlayback_NoteInitAll(); + AudioPlayback_InitNoteFreeList(); + gAudioContext.noteSubsEu = + AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.audioBufferParameters.updatesPerFrame * + gAudioContext.numNotes * sizeof(NoteSubEu)); + + // Initialize audio binary interface command list buffer + for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) { + gAudioContext.abiCmdBufs[j] = + AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64)); + } + + // Initialize unk_3520 (fadeOutVelocities for ADSR) + gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); + func_8018B10C(); + + // Initialize reverbs + for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { + gAudioContext.synthesisReverbs[i].useReverb = 0; + } + + gAudioContext.numSynthesisReverbs = spec->numReverbs; + for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + AudioHeap_InitReverb(i, &spec->reverbSettings[i], 1); + } + + // Initialize sequence players + AudioSeq_InitSequencePlayers(); + for (j = 0; j < gAudioContext.audioBufferParameters.numSequencePlayers; j++) { + AudioSeq_InitSequencePlayerChannels(j); + AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[j]); + } + + // Initialize two additional caches on the audio heap to store individual audio samples + AudioHeap_InitSampleCaches(spec->persistentSampleCacheSize, spec->temporarySampleCacheSize); + AudioLoad_InitSampleDmaBuffers(gAudioContext.numNotes); + + // Initalize Loads + gAudioContext.preloadSampleStackTop = 0; + AudioLoad_InitSlowLoads(); + AudioLoad_InitScriptLoads(); + AudioLoad_InitAsyncLoads(); + gAudioContext.unk_4 = 0x1000; + AudioLoad_LoadPermanentSamples(); + + intMask = osSetIntMask(1); + osWritebackDCacheAll(); + osSetIntMask(intMask); +} + +void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id) { + s32 i; + + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + if (gAudioContext.permanentEntries[i].tableType == tableType && gAudioContext.permanentEntries[i].id == id) { + return gAudioContext.permanentEntries[i].addr; + } + } + return NULL; +} + +void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size) { + void* addr; + s32 index = gAudioContext.permanentPool.count; + + addr = AudioHeap_Alloc(&gAudioContext.permanentPool, size); + gAudioContext.permanentEntries[index].addr = addr; + + if (addr == NULL) { + return NULL; + } + + gAudioContext.permanentEntries[index].tableType = tableType; + gAudioContext.permanentEntries[index].id = id; + gAudioContext.permanentEntries[index].size = size; + //! @bug UB: missing return. "addr" is in v0 at this point, but doing an + // explicit return uses an additional register. + // return addr; +} + +void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache) { + SampleCacheEntry* entry; + + if (cache == CACHE_TEMPORARY) { + entry = AudioHeap_AllocTemporarySampleCacheEntry(size); + } else { + entry = AudioHeap_AllocPersistentSampleCacheEntry(size); + } + + if (entry != NULL) { + entry->sampleBankId = sampleBankId; + entry->sampleAddr = sampleAddr; + entry->origMedium = medium; + return entry->allocatedAddr; + } + return NULL; +} + +/** + * Initializes the persistent and temporary caches used for individual samples. Will attempt to use heap space available + * on the external pool. If no external pool is provided, then default to using space on the misc heap. + */ +void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize) { + void* addr; + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, persistentSampleCacheSize); + if (addr == NULL) { + gAudioContext.persistentSampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize); + } + + addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, temporarySampleCacheSize); + if (addr == NULL) { + gAudioContext.temporarySampleCache.pool.size = 0; + } else { + AudioHeap_AllocPoolInit(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize); + } + + gAudioContext.persistentSampleCache.numEntries = 0; + gAudioContext.temporarySampleCache.numEntries = 0; +} + +SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { + s32 pad2[2]; + void* addr; + s32 pad3[2]; + u8* allocAfter; + u8* allocBefore; + s32 pad1; + s32 index; + s32 i; + SampleCacheEntry* entry; + AudioPreloadReq* preload; + AudioSampleCache* cache; + u8* startAddr; + u8* endAddr; + + cache = &gAudioContext.temporarySampleCache; + allocBefore = cache->pool.curAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + // Reset the heap and try again. We still keep pointers to within the + // heap, so we have to be careful to discard existing overlapping + // allocations further down. + u8* oldAddr = cache->pool.curAddr; + + cache->pool.curAddr = cache->pool.startAddr; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + cache->pool.curAddr = oldAddr; + return NULL; + } + allocBefore = cache->pool.startAddr; + } + + allocAfter = cache->pool.curAddr; + + index = -1; + for (i = 0; i < gAudioContext.preloadSampleStackTop; i++) { + preload = &gAudioContext.preloadSampleStack[i]; + if (preload->isFree == false) { + startAddr = preload->ramAddr; + endAddr = preload->ramAddr + preload->sample->size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, skip this preload. + preload->isFree = true; + } + } + + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + continue; + } + + startAddr = cache->entries[i].allocatedAddr; + endAddr = startAddr + cache->entries[i].size - 1; + + if ((endAddr < allocBefore) && (startAddr < allocBefore)) { + continue; + } + if ((endAddr >= allocAfter) && (startAddr >= allocAfter)) { + continue; + } + + // Overlap, discard existing entry. + AudioHeap_DiscardSampleCacheEntry(&cache->entries[i]); + cache->entries[i].inUse = false; + if (index == -1) { + index = i; + } + } + + if (index == -1) { + for (i = 0; i < cache->numEntries; i++) { + if (!cache->entries[i].inUse) { + break; + } + } + + index = i; + if (index == cache->numEntries) { + if (cache->numEntries == 128) { + return NULL; + } + cache->numEntries++; + } + } + + entry = &cache->entries[index]; + entry->inUse = 1; + entry->allocatedAddr = addr; + entry->size = size; + + return entry; +} + +void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) { + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + s32 instId; + s32 drumId; + s32 sfxId; + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_UnapplySampleCache(entry, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_UnapplySampleCache(entry, inst->highNotesSound.sample); + } + AudioHeap_UnapplySampleCache(entry, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_UnapplySampleCache(entry, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_UnapplySampleCache(entry, sfx->sample); + } + } +} + +void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) || + ((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || entry->sampleBankId == 0 || + entry->sampleBankId == 0xFE) { + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) != NULL) { + if (1) {} + if (AudioLoad_IsFontLoadComplete(fontId) != 0) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } + } + } + } +} + +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { + if (sample != NULL) { + if (sample->sampleAddr == entry->allocatedAddr) { + sample->sampleAddr = entry->sampleAddr; + sample->medium = entry->origMedium; + } + } +} + +SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size) { + AudioSampleCache* cache; + SampleCacheEntry* entry; + void* addr; + + cache = &gAudioContext.persistentSampleCache; + addr = AudioHeap_Alloc(&cache->pool, size); + if (addr == NULL) { + return NULL; + } + + if (cache->numEntries == 128) { + return NULL; + } + + entry = &cache->entries[cache->numEntries]; + entry->inUse = true; + entry->allocatedAddr = addr; + entry->size = size; + cache->numEntries++; + + return entry; +} + +void AudioHeap_DiscardSampleCacheForFont(SampleCacheEntry* entry, s32 sampleBankId1, s32 sampleBankId2, s32 fontId) { + if ((entry->sampleBankId == sampleBankId1) || (entry->sampleBankId == sampleBankId2) || + (entry->sampleBankId == 0)) { + AudioHeap_UnapplySampleCacheForFont(entry, fontId); + } +} + +void AudioHeap_DiscardSampleCaches(void) { + s32 numFonts; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + s32 j; + + numFonts = gAudioContext.soundFontTable->numEntries; + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 == 0xFF) && (sampleBankId2 == 0xFF)) { + continue; + } + if (AudioHeap_SearchCaches(FONT_TABLE, CACHE_PERMANENT, fontId) == NULL || + !AudioLoad_IsFontLoadComplete(fontId)) { + continue; + } + + for (j = 0; j < gAudioContext.persistentSampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.persistentSampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + for (j = 0; j < gAudioContext.temporarySampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioContext.temporarySampleCache.entries[j], sampleBankId1, + sampleBankId2, fontId); + } + } +} + +typedef struct { + uintptr_t oldAddr; + uintptr_t newAddr; + size_t size; + u8 newMedium; +} StorageChange; + +void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) { + if (sample != NULL && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) && + ((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) { + uintptr_t startAddr = change->oldAddr; + uintptr_t endAddr = change->oldAddr + change->size; + + if (startAddr <= (uintptr_t)sample->sampleAddr && (uintptr_t)sample->sampleAddr < endAddr) { + sample->sampleAddr = sample->sampleAddr - startAddr + change->newAddr; + if (D_801FD120 == 0) { + sample->medium = change->newMedium; + } else { + sample->medium = MEDIUM_RAM; + } + } + } +} + +void AudioHeap_DiscardSampleBank(s32 sampleBankId) { + D_801FD120 = 0; + AudioHeap_ApplySampleBankCacheInternal(false, sampleBankId); +} + +void AudioHeap_ApplySampleBankCache(s32 sampleBankId) { + D_801FD120 = 1; + AudioHeap_ApplySampleBankCacheInternal(true, sampleBankId); +} + +void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { + AudioTable* sampleBankTable; + AudioTableEntry* entry; + s32 numFonts; + s32 instId; + s32 drumId; + s32 sfxId; + StorageChange change; + s32 sampleBankId1; + s32 sampleBankId2; + s32 fontId; + Drum* drum; + Instrument* inst; + SoundFontSound* sfx; + uintptr_t* newAddr; + s32 pad[4]; + + sampleBankTable = gAudioContext.sampleBankTable; + numFonts = gAudioContext.soundFontTable->numEntries; + change.oldAddr = AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId); + if (change.oldAddr == 0) { + return; + } + + entry = &sampleBankTable->entries[sampleBankId]; + change.size = entry->size; + change.newMedium = entry->medium; + change.newAddr = entry->romAddr; + + newAddr = &change.oldAddr; + if (apply && (apply == true)) { + uintptr_t oldAddr; + + oldAddr = change.newAddr; + + change.newAddr = *newAddr; + change.oldAddr = oldAddr; + } + + for (fontId = 0; fontId < numFonts; fontId++) { + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if ((sampleBankId1 != 0xFF) || (sampleBankId2 != 0xFF)) { + if (!AudioLoad_IsFontLoadComplete(fontId) || + AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) == NULL) { + continue; + } + + if (sampleBankId1 == sampleBankId) { + } else if (sampleBankId2 == sampleBankId) { + } else { + continue; + } + + for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + inst = AudioPlayback_GetInstrumentInner(fontId, instId); + if (inst != NULL) { + if (inst->normalRangeLo != 0) { + AudioHeap_ChangeStorage(&change, inst->lowNotesSound.sample); + } + if (inst->normalRangeHi != 0x7F) { + AudioHeap_ChangeStorage(&change, inst->highNotesSound.sample); + } + AudioHeap_ChangeStorage(&change, inst->normalNotesSound.sample); + } + } + + for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + drum = AudioPlayback_GetDrum(fontId, drumId); + if (drum != NULL) { + AudioHeap_ChangeStorage(&change, drum->sound.sample); + } + } + + for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { + sfx = AudioPlayback_GetSfx(fontId, sfxId); + if (sfx != NULL) { + AudioHeap_ChangeStorage(&change, sfx->sample); + } + } + } + } +} + +void AudioHeap_DiscardSampleBanks(void) { + AudioCache* cache; + AudioPersistentCache* persistent; + AudioTemporaryCache* temporary; + u32 i; + + cache = &gAudioContext.sampleBankCache; + temporary = &cache->temporary; + + if (temporary->entries[0].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[0].id); + } + + if (temporary->entries[1].id != -1) { + AudioHeap_DiscardSampleBank(temporary->entries[1].id); + } + + persistent = &cache->persistent; + for (i = 0; i < persistent->numEntries; i++) { + AudioHeap_DiscardSampleBank(persistent->entries[i].id); + } +} + +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags) { + s32 windowSize; + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + switch (dataType) { + case 0: + AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, 0); + break; + case 1: + if (data < 4) { + data = 4; + } + + windowSize = data * 64; + if (windowSize < 0x100) { + windowSize = 0x100; + } + + windowSize /= reverb->downsampleRate; + + if (flags == 0) { + if (reverb->unk_1E >= (data / reverb->downsampleRate)) { + if ((reverb->nextRingBufPos >= windowSize) || (reverb->unk_24 >= windowSize)) { + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + } + } else { + break; + } + } + + reverb->windowSize = windowSize; + + if ((reverb->downsampleRate != 1) || reverb->unk_18) { + reverb->unk_0E = 0x8000 / reverb->downsampleRate; + if (reverb->unk_30 == NULL) { + reverb->unk_30 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_34 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); + if (reverb->unk_3C == NULL) { + reverb->downsampleRate = 1; + } + } + } + break; + case 2: + gAudioContext.synthesisReverbs[reverbIndex].unk_0C = data; + break; + case 3: + gAudioContext.synthesisReverbs[reverbIndex].unk_16 = data; + break; + case 4: + gAudioContext.synthesisReverbs[reverbIndex].unk_0A = data; + break; + case 5: + gAudioContext.synthesisReverbs[reverbIndex].leakRtl = data; + break; + case 6: + gAudioContext.synthesisReverbs[reverbIndex].leakLtr = data; + break; + case 7: + if (data != 0) { + if ((flags != 0) || (reverb->unk_278 == 0)) { + reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_278 = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + + reverb->filterLeft = reverb->unk_278; + if (reverb->filterLeft != 0) { + AudioHeap_LoadLowPassFilter(reverb->filterLeft, data); + } + } else { + reverb->filterLeft = 0; + + if (flags != 0) { + reverb->unk_278 = 0; + } + } + + break; + case 8: + if (data != 0) { + if ((flags != 0) || (reverb->unk_27C == 0)) { + reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); + reverb->unk_27C = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + } + reverb->filterRight = reverb->unk_27C; + if (reverb->unk_27C != 0) { + AudioHeap_LoadLowPassFilter(reverb->unk_27C, data); + } + } else { + reverb->filterRight = 0; + if (flags != 0) { + reverb->unk_27C = 0; + } + } + break; + case 9: + reverb->unk_19 = data; + if (data == 0) { + reverb->unk_18 = false; + } else { + reverb->unk_18 = true; + } + break; + default: + break; + } +} + +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) { + SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; + + if (flags != 0) { + reverb->unk_1E = settings->windowSize / settings->downsampleRate; + reverb->unk_30 = 0; + } else if (reverb->unk_1E < (settings->windowSize / settings->downsampleRate)) { + return; + } + + reverb->downsampleRate = settings->downsampleRate; + reverb->unk_18 = false; + reverb->unk_19 = 0; + reverb->unk_1A = 0; + reverb->unk_1C = 0; + AudioHeap_SetReverbData(reverbIndex, 1, settings->windowSize, flags); + reverb->unk_0C = settings->unk_4; + reverb->unk_0A = settings->unk_A; + reverb->unk_14 = settings->unk_6 << 6; + reverb->unk_16 = settings->unk_8; + reverb->leakRtl = settings->leakRtl; + reverb->leakLtr = settings->leakLtr; + reverb->unk_05 = settings->unk_10; + reverb->unk_08 = settings->unk_12; + reverb->useReverb = 8; + + if (flags != 0) { + reverb->leftRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->rightRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + reverb->resampleFlags = 1; + reverb->nextRingBufPos = 0; + reverb->unk_24 = 0; + reverb->curFrame = 0; + reverb->framesToIgnore = 2; + } + + reverb->sound.sample = &reverb->sample; + reverb->sample.loop = &reverb->loop; + reverb->sound.tuning = 1.0f; + reverb->sample.codec = CODEC_REVERB; + reverb->sample.medium = MEDIUM_RAM; + reverb->sample.size = reverb->windowSize * 2; + reverb->sample.sampleAddr = (u8*)reverb->leftRingBuf; + reverb->loop.start = 0; + reverb->loop.count = 1; + reverb->loop.end = reverb->windowSize; + + AudioHeap_SetReverbData(reverbIndex, 7, settings->lowPassFilterCutoffLeft, flags); + AudioHeap_SetReverbData(reverbIndex, 8, settings->lowPassFilterCutoffRight, flags); +} diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index 4e6ef9dfb..b407ef7c9 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -7,6 +7,6 @@ const s16 gAudioTatumInit[] = { const AudioContextInitSizes gAudioContextInitSizes = { 0x137F00, // heapSize - 0x1C480, // initPoolSize + 0x1C480, // mainPoolSplitSize 0x1A000, // permanentPoolSize }; diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 497f9d47a..b63f8192b 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -1,161 +1,2161 @@ +/** + * @file audio_load.c + * + * Implements the transfer of audio data from the cartridge to the audio heap. + * + * The audio data in ROM consists of: + * 1) Sequences stored as a midi-based script called the music-macro language (.mus files) + * 2) SoundFonts stored as various sound-font structs bundled togther in a custom way + * that is extracted through relocs (See SoundFontData, generic .o files) + * 3) Samples consisting of raw soundbytes stored using a compressed ADPCM algorithm (.aifc files) + */ + #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EB60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EC4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/D_801E030C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018EF88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F298.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F310.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F3E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F448.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F478.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F4D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F588.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F6F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F7F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F83C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F880.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F8C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F908.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018F9B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FAD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FCCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FD40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FE5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8018FF60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190204.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190294.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801902D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190544.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190668.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019067C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019075C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019077C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190B50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190BB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80190F64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801911CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191240.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801913C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019144C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191568.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191598.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019161C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191740.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191864.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191870.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801919AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191B40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191BD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80191D94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_8019218C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192340.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192388.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_801924BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192AE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192B54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_load/func_80192BAC.s") +/** + * SoundFont Notes: + * + */ +// opaque type for unpatched sound font data (should maybe get rid of this?) +typedef void SoundFontData; + +typedef struct { + /* 0x00 */ s32 sampleBankId1; + /* 0x04 */ s32 sampleBankId2; + /* 0x08 */ uintptr_t baseAddr1; + /* 0x0C */ uintptr_t baseAddr2; + /* 0x10 */ u32 medium1; + /* 0x14 */ u32 medium2; +} AudioRelocInfo; // size = 0x18 + +void AudioLoad_DiscardFont(s32 fontId); +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2); +u8* AudioLoad_SyncLoadSeq(s32 seqId); +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad); +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId); +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate); +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id); +void* AudioLoad_SearchCaches(s32 tableType, s32 id); +AudioTable* AudioLoad_GetLoadTable(s32 tableType); +void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium); +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam); +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType); +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue); +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId); +void AudioLoad_ProcessSlowLoads(s32 resetStatus); +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size); +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3); +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg); +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg); +void AudioLoad_ProcessAsyncLoads(s32 resetStatus); +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus); +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size); +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3); +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* fontData, AudioRelocInfo* relocInfo); +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo, s32 async); +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus); + +#define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \ + (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (loadStatus)) + +#define ASYNC_TBLTYPE(v) ((u8)(v >> 16)) +#define ASYNC_ID(v) ((u8)(v >> 8)) +#define ASYNC_STATUS(v) ((u8)(v >> 0)) + +typedef enum { + /* 0 */ LOAD_STATUS_WAITING, + /* 1 */ LOAD_STATUS_START, + /* 2 */ LOAD_STATUS_LOADING, + /* 3 */ LOAD_STATUS_DONE +} SlowLoadStatus; + +#define OS_MESG_PRI_NORMAL 0 +#define OS_MESG_PRI_HIGH 1 + +typedef struct { + u16 numInstruments; + u16 numDrums; + u16 numSfx; +} UnloadedFonts; + +OSMesgQueue sScriptLoadQueue; +OSMesg sScriptLoadMesgBuf[0x10]; +s8* sScriptLoadDonePointers[0x10]; +s32 sAudioLoadPad1[2]; // file padding +s32 D_801FD1E0; + +DmaHandler sDmaHandler = osEPiStartDma; +void* sUnusedHandler = NULL; +s32 gAudioContextInitalized = false; + +void AudioLoad_DecreaseSampleDmaTtls(void) { + u32 i; + + for (i = 0; i < gAudioContext.sampleDmaListSize1; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue1WrPos; + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1WrPos] = i; + gAudioContext.sampleDmaReuseQueue1WrPos++; + } + } + } + + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + SampleDma* dma = &gAudioContext.sampleDmas[i]; + + if (dma->ttl != 0) { + dma->ttl--; + if (dma->ttl == 0) { + dma->reuseIndex = gAudioContext.sampleDmaReuseQueue2WrPos; + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2WrPos] = i; + gAudioContext.sampleDmaReuseQueue2WrPos++; + } + } + } + + gAudioContext.unused2648 = 0; +} + +void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) { + s32 pad1; + SampleDma* dma; + s32 hasDma = false; + uintptr_t dmaDevAddr; + u32 pad2; + u32 dmaIndex; + u32 transfer; + s32 bufferPos; + u32 i; + + if (arg2 != 0 || *dmaIndexRef >= gAudioContext.sampleDmaListSize1) { + for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { + dma = &gAudioContext.sampleDmas[i]; + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && ((u32)bufferPos <= dma->size - size)) { + // We already have a DMA request for this memory range. + if (dma->ttl == 0 && + gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue2RdPos) { + gAudioContext.sampleDmaReuseQueue2[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue2RdPos++; + } + dma->ttl = 32; + *dmaIndexRef = (u8)i; + return dma->ramAddr + (devAddr - dma->devAddr); + } + } + + if (arg2 == 0) { + goto search_short_lived; + } + + if (gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos && arg2 != 0) { + // Allocate a DMA from reuse queue 2, unless full. + dmaIndex = gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; + gAudioContext.sampleDmaReuseQueue2RdPos++; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + } else { + search_short_lived: + dma = gAudioContext.sampleDmas + *dmaIndexRef; + i = 0; + again: + bufferPos = devAddr - dma->devAddr; + if (0 <= bufferPos && (u32)bufferPos <= dma->size - size) { + // We already have DMA for this memory range. + if (dma->ttl == 0) { + // Move the DMA out of the reuse queue, by swapping it with the + // read pos, and then incrementing the read pos. + if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue1RdPos) { + gAudioContext.sampleDmaReuseQueue1[dma->reuseIndex] = + gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]; + gAudioContext + .sampleDmas[gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]] + .reuseIndex = dma->reuseIndex; + } + gAudioContext.sampleDmaReuseQueue1RdPos++; + } + dma->ttl = 2; + return dma->ramAddr + (devAddr - dma->devAddr); + } + dma = gAudioContext.sampleDmas + i++; + if (i <= gAudioContext.sampleDmaListSize1) { + goto again; + } + } + + if (!hasDma) { + if (gAudioContext.sampleDmaReuseQueue1RdPos == gAudioContext.sampleDmaReuseQueue1WrPos) { + return NULL; + } + // Allocate a DMA from reuse queue 1. + dmaIndex = gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos++]; + dma = gAudioContext.sampleDmas + dmaIndex; + hasDma = true; + } + + transfer = dma->size; + dmaDevAddr = devAddr & ~0xF; + dma->ttl = 3; + dma->devAddr = dmaDevAddr; + dma->sizeUnused = transfer; + AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMesgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, + OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, + "SUPERDMA"); + *dmaIndexRef = dmaIndex; + return (devAddr - dmaDevAddr) + dma->ramAddr; +} + +// This string does not appear to belong in context to any function between the previous string and the next string +const char D_801E030C[] = "TYPE %d:ID %d is not External Map.\n"; + +void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { + SampleDma* dma; + s32 i; + s32 t2; + s32 j; + + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize1; + gAudioContext.sampleDmas = + AudioHeap_Alloc(&gAudioContext.miscPool, + 4 * gAudioContext.numNotes * sizeof(SampleDma) * gAudioContext.audioBufferParameters.specUnk4); + t2 = 3 * gAudioContext.numNotes * gAudioContext.audioBufferParameters.specUnk4; + + // First 3/4 sampleDmas + for (i = 0; i < t2; i++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = 0; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = i; + gAudioContext.sampleDmas[i].reuseIndex = i; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue1[i] = 0; + } + + gAudioContext.sampleDmaReuseQueue1RdPos = 0; + gAudioContext.sampleDmaReuseQueue1WrPos = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaListSize1 = gAudioContext.sampleDmaCount; + gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize2; + + for (j = 0; j < gAudioContext.numNotes; j++) { + dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + if (dma->ramAddr == NULL) { + break; + } else { + AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); + dma->size = gAudioContext.sampleDmaBufSize; + dma->devAddr = 0U; + dma->sizeUnused = 0; + dma->unused = 0; + dma->ttl = 0; + gAudioContext.sampleDmaCount++; + } + } + + for (i = gAudioContext.sampleDmaListSize1; (u32)i < gAudioContext.sampleDmaCount; i++) { + gAudioContext.sampleDmaReuseQueue2[i - gAudioContext.sampleDmaListSize1] = i; + gAudioContext.sampleDmas[i].reuseIndex = i - gAudioContext.sampleDmaListSize1; + } + + for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { + gAudioContext.sampleDmaReuseQueue2[i] = gAudioContext.sampleDmaListSize1; + } + + gAudioContext.sampleDmaReuseQueue2RdPos = 0; + gAudioContext.sampleDmaReuseQueue2WrPos = gAudioContext.sampleDmaCount - gAudioContext.sampleDmaListSize1; +} + +s32 AudioLoad_IsFontLoadComplete(s32 fontId) { + if (fontId == 0xFF) { + return true; + } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSeqLoadComplete(s32 seqId) { + if (seqId == 0xFF) { + return true; + } else if (gAudioContext.seqLoadStatus[seqId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { + if (sampleBankId == 0xFF) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_2) { + return true; + } else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= + LOAD_STATUS_2) { + return true; + } else { + return false; + } +} + +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) { + if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) { + gAudioContext.fontLoadStatus[fontId] = loadStatus; + } +} + +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) { + if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) { + gAudioContext.seqLoadStatus[seqId] = loadStatus; + } +} + +void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) { + if (sampleBankId != 0xFF) { + if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } + + if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) || + (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) { + AudioHeap_ApplySampleBankCache(sampleBankId); + } + } +} + +void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) { + if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) { + gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + } +} + +void AudioLoad_InitTable(AudioTable* table, uintptr_t romAddr, u16 unkMediumParam) { + s32 i; + + table->unkMediumParam = unkMediumParam; + table->romAddr = romAddr; + + for (i = 0; i < table->numEntries; i++) { + if ((table->entries[i].size != 0) && (table->entries[i].medium == MEDIUM_CART)) { + table->entries[i].romAddr += romAddr; + } + } +} + +SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) { + s32 pad[2]; + s32 index; + SoundFontData* fontData; + s32 numFonts; + s32 fontId; + s32 i; + + if (seqId >= gAudioContext.numSequences) { + return NULL; + } + + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + fontData = AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + *outDefaultFontId = fontId; + return fontData; +} + +void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3) { + s32 pad; + u32 defaultFontId; + + if (seqId < gAudioContext.numSequences) { + if (arg1 & 2) { + AudioLoad_SyncLoadSeqFonts(seqId, &defaultFontId); + } + if (arg1 & 1) { + AudioLoad_SyncLoadSeq(seqId); + } + if (arg2 != 0) { + osSendMesg(arg3, arg2 << 0x18, OS_MESG_NOBLOCK); + } + } +} + +s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { + void* sampleAddr; + + if (sample->unk_bit25 == true) { + if (sample->medium != MEDIUM_RAM) { + sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + if (sampleAddr == NULL) { + return -1; + } + + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, sampleAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + } else { + AudioLoad_SyncDma(sample->sampleAddr, sampleAddr, sample->size, sample->medium); + } + sample->medium = MEDIUM_RAM; + sample->sampleAddr = sampleAddr; + } + } +} + +s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { + if (instId < 0x7F) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return -1; + } + if (instrument->normalRangeLo != 0) { + AudioLoad_SyncLoadSample(instrument->lowNotesSound.sample, fontId); + } + AudioLoad_SyncLoadSample(instrument->normalNotesSound.sample, fontId); + if (instrument->normalRangeHi != 0x7F) { + return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); + } + } else if (instId == 0x7F) { + Drum* drum = AudioPlayback_GetDrum(fontId, drumId); + + if (drum == NULL) { + return -1; + } + AudioLoad_SyncLoadSample(drum->sound.sample, fontId); + return 0; + } +} + +void AudioLoad_AsyncLoad(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + if (AudioLoad_AsyncLoadInner(tableType, id, nChunks, retData, retQueue) == NULL) { + osSendMesg(retQueue, 0xFFFFFFFF, OS_MESG_NOBLOCK); + } +} + +void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SEQUENCE_TABLE, seqId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(SAMPLE_TABLE, sampleBankId, 0, retData, retQueue); +} + +void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue) { + AudioLoad_AsyncLoad(FONT_TABLE, fontId, 0, retData, retQueue); +} + +u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) { + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + + *outNumFonts = gAudioContext.sequenceFontTable[index++]; + if (*outNumFonts == 0) { + return NULL; + } + return &gAudioContext.sequenceFontTable[index]; +} + +void AudioLoad_DiscardSeqFonts(s32 seqId) { + s32 fontId; + s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + s32 numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + numFonts--; + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]); + if (AudioHeap_SearchPermanentCache(FONT_TABLE, fontId) == NULL) { + AudioLoad_DiscardFont(fontId); + AudioLoad_SetFontLoadStatus(fontId, LOAD_STATUS_0); + } + } +} + +void AudioLoad_DiscardFont(s32 fontId) { + u32 i; + AudioCache* pool = &gAudioContext.fontCache; + AudioPersistentCache* persistent; + + if (fontId == pool->temporary.entries[0].id) { + pool->temporary.entries[0].id = -1; + } else if (fontId == pool->temporary.entries[1].id) { + pool->temporary.entries[1].id = -1; + } + + persistent = &pool->persistent; + for (i = 0; i < persistent->numEntries; i++) { + if (fontId == persistent->entries[i].id) { + persistent->entries[i].id = -1; + } + } + + AudioHeap_DiscardFont(fontId); +} + +void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].medium == MEDIUM_RAM_UNLOADED) { + switch (type) { + case 0: + table->entries[id].romAddr = data; + break; + case 1: + table->entries[id].size = data; + break; + default: + break; + } + } +} + +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = 0; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2); + // Intentionally missing return. Returning the result of the above function + // call matches but is UB because it too is missing a return, and using the + // result of a non-void function that has failed to return a value is UB. + // The callers of this function do not use the return value, so it's fine. +} + +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks) { + if (gAudioContext.resetTimer != 0) { + return 0; + } + + gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks; + AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0); + // Missing return, see above. +} + +s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { + SequencePlayer* seqPlayer = &gAudioContext.seqPlayers[playerIdx]; + u8* seqData; + s32 index; + s32 numFonts; + s32 fontId; + + if (seqId >= gAudioContext.numSequences) { + return 0; + } + + AudioSeq_SequencePlayerDisable(seqPlayer); + + if (1) {} + fontId = 0xFF; + index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + numFonts = gAudioContext.sequenceFontTable[index++]; + + while (numFonts > 0) { + fontId = gAudioContext.sequenceFontTable[index++]; + AudioLoad_SyncLoadFont(fontId); + numFonts--; + } + + seqData = AudioLoad_SyncLoadSeq(seqId); + if (seqData == NULL) { + return 0; + } + + AudioSeq_ResetSequencePlayer(seqPlayer); + seqPlayer->seqId = seqId; + + if (fontId != 0xFF) { + seqPlayer->defaultFont = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + } else { + seqPlayer->defaultFont = 0xFF; + } + + seqPlayer->seqData = seqData; + seqPlayer->enabled = true; + seqPlayer->scriptState.pc = seqData; + seqPlayer->scriptState.depth = 0; + seqPlayer->delay = 0; + seqPlayer->finished = false; + seqPlayer->playerIdx = playerIdx; + //! @bug missing return (but the return value is not used so it's not UB) +} + +u8* AudioLoad_SyncLoadSeq(s32 seqId) { + s32 pad; + s32 didAllocate; + + if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) { + return NULL; + } + + return AudioLoad_SyncLoad(SEQUENCE_TABLE, seqId, &didAllocate); +} + +u32 AudioLoad_GetSampleBank(u32 sampleBankId, u32* outMedium) { + return AudioLoad_TrySyncLoadSampleBank(sampleBankId, outMedium, true); +} + +u32 AudioLoad_TrySyncLoadSampleBank(u32 sampleBankId, u32* outMedium, s32 noLoad) { + void* addr; + AudioTable* sampleBankTable; + u32 realTableId = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId); + s8 cachePolicy; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + + addr = AudioLoad_SearchCaches(SAMPLE_TABLE, realTableId); + if (addr != NULL) { + if (gAudioContext.sampleFontLoadStatus[realTableId] != LOAD_STATUS_1) { + AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_2); + } + + *outMedium = MEDIUM_RAM; + return addr; + } + + cachePolicy = sampleBankTable->entries[sampleBankId].cachePolicy; + + if ((cachePolicy == CACHE_LOAD_EITHER_NOSYNC) || (noLoad == true)) { + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; + } + + addr = AudioLoad_SyncLoad(SAMPLE_TABLE, sampleBankId, &noLoad); + if (addr != NULL) { + *outMedium = MEDIUM_RAM; + return addr; + } + + *outMedium = sampleBankTable->entries[sampleBankId].medium; + return sampleBankTable->entries[realTableId].romAddr; +} + +SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { + SoundFontData* fontData; + s32 sampleBankId1; + s32 sampleBankId2; + s32 didAllocate; + AudioRelocInfo relocInfo; + s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); + + if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) { + return NULL; + } + + sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2; + + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.baseAddr1 = AudioLoad_TrySyncLoadSampleBank(relocInfo.sampleBankId1, &relocInfo.medium1, false); + } else { + relocInfo.baseAddr1 = 0; + } + + if (sampleBankId2 != 0xFF) { + relocInfo.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &relocInfo.medium2, false); + } else { + relocInfo.baseAddr2 = 0; + } + + fontData = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate); + if (fontData == NULL) { + return NULL; + } + if (didAllocate == true) { + AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &relocInfo, false); + } + + return fontData; +} + +void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { + size_t size; + AudioTable* table; + s32 medium2; + u32 medium; + s32 loadStatus; + uintptr_t romAddr; + s32 cachePolicy; + void* ramAddr; + u32 realId; + s32 mediumUnk = MEDIUM_UNK; + + realId = AudioLoad_GetRealTableIndex(tableType, id); + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + *didAllocate = false; + loadStatus = LOAD_STATUS_2; + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + *didAllocate = true; + + medium2 = medium; + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + SoundFont* soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size -= 0x10; + } + + bcopy(romAddr, ramAddr, size); + } else if (medium2 == mediumUnk) { + AudioLoad_SyncDmaUnkMedium(romAddr, ramAddr, size, (s16)table->unkMediumParam); + } else { + AudioLoad_SyncDma(romAddr, ramAddr, size, medium); + } + + loadStatus = (cachePolicy == CACHE_LOAD_PERMANENT) ? LOAD_STATUS_5 : LOAD_STATUS_2; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id) { + AudioTable* table = AudioLoad_GetLoadTable(tableType); + + if (table->entries[id].size == 0) { + id = table->entries[id].romAddr; + } + + return id; +} + +void* AudioLoad_SearchCaches(s32 tableType, s32 id) { + void* addr; + + addr = AudioHeap_SearchPermanentCache(tableType, id); + if (addr != NULL) { + return addr; + } + + addr = AudioHeap_SearchCaches(tableType, CACHE_EITHER, id); + if (addr != NULL) { + return addr; + } + + return NULL; +} + +AudioTable* AudioLoad_GetLoadTable(s32 tableType) { + AudioTable* table; + + switch (tableType) { + case SEQUENCE_TABLE: + table = gAudioContext.sequenceTable; + break; + case FONT_TABLE: + table = gAudioContext.soundFontTable; + break; + default: + table = NULL; + break; + case SAMPLE_TABLE: + table = gAudioContext.sampleBankTable; + break; + } + return table; +} + +/** + * + * SoundFontData* mem -> the address of the soundFont as stored in memory + */ +void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo) { + uintptr_t reloc; + uintptr_t reloc2; + Instrument* inst; + Drum* drum; + SoundFontSound* sfx; + s32 i; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + s32 numSfx = gAudioContext.soundFonts[fontId].numSfx; + void** ptrs = (void**)fontData; + +#define BASE_OFFSET(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontData)) + + // relocate drums + reloc2 = ptrs[0]; + if (1) {} + if ((reloc2 != 0) && (numDrums != 0)) { + ptrs[0] = BASE_OFFSET(reloc2); + for (i = 0; i < numDrums; i++) { + reloc = ((Drum**)ptrs[0])[i]; + if (reloc != 0) { + reloc = BASE_OFFSET(reloc); + ((Drum**)ptrs[0])[i] = drum = reloc; + if (!drum->loaded) { + AudioLoad_RelocateSample(&drum->sound, fontData, relocInfo); + reloc = drum->envelope; + drum->envelope = BASE_OFFSET(reloc); + drum->loaded = true; + } + } + } + } + + // relocate sfxs + reloc2 = ptrs[1]; + if (1) {} + if ((reloc2 != 0) && (numSfx != 0)) { + ptrs[1] = BASE_OFFSET(reloc2); + for (i = 0; i < numSfx; i++) { + reloc = (SoundFontSound*)ptrs[1] + i; + if (reloc != 0) { + sfx = reloc; + if (sfx->sample != NULL) { + AudioLoad_RelocateSample(sfx, fontData, relocInfo); + } + } + } + } + + if (numInstruments > 0x7E) { + numInstruments = 0x7E; + } + + // relocate instruments + for (i = 2; i <= 2 + numInstruments - 1; i++) { + if (ptrs[i] != NULL) { + ptrs[i] = BASE_OFFSET(ptrs[i]); + inst = ptrs[i]; + if (!inst->loaded) { + if (inst->normalRangeLo != 0) { + AudioLoad_RelocateSample(&inst->lowNotesSound, fontData, relocInfo); + } + AudioLoad_RelocateSample(&inst->normalNotesSound, fontData, relocInfo); + if (inst->normalRangeHi != 0x7F) { + AudioLoad_RelocateSample(&inst->highNotesSound, fontData, relocInfo); + } + + reloc = inst->envelope; + inst->envelope = BASE_OFFSET(reloc); + inst->loaded = true; + } + } + } + +#undef BASE_OFFSET + + gAudioContext.soundFonts[fontId].drums = ptrs[0]; + gAudioContext.soundFonts[fontId].soundEffects = ptrs[1]; + gAudioContext.soundFonts[fontId].instruments = (Instrument**)(&ptrs[2]); +} + +void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium) { + OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue; + OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg; + size = ALIGN16(size); + + Audio_InvalDCache(ramAddr, size); + + while (true) { + if (size < 0x400) { + break; + } + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, 0x400, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + size -= 0x400; + devAddr += 0x400; + ramAddr += 0x400; + } + + if (size != 0) { + AudioLoad_Dma(ioMesg, OS_MESG_PRI_HIGH, OS_READ, devAddr, ramAddr, size, msgQueue, medium, "FastCopy"); + osRecvMesg(msgQueue, NULL, OS_MESG_BLOCK); + } +} + +void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* ramAddr, size_t size, s32 unkMediumParam) { +} + +s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, + OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType) { + OSPiHandle* handle; + + if (gAudioContext.resetTimer > 16) { + return -1; + } + + switch (medium) { + case MEDIUM_CART: + handle = gAudioContext.cartHandle; + break; + + case MEDIUM_DISK_DRIVE: + // driveHandle is uninitialized and corresponds to stubbed-out disk drive support. + // SM64 Shindou called osDriveRomInit here. + handle = gAudioContext.driveHandle; + break; + + default: + return 0; + } + + if ((size % 0x10) != 0) { + size = ALIGN16(size); + } + + mesg->hdr.pri = priority; + mesg->hdr.retQueue = reqQueue; + mesg->dramAddr = ramAddr; + mesg->devAddr = devAddr; + mesg->size = size; + handle->transferInfo.cmdType = 2; + sDmaHandler(handle, mesg, direction); + return 0; +} + +void AudioLoad_Unused1(void) { +} + +void AudioLoad_SyncLoadSimple(u32 tableType, u32 fontId) { + s32 didAllocate; + + AudioLoad_SyncLoad(tableType, fontId, &didAllocate); +} + +void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { + size_t size; + AudioTable* table; + void* ramAddr; + s32 medium; + s8 cachePolicy; + uintptr_t romAddr; + s32 loadStatus; + SoundFont* soundFont; + u32 realId = AudioLoad_GetRealTableIndex(tableType, id); + u32 pad; + + switch (tableType) { + case SEQUENCE_TABLE: + if (gAudioContext.seqLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case FONT_TABLE: + if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + + case SAMPLE_TABLE: + if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) { + return NULL; + } + break; + } + + ramAddr = AudioLoad_SearchCaches(tableType, realId); + if (ramAddr != NULL) { + loadStatus = LOAD_STATUS_2; + osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK); + } else { + table = AudioLoad_GetLoadTable(tableType); + size = table->entries[realId].size; + size = ALIGN16(size); + medium = table->entries[id].medium; + cachePolicy = table->entries[id].cachePolicy; + romAddr = table->entries[realId].romAddr; + loadStatus = LOAD_STATUS_2; + + switch (cachePolicy) { + case CACHE_LOAD_PERMANENT: + ramAddr = AudioHeap_AllocPermanent(tableType, realId, size); + if (ramAddr == NULL) { + return ramAddr; + } + loadStatus = LOAD_STATUS_5; + break; + + case CACHE_LOAD_PERSISTENT: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_PERSISTENT, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_TEMPORARY: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_TEMPORARY, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + + case CACHE_LOAD_EITHER: + case CACHE_LOAD_EITHER_NOSYNC: + ramAddr = AudioHeap_AllocCached(tableType, size, CACHE_EITHER, realId); + if (ramAddr == NULL) { + return ramAddr; + } + break; + } + + if (medium == MEDIUM_RAM_UNLOADED) { + if (romAddr == 0) { + return NULL; + } + + if (tableType == FONT_TABLE) { + soundFont = &gAudioContext.soundFonts[realId]; + + soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; + soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; + soundFont->numSfx = ((UnloadedFonts*)romAddr)->numSfx; + romAddr += 0x10; + size += -0x10; + } + } + + if (medium == MEDIUM_UNK) { + AudioLoad_StartAsyncLoadUnkMedium((s16)table->unkMediumParam, romAddr, ramAddr, size, medium, nChunks, + retQueue, MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } else { + AudioLoad_StartAsyncLoad(romAddr, ramAddr, size, medium, nChunks, retQueue, + MK_ASYNC_MSG(retData, tableType, realId, loadStatus)); + } + + loadStatus = LOAD_STATUS_1; + } + + switch (tableType) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(realId, loadStatus); + break; + case FONT_TABLE: + AudioLoad_SetFontLoadStatus(realId, loadStatus); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(realId, loadStatus); + break; + default: + break; + } + + return ramAddr; +} + +void AudioLoad_ProcessLoads(s32 resetStatus) { + AudioLoad_ProcessSlowLoads(resetStatus); + AudioLoad_ProcessSamplePreloads(resetStatus); + AudioLoad_ProcessAsyncLoads(resetStatus); +} + +void AudioLoad_SetDmaHandler(DmaHandler callback) { + sDmaHandler = callback; +} + +void AudioLoad_SetUnusedHandler(void* callback) { + sUnusedHandler = callback; +} + +void AudioLoad_InitSoundFontMeta(s32 fontId) { + SoundFont* font = &gAudioContext.soundFonts[fontId]; + AudioTableEntry* entry = &gAudioContext.soundFontTable->entries[fontId]; + + font->sampleBankId1 = (entry->shortData1 >> 8) & 0xFF; + font->sampleBankId2 = (entry->shortData1) & 0xFF; + font->numInstruments = (entry->shortData2 >> 8) & 0xFF; + font->numDrums = entry->shortData2 & 0xFF; + font->numSfx = entry->shortData3; +} + +void AudioLoad_Init(void* heap, size_t heapSize) { + s32 pad1[9]; + s32 numFonts; + s32 pad2[2]; + u8* audioContextPtr; + void* addr; + s32 i; + s32 j; + + D_80208E68 = NULL; + D_80208E70 = NULL; + D_80208E74 = NULL; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.unk_29A8); i++) { + gAudioContext.unk_29A8[i] = NULL; + } + + gAudioContext.resetTimer = 0; + gAudioContext.unk_29B8 = false; + + // Set all of gAudioContext to 0 + audioContextPtr = (u8*)&gAudioContext; + for (j = sizeof(gAudioContext); j >= 0; j--) { + *audioContextPtr++ = 0; + } + + switch (osTvType) { + case OS_TV_PAL: + gAudioContext.unk_2960 = 20.03042f; + gAudioContext.refreshRate = 50; + break; + + case OS_TV_MPAL: + gAudioContext.unk_2960 = 16.546f; + gAudioContext.refreshRate = 60; + break; + + case OS_TV_NTSC: + default: + gAudioContext.unk_2960 = 16.713f; + gAudioContext.refreshRate = 60; + } + + Audio_InitMesgQueues(); + + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { + gAudioContext.aiBufLengths[i] = 0xA0; + } + + gAudioContext.totalTaskCount = 0; + gAudioContext.rspTaskIndex = 0; + gAudioContext.curAiBuffferIndex = 0; + gAudioContext.soundMode = AUDIO_MODE_STEREO; + gAudioContext.curTask = NULL; + gAudioContext.rspTask[0].task.t.dataSize = 0; + gAudioContext.rspTask[1].task.t.dataSize = 0; + + osCreateMesgQueue(&gAudioContext.syncDmaQueue, &gAudioContext.syncDmaMesg, 1); + osCreateMesgQueue(&gAudioContext.currAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMesgBuf, + ARRAY_COUNT(gAudioContext.currAudioFrameDmaMesgBuf)); + osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMesgBuf, + ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); + osCreateMesgQueue(&gAudioContext.preloadSampleQueue, gAudioContext.preloadSampleMesgBuf, + ARRAY_COUNT(gAudioContext.preloadSampleMesgBuf)); + gAudioContext.curAudioFrameDmaCount = 0; + gAudioContext.sampleDmaCount = 0; + gAudioContext.cartHandle = osCartRomInit(); + + if (heap == NULL) { + gAudioContext.audioHeap = gAudioHeap; + gAudioContext.audioHeapSize = gAudioContextInitSizes.heapSize; + } else { + void** hp = &heap; + gAudioContext.audioHeap = *hp; + gAudioContext.audioHeapSize = heapSize; + } + + for (i = 0; i < (s32)gAudioContext.audioHeapSize / 8; i++) { + ((u64*)gAudioContext.audioHeap)[i] = 0; + } + + // Main Pool Split (split entirety of audio heap into initPool and sessionPool) + AudioHeap_InitMainPool(gAudioContextInitSizes.mainPoolSplitSize); + + // Initialize the audio interface buffer + for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBuffers); i++) { + gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); + } + + // Connect audio tables to their tables in memory + gAudioContext.sequenceTable = (AudioTable*)gSequenceTable; + gAudioContext.soundFontTable = (AudioTable*)gSoundFontTable; + gAudioContext.sampleBankTable = (AudioTable*)gSampleBankTable; + gAudioContext.sequenceFontTable = gSequenceFontTable; + + gAudioContext.numSequences = gAudioContext.sequenceTable->numEntries; + + gAudioContext.audioResetSpecIdToLoad = 0; + gAudioContext.resetStatus = 1; // Set reset to immediately initialize the audio heap + AudioHeap_ResetStep(); + + // Initialize audio tables + AudioLoad_InitTable(gAudioContext.sequenceTable, SEGMENT_ROM_START(Audioseq), 0); + AudioLoad_InitTable(gAudioContext.soundFontTable, SEGMENT_ROM_START(Audiobank), 0); + AudioLoad_InitTable(gAudioContext.sampleBankTable, SEGMENT_ROM_START(Audiotable), 0); + + numFonts = gAudioContext.soundFontTable->numEntries; + gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + + for (i = 0; i < numFonts; i++) { + AudioLoad_InitSoundFontMeta(i); + } + + if (addr = AudioHeap_Alloc(&gAudioContext.audioInitPool, gAudioContextInitSizes.permanentPoolSize), addr == NULL) { + // cast away const from D_8014A6C4 + *((u32*)&gAudioContextInitSizes.permanentPoolSize) = 0; + } + + AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, addr, gAudioContextInitSizes.permanentPoolSize); + gAudioContextInitalized = true; + osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK); +} + +void AudioLoad_InitSlowLoads(void) { + gAudioContext.slowLoads[0].status = 0; + gAudioContext.slowLoads[1].status = 0; +} + +s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { + SoundFontSample* sample; + AudioSlowLoad* slowLoad; + + sample = AudioLoad_GetFontSample(fontId, instId); + if (sample == NULL) { + *isDone = 0; + return -1; + } + + if (sample->medium == MEDIUM_RAM) { + *isDone = 2; + return 0; + } + + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample = *sample; + slowLoad->isDone = isDone; + slowLoad->curRamAddr = + AudioHeap_AllocSampleCache(sample->size, fontId, sample->sampleAddr, (s32)sample->medium, CACHE_TEMPORARY); + + if (slowLoad->curRamAddr == NULL) { + if (sample->medium == MEDIUM_UNK || sample->codec == CODEC_S16_INMEMORY) { + *isDone = 0; + return -1; + } else { + *isDone = 3; + return -1; + } + } + + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = ALIGN16(sample->size); + slowLoad->ramAddr = slowLoad->curRamAddr; + slowLoad->curDevAddr = sample->sampleAddr; + slowLoad->medium = sample->medium; + slowLoad->seqOrFontId = fontId; + slowLoad->instId = instId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = gAudioContext.sampleBankTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { + SoundFontSample* sample; + + if (instId < 0x80) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); + + if (instrument == NULL) { + return NULL; + } + sample = instrument->normalNotesSound.sample; + } else if (instId < 0x100) { + Drum* drum = AudioPlayback_GetDrum(fontId, instId - 0x80); + + if (drum == NULL) { + return NULL; + } + sample = drum->sound.sample; + } else { + SoundFontSound* sound = AudioPlayback_GetSfx(fontId, instId - 0x100); + + if (sound == NULL) { + return NULL; + } + sample = sound->sample; + } + + return sample; +} + +void AudioLoad_Unused2(void) { +} + +void AudioLoad_FinishSlowLoad(AudioSlowLoad* slowLoad) { + SoundFontSample* sample; + + if (slowLoad->sample.sampleAddr == NULL) { + return; + } + + sample = AudioLoad_GetFontSample(slowLoad->seqOrFontId, slowLoad->instId); + if (sample == NULL) { + return; + } + + slowLoad->sample = *sample; + sample->sampleAddr = slowLoad->ramAddr; + sample->medium = MEDIUM_RAM; +} + +void AudioLoad_ProcessSlowLoads(s32 resetStatus) { + AudioSlowLoad* slowLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.slowLoads); i++) { + slowLoad = &gAudioContext.slowLoads[i]; + switch (gAudioContext.slowLoads[i].status) { + case LOAD_STATUS_LOADING: + if (slowLoad->medium != MEDIUM_UNK) { + osRecvMesg(&slowLoad->msgqueue, NULL, OS_MESG_BLOCK); + } + + if (resetStatus != 0) { + slowLoad->status = LOAD_STATUS_DONE; + continue; + } + case LOAD_STATUS_START: + slowLoad->status = LOAD_STATUS_LOADING; + if (slowLoad->bytesRemaining == 0) { + AudioLoad_FinishSlowLoad(slowLoad); + slowLoad->status = LOAD_STATUS_DONE; + *slowLoad->isDone = 1; + } else if ((s32)slowLoad->bytesRemaining < 0x400) { + if (slowLoad->medium == MEDIUM_UNK) { + size_t size = slowLoad->bytesRemaining; + + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, size, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, slowLoad->bytesRemaining); + } + slowLoad->bytesRemaining = 0; + } else { + if (slowLoad->medium == MEDIUM_UNK) { + AudioLoad_DmaSlowCopyUnkMedium(slowLoad->curDevAddr, slowLoad->curRamAddr, 0x400, + slowLoad->unkMediumParam); + } else { + AudioLoad_DmaSlowCopy(slowLoad, 0x400); + } + slowLoad->bytesRemaining -= 0x400; + slowLoad->curRamAddr += 0x400; + slowLoad->curDevAddr += 0x400; + } + break; + } + } +} + +void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size) { + Audio_InvalDCache(slowLoad->curRamAddr, size); + osCreateMesgQueue(&slowLoad->msgqueue, &slowLoad->msg, 1); + AudioLoad_Dma(&slowLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, slowLoad->curDevAddr, slowLoad->curRamAddr, size, + &slowLoad->msgqueue, slowLoad->medium, "SLOWCOPY"); +} + +void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3) { +} + +s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { + AudioSlowLoad* slowLoad; + AudioTable* seqTable; + size_t size; + + if (seqId >= gAudioContext.numSequences) { + *isDone = 0; + return -1; + } + + seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId); + seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE); + slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + if (slowLoad->status == LOAD_STATUS_DONE) { + slowLoad->status = LOAD_STATUS_WAITING; + } + + slowLoad->sample.sampleAddr = NULL; + slowLoad->isDone = isDone; + size = seqTable->entries[seqId].size; + size = ALIGN16(size); + slowLoad->curRamAddr = ramAddr; + slowLoad->status = LOAD_STATUS_START; + slowLoad->bytesRemaining = size; + slowLoad->ramAddr = ramAddr; + slowLoad->curDevAddr = seqTable->entries[seqId].romAddr; + slowLoad->medium = seqTable->entries[seqId].medium; + slowLoad->seqOrFontId = seqId; + + if (slowLoad->medium == MEDIUM_UNK) { + slowLoad->unkMediumParam = seqTable->unkMediumParam; + } + + gAudioContext.slowLoadPos ^= 1; + return 0; +} + +void AudioLoad_InitAsyncLoads(void) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + gAudioContext.asyncLoads[i].status = 0; + } +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t devAddr, void* ramAddr, size_t size, + s32 medium, s32 nChunks, OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + + asyncLoad = AudioLoad_StartAsyncLoad(devAddr, ramAddr, size, medium, nChunks, retQueue, retMsg); + if (asyncLoad == NULL) { + return NULL; + } + + osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); + asyncLoad->unkMediumParam = unkMediumParam; + return asyncLoad; +} + +AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_t size, s32 medium, s32 nChunks, + OSMesgQueue* retQueue, s32 retMsg) { + AudioAsyncLoad* asyncLoad; + s32 i; + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 0) { + asyncLoad = &gAudioContext.asyncLoads[i]; + break; + } + } + + // no more available async loads + if (i == ARRAY_COUNT(gAudioContext.asyncLoads)) { + return NULL; + } + + asyncLoad->status = LOAD_STATUS_START; + asyncLoad->curDevAddr = devAddr; + asyncLoad->ramAddr = ramAddr; + asyncLoad->curRamAddr = ramAddr; + asyncLoad->bytesRemaining = size; + + if (nChunks == 0) { + asyncLoad->chunkSize = 0x1000; + } else if (nChunks == 1) { + asyncLoad->chunkSize = size; + } else { + asyncLoad->chunkSize = ALIGN256((s32)size / nChunks); + if (asyncLoad->chunkSize < 0x100) { + asyncLoad->chunkSize = 0x100; + } + } + + asyncLoad->retQueue = retQueue; + asyncLoad->delay = 3; + asyncLoad->medium = medium; + asyncLoad->retMsg = retMsg; + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + return asyncLoad; +} + +void AudioLoad_ProcessAsyncLoads(s32 resetStatus) { + AudioAsyncLoad* asyncLoad; + s32 i; + + if (gAudioContext.resetTimer == 1) { + return; + } + + if (gAudioContext.curUnkMediumLoad == NULL) { + if (resetStatus != 0) { + // Clear and ignore queue if resetting. + do { + } while (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) != -1); + } else if (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) == -1) { + gAudioContext.curUnkMediumLoad = NULL; + } else { + gAudioContext.curUnkMediumLoad = asyncLoad; + } + } + + if (gAudioContext.curUnkMediumLoad != NULL) { + AudioLoad_ProcessAsyncLoadUnkMedium(gAudioContext.curUnkMediumLoad, resetStatus); + } + + for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { + if (gAudioContext.asyncLoads[i].status == 1) { + asyncLoad = &gAudioContext.asyncLoads[i]; + if (asyncLoad->medium != MEDIUM_UNK) { + AudioLoad_ProcessAsyncLoad(asyncLoad, resetStatus); + } + } + } +} + +void AudioLoad_ProcessAsyncLoadUnkMedium(AudioAsyncLoad* asyncLoad, s32 resetStatus) { +} + +void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { + u32 retMsg = asyncLoad->retMsg; + u32 fontId; + u32 pad; + OSMesg doneMsg; + u32 sampleBankId1; + u32 sampleBankId2; + AudioRelocInfo relocInfo; + + if (1) {} + switch (ASYNC_TBLTYPE(retMsg)) { + case SEQUENCE_TABLE: + AudioLoad_SetSeqLoadStatus(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case SAMPLE_TABLE: + AudioLoad_SetSampleFontLoadStatusAndApplyCaches(ASYNC_ID(retMsg), ASYNC_STATUS(retMsg)); + break; + case FONT_TABLE: + fontId = ASYNC_ID(retMsg); + sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + relocInfo.sampleBankId1 = sampleBankId1; + relocInfo.sampleBankId2 = sampleBankId2; + relocInfo.baseAddr1 = + sampleBankId1 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId1, &relocInfo.medium1) : 0; + relocInfo.baseAddr2 = + sampleBankId2 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId2, &relocInfo.medium2) : 0; + AudioLoad_SetFontLoadStatus(fontId, ASYNC_STATUS(retMsg)); + AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &relocInfo, true); + break; + } + + doneMsg = asyncLoad->retMsg; + if (1) {} + asyncLoad->status = LOAD_STATUS_WAITING; + osSendMesg(asyncLoad->retQueue, doneMsg, OS_MESG_NOBLOCK); +} + +void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus) { + AudioTable* sampleBankTable = gAudioContext.sampleBankTable; + + if (asyncLoad->delay >= 2) { + asyncLoad->delay--; + return; + } + + if (asyncLoad->delay == 1) { + asyncLoad->delay = 0; + } else if (resetStatus != 0) { + // Await the previous DMA response synchronously, then return. + osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_BLOCK); + asyncLoad->status = LOAD_STATUS_WAITING; + return; + } else if (osRecvMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK) == -1) { + // If the previous DMA step isn't done, return. + return; + } + + if (asyncLoad->bytesRemaining == 0) { + AudioLoad_FinishAsyncLoad(asyncLoad); + return; + } + + if (asyncLoad->bytesRemaining < asyncLoad->chunkSize) { + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->bytesRemaining, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->bytesRemaining); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->bytesRemaining); + } + asyncLoad->bytesRemaining = 0; + return; + } + + if (asyncLoad->medium == MEDIUM_UNK) { + AudioLoad_AsyncDmaUnkMedium(asyncLoad->curDevAddr, asyncLoad->curRamAddr, asyncLoad->chunkSize, + sampleBankTable->unkMediumParam); + } else if (asyncLoad->medium == MEDIUM_RAM_UNLOADED) { + AudioLoad_AsyncDmaRamUnloaded(asyncLoad, asyncLoad->chunkSize); + } else { + AudioLoad_AsyncDma(asyncLoad, asyncLoad->chunkSize); + } + + asyncLoad->bytesRemaining -= asyncLoad->chunkSize; + asyncLoad->curDevAddr += asyncLoad->chunkSize; + asyncLoad->curRamAddr = asyncLoad->curRamAddr + asyncLoad->chunkSize; +} + +void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + AudioLoad_Dma(&asyncLoad->ioMesg, OS_MESG_PRI_NORMAL, OS_READ, asyncLoad->curDevAddr, asyncLoad->curRamAddr, size, + &asyncLoad->msgQueue, asyncLoad->medium, "BGCOPY"); +} + +void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size) { + if (size) {} + size = ALIGN16(size); + Audio_InvalDCache(asyncLoad->curRamAddr, size); + osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); + bcopy(asyncLoad->curDevAddr, asyncLoad->curRamAddr, size); + osSendMesg(&asyncLoad->msgQueue, NULL, OS_MESG_NOBLOCK); +} + +void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3) { +} + +#define RELOC(v, base) (reloc = (void*)((uintptr_t)(v) + (uintptr_t)(base))) + +void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRelocInfo* relocInfo) { + SoundFontSample* sample; + void* reloc; + + if ((uintptr_t)sound->sample <= 0x80000000) { + sample = sound->sample = RELOC(sound->sample, mem); + if (sample->size != 0 && sample->unk_bit25 != true) { + sample->loop = RELOC(sample->loop, mem); + sample->book = RELOC(sample->book, mem); + + // Resolve the sample medium 2-bit bitfield into a real value based on relocInfo. + switch (sample->medium) { + case 0: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1); + sample->medium = relocInfo->medium1; + break; + case 1: + sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2); + sample->medium = relocInfo->medium2; + break; + case 2: + case 3: + // Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE + // respectively, and the sampleAddr unrelocated. + break; + } + + sample->unk_bit25 = true; + if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } + } + } +} + +#undef RELOC + +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, AudioRelocInfo* relocInfo, s32 async) { + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + SoundFontSample* sample; + size_t size; + s32 nChunks; + u8* sampleRamAddr; + s32 preloadInProgress; + s32 i; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } else { + D_801FD1E0 = 0; + } + + gAudioContext.numUsedSamples = 0; + AudioLoad_RelocateFont(fontId, mem, relocInfo); + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size && size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + sampleRamAddr = NULL; + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + sample->sampleAddr, sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == MEDIUM_DISK_DRIVE) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, + CACHE_TEMPORARY); + } + break; + } + if (sampleRamAddr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, sample->medium); + sample->sampleAddr = sampleRamAddr; + sample->medium = MEDIUM_RAM; + } + if (sample->medium == MEDIUM_DISK_DRIVE) {} + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = sampleRamAddr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { + SoundFontSample* sample; + AudioPreloadReq* preload; + u32 preloadIndex; + u32 key; + u32 nChunks; + s32 pad; + + if (gAudioContext.preloadSampleStackTop > 0) { + if (resetStatus != 0) { + // Clear result queue and preload stack and return. + osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK); + gAudioContext.preloadSampleStackTop = 0; + return false; + } + if (osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK) == -1) { + // Previous preload is not done yet. + return false; + } + + preloadIndex >>= 24; + preload = &gAudioContext.preloadSampleStack[preloadIndex]; + + if (preload->isFree == false) { + sample = preload->sample; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key == preload->endAndMediumKey) { + // Change storage for sample to the preloaded version. + sample->sampleAddr = preload->ramAddr; + sample->medium = MEDIUM_RAM; + } + preload->isFree = true; + } + + // Pop requests with isFree = true off the stack, as far as possible, + // and dispatch the next DMA. + for (;;) { + if (gAudioContext.preloadSampleStackTop <= 0) { + break; + } + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + if (preload->isFree == true) { + gAudioContext.preloadSampleStackTop--; + continue; + } + + sample = preload->sample; + nChunks = (sample->size >> 12) + 1; + key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + if (key != preload->endAndMediumKey) { + preload->isFree = true; + gAudioContext.preloadSampleStackTop--; + } else { + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, preload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, preload->encodedInfo); + break; + } + } + } + return true; +} + +s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontSample** sampleSet) { + s32 i; + + for (i = 0; i < numSamples; i++) { + if (sample->sampleAddr == sampleSet[i]->sampleAddr) { + break; + } + } + + if (i == numSamples) { + sampleSet[numSamples] = sample; + numSamples++; + } + + return numSamples; +} + +s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { + s32 i; + s32 numSamples = 0; + s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; + s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + + for (i = 0; i < numDrums; i++) { + Drum* drum = AudioPlayback_GetDrum(fontId, i); + + if (1) {} + if (drum != NULL) { + numSamples = AudioLoad_AddToSampleSet(drum->sound.sample, numSamples, sampleSet); + } + } + + for (i = 0; i < numInstruments; i++) { + Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, i); + + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + numSamples = AudioLoad_AddToSampleSet(instrument->lowNotesSound.sample, numSamples, sampleSet); + } + if (instrument->normalRangeHi != 0x7F) { + numSamples = AudioLoad_AddToSampleSet(instrument->highNotesSound.sample, numSamples, sampleSet); + } + numSamples = AudioLoad_AddToSampleSet(instrument->normalNotesSound.sample, numSamples, sampleSet); + } + } + + // Should really also process sfx, but this method is never called + return numSamples; +} + +void AudioLoad_AddUsedSample(SoundFontSound* sound) { + SoundFontSample* sample = sound->sample; + + if ((sample->size != 0) && (sample->unk_bit26) && (sample->medium != MEDIUM_RAM)) { + gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + } +} + +void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relocInfo) { + s32 numDrums; + s32 numInstruments; + s32 numSfx; + Drum* drum; + Instrument* instrument; + SoundFontSound* sound; + AudioPreloadReq* preload; + AudioPreloadReq* topPreload; + u8* addr; + size_t size; + s32 i; + SoundFontSample* sample; + s32 preloadInProgress; + s32 nChunks; + + preloadInProgress = false; + if (gAudioContext.preloadSampleStackTop != 0) { + preloadInProgress = true; + } + + gAudioContext.numUsedSamples = 0; + + numDrums = gAudioContext.soundFonts[fontId].numDrums; + numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + numSfx = gAudioContext.soundFonts[fontId].numSfx; + + for (i = 0; i < numInstruments; i++) { + instrument = AudioPlayback_GetInstrumentInner(fontId, i); + if (instrument != NULL) { + if (instrument->normalRangeLo != 0) { + AudioLoad_AddUsedSample(&instrument->lowNotesSound); + } + if (instrument->normalRangeHi != 0x7F) { + AudioLoad_AddUsedSample(&instrument->highNotesSound); + } + AudioLoad_AddUsedSample(&instrument->normalNotesSound); + } + } + + for (i = 0; i < numDrums; i++) { + drum = AudioPlayback_GetDrum(fontId, i); + if (drum != NULL) { + AudioLoad_AddUsedSample(&drum->sound); + } + } + + for (i = 0; i < numSfx; i++) { + sound = AudioPlayback_GetSfx(fontId, i); + if (sound != NULL) { + AudioLoad_AddUsedSample(sound); + } + } + + if (gAudioContext.numUsedSamples == 0) { + return; + } + + size = 0; + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + size += ALIGN16(gAudioContext.usedSamples[i]->size); + } + if (size) {} + + for (i = 0; i < gAudioContext.numUsedSamples; i++) { + if (gAudioContext.preloadSampleStackTop == 120) { + break; + } + + sample = gAudioContext.usedSamples[i]; + if (sample->medium == MEDIUM_RAM) { + continue; + } + + switch (async) { + case false: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_PERSISTENT); + } + break; + + case true: + if (sample->medium == relocInfo->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } else if (sample->medium == relocInfo->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + sample->medium, CACHE_TEMPORARY); + } + break; + } + if (addr == NULL) { + continue; + } + + switch (async) { + case false: + if (sample->medium == MEDIUM_UNK) { + AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, addr, sample->size, + gAudioContext.sampleBankTable->unkMediumParam); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } else { + AudioLoad_SyncDma((uintptr_t)sample->sampleAddr, addr, sample->size, sample->medium); + sample->sampleAddr = addr; + sample->medium = MEDIUM_RAM; + } + break; + + case true: + preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload->sample = sample; + preload->ramAddr = addr; + preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->isFree = false; + preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; + gAudioContext.preloadSampleStackTop++; + break; + } + } + gAudioContext.numUsedSamples = 0; + + if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + sample = topPreload->sample; + nChunks = (sample->size >> 12) + 1; + AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, + nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + } +} + +void AudioLoad_LoadPermanentSamples(void) { + s32 pad; + u32 fontId; + AudioTable* sampleBankTable; + s32 pad2; + s32 i; + + sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); + for (i = 0; i < gAudioContext.permanentPool.count; i++) { + AudioRelocInfo relocInfo; + + if (gAudioContext.permanentEntries[i].tableType == FONT_TABLE) { + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentEntries[i].id); + relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; + relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + + if (relocInfo.sampleBankId1 != 0xFF) { + relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1); + relocInfo.medium1 = sampleBankTable->entries[relocInfo.sampleBankId1].medium; + } + + if (relocInfo.sampleBankId2 != 0xFF) { + relocInfo.sampleBankId2 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId2); + relocInfo.medium2 = sampleBankTable->entries[relocInfo.sampleBankId2].medium; + } + AudioLoad_PreloadSamplesForFont(fontId, false, &relocInfo); + } + } +} + +void AudioLoad_Unused3(void) { +} + +void AudioLoad_Unused4(void) { +} + +void AudioLoad_Unused5(void) { +} + +void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone) { + static u32 sLoadIndex = 0; + + sScriptLoadDonePointers[sLoadIndex] = isDone; + AudioLoad_AsyncLoad(tableType, id, 0, sLoadIndex, &sScriptLoadQueue); + sLoadIndex++; + if (sLoadIndex == 0x10) { + sLoadIndex = 0; + } +} + +void AudioLoad_ProcessScriptLoads(void) { + u32 temp; + u32 sp20; + s8* isDone; + + if (osRecvMesg(&sScriptLoadQueue, (OSMesg*)&sp20, OS_MESG_NOBLOCK) != -1) { + temp = sp20 >> 24; + isDone = sScriptLoadDonePointers[temp]; + if (isDone != NULL) { + *isDone = false; + } + } +} + +void AudioLoad_InitScriptLoads(void) { + osCreateMesgQueue(&sScriptLoadQueue, sScriptLoadMesgBuf, ARRAY_COUNT(sScriptLoadMesgBuf)); +} diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index 78161943c..6ae5696f1 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -982,7 +982,7 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; note->playbackState.unk_84 = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x2E0); - note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.notesAndBuffersPool, 0x10); + note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x2E0); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); } } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index 56d8ac951..e57ad19b5 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -20,7 +20,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197C8C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80197D24.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisableAsFinished.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_SequencePlayerDisable.s") @@ -64,10 +64,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AB40.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_ResetSequencePlayer.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019AC10.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayerChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ACEC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s") diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c index d408361c7..20b4239da 100644 --- a/src/code/audio/code_80192BE0.c +++ b/src/code/audio/code_80192BE0.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019387C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938A0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938D0.s") @@ -76,6 +76,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194568.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801946E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s") diff --git a/src/code/audio/code_8019AF00.c b/src/code/audio/code_8019AF00.c index 5d0a166a2..2e7cc91e1 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -1,6 +1,1887 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/D_801E0BD0.s") +typedef struct { + /* 0x0 */ s8 x; + /* 0x1 */ s8 y; +} OcarinaControlStick; // size = 0x2 + +typedef struct { + /* 0x0 */ u16 playerIO; + /* 0x2 */ u16 channelMask; + /* 0x4 */ u8 channelIO[3 * 33 + 1]; +} NatureAmbienceDataIO; // size = 0x68 + +typedef struct { + /* 0x0 */ Vec3f* pos; + /* 0x4 */ f32 freqScale; + /* 0x8 */ s8 reverbAdd; +} SfxSettings; // size = 0x9 + +typedef struct { + /* 0x0 */ f32 vol; + /* 0x4 */ f32 freqScale; + /* 0x8 */ s8 reverb; + /* 0x9 */ s8 panSigned; + /* 0xA */ s8 stereoBits; + /* 0xB */ u8 filter; + /* 0xC */ u8 unk_0C; + /* 0xD */ u8 unk_0D; +} SfxPlayerState; // size = 0xE + +typedef enum { + /* 0x0 */ SFX_CHANNEL_PLAYER0, // SfxPlayerBank + /* 0x1 */ SFX_CHANNEL_PLAYER1, + /* 0x2 */ SFX_CHANNEL_PLAYER2, + /* 0x3 */ SFX_CHANNEL_ITEM0, // SfxItemBank + /* 0x4 */ SFX_CHANNEL_ITEM1, + /* 0x5 */ SFX_CHANNEL_ENV0, // SfxEnvironmentBank + /* 0x6 */ SFX_CHANNEL_ENV1, + /* 0x7 */ SFX_CHANNEL_ENV2, + /* 0x8 */ SFX_CHANNEL_ENEMY0, // SfxEnemyBank + /* 0x9 */ SFX_CHANNEL_ENEMY1, + /* 0xA */ SFX_CHANNEL_ENEMY2, + /* 0xB */ SFX_CHANNEL_SYSTEM0, // SfxSystemBank + /* 0xC */ SFX_CHANNEL_SYSTEM1, + /* 0xD */ SFX_CHANNEL_OCARINA, // SfxOcarinaBank + /* 0xE */ SFX_CHANNEL_VOICE0, // SfxVoiceBank + /* 0xF */ SFX_CHANNEL_VOICE1 +} SfxChannelIndex; // playerIndex = 2 + +// Global IO ports for sequences, 8 global ports per seqPlayer +typedef enum { + /* 0x0 */ SEQ_PLAYER_IO_PORT_0, + /* 0x1 */ SEQ_PLAYER_IO_PORT_1, + /* 0x2 */ SEQ_PLAYER_IO_PORT_2, + /* 0x3 */ SEQ_PLAYER_IO_PORT_3, + /* 0x4 */ SEQ_PLAYER_IO_PORT_4, + /* 0x5 */ SEQ_PLAYER_IO_PORT_5, + /* 0x6 */ SEQ_PLAYER_IO_PORT_6, + /* 0x7 */ SEQ_PLAYER_IO_PORT_7, +} SeqPlayerIOPort; + +typedef struct { + /* 0x0 */ f32 value; + /* 0x4 */ f32 target; + /* 0x8 */ f32 step; + /* 0xC */ s32 remainingFrames; +} FreqLerp; // size = 0x10 + +s32 AudioOcarina_MemoryGameGenerateNotes(void); +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); +void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); + +// Sfx bss +SfxSettings sSfxSettings[8]; +u8 sSfxSettingsFlags; +f32 sTwoSemitonesLoweredFreq; +s8 sSfxIncreasedReverb; +f32 sSfxSyncedVolume; +f32 sSfxSyncedVolumeForMetalEffects; +f32 sSfxSyncedFreq; +FreqLerp sRiverFreqScaleLerp; +FreqLerp sWaterfallFreqScaleLerp; +f32 sSfxAdjustedFreq; +s8 sSfxCustomReverb; +u8 sRiverSoundMainBgmVol; +u8 sRiverSoundMainBgmCurrentVol; +u8 sRiverSoundMainBgmLower; +u8 sRiverSoundMainBgmRestore; +u8 sGanonsTowerVol; +f32* sSfxVolumeCur; +f32 sSfxVolumeTarget; +f32 sSfxVolumeRate; +u16 sSceneSeqId1; +SfxPlayerState sSfxChannelState[16]; + +// Sequence bss +u8 D_801FD3A8; +u8 D_801FD3A9; +u8 sRiverSoundBgmTimer; +u8 sFanfareState; +u16 sFanfareSeqId; +u8 sMuteOnlySfxAndNatureSeq; +u8 sAllPlayersMutedExceptOcaAndSys; +u8 sAudioPauseState; +u8 sSpatialSeqIsActive[4]; +u8 sSequenceFilter[8 * 4]; +u8 sIsFinalHoursOrSoaring; +u8 sObjSoundFanfareSeqId; +u8 sObjSoundFanfareRequested; +Vec3f sObjSoundFanfarePos; +u8 sObjSoundPlayerIndex; +Vec3f sObjSoundPos; +s16 sObjSoundFlags; +f32 sObjSoundMinDist; +f32 sObjSoundMaxDist; +f32 sObjSoundMaxVol; +f32 sObjSoundMinVol; +Vec3f sSpatialSeqNoFilterPos; +Vec3f sSpatialSeqFilterPos; +f32 sSpatialSeqMaxDist; +u8 sSpatialSeqSeqId; +u8 sSpatialSeqFlags; +u8 D_801FD432; +u8 sSpatialSubBgmFadeTimer; +u8 D_801FD434; +u8 sSpatialSeqPlayerIndex; +u8 sSpatialSeqFadeTimer; +u16 D_801FD438; + +// AudioOcarina bss +OcarinaStaff sPlayingStaff; +OcarinaStaff sPlaybackStaff; +OcarinaStaff sRecordingStaff; +u32 sOcarinaUpdateTaskCurrent; +OcarinaControlStick sOcarinaInputStickRel; +u32 sOcarinaInputButtonCur; +u32 sOcarinaInputButtonStart; +u32 sOcarinaInputButtonPrev; +s32 sOcaInputBtnPress; +u8 sOcarinaResetDelay; +u8 sOcarinaResetUnused; +u8 sOcarinaHasStartedSong; +u8 sFirstOcarinaSongIndex; +u8 sLastOcarinaSongIndex; +u32 sOcarinaAvailSongs; +u8 sOcarinaStaffPlayingPos; +u16 sMusicStaffPos[OCARINA_SONG_MAX]; +u16 sMusicStaffCurHeldLength[OCARINA_SONG_MAX]; +u16 sMusicStaffExpectedLength[OCARINA_SONG_MAX]; +u8 sMusicStaffExpectedPitch[OCARINA_SONG_MAX]; // Next required pitch in song playback +u8 D_801FD518[OCARINA_SONG_MAX]; +u32 D_801FD530[OCARINA_SONG_MAX]; +OcarinaNote sRecordingSongNote; +u16 sCustomSequencePc; + +// Sfx Data +u8 D_801D6600[] = { + true, false, true, true, false, false, true, +}; +u8 D_801D6608[] = { + true, true, true, true, true, false, true, +}; +u8 gChannelsPerBank[4][7] = { + { 3, 2, 3, 3, 2, 1, 2 }, + { 3, 2, 2, 2, 2, 2, 2 }, + { 3, 2, 2, 2, 2, 2, 2 }, + { 4, 1, 0, 0, 2, 2, 2 }, +}; +u8 gUsedChannelsPerBank[4][7] = { + { 3, 2, 3, 2, 2, 1, 1 }, + { 3, 1, 1, 1, 2, 1, 1 }, + { 3, 1, 1, 1, 2, 1, 1 }, + { 2, 1, 0, 0, 1, 1, 1 }, +}; +f32 sGiantsMaskFreq = 0.89167805f; // Around 2 semitones down in pitch +s8 sGiantsMaskReverbAdd = 0x40; +f32 sWaterWheelVolume = 0.65f; +f32 gSfxVolume = 1.0f; +s8 sSfxTimer = 20; +s8 sSfxTimerLerpRange2 = 30; +s8 sSfxTimerLerpRange1 = 20; +f32 sBehindScreenZ[2] = { -15.0f, -65.0f }; // Unused Remnant of OoT +u8 sAudioIncreasingTranspose = 0; // Remnant of OoT, only unsed in unused functions +u8 gMorphaTransposeTable[16] = { 0, 0, 0, 1, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8 }; // Unused Remnant of OoT +u8 sPrevChargeLevel = 0; +f32 sChargeLevelsSfxFreq[] = { 1.0f, 1.12246f, 1.33484f, 1.33484f }; +f32 sCurChargeLevelSfxFreq = 1.0f; +u8 sGanonsTowerLevelsVol[] = { + 127, 80, 75, 73, 70, 68, 65, 60 // volumes +}; +u8 sEnterGanonsTowerTimer = 0; +u16 sSfxVolumeDuration = 0; + +// System Data +s8 sAudioFileSelectSetting = AUDIO_FS_STEREO; +s8 sAudioIsWindowOpen = false; +s8 sAudioCutsceneFlag = false; +s8 sSpecReverb = 0; +s8 sAudioEnvReverb = 0; +s8 sAudioCodeReverb = 0; + +// Sequence Data +u8 sPrevSeqMode = 0; +f32 sAudioEnemyDist = 0.0f; +s8 sAudioEnemyVol = 127; +u16 sPrevMainBgmSeqId = NA_BGM_DISABLED; +u8 sBgmPlayerIOPort7 = 0; +u8 sSceneSeqId2 = NA_BGM_GENERAL_SFX; +u32 sNumFramesStill = 0; +u32 sNumFramesMoving = 0; +u8 sAudioBaseFilter = 0; +u8 sAudioExtraFilter = 0; +u8 sAudioBaseFilter2 = 0; +u8 sAudioExtraFilter2 = 0; +s8 gUnderwaterSfxReverbAdd = 0; +Vec3f* sRiverSoundBgmPos = NULL; +f32 sRiverSoundXZDistToPlayer = 2000.0f; +u8 sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; +u8 sSeqFlags[] = { + 0x3, // NA_BGM_GENERAL_SFX + 0x1, // NA_BGM_NATURE_AMBIENCE + 0x1, // NA_BGM_TERMINA_FIELD + 0x8, // NA_BGM_CHASE + 0, // NA_BGM_MAJORAS_THEME + 0, // NA_BGM_CLOCK_TOWER + 0x1, // NA_BGM_STONE_TOWER_TEMPLE + 0x1, // NA_BGM_INV_STONE_TOWER_TEMPLE + 0x2, // NA_BGM_FAILURE_0 + 0x2, // NA_BGM_FAILURE_1 + 0, // NA_BGM_HAPPY_MASK_SALESMAN + 0, // NA_BGM_SONG_OF_HEALING + 0x1, // NA_BGM_SWAMP_REGION + 0, // NA_BGM_ALIEN_INVASION + 0x2, // NA_BGM_SWAMP_CRUISE + 0, // NA_BGM_SHARPS_CURSE + 0x1, // NA_BGM_GREAT_BAY_REGION + 0x1, // NA_BGM_IKANA_REGION + 0, // NA_BGM_DEKU_KING + 0x1, // NA_BGM_MOUNTAIN_REGION + 0, // NA_BGM_PIRATES_FORTRESS + 0, // NA_BGM_CLOCK_TOWN_DAY_1 + 0, // NA_BGM_CLOCK_TOWN_DAY_2 + 0, // NA_BGM_CLOCK_TOWN_DAY_3 + 0x40, // NA_BGM_FILE_SELECT + 0x10, // NA_BGM_CLEAR_EVENT + 0, // NA_BGM_ENEMY + 0x8, // NA_BGM_BOSS + 0x1, // NA_BGM_WOODFALL_TEMPLE + 0, // NA_BGM_MARKET + 0, // NA_BGM_OPENING + 0x20, // NA_BGM_INSIDE_A_HOUSE + 0x2, // NA_BGM_GAME_OVER + 0, // NA_BGM_CLEAR_BOSS + 0x2, // NA_BGM_GET_ITEM + 0x2, // NA_BGM_GATE_OPEN + 0x2, // NA_BGM_GET_HEART + 0x8, // NA_BGM_TIMED_MINI_GAME + 0, // NA_BGM_GORON_RACE + 0, // NA_BGM_MUSIC_BOX_HOUSE + 0, // NA_BGM_FAIRY_FOUNTAIN + 0, // NA_BGM_ZELDAS_LULLABY + 0, // NA_BGM_ROSA_SISTERS + 0x2, // NA_BGM_OPEN_CHEST + 0, // NA_BGM_MARINE_RESEARCH_LAB + 0x40, // NA_BGM_GIANTS_THEME + 0, // NA_BGM_SONG_OF_STORMS + 0, // NA_BGM_ROMANI_RANCH + 0, // NA_BGM_GORON_VILLAGE + 0, // NA_BGM_MAYORS_OFFICE + 0x2, // NA_BGM_OCA_EPONA + 0x2, // NA_BGM_OCA_SUNS + 0x2, // NA_BGM_OCA_TIME + 0x2, // NA_BGM_OCA_STORM + 0x10, // NA_BGM_ZORA_HALL + 0x2, // NA_BGM_GET_NEW_MASK + 0x8, // NA_BGM_MINI_BOSS + 0x2, // NA_BGM_GET_SMALL_ITEM + 0, // NA_BGM_ASTRAL_OBSERVATORY + 0x1, // NA_BGM_CAVERN + 0x11, // NA_BGM_MILK_BAR + 0x2, // NA_BGM_ZELDA_APPEAR + 0, // NA_BGM_SARIAS_SONG + 0, // NA_BGM_GORON_GOAL + 0, // NA_BGM_HORSE + 0, // NA_BGM_HORSE_GOAL + 0, // NA_BGM_INGO + 0, // NA_BGM_KOTAKE_POTION_SHOP + 0x20, // NA_BGM_SHOP + 0x2, // NA_BGM_OWL + 0x20, // NA_BGM_MINI_GAME + 0x2, // NA_BGM_OCA_SOARING + 0x2, // NA_BGM_OCA_HEALING + 0x2, // NA_BGM_INVERTED_SONG_OF_TIME + 0x2, // NA_BGM_SONG_OF_DOUBLE_TIME + 0x2, // NA_BGM_SONATA_OF_AWAKENING + 0x2, // NA_BGM_GORON_LULLABY + 0x2, // NA_BGM_NEW_WAVE_BOSSA_NOVA + 0x2, // NA_BGM_ELEGY_OF_EMPTINESS + 0x2, // NA_BGM_OATH_TO_ORDER + 0, // NA_BGM_SWORD_TRAINING_HALL + 0x2, // NA_BGM_GORON_LULLABY_INTRO + 0x2, // NA_BGM_OCA_FAIRY + 0x2, // NA_BGM_BREMEN_MARCH + 0x2, // NA_BGM_BALLAD_OF_THE_WIND_FISH + 0x8, // NA_BGM_SONG_OF_SOARING + 0, // NA_BGM_MILK_BAR_DUPLICATE + 0, // NA_BGM_FINAL_HOURS + 0x2, // NA_BGM_MIKAU_RIFF + 0x2, // NA_BGM_MIKAU_FINALE + 0, // NA_BGM_FROG_SONG + 0x2, // NA_BGM_OCA_SONATA + 0x2, // NA_BGM_OCA_LULLABY + 0x2, // NA_BGM_OCA_NEW_WAVE + 0x2, // NA_BGM_OCA_ELEGY + 0x2, // NA_BGM_OCA_OATH + 0, // NA_BGM_MAJORAS_LAIR + 0x2, // NA_BGM_OCA_LULLABY_INTRO + 0x2, // NA_BGM_OCA_GUITAR_BASS_SESSION + 0x2, // NA_BGM_PIANO_SESSION + 0x2, // NA_BGM_INDIGO_GO_SESSION + 0x1, // NA_BGM_SNOWHEAD_TEMPLE + 0x1, // NA_BGM_GREAT_BAY_TEMPLE + 0x2, // NA_BGM_NEW_WAVE_SAXOPHONE + 0x2, // NA_BGM_NEW_WAVE_VOCAL + 0, // NA_BGM_MAJORAS_WRATH + 0, // NA_BGM_MAJORAS_INCARNATION + 0, // NA_BGM_MAJORAS_MASK + 0x2, // NA_BGM_BASS_PLAY + 0x2, // NA_BGM_DRUMS_PLAY + 0x2, // NA_BGM_PIANO_PLAY + 0x1, // NA_BGM_IKANA_CASTLE + 0, // NA_BGM_GATHERING_GIANTS + 0x4, // NA_BGM_KAMARO_DANCE + 0, // NA_BGM_CREMIA_CARRIAGE + 0x2, // NA_BGM_KEATON_QUIZ + 0, // NA_BGM_END_CREDITS_1 + 0, // NA_BGM_OPENING_LOOP + 0, // NA_BGM_TITLE_THEME + 0x2, // NA_BGM_DUNGEON_APPEAR + 0x2, // NA_BGM_WOODFALL_CLEAR + 0x2, // NA_BGM_SNOWHEAD_CLEAR + 0, // + 0, // NA_BGM_INTO_THE_MOON + 0, // NA_BGM_GOODBYE_GIANT + 0, // NA_BGM_TATL_AND_TAEL + 0, // NA_BGM_MOONS_DESTRUCTION + 0, // NA_BGM_END_CREDITS_2 +}; + +s8 sSpecReverbs[20] = { + 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +NatureAmbienceDataIO sNatureAmbienceData[20] = { + // natureSeqId: 0 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 1 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_16), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(0), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_06), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 2 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(48), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_2_BEND_PITCH(48), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(32), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_4_BEND_PITCH(64), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(0), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(63), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 3 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(64), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(48), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(32), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(32), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), + NATURE_IO_CRITTER_3_BEND_PITCH(64), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 4 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_1_BEND_PITCH(64), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), + NATURE_IO_CRITTER_3_BEND_PITCH(64), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_4_BEND_PITCH(64), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_5_BEND_PITCH(112), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(48), + + // Channel 14 + NATURE_IO_RAIN_PORT4(63), + + // End + NATURE_IO_ENTRIES_END, + + }, + }, + + // natureSeqId: 5 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), + NATURE_IO_CRITTER_0_BEND_PITCH(64), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(32), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_1_BEND_PITCH(0), + NATURE_IO_CRITTER_1_NUM_LAYERS(1), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), + NATURE_IO_CRITTER_2_BEND_PITCH(112), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(48), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), + NATURE_IO_CRITTER_3_BEND_PITCH(127), + NATURE_IO_CRITTER_3_NUM_LAYERS(0), + NATURE_IO_CRITTER_3_PORT5(63), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(1), + NATURE_IO_CRITTER_4_PORT5(16), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(3), + NATURE_IO_CRITTER_5_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 6 + { + 0xC0FF, // PlayerIO Data + 0xC0FE, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_0_BEND_PITCH(112), + NATURE_IO_CRITTER_0_NUM_LAYERS(0), + NATURE_IO_CRITTER_0_PORT5(48), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_1_BEND_PITCH(112), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(63), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_2_BEND_PITCH(48), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // Channel 4 + NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), + NATURE_IO_CRITTER_3_BEND_PITCH(48), + NATURE_IO_CRITTER_3_NUM_LAYERS(1), + NATURE_IO_CRITTER_3_PORT5(16), + + // Channel 5 + NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_4_BEND_PITCH(127), + NATURE_IO_CRITTER_4_NUM_LAYERS(0), + NATURE_IO_CRITTER_4_PORT5(32), + + // Channel 6 + NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), + NATURE_IO_CRITTER_5_BEND_PITCH(127), + NATURE_IO_CRITTER_5_NUM_LAYERS(0), + NATURE_IO_CRITTER_5_PORT5(48), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 7 + { + 0xC001, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 8 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(3), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 9 + { + 0xC00F, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_16), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(2), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_12), + NATURE_IO_CRITTER_1_BEND_PITCH(112), + NATURE_IO_CRITTER_1_NUM_LAYERS(0), + NATURE_IO_CRITTER_1_PORT5(48), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_15), + NATURE_IO_CRITTER_2_BEND_PITCH(127), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 10 + { + 0xC081, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_1), + NATURE_IO_STREAM_0_PORT3(8), + + // Channel 7 + NATURE_IO_CRITTER_6_TYPE(NATURE_CRITTER_11), + NATURE_IO_CRITTER_6_BEND_PITCH(112), + NATURE_IO_CRITTER_6_NUM_LAYERS(2), + NATURE_IO_CRITTER_6_PORT5(32), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 11 + { + 0xC00F, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_3), + NATURE_IO_STREAM_0_PORT3(8), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(3), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_1_BEND_PITCH(127), + NATURE_IO_CRITTER_1_NUM_LAYERS(2), + NATURE_IO_CRITTER_1_PORT5(16), + + // Channel 3 + NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_06), + NATURE_IO_CRITTER_2_BEND_PITCH(127), + NATURE_IO_CRITTER_2_NUM_LAYERS(1), + NATURE_IO_CRITTER_2_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 12 + { + 0xC007, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_00), + NATURE_IO_CRITTER_0_BEND_PITCH(127), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // Channel 2 + NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_01), + NATURE_IO_CRITTER_1_BEND_PITCH(127), + NATURE_IO_CRITTER_1_NUM_LAYERS(3), + NATURE_IO_CRITTER_1_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 13 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 14 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 15 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 16 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 17 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 18 + { + 0xC000, // PlayerIO Data + 0xC000, // Channel Mask + { + // Channel 0 + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + + // End + NATURE_IO_ENTRIES_END, + }, + }, + + // natureSeqId: 19 + { + 0xC003, // PlayerIO Data + 0xC000, // Channel Mask + { + NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + NATURE_IO_STREAM_0_PORT3(0), + + // Channel 1 + NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), + NATURE_IO_CRITTER_0_BEND_PITCH(0), + NATURE_IO_CRITTER_0_NUM_LAYERS(1), + NATURE_IO_CRITTER_0_PORT5(16), + + // End + NATURE_IO_ENTRIES_END, + + }, + }, +}; + +// AudioOcarina Data +u8 sIsOcarinaInputEnabled = false; +s8 sOcarinaInstrumentId = OCARINA_INSTRUMENT_OFF; +u8 sCurOcarinaPitch = OCARINA_PITCH_NONE; +u8 sPrevOcarinaPitch = 0; +u8 sCurOcarinaButtonIndex = 0; +u8 sMusicStaffPrevPitch = 0; +f32 sCurOcarinaBendFreq = 1.0f; +f32 sDefaultOcarinaVolume = 0.68503935f; +s8 sCurOcarinaBendIndex = 0; +s8 sCurOcarinaVolume = 0x57; +s8 sCurOcarinaVibrato = 0; +u8 sPlaybackState = 0; +u8 D_801D6FE4 = 0xFF; +u8 D_801D6FE8 = 0xFF; +u32 sOcarinaFlags = 0; +s32 sPlaybackNoteTimer = 0; +u16 sPlaybackNotePos = 0; +u16 sPlaybackStaffPos = 0; +u32 sPrevOcarinaSongFlags = 0; // Stores sOcarinaFlags but never used +u8 sPlaybackNoteValue = OCARINA_PITCH_NONE; +u8 sNotePlaybackVolume = 0; +u8 sNotePlaybackVibrato = 0; +s8 sNotePlaybackBend = 0; +f32 sNormalizedNotePlaybackTone = 1.0f; +f32 sNormalizedNotePlaybackVolume = 1.0f; +u32 sOcarinaPlaybackTaskStart = 0; +u32 sOcarinaWallCounter = 0; +u8 sCurOcarinaSong[8] = { + OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, + OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, OCARINA_PITCH_C4, +}; +u8 sOcarinaSongAppendPos = 0; +u8 sOcarinaSongStartingPos = 0; + +u8 sButtonToPitchMap[5] = { + OCARINA_PITCH_D4, // OCARINA_BTN_A + OCARINA_PITCH_F4, // OCARINA_BTN_C_DOWN + OCARINA_PITCH_A4, // OCARINA_BTN_C_RIGHT + OCARINA_PITCH_B4, // OCARINA_BTN_C_LEFT + OCARINA_PITCH_D5, // OCARINA_BTN_C_UP +}; + +u8 sOcarinaMemoryGameAppendPos = 0; +u8 sOcaMemoryGameEndPos = 0; +u8 sOcaMemoryGameNumNotes[] = { 5, 6, 8 }; +OcarinaNote sOcarinaSongNotes[OCARINA_SONG_MAX][20] = { + // 0: Sonata of Awakening + { + { OCARINA_PITCH_D5, 19, 92, 0, 0, 0 }, + { OCARINA_PITCH_B4, 19, 90, 0, 0, 0 }, + { OCARINA_PITCH_D5, 19, 90, 0, 0, 0 }, + { OCARINA_PITCH_B4, 38, 90, 0, 0, 0 }, + { OCARINA_PITCH_D4, 39, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 76, 89, 0, 0, 0 }, + { OCARINA_PITCH_D4, 77, 82, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 86, 0, 0, 0 }, + }, + + // 1: Goron Lullaby + { + { OCARINA_PITCH_D4, 41, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 40, 72, 0, 0, 0 }, + { OCARINA_PITCH_B4, 39, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 42, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 40, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 39, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 41, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 80, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 40, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 2: New Wave Bossa Nova + { + { OCARINA_PITCH_B4, 64, 74, 0, 0, 0 }, + { OCARINA_PITCH_D5, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 12, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 76, 0, 0, 0 }, + { OCARINA_PITCH_B4, 13, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 114, 76, 6, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 3: Elegy of Emptyness + { + { OCARINA_PITCH_A4, 85, 93, 0, 0, 0 }, + { OCARINA_PITCH_B4, 43, 91, 0, 0, 0 }, + { OCARINA_PITCH_A4, 43, 93, 0, 0, 0 }, + { OCARINA_PITCH_F4, 21, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 21, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 43, 101, 0, 0, 0 }, + { OCARINA_PITCH_B4, 85, 95, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 94, 0, 0, 0 }, + }, + + // 4: Oath to Order + { + { OCARINA_PITCH_A4, 97, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 48, 88, 0, 0, 0 }, + { OCARINA_PITCH_D4, 49, 78, 0, 0, 0 }, + { OCARINA_PITCH_F4, 49, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 48, 94, 0, 0, 0 }, + { OCARINA_PITCH_D5, 97, 100, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 96, 0, 0, 0 }, + + }, + + // 5: Sarias Song + { + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 34, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 136, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 6: Song of Time + { + { OCARINA_PITCH_A4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 33, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 99, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 7: Song of Healing + { + { OCARINA_PITCH_B4, 32, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 33, 69, 0, 0, 0 }, + { OCARINA_PITCH_B4, 32, 94, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 121, 86, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 10, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 8: Eponas Song + { + { OCARINA_PITCH_D5, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 72, 80, 0, 0, 0 }, + { OCARINA_PITCH_D5, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 144, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 9: Song of Soaring + { + { OCARINA_PITCH_F4, 18, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 80, 0, 0, 0 }, + { OCARINA_PITCH_D5, 36, 94, 0, 0, 0 }, + { OCARINA_PITCH_F4, 18, 73, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 76, 0, 0, 0 }, + { OCARINA_PITCH_D5, 108, 96, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 10: Song of Storms + { + { OCARINA_PITCH_D4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 45, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 90, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 11: Suns Song + { + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 29, 80, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 9, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 120, 80, 3, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 12: Inverted Song of Time + { + { OCARINA_PITCH_F4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 32, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 65, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 99, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 13: Song of Double Time + { + { OCARINA_PITCH_A4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 29, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 99, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, + }, + + // 14: Goron Lullaby Intro + { + { OCARINA_PITCH_D4, 32, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 90, 0, 0, 0 }, + { OCARINA_PITCH_B4, 33, 87, 0, 0, 0 }, + { OCARINA_PITCH_D4, 32, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 86, 0, 0, 0 }, + { OCARINA_PITCH_B4, 130, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + { + { OCARINA_PITCH_D5, 89, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 41, 72, 0, 0, 0 }, + { OCARINA_PITCH_B4, 22, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 91, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 30, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + { + { OCARINA_PITCH_D4, 52, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 8, 72, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_F4, 34, 76, 0, 0, 0 }, + { OCARINA_PITCH_D4, 52, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 8, 72, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_D4, 30, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 66, 0, 0, 0 }, + { OCARINA_PITCH_A4, 34, 76, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + { + { OCARINA_PITCH_D5, 11, 80, 0, 0, 0 }, + { OCARINA_PITCH_A4, 11, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 100, 76, 0, 0, 0 }, + { OCARINA_PITCH_D5, 11, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 11, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 11, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 100, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + { + { OCARINA_PITCH_A4, 54, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 77, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 19, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 20, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 19: Evan HP (Zora Band Leader) Song Part 1 + { + { OCARINA_PITCH_A4, 33, 100, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 92, 0, 0, 0 }, + { OCARINA_PITCH_A4, 37, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 24, 100, 0, 0, 0 }, + { OCARINA_PITCH_D4, 70, 97, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 96, 0, 0, 0 }, + { OCARINA_PITCH_D4, 12, 93, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 100, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 62, 0, 0, 0 }, + { OCARINA_PITCH_D4, 170, 91, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 20: Evan HP (Zora Band Leader) Song Part 2 + { + { OCARINA_PITCH_B4, 33, 107, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 100, 0, 0, 0 }, + { OCARINA_PITCH_B4, 37, 104, 0, 0, 0 }, + { OCARINA_PITCH_A4, 24, 97, 0, 0, 0 }, + { OCARINA_PITCH_F4, 70, 104, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 104, 0, 0, 0 }, + { OCARINA_PITCH_F4, 12, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 96, 0, 0, 0 }, + { OCARINA_PITCH_B4, 12, 81, 0, 0, 0 }, + { OCARINA_PITCH_F4, 170, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // 21: Zeldas Lullaby + { + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 100, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // 22: Scarecrow + { + { OCARINA_PITCH_D4, 3, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 255, 0, 0, 0 }, + }, + + // 23: Termina Field 2D Song Buttons Appearing on Wall (In OoT, this is Ocarina Memory Game) + { + { OCARINA_PITCH_D4, 3, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 255, 0, 0, 0 }, + }, +}; + +OcarinaNote sOoTOcarinaSongNotes[9][20] = { + // Minuet + { + { OCARINA_PITCH_D4, 18, 86, 0, 0, 0 }, + { OCARINA_PITCH_D5, 18, 92, 0, 0, 0 }, + { OCARINA_PITCH_B4, 72, 86, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 144, 86, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 86, 0, 0, 0 }, + }, + + // Bolero + { + { OCARINA_PITCH_F4, 15, 80, 0, 0, 0 }, + { OCARINA_PITCH_D4, 15, 72, 0, 0, 0 }, + { OCARINA_PITCH_F4, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_D4, 15, 76, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 15, 74, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 78, 0, 0, 0 }, + { OCARINA_PITCH_F4, 135, 66, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 66, 0, 0, 0 }, + }, + + // Serenade + { + { OCARINA_PITCH_D4, 36, 60, 0, 0, 0 }, + { OCARINA_PITCH_F4, 36, 78, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 82, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 82, 0, 0, 0 }, + { OCARINA_PITCH_A4, 36, 84, 0, 0, 0 }, + { OCARINA_PITCH_B4, 144, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Requiem + { + { OCARINA_PITCH_D4, 45, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 23, 86, 0, 0, 0 }, + { OCARINA_PITCH_D4, 22, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 45, 86, 0, 0, 0 }, + { OCARINA_PITCH_F4, 45, 94, 0, 0, 0 }, + { OCARINA_PITCH_D4, 180, 94, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 94, 0, 0, 0 }, + }, + + // Nocturne + { + { OCARINA_PITCH_B4, 36, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 33, 84, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 3, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 82, 0, 0, 0 }, + { OCARINA_PITCH_D4, 18, 60, 0, 0, 0 }, + { OCARINA_PITCH_B4, 18, 90, 0, 0, 0 }, + { OCARINA_PITCH_A4, 18, 88, 0, 0, 0 }, + { OCARINA_PITCH_F4, 144, 96, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 96, 0, 0, 0 }, + }, + + // Prelude + { + { OCARINA_PITCH_D5, 15, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 45, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 15, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 15, 82, 0, 0, 0 }, + { OCARINA_PITCH_B4, 15, 86, 0, 0, 0 }, + { OCARINA_PITCH_D5, 60, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 75, 90, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Sarias + { + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 34, 80, 0, 0, 0 }, + { OCARINA_PITCH_F4, 17, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 17, 88, 0, 0, 0 }, + { OCARINA_PITCH_B4, 136, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Zeldas Lullaby + { + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 78, 80, 0, 0, 0 }, + { OCARINA_PITCH_B4, 51, 84, 0, 0, 0 }, + { OCARINA_PITCH_D5, 25, 88, 0, 0, 0 }, + { OCARINA_PITCH_A4, 100, 80, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, + + // Suns Song + { + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 29, 80, 2, 0, 0 }, + { OCARINA_PITCH_NONE, 9, 84, 0, 0, 0 }, + { OCARINA_PITCH_A4, 12, 84, 0, 0, 0 }, + { OCARINA_PITCH_F4, 13, 88, 0, 0, 0 }, + { OCARINA_PITCH_D5, 120, 80, 3, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 90, 0, 0, 0 }, + }, +}; + +u8 sOoTOcarinaSongsNumNotes[] = { + 6, // Minuet + 8, // Bolero + 5, // Serenade + 6, // Requiem + 7, // Nocturne + 6, // Prelude + 6, // Sarias + 6, // Zeldas Lullaby + 6, // Suns Song +}; + +OcarinaNote* sPlaybackSong = sOcarinaSongNotes[OCARINA_SONG_SONATA]; +u8 sFrogsSongNotes[14] = { + OCARINA_BTN_A, OCARINA_BTN_C_LEFT, OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_DOWN, OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_DOWN, OCARINA_BTN_A, OCARINA_BTN_C_DOWN, OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, OCARINA_BTN_C_RIGHT, OCARINA_BTN_C_LEFT, OCARINA_BTN_A, +}; +u8* gFrogsSongPtr = sFrogsSongNotes; +u8 sRecordingState = OCARINA_RECORD_OFF; +u8 sRecordSongPos = 0; +u32 sOcarinaRecordTaskStart = 0; +u8 sRecordOcarinaPitch = 0; +u8 sRecordOcarinaVolume = 0; +u8 sRecordOcarinaVibrato = 0; +s8 sRecordOcarinaBendIndex = 0; +u8 sRecordOcarinaButtonIndex = 0; +u8 sPlayedOcarinaSongIndexPlusOne = 0; +u8 sMusicStaffNumNotesPerTest = 0; +u8 D_801D8530 = false; +u32 D_801D8534 = 0; +u8 sIsOcarinaNoteChanged = false; + +OcarinaNote sScarecrowsLongSongNotes[108] = { + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, + { OCARINA_PITCH_NONE, 0, 0, 0, 0, 0 }, +}; + +OcarinaNote* gScarecrowLongSongPtr = sScarecrowsLongSongNotes; +u8* gScarecrowSpawnSongPtr = (u8*)&sOcarinaSongNotes[OCARINA_SONG_SCARECROW]; +OcarinaNote* sTerminaWallSongPtr = sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL]; + +u8 sPitchToButtonMap[16] = { + OCARINA_BTN_A, // OCARINA_PITCH_C4 + OCARINA_BTN_A, // OCARINA_PITCH_DFLAT4 + OCARINA_BTN_A, // OCARINA_PITCH_D4 + OCARINA_BTN_A, // OCARINA_PITCH_EFLAT4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_E4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_F4 + OCARINA_BTN_C_DOWN, // OCARINA_PITCH_GFLAT4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_G4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_AFLAT4 + OCARINA_BTN_C_RIGHT, // OCARINA_PITCH_A4 + OCARINA_BTN_C_RIGHT + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_BFLAT4: Interface/Overlap between C_RIGHT and C_LEFT + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_B4 + OCARINA_BTN_C_LEFT, // OCARINA_PITCH_C5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_DFLAT5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_D5 + OCARINA_BTN_C_UP, // OCARINA_PITCH_EFLAT5 +}; + +// seqData written in the music macro language +// Only used in unused functions +u8 sCustomSequenceScript[400] = { + 0xFE, 0xFE, 0xD3, 0x20, 0xD7, 0x00, 0x01, 0xCC, 0x00, 0x70, 0x90, 0x00, 0x16, 0xDB, 0x64, 0xDD, 0x78, + 0xFE, 0x00, 0xF3, 0xFC, 0xFF, 0xC3, 0x88, 0x00, 0x29, 0x89, 0x00, 0x2B, 0xDF, 0x7F, 0xE9, 0x0F, 0xDD, + 0x37, 0xD4, 0x40, 0xC1, 0x52, 0xFE, 0x80, 0xF3, 0xFC, 0xFF, 0xC2, 0xFB, 0xC0, 0x00, 0xC1, 0x57, 0xC9, +}; + +OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { + // 0: Sonata of Awakening + { + 7, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 1: Goron Lullaby + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 2: New Wave Bossa Nova + { + 7, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 3: Elegy of Emptyness + { + 7, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + }, + }, + + // 4: Oath to Order + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + }, + }, + + // 5; Sarias Song + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + }, + }, + + // 6: Song of Time + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + }, + }, + + // 7: Song of Healing + { + 6, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 8: Eponas Song + { + 6, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 9: Song of Soaring + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + }, + }, + + // 10: Song of Storms + { + 6, + { + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + }, + }, + + // 11: Suns Song + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_UP, + }, + }, + + // 12: Inverted Song of Time + { + 6, + { + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 13; Song of Double Time + { + 6, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_DOWN, + }, + }, + + // 14: Goron Lullaby Intro + { + 6, + { + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + }, + }, + + // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + { + 4, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + { + 8, + { + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + { + 5, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 19: Evan HP (Zora Band Leader) Song Part 1 + { + 8, + { + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_A, + }, + }, + + // 20: Evan HP (Zora Band Leader) Song Part 2 + { + 8, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_DOWN, + }, + }, + + // 21: Zeldas Lullaby + { + 6, + { + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_RIGHT, + }, + }, + + // 22: Scarecrow + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + OCARINA_BTN_A, + }, + }, + + // 23: Termina Field 2D Song Buttons Appearing on Wall (In OoT, this is Ocarina Memory Game) + { + 8, + { + OCARINA_BTN_A, + OCARINA_BTN_C_DOWN, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_UP, + OCARINA_BTN_C_LEFT, + OCARINA_BTN_C_RIGHT, + OCARINA_BTN_C_DOWN, + }, + }, +}; + +// Static In-Function Data +u8 sScarecrowAfterCreditsState = 0; +u8 sScarecrowAfterCreditsIntrumentId = OCARINA_INSTRUMENT_DEFAULT; +u16 sScarecrowAfterCreditsTimer = 1200; +u8 sRequestCustomSequence = false; +s8 D_801D8B30[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, + 64, 65, 65, 65, 66, 66, 66, 67, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, +}; +f32 sBigBellsVolume[8] = { + 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, +}; +u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; +f32 sSfxOriginalPos[] = { 0.0f, 0.0f, 0.0f }; + +// OoT's soundEffects from EnRiverSound +const u16 gAudioEnvironmentalSfx[] = { + NA_SE_EV_RIVER_STREAM - SFX_FLAG, NA_SE_EV_WAVE - SFX_FLAG, + NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, NA_SE_EV_WATER_WALL - SFX_FLAG, + NA_SE_EV_MAGMA_LEVEL - SFX_FLAG, NA_SE_EV_MAGMA_LEVEL_M - SFX_FLAG, + NA_SE_EV_MAGMA_LEVEL_L - SFX_FLAG, NA_SE_EV_TORCH - SFX_FLAG, + NA_SE_EV_FOUNTAIN - SFX_FLAG, NA_SE_EV_DRAIN - SFX_FLAG, + NA_SE_EV_CROWD - SFX_FLAG, NA_SE_EV_WATER_CONVECTION - SFX_FLAG, + NA_SE_EV_GORON_CHEER - SFX_FLAG, NA_SE_EV_WATER_WALL_BIG_SILENT - SFX_FLAG, + NA_SE_EV_WATER_BUBBLE - SFX_FLAG, NA_SE_EV_COW_CRY_LV - SFX_FLAG, + NA_SE_EV_MAKE_TURRET - SFX_FLAG, NA_SE_EV_BOILED_WATER_S - SFX_FLAG, + NA_SE_EV_BOILED_WATER_L - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, + NA_SE_EV_WAVE_S - SFX_FLAG, NA_SE_EV_WAVE_S - SFX_FLAG, +}; + +extern const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX]; +/** +const u8 sIsOcarinaSongReserved[OCARINA_SONG_MAX] = { + true, // OCARINA_SONG_SONATA + true, // OCARINA_SONG_GORON_LULLABY + true, // OCARINA_SONG_NEW_WAVE + true, // OCARINA_SONG_ELEGY + true, // OCARINA_SONG_OATH + false, // OCARINA_SONG_SARIAS + true, // OCARINA_SONG_TIME + true, // OCARINA_SONG_HEALING + true, // OCARINA_SONG_EPONAS + true, // OCARINA_SONG_SOARING + true, // OCARINA_SONG_STORMS + false, // OCARINA_SONG_SUNS + true, // OCARINA_SONG_INVERTED_TIME + true, // OCARINA_SONG_DOUBLE_TIME + true, // OCARINA_SONG_GORON_LULLABY_INTRO + false, // OCARINA_SONG_WIND_FISH_HUMAN + false, // OCARINA_SONG_WIND_FISH_GORON + false, // OCARINA_SONG_WIND_FISH_ZORA + false, // OCARINA_SONG_WIND_FISH_DEKU + true, // OCARINA_SONG_EVAN_PART1 + true, // OCARINA_SONG_EVAN_PART2 + false, // OCARINA_SONG_ZELDAS_LULLABY + true, // OCARINA_SONG_SCARECROW + false, // OCARINA_SONG_TERMINA_WALL +}; +*/ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019AF00.s") @@ -10,7 +1891,8 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B02C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B074.s") +void AudioOcarina_MapSongFromNotesToButtons(u8 noteSongIndex, u8 buttonSongIndex, u8 numButtons); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B144.s") @@ -22,7 +1904,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B4B8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B544.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019B568.s") @@ -48,7 +1930,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C2E4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C300.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C398.s") @@ -56,7 +1938,14 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019C8D8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/D_801E0C14.s") +const char sAudioOcarinaUnusedText0[] = "key step is too long !!! %d:%d>%d\n"; +const char sAudioOcarinaUnusedText1[] = "You played %d Melody !!! (last step:%d)\n"; +const char sAudioOcarinaUnusedText2[] = "pass 0\n"; +const char sAudioOcarinaUnusedText3[] = "pass 1\n"; +const char sAudioOcarinaUnusedText4[] = "pass 2\n"; +const char sAudioOcarinaUnusedText5[] = "last key is bad !!! %d %d %02X %02X\n"; +const char sAudioOcarinaUnusedText6[] = "last key step is too short !!! %d:%d %d<%d\n"; +const char sAudioOcarinaUnusedText7[] = "check is over!!! %d %d %d\n"; #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CD08.s") @@ -70,17 +1959,154 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF78.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CF9C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019CFA8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D134.s") +/** + * Tests to see if the notes from songIndex contain identical notes + * within its song to any of the reserved songIndex from 0 up to maxSongIndex + */ +s32 AudioOcarina_TerminaWallValidateNotes(u8 songIndex, u8 maxSongIndex) { + u8 curSongIndex; + u8 j; + u8 k; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D26C.s") + // loop through all possible songs up to maxSongIndex + for (curSongIndex = 0; curSongIndex < maxSongIndex; curSongIndex++) { + // check to see if the song is reserved or not + if (sIsOcarinaSongReserved[curSongIndex]) { + // starting index to test the song + for (j = 0; j < (9 - gOcarinaSongButtons[curSongIndex].numButtons); j++) { + // loop through each note in the song + for (k = 0; (k < gOcarinaSongButtons[curSongIndex].numButtons) && ((k + j) < 8) && + (gOcarinaSongButtons[curSongIndex].buttonIndex[k] == + gOcarinaSongButtons[songIndex].buttonIndex[(k + j)]); + k++) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D488.s") + if (k == gOcarinaSongButtons[curSongIndex].numButtons) { + // failure: songIndex is identical to curSongIndex. + return -1; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D4F8.s") + // success: notes are accepted and used + return 0; +} + +/** + * Generates the notes displayed on the Termina Field wall of musical notes + * Song generation loop alternates between 8 random notes and a random song from Ocarina of Time (OoT). + * Will check to see that the notes are valid by ensuring no playable song is within the selected notes + * All OoT songs are valid, so the outer loop will run a maxiumum of two times. + * i.e. if random notes fails, then the next set of notes will be from a valid OoT song + */ +void AudioOcarina_TerminaWallGenerateNotes(void) { + OcarinaNote* ocarinaNote; + u8 randButtonIndex; + u8 i; + u8 j; + + do { + i = 0; + if (sOcarinaWallCounter++ % 2) { + j = 0; + + for (; i < 8; i++) { + randButtonIndex = Audio_NextRandom() % ARRAY_COUNT(sButtonToPitchMap); + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = sButtonToPitchMap[randButtonIndex]; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 19; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 80; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].length = 3; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].volume = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j].bend = 0; + j++; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 2].length = 90; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j - 1].length = 22; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][j + 1].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, 8); + } else { + j = Audio_NextRandom() % ARRAY_COUNT(sOoTOcarinaSongNotes); + ocarinaNote = sOoTOcarinaSongNotes[j]; + + for (; ocarinaNote[i].length != 0; i++) { + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i] = ocarinaNote[i]; + } + + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_TERMINA_WALL][i].length = 0; + AudioOcarina_MapSongFromNotesToButtons(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL, + sOoTOcarinaSongsNumNotes[j]); + } + } while (AudioOcarina_TerminaWallValidateNotes(OCARINA_SONG_TERMINA_WALL, OCARINA_SONG_TERMINA_WALL) != 0); +} + +/** + * Unused remnant of OoT + */ +void AudioOcarina_MemoryGameSetNumNotes(u8 minigameRound) { + u8 i; + + if (minigameRound > 2) { + minigameRound = 2; + } + + sOcarinaMemoryGameAppendPos = 0; + sOcaMemoryGameEndPos = sOcaMemoryGameNumNotes[minigameRound]; + + for (i = 0; i < 3; i++) { + AudioOcarina_MemoryGameGenerateNotes(); + } +} + +/** + * Unused remnant of OoT, Id 14 now represent Goron Lullaby Intro instead of the OoT ocarina memory game + * //! @bug calling this function in MM will overwrite Goron Lullaby Intro + */ +#define OCARINA_SONG_MEMORYGAME 14 +s32 AudioOcarina_MemoryGameGenerateNotes(void) { + u32 randButtonIndex; + u8 randPitch; + + if (sOcarinaMemoryGameAppendPos == sOcaMemoryGameEndPos) { + return true; + } + + randButtonIndex = Audio_NextRandom(); + randPitch = sButtonToPitchMap[randButtonIndex % ARRAY_COUNT(sButtonToPitchMap)]; + + if (sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos - 1].pitch == randPitch) { + randPitch = sButtonToPitchMap[(randButtonIndex + 1) % ARRAY_COUNT(sButtonToPitchMap)]; + } + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = randPitch; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 45; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].volume = 0x50; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].vibrato = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].bend = 0; + + sOcarinaMemoryGameAppendPos++; + + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos].length = 0; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].pitch = OCARINA_PITCH_NONE; + sOcarinaSongNotes[OCARINA_SONG_MEMORYGAME][sOcarinaMemoryGameAppendPos + 1].length = 0; + if (1) {} + return false; +} +#undef OCARINA_SONG_MEMORYGAME #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019D600.s") @@ -188,11 +2214,50 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF38.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019FF9C.s") +/** + * Used for EnRiverSound + */ +void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_RIVER_STREAM - SFX_FLAG)) { + sRiverFreqScaleLerp.value = freqScale; + } else if (freqScale != sRiverFreqScaleLerp.value) { + sRiverFreqScaleLerp.target = freqScale; + sRiverFreqScaleLerp.remainingFrames = 40; + sRiverFreqScaleLerp.step = (sRiverFreqScaleLerp.target - sRiverFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_RIVER_STREAM - SFX_FLAG, pos, 4, &sRiverFreqScaleLerp.value, &D_801DB4B0, + &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0048.s") +/** + * Unused remnant of OoT's EnRiverSound + * Used for Zora's River Waterfall + */ +void Audio_PlaySfxForWaterfall(Vec3f* pos, f32 freqScale) { + if (!Audio_IsSfxPlaying(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG)) { + sWaterfallFreqScaleLerp.value = freqScale; + } else if (freqScale != sWaterfallFreqScaleLerp.value) { + sWaterfallFreqScaleLerp.target = freqScale; + sWaterfallFreqScaleLerp.remainingFrames = 40; + sWaterfallFreqScaleLerp.step = (sWaterfallFreqScaleLerp.target - sWaterfallFreqScaleLerp.value) / 40; + } + Audio_PlaySfxGeneral(NA_SE_EV_WATER_WALL_BIG - SFX_FLAG, pos, 4, &sWaterfallFreqScaleLerp.value, + &sWaterfallFreqScaleLerp.value, &D_801DB4B8); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A00EC.s") +/** + * Used for EnRiverSound variables + */ +void Audio_StepFreqLerp(FreqLerp* lerp) { + if (lerp->remainingFrames != 0) { + lerp->remainingFrames--; + if (lerp->remainingFrames != 0) { + lerp->value += lerp->step; + } else { + lerp->value = lerp->target; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0124.s") @@ -204,13 +2269,131 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0238.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A026C.s") +/** + * Unused remnant from OoT's EnRiverSound + * Was designed to incrementally increase volume of NA_BGM_GANON_TOWER for each new room during the climb of Ganon's + * Tower + */ +void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) { + u8 channelIndex; + s8 pan = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0318.s") + // Ganondorfs's Lair + if (ganonsTowerLevel == 0) { + pan = 0x7F; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0450.s") + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + // CHAN_UPD_PAN_UNSIGNED + Audio_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A046C.s") + // Lowest room in Ganon's Tower (Entrance Room) + if (ganonsTowerLevel == 7) { + // Adds a delay to setting the volume in the first room + sEnterGanonsTowerTimer = 2; + } else { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[ganonsTowerLevel % ARRAY_COUNTU(sGanonsTowerLevelsVol)]); + } +} + +/** + * Unused remnant from OoT's EnRiverSound + * If a new volume is requested for ganon's tower, update the volume and + * calculate a new low-pass filter cutoff and reverb based on the new volume + */ +s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { + u8 lowPassFilterCutoff; + u8 channelIndex; + u16 reverb; + + if (sGanonsTowerVol != targetVolume) { + // Sets the volume + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, targetVolume, 2); + + // Sets the filter cutoff of the form (lowPassFilterCutoff << 4) | (highPassFilter & 0xF). highPassFilter is + // always set to 0 + if (targetVolume < 0x40) { + // Only the first room + lowPassFilterCutoff = 0x10; + } else { + // Higher volume leads to a higher cut-off frequency in the low-pass filtering + lowPassFilterCutoff = (((targetVolume - 0x40) >> 2) + 1) << 4; + } + + Audio_QueueSeqCmd((8 << 28) | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u8)(4) << 16) | ((u8)(15) << 8) | + (u8)(lowPassFilterCutoff)); + + // Sets the reverb + for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels); + channelIndex++) { + if (&gAudioContext.sequenceChannelNone != + gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) { + // soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT) + if ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] != + 0xFF) { + // Higher volume leads to lower reverb + reverb = + (((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] - + targetVolume) + + 0x7F); + + if (reverb > 0x7F) { + reverb = 0x7F; + } + + // CHAN_UPD_REVERB + Audio_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | + _SHIFTL(channelIndex, 8, 8), + (u8)reverb); + } + } + } + + sGanonsTowerVol = targetVolume; + } + return -1; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Responsible for lowering market bgm in Child Market Entrance and Child Market Back Alley + * Only lowers volume for 1 frame, so must be called every frame to maintain lower volume + */ +void Audio_LowerMainBgmVolume(u8 volume) { + sRiverSoundMainBgmVol = volume; + sRiverSoundMainBgmLower = true; +} + +/** + * Unused remnant from OoT's EnRiverSound + * Still called by Audio_Update every frame, but none of these processes get initialized + */ +void Audio_UpdateRiverSoundVolumes(void) { + // Updates Main Bgm Volume (RiverSound of type RS_LOWER_MAIN_BGM_VOLUME) + if (sRiverSoundMainBgmLower == true) { + if (sRiverSoundMainBgmCurrentVol != sRiverSoundMainBgmVol) { + // lowers the volume for 1 frame + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 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); + sRiverSoundMainBgmCurrentVol = 0x7F; + sRiverSoundMainBgmRestore = false; + } + + // Update Ganon's Tower Volume (RiverSound of type RS_GANON_TOWER_7) + if (sEnterGanonsTowerTimer != 0) { + sEnterGanonsTowerTimer--; + if (sEnterGanonsTowerTimer == 0) { + Audio_SetGanonsTowerBgmVolume(sGanonsTowerLevelsVol[7]); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0554.s") @@ -224,13 +2407,71 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0868.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A09D4.s") +/** + * Unused remnant of OoT's EnRiverSound (func_800F4E30) + */ +void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) { + f32 volumeRel; + s8 pan; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C70.s") + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } else if (sRiverSoundBgmPos != pos) { + if (sRiverSoundXZDistToPlayer > xzDistToPlayer) { + sRiverSoundBgmPos = pos; + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } + } else { + sRiverSoundXZDistToPlayer = xzDistToPlayer; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0C90.s") + if (sRiverSoundBgmPos->x > 100.0f) { + pan = 0x7F; + } else if (sRiverSoundBgmPos->x < -100.0f) { + pan = 0; + } else { + pan = ((sRiverSoundBgmPos->x / 100.0f) * 64.0f) + 64.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0CB0.s") + if (sRiverSoundXZDistToPlayer > 400.0f) { + volumeRel = 0.1f; + } else if (sRiverSoundXZDistToPlayer < 120.0f) { + volumeRel = 1.0f; + } else { + volumeRel = ((1.0f - ((sRiverSoundXZDistToPlayer - 120.0f) / 280.0f)) * 0.9f) + 0.1f; + } + + for (channelIndex = 0; channelIndex < 16; 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))); + Audio_QueueCmdS8(0x03000000 | ((u8)((u32)channelIndex) << 8), pan); + } + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm(void) { + if (sRiverSoundBgmPos != NULL) { + sRiverSoundBgmPos = NULL; + } +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgmAtPos(Vec3f* pos) { + if (sRiverSoundBgmPos == pos) { + sRiverSoundBgmPos = NULL; + } +} + +void Audio_SplitBgmChannels(s8 volumeSplit); +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s") @@ -264,9 +2505,58 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2090.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A21FC.s") +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { + f32 absY; + f32 dist; + u8 targetVolume; + f32 prevDist; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2460.s") + if (sRiverSoundBgmTimer != 0) { + sRiverSoundBgmTimer--; + return; + } + + dist = sqrtf(SQ(pos->z) + (SQ(pos->x) + SQ(pos->y))); + + if (sRiverSoundBgmPos == NULL) { + sRiverSoundBgmPos = pos; + func_801A3238(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); + } else { + prevDist = sqrtf(SQ(sRiverSoundBgmPos->z) + SQ(sRiverSoundBgmPos->x)); + if (dist < prevDist) { + sRiverSoundBgmPos = pos; + } else { + dist = prevDist; + } + } + + absY = ABS_ALT(pos->y); + + if ((distMax / 15.0f) < absY) { + targetVolume = 0; + } else if (dist < distMax) { + targetVolume = (1.0f - (dist / distMax)) * 127.0f; + } else { + targetVolume = 0; + } + + if (seqId != NA_BGM_FAIRY_FOUNTAIN) { + Audio_SplitBgmChannels(targetVolume); + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, targetVolume, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - targetVolume, 0); +} + +/** + * Unused remnant of OoT's EnRiverSound + */ +void Audio_ClearSariaBgm2(void) { + sRiverSoundBgmPos = NULL; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") @@ -350,7 +2640,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3EC0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F54.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F6C.s") diff --git a/src/code/audio/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c index 7d796aa9f..8397fd52e 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -40,6 +40,6 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A787C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A78E4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A794C.s") diff --git a/src/code/audio/code_801A7B10.c b/src/code/audio/code_801A7B10.c index d2d9a71a2..6d3faaeab 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -18,7 +18,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8B2C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8BD0.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") diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index dcf540483..ee6014137 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -79,7 +79,7 @@ void AudioMgr_ThreadEntry(void* arg) { s32 exit; func_801A4C30(); - func_80190B38(DmaMgr_DmaCallback0); + AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); func_801A4D00(); 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 754b8759d..d95f53269 100644 --- a/src/code/code_800E8EA0.c +++ b/src/code/code_800E8EA0.c @@ -57,15 +57,13 @@ s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* Player* player = GET_PLAYER(globalCtx); s16 sVar3; Vec3f local_14; - s16 sVar3A; actor->focus.pos = actor->world.pos; actor->focus.pos.y += param_5; if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y; - sVar3A = ABS_ALT(sVar3); - if (sVar3A >= 0x4300) { + sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (sVar3 >= 0x4300) { func_800E8F08(param_3, param_4); return 0; } @@ -86,14 +84,12 @@ s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* Player* player = GET_PLAYER(globalCtx); s16 sVar3; Vec3f local_14; - s16 sVar3A; actor->focus.pos = param_5; if (((globalCtx->csCtx).state == 0) && (D_801D0D50 == 0)) { - sVar3 = actor->yawTowardsPlayer - actor->shape.rot.y; - sVar3A = ABS_ALT(sVar3); - if (sVar3A >= 0x4300) { + sVar3 = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y)); + if (sVar3 >= 0x4300) { func_800E8F08(param_3, param_4); return 0; } diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index 648f05556..9e0a9b516 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -107,7 +107,7 @@ void* gItemIcons[] = { 0x08007000, // ITEM_BOMBCHU 0x08008000, // ITEM_STICK 0x08009000, // ITEM_NUT - 0x0800A000, // ITEM_MAGIC_BEANS + 0x0800A000, // ITEM_BEAN 0x0800B000, // ITEM_SLINGSHOT 0x0800C000, // ITEM_POWDER_KEG 0x0800D000, // ITEM_PICTO_BOX @@ -504,7 +504,7 @@ void Inventory_ChangeEquipment(s16 value) { u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { Player* player = GET_PLAYER(globalCtx); - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { SET_EQUIP_VALUE(EQUIP_SHIELD, 0); Player_SetEquipmentData(globalCtx, player); return true; @@ -691,15 +691,17 @@ void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; for (i = 0; i < 8; i++) { - gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = gSaveContext.save.playerData.playerName[i]; + gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = + gSaveContext.save.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.skullTokenCount = + ((u16)(((gSaveContext.save.skullTokenCount & 0xFFFF0000) >> 0x10) + 1) << 0x10) | + (gSaveContext.save.skullTokenCount & 0xFFFF); } else { // Ocean Spider House (increment low bits of skullTokenCount) gSaveContext.save.skullTokenCount = @@ -720,8 +722,9 @@ s16 Inventory_GetSkullTokenCount(s16 sceneIndex) { void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) { u16 lotteryCodeGuess; - lotteryCodeGuess = ((globalCtx->msgCtx.unk12054 & 0xF) << 8); // First Digit - lotteryCodeGuess |= ((globalCtx->msgCtx.unk12056 & 0xF) << 4); // Second Digit - lotteryCodeGuess |= (globalCtx->msgCtx.unk12058 & 0xF); // Third Digit - gSaveContext.save.lotteryCodeGuess = (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); + lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit + lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit + lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit + gSaveContext.save.lotteryCodeGuess = + (gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF); } diff --git a/src/code/sched.c b/src/code/sched.c index 5f9cdf236..927a48f66 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index d676a437c..45b94d569 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -130,7 +130,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D220.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D2FC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/Math3D_LineSegVsPlane.s") #pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017D404.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index f41fb43df..93eeeddc7 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1279,7 +1279,7 @@ f32 Actor_HeightDiff(Actor* actor1, Actor* actor2) { * Sets the current and new inputs. */ void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 magnitude, s16 baseYaw) { - s16 relativeYaw = baseYaw - func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 relativeYaw = baseYaw - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); input->cur.stick_x = -Math_SinS(relativeYaw) * magnitude; input->rel.stick_x = input->cur.stick_x; @@ -1341,7 +1341,7 @@ void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player) { EnHorse* rideActor = (EnHorse*)player->rideActor; if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) { - func_800DFAC8(Play_GetCamera(globalCtx, MAIN_CAM), 4); + func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 4); } } } @@ -2016,7 +2016,7 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa player->getItemDirection = absYawDiff; if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[1]); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[1]); } return true; @@ -2237,7 +2237,7 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn s32 i; gSaveContext.save.weekEventReg[92] |= 0x80; - cycleFlags = &gSaveContext.cycleSceneFlags[convert_scene_number_among_shared_scenes(globalCtx->sceneNum)]; + cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; bzero(actorCtx, sizeof(ActorContext)); ActorOverlayTable_Init(); @@ -2252,8 +2252,8 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn } actorCtx->flags.chest = cycleFlags->chest; - actorCtx->flags.switches[0] = cycleFlags->swch0; - actorCtx->flags.switches[1] = cycleFlags->swch1; + actorCtx->flags.switches[0] = cycleFlags->switch0; + actorCtx->flags.switches[1] = cycleFlags->switch1; if (globalCtx->sceneNum == SCENE_INISIE_R) { cycleFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; } @@ -3037,7 +3037,7 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { actorCtx->absoluteSpace = NULL; } - func_80169D40(globalCtx); + Play_SaveCycleSceneFlags(&globalCtx->state); ActorOverlayTable_Cleanup(); } @@ -3329,7 +3329,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC if ((player != NULL) && (actor == player->unk_730)) { func_80123DA4(player); - Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCameraIndex(globalCtx)), 0); + Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCamId(globalCtx)), 0); } if (actor == actorCtx->targetContext.arrowPointedActor) { @@ -3405,7 +3405,8 @@ void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, if (((phi_s2) || (phi_s2_2)) && (func_800B83BC(actor, temp_f0_2))) { if (func_800BB59C(globalCtx, actor)) { if (((!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.focus.pos, - &actor->focus.pos, &sp70, &sp80, 1, 1, 1, 1, &sp7C)) || + &actor->focus.pos, &sp70, &sp80, true, true, true, true, + &sp7C)) || (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C)))) { if (actor->targetPriority != 0) { if ((phi_s2 != 0) && (actor->targetPriority < D_801ED8D4)) { @@ -3798,13 +3799,13 @@ void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { Quake_SetCountdown(idx, countdown); } -void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) { - if (arg2 >= 5) { +void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown) { + if (y >= 5) { func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150); } else { func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100); } - func_800BC770(globalCtx, arg2, arg3); + func_800BC770(globalCtx, y, countdown); } typedef struct { @@ -3907,104 +3908,148 @@ Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) { return Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); } -void func_800BCCDC(Vec3s* points, s32 pathCount, Vec3f* pos1, Vec3f* pos2, s32 arg4) { - s32 spB4; - s32 spB0; - s32 spA8[2] = { 0, 0 }; - s32 spA0[2] = { 0, 0 }; - Vec3f sp94; - Vec3f sp7C[2]; - Vec3f sp70; - Vec3f sp64; - f32 sp60; - f32 sp5C; - f32 sp54[2]; +/** + * Calculates the closest position `dstPos` to the input position `srcPos` along the path given by `points`/`numPoints` + * Whether the points provided forms a closed-loop path is indicated by `isPathLoop` + */ +void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3f* dstPos, s32 isPathLoop) { + s32 pointIndex; + s32 closestPointIndex; + s32 useAdjacentLines[2] = { + false, // determines whether to use line connecting to previous point in calculations + false, // determines whether to use line connecting to next point in calculations + }; + s32 isRightSideOfAdjacentLines[2] = { + false, // determines whether srcPos is on the right side of the line from prev to curr point + false, // determines whether srcPos is on the right side of the line from curr to next point + }; + Vec3f closestPoint; + Vec3f closestPos[2]; + Vec3f closestPointNext; + Vec3f closestPointPrev; + f32 distSq; // First used as distSq to closest point, then used as distSq to closest position + f32 closestPointDistSq; + f32 loopDistSq[2]; + s32 i; - spB0 = 0; - sp5C = SQ(40000.0f); + closestPointIndex = 0; + closestPointDistSq = SQ(40000.0f); - for (spB4 = 0; spB4 < pathCount; spB4++) { - sp60 = Math3D_XZDistanceSquared(pos1->x, pos1->z, points[spB4].x, points[spB4].z); - if (sp60 < sp5C) { - sp5C = sp60; - spB0 = spB4; + // Find the point closest to srcPos + for (pointIndex = 0; pointIndex < numPoints; pointIndex++) { + distSq = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, points[pointIndex].x, points[pointIndex].z); + if (distSq < closestPointDistSq) { + closestPointDistSq = distSq; + closestPointIndex = pointIndex; } } - sp94.x = (points + spB0)->x; - sp94.z = (points + spB0)->z; - pos2->y = (points + spB0)->y; - if (spB0 != 0) { - sp64.x = (points + spB0 - 1)->x; - sp64.z = (points + spB0 - 1)->z; - } else if (arg4) { - sp64.x = (points + pathCount - 1)->x; - sp64.z = (points + pathCount - 1)->z; + closestPoint.x = (points + closestPointIndex)->x; + closestPoint.z = (points + closestPointIndex)->z; + dstPos->y = (points + closestPointIndex)->y; + + // Analyze point on path immediately previous to the closest point + if (closestPointIndex != 0) { + // The point previous to the closest point + closestPointPrev.x = (points + closestPointIndex - 1)->x; + closestPointPrev.z = (points + closestPointIndex - 1)->z; + } else if (isPathLoop) { + // Closest point is the first point in the path list + // Set the previous point to loop around to the the final point on the path + closestPointPrev.x = (points + numPoints - 1)->x; + closestPointPrev.z = (points + numPoints - 1)->z; + } + if ((closestPointIndex != 0) || isPathLoop) { + // Use the adjacent line + useAdjacentLines[0] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPointPrev.x, closestPointPrev.z, closestPoint.x, + closestPoint.z, &closestPos[0].x, &closestPos[0].z, &distSq); } - if ((spB0 != 0) || arg4) { - spA8[0] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp64.x, sp64.z, sp94.x, sp94.z, &sp7C[0].x, &sp7C[0].z, &sp60); + // Analyze point on path immediately next to the closest point + if (closestPointIndex + 1 != numPoints) { + // The point next to the closest point + closestPointNext.x = (points + closestPointIndex + 1)->x; + closestPointNext.z = (points + closestPointIndex + 1)->z; + } else if (isPathLoop) { + // Closest point is the final point in the path list + // Set the next point to loop around to the the first point on the path + closestPointNext.x = (points + 0)->x; + closestPointNext.z = (points + 0)->z; + } + if ((closestPointIndex + 1 != numPoints) || isPathLoop) { + useAdjacentLines[1] = + Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPoint.x, closestPoint.z, closestPointNext.x, + closestPointNext.z, &closestPos[1].x, &closestPos[1].z, &distSq); } - if (spB0 + 1 != pathCount) { - sp70.x = (points + spB0 + 1)->x; - sp70.z = (points + spB0 + 1)->z; - } else if (arg4) { - sp70.x = points->x; - sp70.z = points->z; - } + /** + * For close-looped paths, they must be defined in a clockwise orientation looking from the top down. + * Therefore, `srcPos` being interior of the loop will lead to both lines of `isRightSideOfAdjacentLines` + * returning true. + */ + if (isPathLoop) { + isRightSideOfAdjacentLines[0] = ((closestPointPrev.x - srcPos->x) * (closestPoint.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPoint.x - srcPos->x)); - if ((spB0 + 1 != pathCount) || arg4) { - spA8[1] = - Math3D_PointDistToLine2D(pos1->x, pos1->z, sp94.x, sp94.z, sp70.x, sp70.z, &sp7C[1].x, &sp7C[1].z, &sp60); - } + isRightSideOfAdjacentLines[1] = ((closestPointNext.z - srcPos->z) * (closestPoint.x - srcPos->x)) < + ((closestPoint.z - srcPos->z) * (closestPointNext.x - srcPos->x)); - if (arg4) { - s32 phi_s0_2; - - spA0[0] = ((sp64.x - pos1->x) * (sp94.z - pos1->z)) < ((sp64.z - pos1->z) * (sp94.x - pos1->x)); - spA0[1] = ((sp70.z - pos1->z) * (sp94.x - pos1->x)) < ((sp94.z - pos1->z) * (sp70.x - pos1->x)); - - for (phi_s0_2 = 0; phi_s0_2 < ARRAY_COUNT(sp54); phi_s0_2++) { - if (spA8[phi_s0_2] != 0) { - sp54[phi_s0_2] = Math3D_XZDistanceSquared(pos1->x, pos1->z, sp7C[phi_s0_2].x, sp7C[phi_s0_2].z); + for (i = 0; i < ARRAY_COUNT(loopDistSq); i++) { + if (useAdjacentLines[i]) { + // Get distSq from srcPos to closestPos + loopDistSq[i] = Math3D_XZDistanceSquared(srcPos->x, srcPos->z, closestPos[i].x, closestPos[i].z); } else { - sp54[phi_s0_2] = SQ(40000.0f); + // The closest Pos is not contained within the line-segment + loopDistSq[i] = SQ(40000.0f); } } } - if (arg4 && (((spA0[0] != 0) && (spA0[1] != 0)) || ((spA0[0] != 0) && (spA8[0] != 0) && (sp54[0] < sp54[1])) || - ((spA0[1] != 0) && (spA8[1] != 0) && (sp54[1] < sp54[0])))) { - pos2->x = pos1->x; - pos2->z = pos1->z; - } else if ((spA8[0] != 0) && (spA8[1] != 0)) { - if ((spA0[0] == 0) && (spA0[1] == 0)) { - if (Math3D_PointDistToLine2D(pos1->x, pos1->z, sp7C[0].x, sp7C[0].z, sp7C[1].x, sp7C[1].z, &pos2->x, - &pos2->z, &sp60) == 0) { - pos2->x = (sp7C[1].x + sp7C[0].x) * 0.5f; - pos2->z = (sp7C[1].z + sp7C[0].z) * 0.5f; + // Calculate closest position along path + if (isPathLoop && ((isRightSideOfAdjacentLines[0] && isRightSideOfAdjacentLines[1]) || + (isRightSideOfAdjacentLines[0] && useAdjacentLines[0] && (loopDistSq[0] < loopDistSq[1])) || + (isRightSideOfAdjacentLines[1] && useAdjacentLines[1] && (loopDistSq[1] < loopDistSq[0])))) { + // srcPos is contained within the closed loop + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; + } else if (useAdjacentLines[0] && useAdjacentLines[1]) { + // srcPos is somewhere withing the bend of the path + if (!isRightSideOfAdjacentLines[0] && !isRightSideOfAdjacentLines[1]) { + // srcPos is not inside a loop + if (!Math3D_PointDistToLine2D(srcPos->x, srcPos->z, closestPos[0].x, closestPos[0].z, closestPos[1].x, + closestPos[1].z, &dstPos->x, &dstPos->z, &distSq)) { + // The dstPos calculated in Math3D_PointDistToLine2D was not valid. + // Take the midpoint of the two closest ponits instead + dstPos->x = (closestPos[1].x + closestPos[0].x) * 0.5f; + dstPos->z = (closestPos[1].z + closestPos[0].z) * 0.5f; } - } else if (sp54[1] < sp54[0]) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; + } else if (loopDistSq[1] < loopDistSq[0]) { + // Use closest position along the line in the loop connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; } else { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; + // Use closest position along the ling in the loop connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; } - } else if (spA8[0] != 0) { - pos2->x = sp7C[0].x; - pos2->z = sp7C[0].z; - } else if (spA8[1] != 0) { - pos2->x = sp7C[1].x; - pos2->z = sp7C[1].z; - } else if (arg4 && ((((sp64.x - pos1->x) * (sp70.z - pos1->z)) < ((sp64.z - pos1->z) * (sp70.x - pos1->x))))) { - pos2->x = pos1->x; - pos2->z = pos1->z; + } else if (useAdjacentLines[0]) { + // Use closest position along line segment connecting the closest point and the prev point + dstPos->x = closestPos[0].x; + dstPos->z = closestPos[0].z; + } else if (useAdjacentLines[1]) { + // Use closest position along line segment connecting the closest point and the next point + dstPos->x = closestPos[1].x; + dstPos->z = closestPos[1].z; + } else if (isPathLoop && ((((closestPointPrev.x - srcPos->x) * (closestPointNext.z - srcPos->z)) < + ((closestPointPrev.z - srcPos->z) * (closestPointNext.x - srcPos->x))))) { + // Inside the line that directly connects the previous point to the next point (inside the bend of a corner) + dstPos->x = srcPos->x; + dstPos->z = srcPos->z; } else { - pos2->x = sp94.x; - pos2->z = sp94.z; + // The closest point and the closest position are the same (srcPos is near the outer region of a corner) + dstPos->x = closestPoint.x; + dstPos->z = closestPoint.z; } } @@ -4187,11 +4232,11 @@ Gfx D_801AEFA0[] = { gsSPEndDisplayList(), }; -void* func_800BD9A0(GraphicsContext* gfxCtx) { +Gfx* func_800BD9A0(GraphicsContext* gfxCtx) { Gfx* displayListHead; Gfx* displayList; - displayListHead = displayList = GRAPH_ALLOC(gfxCtx, 0x10); + displayListHead = displayList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); gDPSetRenderMode(displayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | @@ -4252,7 +4297,7 @@ s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { return arg2; } -void Actor_ChangeAnimation(SkelAnime* skelAnime, ActorAnimationEntry* animation, s32 index) { +void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation, s32 index) { f32 frameCount; animation += index; @@ -4445,39 +4490,42 @@ s32 func_800BE63C(struct EnBox* chest) { return false; } -TexturePtr D_801AEFA8[] = { - gameplay_keep_Tex_091DE0, - gameplay_keep_Tex_091FE0, - gameplay_keep_Tex_0921E0, - gameplay_keep_Tex_0923E0, +TexturePtr sElectricSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, }; -// Draw common damageEffects -void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 arg3, f32 effectScale, f32 steamScale, - f32 effectAlpha, u8 mode) { +/** + * Draw common damage effects applied to each limb provided in limbPos + */ +void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale, + f32 frozenSteamScale, f32 effectAlpha, u8 type) { if (effectAlpha > 0.001f) { - s32 temp_v1_3; - s16 i; - MtxF* temp_s3; + s32 twoTexScrollParam; + s16 limbIndex; + MtxF* currentMatrix; f32 alpha; - f32 sp124; - f32 sp120; - f32 sp11C; - f32 sp118; - Vec3f* limbAux = limbPos; - u32 sp110 = globalCtx->gameplayFrames; - f32 sp74; + f32 frozenScale; + f32 lightOrbsScale; + f32 electricSparksScale; + f32 steamScale; + Vec3f* limbPosStart = limbPos; + u32 gameplayFrames = globalCtx->gameplayFrames; + f32 effectAlphaScaled; - temp_s3 = Matrix_GetCurrentState(); + currentMatrix = Matrix_GetCurrentState(); + // Apply sfx along with damage effect if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) { - if (mode == 0) { + if (type == ACTOR_DRAW_DMGEFF_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - } else if (mode == 1) { + } else if (type == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { Actor_PlaySfxAtPos(actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); - } else if (mode == 0xB) { + } else if (type == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { Actor_PlaySfxAtPos(actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - } else if ((mode == 0x14) || (mode == 0x15)) { + } 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); } } @@ -4486,58 +4534,60 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 func_8012C2DC(globalCtx->state.gfxCtx); - switch (mode) { - case 0xA: - case 0xB: - sp124 = ((KREG(19) * 0.01f) + 2.3f) * effectScale; - sp118 = ((KREG(28) * 0.0001f) + 0.035f) * steamScale; + switch (type) { + case ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX: + case ACTOR_DRAW_DMGEFF_FROZEN_SFX: + frozenScale = ((KREG(19) * 0.01f) + 2.3f) * effectScale; + steamScale = ((KREG(28) * 0.0001f) + 0.035f) * frozenSteamScale; func_800BCC68(limbPos, globalCtx); + // Setup to draw ice over frozen actor + gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp110 & 0xFF, 0x20, 0x10, 1, 0, - (sp110 * 2) & 0xFF, 0x40, 0x20)); - + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 32, 16, 1, 0, + (gameplayFrames * 2) & 0xFF, 64, 32)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceDL); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_050648); + effectAlphaScaled = effectAlpha * 255.0f; - sp74 = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - (30.0f * alpha); - if (sp74 < (30.0f * (i & 3))) { + // Apply and draw ice over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - (30.0f * alpha); + if (effectAlphaScaled < (30.0f * (limbIndex & 3))) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 0xC8, KREG(21) + 0xC8, KREG(22) + 0xFF, (u8)alpha); + gDPSetEnvColor(POLY_XLU_DISP++, KREG(20) + 200, KREG(21) + 200, KREG(22) + 255, (u8)alpha); Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_Scale(sp124, sp124, sp124, MTXMODE_APPLY); - if (i & 1) { + Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY); + + if (limbIndex & 1) { Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); } - if (i & 2) { + + if (limbIndex & 2) { Matrix_InsertZRotation_f(M_PI, MTXMODE_APPLY); } gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0506E0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenIceVtxDL); } - limbPos = limbAux; + limbPos = limbPosStart; // reset limbPos + + // Setup to draw steam over frozen actor gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); - gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); - - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); alpha = effectAlpha * 100.0f; if (alpha > 100.0f) { @@ -4546,157 +4596,165 @@ void func_800BE680(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (u8)alpha); - for (i = 0; i < arg3; i++) { - temp_v1_3 = ((i * 3) + sp110); + // Apply and draw steam over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + twoTexScrollParam = ((limbIndex * 3) + gameplayFrames); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, temp_v1_3 * 3, temp_v1_3 * -0xC, 0x20, 0x40, - 1, 0, 0, 0x20, 0x20)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3, + twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32)); Matrix_InsertTranslation(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); - Matrix_Scale(sp118, sp118, 1.0f, MTXMODE_APPLY); + Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } break; - case 0x0: - case 0x1: - if (mode == 0) { + case ACTOR_DRAW_DMGEFF_FIRE: + case ACTOR_DRAW_DMGEFF_BLUE_FIRE: + if (type == ACTOR_DRAW_DMGEFF_FIRE) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); } else { gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 0); - mode = 0xFF; + // Reuse type for blue primitive color + type = 255; } Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, 1); + Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, + MTXMODE_APPLY); - sp74 = effectAlpha * 255.0f; + effectAlphaScaled = effectAlpha * 255.0f; - for (i = 0; i < arg3; i++) { - alpha = i & 3; - alpha = sp74 - 30.0f * alpha; - if (sp74 < 30.0f * (i & 3)) { + // Apply and draw fire on every limb + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + alpha = limbIndex & 3; + alpha = effectAlphaScaled - 30.0f * alpha; + if (effectAlphaScaled < 30.0f * (limbIndex & 3)) { alpha = 0.0f; } if (alpha > 255.0f) { alpha = 255.0f; } - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, mode, (u8)alpha); + // Use type for blue primitive color + // = 0 for ACTOR_DRAW_DMGEFF_FIRE + // = 255 for ACTOR_DRAW_DMGEFF_BLUE_FIRE + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, type, (u8)alpha); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, - ((i * 10 + sp110) * -0x14) & 0x1FF, 0x20, 0x80)); + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128)); Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - - limbPos++; } break; - case 0x14: - case 0x15: - sp120 = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + case ACTOR_DRAW_DMGEFF_LIGHT_ORBS: + case ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS: - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + // Setup to draw light orbs on actor + + lightOrbsScale = ((KREG(19) * 0.01f) + 4.0f) * effectScale; + + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); alpha = effectAlpha * 255.0f; if (alpha > 255.0f) { alpha = 255.0f; } - if (mode == 0x15) { - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0xFF), (u8)alpha); + if (type == ACTOR_DRAW_DMGEFF_BLUE_LIGHT_ORBS) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), + (u8)(sREG(18) + 255), (u8)alpha); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), 0x80); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)sREG(19), (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), 128); } else { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp120, sp120, 1.0f, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { + Matrix_SetCurrentState(&globalCtx->billboardMtxF); + Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY); + + // Apply and draw a light orb over each limb of frozen actor + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { Matrix_InsertZRotation_f(randPlusMinusPoint5Scaled(2 * M_PI), MTXMODE_APPLY); - temp_s3->mf[3][0] = limbPos->x; - temp_s3->mf[3][1] = limbPos->y; - temp_s3->mf[3][2] = limbPos->z; + currentMatrix->mf[3][0] = limbPos->x; + currentMatrix->mf[3][1] = limbPos->y; + currentMatrix->mf[3][2] = limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } break; - case 0x1E: - case 0x1F: - case 0x20: - if (mode == 0x1E) { - sp11C = (KREG(19) * 0.01f + 1.0f) * effectScale; - } else if (mode == 0x1F) { - sp11C = (KREG(19) * 0.01f + 1.5f) * effectScale; + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM: + case ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE: + if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { + electricSparksScale = (KREG(19) * 0.01f + 1.0f) * effectScale; + } else if (type == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM) { + electricSparksScale = (KREG(19) * 0.01f + 1.5f) * effectScale; } else { - sp11C = (KREG(19) * 0.01f + 2.0f) * effectScale; + electricSparksScale = (KREG(19) * 0.01f + 2.0f) * effectScale; } - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_801AEFA8[globalCtx->gameplayFrames & 3])); + gSPSegment(POLY_XLU_DISP++, 0x08, + Lib_SegmentedToVirtual(sElectricSparkTextures[globalCtx->gameplayFrames % 4])); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023480); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkDL); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 0xFF), (u8)(sREG(17) + 0xFF), - (u8)(sREG(18) + 0x96), (u8)(sREG(19) + 0xFF)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), (u8)(sREG(18) + 150), + (u8)(sREG(19) + 255)); - gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 0xFF), (u8)(sREG(21) + 0xFF), (u8)sREG(22), - (u8)sREG(23)); + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); Matrix_SetCurrentState(&globalCtx->billboardMtxF); - Matrix_Scale(sp11C, sp11C, sp11C, MTXMODE_APPLY); + Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); - for (i = 0; i < arg3; i++) { + // Every limb draws two electric sparks at random orientations + for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) { + // first electric spark Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); + // second electric spark Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(2 * M_PI)); - Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), 1); - temp_s3->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; - temp_s3->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; - temp_s3->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; + Matrix_InsertZRotation_f(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY); + currentMatrix->mf[3][0] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->x; + currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y; + currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z; gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0234F0); - - limbPos++; + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL); } + break; } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 7fa1b755b..b2891de90 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "vt.h" @@ -5,11 +6,11 @@ #define DYNA_RAYCAST_WALLS 2 #define DYNA_RAYCAST_CEILINGS 4 -static u32 sWallFlags[32] = { +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, }; -static u16 sSurfaceTypeSfx[] = { +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, @@ -27,7 +28,7 @@ static u16 sSurfaceTypeSfx[] = { /* 0x0E */ NA_SE_PL_WALK_SNOW - SFX_FLAG }; -static u8 D_801B46C0[] = { +u8 D_801B46C0[] = { /* 0x00 */ 1, /* 0x01 */ 1, /* 0x02 */ 0, @@ -45,7 +46,7 @@ static u8 D_801B46C0[] = { /* 0x0E */ 1 }; -static s16 sSmallMemScenes[] = { +s16 sSmallMemScenes[] = { SCENE_F01, }; @@ -54,7 +55,7 @@ typedef struct { u32 memSize; } BgCheckSceneMemEntry; -static BgCheckSceneMemEntry sSceneMemList[] = { +BgCheckSceneMemEntry sSceneMemList[] = { { SCENE_00KEIKOKU, 0xC800 }, }; @@ -4047,7 +4048,7 @@ u16 func_800C9728(CollisionContext* colCtx, u32 camId, s32 bgId) { return 0; } camData = colHeader->cameraDataList; - result = camData[camId].cameraSType; + result = camData[camId].setting; return result; } @@ -4088,7 +4089,7 @@ u16 func_800C97F8(CollisionContext* colCtx, u32 camId, s32 bgId) { if (camData == NULL) { return 0; } - return camData[camId].unk_02; + return camData[camId].numData; } /** @@ -4114,7 +4115,7 @@ u16 func_800C9844(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { } /** - * CamData get camPosData + * CamData get data */ Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); @@ -4127,11 +4128,11 @@ Vec3s* func_800C98CC(CollisionContext* colCtx, s32 camId, s32 bgId) { if (cameraDataList == NULL) { return NULL; } - return Lib_SegmentedToVirtual(cameraDataList[camId].camPosData); + return Lib_SegmentedToVirtual(cameraDataList[camId].data); } /** - * SurfaceType Get camPosData + * SurfaceType Get data */ Vec3s* SurfaceType_GetCamPosData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { CollisionHeader* colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); @@ -4573,7 +4574,7 @@ u16 WaterBox_GetCameraSetting(CollisionContext* colCtx, WaterBox* waterBox, s32 return result; } - result = camData[camId].cameraSType; + result = camData[camId].setting; return result; } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 1e983c954..d3f1f9203 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -320,19 +320,19 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFAC8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFB14.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/func_800DFC68.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFC90.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFCB4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirPitch.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFCDC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_GetCamDirYaw.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DFD04.s") @@ -356,7 +356,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01AC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E01B8.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") @@ -364,10 +364,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0238.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E02AC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E0308.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetTargetActor.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800E031C.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") diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index ddf21fe17..4b7f48696 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; @@ -1145,7 +1146,7 @@ ColChkResetFunc sATResetFuncs[] = { s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sATResetFuncs[collider->shape](globalCtx, collider); @@ -1171,7 +1172,7 @@ s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot. */ s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sATResetFuncs[collider->shape](globalCtx, collider); @@ -1205,7 +1206,7 @@ ColChkResetFunc sACResetFuncs[] = { s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sACResetFuncs[collider->shape](globalCtx, collider); @@ -1231,7 +1232,7 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot */ s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sACResetFuncs[collider->shape](globalCtx, collider); @@ -1265,7 +1266,7 @@ ColChkResetFunc sOCResetFuncs[] = { s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sOCResetFuncs[collider->shape](globalCtx, collider); @@ -1291,7 +1292,7 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtx * will be inserted into the next slot. */ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } sOCResetFuncs[collider->shape](globalCtx, collider); @@ -1323,7 +1324,7 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, OcLine* line) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx)) { + if (FrameAdvance_IsEnabled(&globalCtx->state)) { return -1; } diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index a2081af73..54ba92f6b 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -3,7 +3,8 @@ SaveContext gSaveContext; void SaveContext_Init(void) { - bzero(&gSaveContext, sizeof(gSaveContext)); + bzero(&gSaveContext, sizeof(SaveContext)); + gSaveContext.save.playerForm = 0; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 72eeb742e..0af7dfb4d 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,99 +1,1686 @@ +#include "prevent_bss_reordering.h" #include "global.h" +#include "overlays/gamestates/ovl_daytelop/z_daytelop.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_Init.s") +void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA0D4.s") +// Unused +UNK_TYPE4 D_801BB120 = 0; +u16 D_801BB124 = 0; +u16 D_801BB128 = 0; +u8 D_801BB12C = 0; +u8 sCutsceneStoredPlayerForm = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA0EC.s") +// bss +#ifndef NON_MATCHING +static u16 seqId; +#endif +s16 sCutsceneQuakeIndex; +DbCameraUnkStruct sCutsceneCameraInfo; +u16 D_801F4DC8[10]; +UNK_TYPE D_801F4DDC; +u8 D_801F4DE0; +s16 D_801F4DE2; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_StepCutscene1.s") +void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_StepCutscene2.s") + csCtx->state = CS_STATE_0; + csCtx->frames = 0; + csCtx->unk_0C = 0.0f; + globalCtx->csCtx.sceneCsCount = 0; + globalCtx->csCtx.currentCsIndex = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_Nop800EA210.s") + for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { + D_801F4DC8[i] = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA220.s") + D_801F4DE0 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA258.s") + Audio_SetCutsceneFlag(false); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA2B8.s") +void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx) { + csCtx->state = CS_STATE_1; + csCtx->playerAction = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EA324.s") +void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (csCtx->state != CS_STATE_4) { + csCtx->state = CS_STATE_3; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EABAC.s") +typedef void (*CutsceneStateHandler)(GlobalContext* globalCtx, CutsceneContext* csCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC08.s") +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 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC44.s") +void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (gSaveContext.save.cutscene < 0xFFF0) { + sCsStateHandlers1[csCtx->state](globalCtx, csCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAC94.s") +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 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD14.s") +void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (globalCtx->sceneLoadFlag == 0x14)) { + gSaveContext.cutsceneTrigger = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD48.s") + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0)) { + gSaveContext.save.cutscene = 0xFFFD; + gSaveContext.cutsceneTrigger = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAD7C.s") + if (gSaveContext.save.cutscene >= 0xFFF0) { + func_800EDA84(globalCtx, csCtx); + sCsStateHandlers2[csCtx->state](globalCtx, csCtx); + } +} +void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx) { +} + +s32 func_800EA220(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target) { + return Math_StepToF(&csCtx->unk_0C, target, 0.1f); +} + +void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx) { + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + if (func_800EA220(globalCtx, csCtx, 1.0f)) { + Audio_SetCutsceneFlag(true); + csCtx->state++; + } +} + +void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) { + func_800ED980(globalCtx, csCtx); + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + if (func_800EA220(globalCtx, csCtx, 1.0f)) { + Audio_SetCutsceneFlag(true); + csCtx->state++; + } +} + +/* Start of command handling section */ + +// Command 0x96: Miscellaneous commands. +void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, CsCmdBase* cmd) { + static u16 D_801BB15C = 0xFFFF; + Player* player = GET_PLAYER(globalCtx2); + GlobalContext* globalCtx = globalCtx2; + u8 isStartFrame = false; + f32 progress; + SceneTableEntry* loadedScene; + u16 time; + + if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { + return; + } + + progress = Environment_LerpWeight(cmd->endFrame - 1, cmd->startFrame, csCtx->frames); + if (csCtx->frames == cmd->startFrame) { + isStartFrame = true; + } + + // TODO: consider creating an enum for this when we understand what each value does + switch (cmd->base) { + case 0x1: + if (isStartFrame) { + func_800FD78C(globalCtx); + globalCtx->envCtx.unk_F2[0] = 0x3C; + } + break; + case 0x2: + if (isStartFrame) { + func_801A47DC(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); + Environment_AddLightningBolts(globalCtx, 3); + D_801F4E68 = 1; + } + break; + case 0x3: + if (globalCtx->envCtx.lightSettings.fogFar < 12800) { + globalCtx->envCtx.lightSettings.fogFar += 35; + } + break; + case 0x4: + if (isStartFrame) { + globalCtx->envCtx.unk_19 = 1; + globalCtx->envCtx.unk_17 = 1; + globalCtx->envCtx.unk_18 = 0; + globalCtx->envCtx.unk_1A = 0x3C; + globalCtx->envCtx.unk_21 = 1; + globalCtx->envCtx.unk_1F = 0; + globalCtx->envCtx.unk_20 = 1; + globalCtx->envCtx.unk_24 = 0x3C; + globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24; + } + break; + case 0x5: + if (isStartFrame && (csCtx->state != CS_STATE_4)) { + csCtx->state = CS_STATE_3; + } + break; + case 0x7: + if (isStartFrame) { + loadedScene = globalCtx->loadedScene; + if (loadedScene->titleTextId != 0) { + func_80151A68(globalCtx, loadedScene->titleTextId); + } + } + break; + case 0x8: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 22000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + case 0x9: + if (isStartFrame) { + Quake_Init(); + } + break; + case 0xA: + D_801F6D30.r = 255; + D_801F6D30.g = 255; + D_801F6D30.b = 255; + D_801F6D30.a = 255 * progress; + break; + case 0xB: + D_801F6D30.r = 255; + D_801F6D30.g = 180; + D_801F6D30.b = 100; + D_801F6D30.a = 255 * progress; + break; + case 0xC: + globalCtx->roomCtx.currRoom.segment = NULL; + break; + case 0xD: + if (globalCtx->state.frames & 8) { + if (globalCtx->envCtx.lightSettings.ambientColor[0] < 40) { + globalCtx->envCtx.lightSettings.ambientColor[0] += 2; + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 3; + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 3; + } + } else { + if (globalCtx->envCtx.lightSettings.ambientColor[0] > 2) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 2; + globalCtx->envCtx.lightSettings.diffuseColor1[1] += 3; + globalCtx->envCtx.lightSettings.diffuseColor1[2] += 3; + } + } + break; + case 0xE: + globalCtx->unk_18845 = 1; + break; + case 0xF: + globalCtx->unk_18845 = 0; + break; + case 0x10: + if (isStartFrame) { + globalCtx->envCtx.sandstormState = 1; + } + func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG); + break; + case 0x11: + gSaveContext.sunsSongState = SUNSSONG_START; + break; + case 0x12: + if (!gSaveContext.save.isNight) { + time = gSaveContext.save.time; + gSaveContext.save.time = time - (u16)REG(15); + } else { + time = gSaveContext.save.time; + gSaveContext.save.time = time - (u16)(2 * REG(15)); + } + break; + case 0x13: + // AudioOcarina_PlayLongScarecrowAfterCredits + func_8019D758(); + csCtx->frames = cmd->startFrame - 1; + break; + case 0x14: + EnvFlags_Set(globalCtx, 3); + break; + case 0x15: + EnvFlags_Set(globalCtx, 4); + break; + case 0x16: + gSaveContext.save.playerForm = PLAYER_FORM_DEKU; + break; + case 0x17: + player->stateFlags2 |= 0x4000000; + break; + case 0x18: + player->stateFlags2 &= ~0x4000000; + break; + case 0x19: + sCutsceneStoredPlayerForm = gSaveContext.save.playerForm; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + break; + case 0x1A: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 30000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + case 0x1B: + if (isStartFrame) { + globalCtx->nextEntranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0xFFF8; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + case 0x1C: + if (isStartFrame) { + globalCtx->envCtx.unk_17 = 0xD; + } + break; + case 0x1D: + gSaveContext.save.playerForm = sCutsceneStoredPlayerForm; + break; + case 0x1E: + D_801F4DE0 = true; + break; + case 0x1F: + D_801F4DE0 = false; + break; + case 0x21: + if (isStartFrame) { + Sram_SaveSpecialEnterClockTown(globalCtx); + } + break; + case 0x22: + if (isStartFrame) { + func_80144A94(&globalCtx->sramCtx); + } + break; + case 0x23: + if (csCtx->frames != D_801BB15C) { + D_801BB15C = csCtx->frames; + + if (REG(15) != 0) { + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)REG(15) + time; + time = gSaveContext.save.time; + gSaveContext.save.time = (u16)gSaveContext.save.daySpeed + time; + } + } + break; + case 0x24: + func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); + if (isStartFrame) { + sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + Quake_SetSpeed(sCutsceneQuakeIndex, 22000); + Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); + Quake_SetCountdown(sCutsceneQuakeIndex, 800); + } + break; + + case 0x26: + // Seems to be used to trigger "Dawn of A New Day" + + gSaveContext.save.day = 9; + + { + GameState* gameState = &globalCtx->state; + gameState->running = false; + } + SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + + Sram_SaveSpecialNewDay(globalCtx); + break; + + case 0x27: + gSaveContext.save.playerForm = PLAYER_FORM_ZORA; + break; + + case 0x28: + csCtx->frames = cmd->startFrame - 1; + break; + } +} + +// Command 0x97: Set Environment Lighting +void Cutscene_Command_SetLighting(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { + if (csCtx->frames == cmd->startFrame) { + if (cmd->setting != 0x20) { + globalCtx->envCtx.lightSettingOverride = cmd->setting - 1; + globalCtx->envCtx.lightBlend = 1.0f; + } else { + globalCtx->envCtx.lightSettingOverride = 0xFF; + } + } +} + +// Command 0x12C: Plays a sequence (Background music or Fanfare) +void Cutscene_Command_PlaySequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { + if (csCtx->frames == cmd->startFrame) { + func_801A2C88(cmd->sequence - 1); + } +} + +// Command 0x12D: Stops a sequence (Background music or Fanfare) +void Cutscene_Command_StopSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + func_801A2D54(cmd->sequence - 1); + } +} + +// Command 0x9C: Fade a sequence (Background music or Fanfare) over duration +void Cutscene_Command_FadeSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceFade* cmd) { + if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { + u8 fadeTimer = cmd->endFrame - cmd->startFrame; + + if (cmd->type == 2) { + Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x110000FF); + } else { + Audio_QueueSeqCmd((fadeTimer << 0x10) | NA_BGM_STOP); + } + } +} + +// Command 0x12E: Play Ambience sequence +void Cutscene_Command_PlayAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_PlayNatureAmbienceSequence + // nightSeqIndex is natureAmbienceId + func_801A4A28(globalCtx->soundCtx.nightSeqIndex); + } +} + +// Command 0x130: +void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_SetSfxReverbIndexExceptOcarinaBank + func_801A4428(2); + } +} + +// Command 0x131: +void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame) { + // Audio_SetSfxReverbIndexExceptOcarinaBank + func_801A4428(1); + } +} + +#ifdef NON_MATCHING +// needs in-function static bss +// audio related +void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + static u16 seqId; + u8 dayMinusOne; + + if (csCtx->frames == 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); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 1); + break; + + case 2: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_0); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 0); + break; + + case 3: + // func_801A246C(SEQ_PLAYER_BGM_MAIN, TYPE_2); + func_801A246C(SEQ_PLAYER_BGM_MAIN, 2); + break; + + case 4: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_1); + func_801A246C(SEQ_PLAYER_NATURE, 1); + break; + + case 5: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_0); + func_801A246C(SEQ_PLAYER_NATURE, 0); + break; + + case 6: + // func_801A246C(SEQ_PLAYER_NATURE, TYPE_2); + func_801A246C(SEQ_PLAYER_NATURE, 2); + break; + + case 7: + // Audio_GetActiveSequence + seqId = func_801A8A50(0); + break; + + case 8: + if (seqId != NA_BGM_DISABLED) { + // Audio_PlayBgmForDayScene + func_801A25E4(seqId, dayMinusOne); + } + break; + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EADB0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAECC.s") +// Command 0x12F: Fade Ambience sequence +void Cutscene_Command_FadeAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (csCtx->frames == cmd->startFrame && csCtx->frames < cmd->endFrame) { + u8 fadeTimer = cmd->endFrame - cmd->startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAF20.s") + Audio_QueueSeqCmd((fadeTimer << 0x10) | 0x140000FF); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EAFE0.s") +// Command 0x190: Rumble +void Cutscene_Command_Rumble(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdRumble* cmd) { + switch (cmd->type) { + case 1: + if (csCtx->frames == cmd->startFrame) { + func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB1DC.s") + case 2: + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + if ((csCtx->frames == cmd->startFrame) || (globalCtx->state.frames % 64 == 0)) { + func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8); + } + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB364.s") +// Command 0x9B: +void Cutscene_Command_FadeColorScreen(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + f32 alpha; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB4B4.s") + globalCtx->envCtx.fillScreen = true; + alpha = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EB6F8.s") + if (((cmd->unk0 == 1)) || (cmd->unk0 == 2)) { + globalCtx->envCtx.screenFillColor[0] = cmd->color.r; + globalCtx->envCtx.screenFillColor[1] = cmd->color.g; + globalCtx->envCtx.screenFillColor[2] = cmd->color.b; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBB68.s") + if (cmd->unk0 == 2) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * alpha; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBCD0.s") +// Command 0x9D: Set Time of Day & Environment Time +void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd) { + u16 nextTime; + u16 hourAsMinutes; + u16 minutes; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EBD60.s") + if (csCtx->frames == cmd->startFrame) { + hourAsMinutes = CLOCK_TIME_ALT_F(cmd->hour, 0); + minutes = CLOCK_TIME_ALT_F(0, cmd->minute + 1); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC678.s") + nextTime = hourAsMinutes + minutes; + gSaveContext.save.time = nextTime; + gSaveContext.environmentTime = nextTime; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC6D4.s") +void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + csCtx->state = CS_STATE_4; + func_80165690(); + Audio_SetCutsceneFlag(false); + gSaveContext.unk_3F48 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EC924.s") + if ((gSaveContext.gameMode != 0) && (csCtx->frames != cmd->startFrame)) { + gSaveContext.unk_3F1E = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ECD7C.s") + gSaveContext.save.cutscene = 0; + if (cmd->base == 1) { + globalCtx->nextEntranceIndex = globalCtx->csCtx.sceneCsList[globalCtx->csCtx.currentCsIndex].nextEntranceIndex; + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + if (gSaveContext.gameMode != 1) { + Scene_SetExitFade(globalCtx); + } else { + D_801BB12C++; + if (D_801BB12C >= 2) { + D_801BB12C = 0; + } + globalCtx->unk_1887F = 4; + } + if ((globalCtx->nextEntranceIndex & 0xF) > 0) { + gSaveContext.nextCutsceneIndex = (globalCtx->nextEntranceIndex & 0xF) + 0xFFEF; + } + + globalCtx->nextEntranceIndex &= ~0xF; + } +} + +// Command 0x15E +void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if (cmd->base == 1) { + if (csCtx->frames == cmd->startFrame) { + Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + } + } else if (cmd->base == 2) { + if (csCtx->frames == cmd->startFrame) { + func_80165690(); + + switch (D_801F4DE2) { + case 0x1F: + if (gSaveContext.save.weekEventReg[20] & 2) { + globalCtx->nextEntranceIndex = 0x3010; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } else { + globalCtx->nextEntranceIndex = 0x8600; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + + case 0x44: + if (gSaveContext.save.weekEventReg[33] & 0x80) { + globalCtx->nextEntranceIndex = 0xAE70; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } else { + globalCtx->nextEntranceIndex = 0xAE00; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + } + break; + + case 0x5F: + gSaveContext.save.weekEventReg[55] |= 0x80; + globalCtx->nextEntranceIndex = 0x6A80; + gSaveContext.nextCutsceneIndex = 0xFFF0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + break; + + case 0x36: + gSaveContext.save.weekEventReg[52] |= 0x20; + globalCtx->nextEntranceIndex = 0x2000; + gSaveContext.nextCutsceneIndex = 0xFFF1; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + break; + } + } + } +} + +// Command 0x15F: Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding +// mask +void Cutscene_Command_ChooseCreditsScenes(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) { + switch (cmd->base) { + case 1: + Cutscene_TerminatorImpl(globalCtx, csCtx, cmd); + break; + + case 2: + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 3: + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + // Fairy's fountain + globalCtx->nextEntranceIndex = 0x4600; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C10; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 4: + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { + // Romani ranch + globalCtx->nextEntranceIndex = 0x6400; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C20; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 5: + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + // West clock town + globalCtx->nextEntranceIndex = 0xD400; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C30; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 6: + if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF1; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C50; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 7: + if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { + // Milk bar + globalCtx->nextEntranceIndex = 0x2400; + gSaveContext.nextCutsceneIndex = 0xFFF3; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C60; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 8: + // Ikana canyon + globalCtx->nextEntranceIndex = 0x2000; + gSaveContext.nextCutsceneIndex = 0xFFF3; + globalCtx->sceneLoadFlag = 0x14; + break; + + case 9: + if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { + // Termina field + globalCtx->nextEntranceIndex = 0x5400; + gSaveContext.nextCutsceneIndex = 0xFFF8; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C70; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 10: + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + // Cucco shack + globalCtx->nextEntranceIndex = 0x7E00; + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C40; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + + case 11: + if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { + // Termina field + globalCtx->nextEntranceIndex = 0x5410; + gSaveContext.nextCutsceneIndex = 0xFFF8; + } else { + // SPOT00 + globalCtx->nextEntranceIndex = 0x1C80; + gSaveContext.nextCutsceneIndex = 0xFFF9; + } + globalCtx->sceneLoadFlag = 0x14; + break; + } + } +} + +// Command 0x99: Motion blur +void Cutscene_Command_MotionBlur(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + if ((csCtx->frames == cmd->startFrame) && (cmd->base == 1)) { + func_8016566C(180); + } + + if (cmd->base == 2) { + f32 progress = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + + if (progress >= 0.9f) { + func_80165690(); + } else { + func_80165658((1.0f - progress) * 180.0f); + } + } + } +} + +// Command 0x9A: Gives Tatl to the player +void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + Player* player = GET_PLAYER(globalCtx); + + if (csCtx->frames == cmd->startFrame) { + if (cmd->base == 1) { + gSaveContext.save.hasTatl = true; + if (player->tatlActor != NULL) { + return; + } + player->tatlActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0); + } + } +} + +// Command 0x98 +void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) { + f32 temp_f0; + + globalCtx->envCtx.fillScreen = true; + temp_f0 = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); + + switch (cmd->base) { + case 1: + case 5: + globalCtx->envCtx.screenFillColor[0] = 160; + globalCtx->envCtx.screenFillColor[1] = 160; + globalCtx->envCtx.screenFillColor[2] = 160; + if (cmd->base == 1) { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + if (temp_f0 == 0.0f) { + func_8019F128(NA_SE_EV_S_STONE_FLASH); + } + } else { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } + break; + + case 2: + case 6: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 255; + if (cmd->base == 2) { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } else { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } + break; + + case 3: + case 7: + globalCtx->envCtx.screenFillColor[0] = 255; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 3) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 4: + case 8: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 255; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 4) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 9: + gSaveContext.unk_3F48 = 1; + break; + + case 10: + case 11: + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[2] = 0; + if (cmd->base == 10) { + globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f; + } else { + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; + } + break; + + case 12: + globalCtx->envCtx.screenFillColor[0] = (160.0f * (1.0f - temp_f0)); + globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[3] = 255; + break; + + case 13: + globalCtx->envCtx.screenFillColor[0] = (160.0f * temp_f0); + globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0]; + globalCtx->envCtx.screenFillColor[3] = 255; + break; + } + } +} + +// Command 0x5A: Camera +s32 Cutscene_Command_Camera(GlobalContext* globalCtx, u8* cmd) { + s32 sp1C = 0; + + bcopy(cmd, &sp1C, sizeof(s32)); + cmd += sizeof(s32); + if (func_8016A168() == 0) { + func_80161998(cmd, &sCutsceneCameraInfo); + } + return sp1C + sizeof(s32); +} + +/** + * Counts how many masks the player has + * The count doesn't include transformation masks + */ +s32 Cutscene_CountNormalMasks(void) { + s32 count = 0; + + if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAFEIS_MASK) == ITEM_MASK_KAFEIS_MASK) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ALL_NIGHT) == ITEM_MASK_ALL_NIGHT) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KEATON) == ITEM_MASK_KEATON) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { + count++; + } + if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_DON_GERO) == ITEM_MASK_DON_GERO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + count++; + } + if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + count++; + } + + return count; +} + +// Command 0xA: Textbox +void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd) { + static s32 D_801BB160 = CS_TEXTBOX_TYPE_DEFAULT; + u8 dialogState; + s32 pad; + u16 originalCsFrames; + s32 pad2; + + if ((cmd->startFrame >= csCtx->frames) || ((cmd->endFrame < csCtx->frames))) { + return; + } + + if (cmd->type != CS_TEXTBOX_TYPE_LEARN_SONG) { + if (D_801BB124 != cmd->base) { + if (D_801BB160 == CS_TEXTBOX_TYPE_3) { + csCtx->frames--; + } + D_801BB160 = CS_TEXTBOX_TYPE_1; + D_801BB124 = cmd->base; + if (cmd->type == CS_TEXTBOX_TYPE_BOSSES_REMAINS) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + if (cmd->textId1 != 0xFFFF) { + Message_StartTextbox(globalCtx, cmd->textId1, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else if (cmd->type == CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS) { + if (Cutscene_CountNormalMasks() == 20) { + if (cmd->textId1 != 0xFFFF) { + Message_StartTextbox(globalCtx, cmd->textId1, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else { + Message_StartTextbox(globalCtx, cmd->base, NULL); + } + } else { + goto else_label; + } + } else if (D_801BB128 != cmd->base) { + D_801BB160 = CS_TEXTBOX_TYPE_LEARN_SONG; + D_801BB128 = cmd->base; + func_80152434(globalCtx, 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; + dialogState = Message_GetState(&globalCtx->msgCtx); + if ((dialogState != 2) && (dialogState != 0) && (dialogState != 7) && (dialogState != 8)) { + csCtx->frames--; + if ((dialogState == 4) && Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (cmd->base == 0x33BD) { + func_8019F230(); + } + + if (cmd->textId1 != 0xFFFF) { + func_80151938(globalCtx, cmd->textId1); + if (cmd->type == CS_TEXTBOX_TYPE_3) { + D_801BB160 = CS_TEXTBOX_TYPE_3; + if (cmd->textId2 != 0xFFFF) { + csCtx->frames++; + } + } + } else { + func_801477B4(globalCtx); + csCtx->frames++; + } + } else { + if (cmd->base == 0x33BD) { + func_8019F208(); + } + + if (cmd->textId2 != 0xFFFF) { + func_80151938(globalCtx, cmd->textId2); + if (cmd->type == CS_TEXTBOX_TYPE_3) { + D_801BB160 = CS_TEXTBOX_TYPE_3; + if (cmd->textId1 != 0xFFFF) { + csCtx->frames++; + } + } + } else { + func_801477B4(globalCtx); + csCtx->frames++; + } + } + } + + if (dialogState == 5 && Message_ShouldAdvance(globalCtx)) { + func_80152434(globalCtx, cmd->base); + } + } + + if ((dialogState == 2) && (D_801BB160 == CS_TEXTBOX_TYPE_3)) { + csCtx->frames--; + D_801BB124++; + } + + if (originalCsFrames == csCtx->frames) { + Interface_ChangeAlpha(1); + D_801BB124 = 0; + D_801BB128 = 0; + func_80161C0C(); + } else { + func_80161BE0(1); + } + } + } +} + +// Related to actorActions. Maybe a generic actorAction setter? +void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) { + s32 i; + s32 count; + + bcopy(*cutscenePtr, &count, sizeof(s32)); + *cutscenePtr += sizeof(s32); + + for (i = 0; i < count; i++) { + CsCmdActorAction* actorAction = *(CsCmdActorAction**)cutscenePtr; + + if ((csCtx->frames >= actorAction->startFrame) && (csCtx->frames < actorAction->endFrame)) { + csCtx->actorActions[index] = actorAction; + } + + *cutscenePtr += sizeof(CsCmdActorAction); + } +} + +#ifdef NON_MATCHING +// Some stack issues, and a few instructions in the "wrong" places +/** + * Loops over the cutscene data itself (`cutscenePtr`), 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 + * - A beginning, which contains the number of command lists of this cutscene and the ending frame (see + * `CS_BEGIN_CUTSCENE`). + * - Any number of cutscene command lists (which should be the number specified in the beginning), each one of which + * contains commands of the corresponding category. + * - A end marker (see `CS_END`). + * + * This function iterates over each command list until either it has processed the number of command lists stated on + * `CS_BEGIN_CUTSCENE` or until it finds a end marker. + * + * A command list starts with a pair of words containing the command category and a count of how many commands this list + * 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 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. + */ +void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr) { + s32 i; + s16 phi_s0; + s32 totalEntries; + s32 j; + u32 cmdType; // sp5C + s32 pad; + s32 cmdEntries; // sp58 + s32 cutsceneEndFrame; // sp50 + s16 phi_s0_23; + CsCmdBase* 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); + + if (((u16)cutsceneEndFrame < csCtx->frames) && (globalCtx->sceneLoadFlag != 0x14) && (csCtx->state != CS_STATE_4)) { + csCtx->state = CS_STATE_3; + 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); + + // TODO: This should probably be added to the CutsceneCmd enum. Consider doing it when this function matches. + if (cmdType == 0xFFFFFFFF) { + 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 (phi_s0 = 0; phi_s0 < ARRAY_COUNT(D_801F4DC8); phi_s0++) { + if ((u16)cmdType == D_801F4DC8[phi_s0]) { + func_800ECD7C(csCtx, &cutscenePtr, phi_s0); + cmdType = -2; + break; + } else if (D_801F4DC8[phi_s0] == 0) { + D_801F4DC8[phi_s0] = cmdType; + func_800ECD7C(csCtx, &cutscenePtr, phi_s0); + cmdType = -2; + break; + } + } + } + + switch (cmdType) { + case CS_CMD_MISC: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Misc(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_SET_LIGHTING: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_SetLighting(globalCtx, csCtx, (CsCmdEnvLighting*)cutscenePtr); + cutscenePtr += sizeof(CsCmdEnvLighting); + } + break; + + case CS_CMD_PLAYSEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_PlaySequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceChange); + } + break; + + case CS_CMD_STOPSEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_StopSequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceChange); + } + break; + + case CS_CMD_FADESEQ: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeSequence(globalCtx, csCtx, (CsCmdSequenceFade*)cutscenePtr); + cutscenePtr += sizeof(CsCmdSequenceFade); + } + break; + + case CS_CMD_PLAYAMBIENCE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_PlayAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_FADEAMBIENCE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_130: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EAD48(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_131: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EAD7C(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_132: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + func_800EADB0(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_RUMBLE: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Rumble(globalCtx, csCtx, (CsCmdRumble*)cutscenePtr); + cutscenePtr += sizeof(CsCmdRumble); + } + break; + + case CS_CMD_FADESCREEN: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_FadeColorScreen(globalCtx, csCtx, (CsCmdFadeScreen*)cutscenePtr); + cutscenePtr += sizeof(CsCmdFadeScreen); + } + break; + + case CS_CMD_SETTIME: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_SetTime(globalCtx, csCtx, (CsCmdDayTime*)cutscenePtr); + cutscenePtr += sizeof(CsCmdDayTime); + } + break; + + case CS_CMD_SET_PLAYER_ACTION: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cmd = (CsCmdBase*)cutscenePtr; + if ((csCtx->frames >= cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { + csCtx->playerAction = (CsCmdActorAction*)cutscenePtr; + } + cutscenePtr += sizeof(CsCmdActorAction); + } + break; + + case CS_CMD_CAMERA: + cutscenePtr = &cutscenePtr[Cutscene_Command_Camera(globalCtx, cutscenePtr)]; + break; + + case CS_CMD_TERMINATOR: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_Terminator(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_CHOOSE_CREDITS_SCENES: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_ChooseCreditsScenes(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_TEXTBOX: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cmd = (CsCmdBase*)cutscenePtr; + if (cmd->base != 0xFFFF) { + Cutscene_Command_Textbox(globalCtx, csCtx, (CsCmdTextbox*)cutscenePtr); + } + cutscenePtr += sizeof(CsCmdTextbox); + } + break; + + case CS_CMD_SCENE_TRANS_FX: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_TransitionFX(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_MOTIONBLUR: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_MotionBlur(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case CS_CMD_GIVETATL: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + Cutscene_Command_GiveTatlToPlayer(globalCtx, csCtx, (CsCmdBase*)cutscenePtr); + cutscenePtr += sizeof(CsCmdBase); + } + break; + + case -2: + break; + + default: + bcopy(cutscenePtr, &cmdEntries, sizeof(s32)); + cutscenePtr += sizeof(s32); + for (j = 0; j < cmdEntries; j++) { + cutscenePtr += sizeof(CsCmdBase); + } + break; + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ED980.s") +/* End of command handling section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800ED9C4.s") +void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (gSaveContext.save.cutscene >= 0xFFF0) { + csCtx->frames++; + Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.csData); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDA04.s") +void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (func_800EA220(globalCtx, csCtx, 0.0f)) { + Audio_SetCutsceneFlag(false); + csCtx->state = CS_STATE_0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDA84.s") +// unused +void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if (func_800EA220(globalCtx, csCtx, 0.0f)) { + s16 i; + csCtx->playerAction = NULL; + + for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { + csCtx->actorActions[i] = NULL; + } + + gSaveContext.save.cutscene = 0; + gSaveContext.gameMode = 0; + ActorCutscene_Stop(0x7F); + Audio_SetCutsceneFlag(false); + csCtx->state = CS_STATE_0; + } +} + +void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) { + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&globalCtx->state)) { + gSaveContext.save.cutscene = 0xFFFD; + } + + if ((gSaveContext.save.cutscene >= 0xFFF0) && (csCtx->state == CS_STATE_0)) { + s16 i; + + D_801BB124 = 0; + D_801BB128 = 0; + csCtx->playerAction = NULL; + + for (i = 0; i < ARRAY_COUNT(csCtx->actorActions); i++) { + csCtx->actorActions[i] = NULL; + } + + csCtx->state++; + if (csCtx->state == CS_STATE_1) { + Audio_SetCutsceneFlag(true); + + csCtx->frames = 0xFFFF; + csCtx->csCamId = ActorCutscene_GetCurrentCamera(0x7F); + func_8016119C(Play_GetCamera(globalCtx, csCtx->csCamId), &sCutsceneCameraInfo); + csCtx->unk_18 = 0xFFFF; + + if (gSaveContext.cutsceneTrigger == 0) { + Interface_ChangeAlpha(1); + ShrinkWindow_SetLetterboxTarget(32); + ShrinkWindow_SetLetterboxMagnitude(0x20); + csCtx->state++; + } + + func_800ED980(globalCtx, csCtx); + } + + gSaveContext.cutsceneTrigger = 0; + } +} + +#ifdef NON_MATCHING +// HandleFlags? +// regalloc +void func_800EDBE0(GlobalContext* globalCtx) { + CutsceneEntry* temp_a3; + s16 sp2A; + SceneTableEntry* sp24; + s32 temp_v0_3; + + 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) { + temp_a3 = ((void)0, globalCtx->csCtx.sceneCsList); + if ((temp_a3[temp_v0_3].unk7 != 0xFF) && (gSaveContext.respawnFlag == 0)) { + if (temp_a3[temp_v0_3].unk7 == 0xFE) { + ActorCutscene_Start(sp2A, NULL); + gSaveContext.showTitleCard = false; + } else if (!((1 << (temp_a3[temp_v0_3].unk7 % 8)) & + gSaveContext.save.weekEventReg[temp_a3[temp_v0_3].unk7 / 8])) { + gSaveContext.save.weekEventReg[(temp_a3[temp_v0_3].unk7 / 8)] |= + 1 << (temp_a3[temp_v0_3].unk7 % 8); + ActorCutscene_Start(sp2A, NULL); + gSaveContext.showTitleCard = false; + } + } + } else { + ActorCutscene_StartAndSetUnkLinkFields(sp2A, NULL); + } + } + } + + if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { + sp24 = globalCtx->loadedScene; + if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) { + if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.save.entranceIndex) & + 0x4000) != 0) { + func_80151A68(globalCtx, sp24->titleTextId); + } + } + + gSaveContext.showTitleCard = true; + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDBE0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/nop_800EDDB0.s") +void func_800EDDB0(GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDDBC.s") +void func_800EDDBC(UNK_TYPE arg0, UNK_TYPE arg1) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDDCC.s") +void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex) { + if (dREG(95) == 0) { + globalCtx->csCtx.currentCsIndex = csIndex; + globalCtx->csCtx.csData = Lib_SegmentedToVirtual(globalCtx->csCtx.sceneCsList[csIndex].segmentedData); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDE34.s") + gSaveContext.cutsceneTrigger = 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDF24.s") +/* Start of actor utilities section */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDF78.s") +/** + * Interpolates the actor's position based on the corresponding actor action's position + * and the current cutscene frame + */ +void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry = globalCtx->csCtx.actorActions[actorActionIndex]; + f32 progress; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE0CC.s") + 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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE1D8.s") + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE200.s") + VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE29C.s") +/** + * 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, GlobalContext* globalCtx, s32 actorActionIndex) { + Cutscene_ActorTranslate(actor, globalCtx, actorActionIndex); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EE2F4.s") + actor->world.rot.y = globalCtx->csCtx.actorActions[actorActionIndex]->urot.y; + actor->shape.rot.y = actor->world.rot.y; +} + +/** + * 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, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry; + f32 progress; + + start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x; + start.y = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.y; + start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x; + end.y = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.y; + end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z; + + entry = globalCtx->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + + VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress); + + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + actor->shape.rot.y = actor->world.rot.y; +} + +/** + * 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, GlobalContext* globalCtx, s32 actorActionIndex) { + Vec3f start; + Vec3f end; + CsCmdActorAction* entry; + f32 progress; + + start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x; + start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z; + end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x; + end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z; + + entry = globalCtx->csCtx.actorActions[actorActionIndex]; + progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames); + + actor->world.pos.x = start.x + (end.x - start.x) * progress; + actor->world.pos.z = start.z + (end.z - start.z) * progress; + + Math_SmoothStepToS(&actor->world.rot.y, Math_Vec3f_Yaw(&start, &end), 10, 1000, 1); + actor->shape.rot.y = actor->world.rot.y; +} + +s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) { + s32 sceneSetupIndex = 0; + + if (gSaveContext.sceneSetupIndex > 0) { + sceneSetupIndex = gSaveContext.sceneSetupIndex; + } + return sceneSetupIndex; +} + +s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) { + s32 i; + s32 index = -1; + + for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) { + if (actorActionCmd == D_801F4DC8[i]) { + index = i; + } + } + + return index; +} + +s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd) { + if (globalCtx->csCtx.state != CS_STATE_0) { + s32 index = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); + + if (index != -1) { + return globalCtx->csCtx.actorActions[index] != NULL; + } + } + + return false; +} + +u8 Cutscene_IsPlaying(GlobalContext* globalCtx) { + return (gSaveContext.cutsceneTrigger != 0) || (globalCtx->csCtx.state != CS_STATE_0); +} + +/* End of actor utilities section */ diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c index 112f7fe73..e3a051fb4 100644 --- a/src/code/z_eff_shield_particle.c +++ b/src/code/z_eff_shield_particle.c @@ -184,7 +184,7 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { } SkinMatrix_SetTranslate(&spC4, this->position.x, this->position.y, this->position.z); - SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, 0); + SkinMatrix_SetRotateRPY(&sp104, 0, elem->yaw, MTXMODE_NEW); SkinMatrix_MtxFMtxFMult(&spC4, &sp104, &sp84); SkinMatrix_SetRotateRPY(&sp104, 0, 0, elem->pitch); SkinMatrix_MtxFMtxFMult(&sp84, &sp104, &spC4); diff --git a/src/code/z_effect.c b/src/code/z_effect.c index dd696393f..4c446b650 100644 --- a/src/code/z_effect.c +++ b/src/code/z_effect.c @@ -124,7 +124,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg *pIndex = TOTAL_EFFECT_COUNT; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(&globalCtx->state) != true) { slotFound = false; switch (type) { case EFFECT_SPARK: diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 11545da01..fd1d0212c 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -152,7 +152,7 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) { void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(&globalCtx->state) != true) { if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) { sEffectSsInfo.searchIndex = index + 1; sEffectSsInfo.data_table[index] = *effectsSs; @@ -255,9 +255,12 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) { for (i = 0; i < sEffectSsInfo.size; i++) { if (sEffectSsInfo.data_table[i].life > -1) { - if ((sEffectSsInfo.data_table[i].pos.x > 32000.0f) || (sEffectSsInfo.data_table[i].pos.x < -32000.0f) || - (sEffectSsInfo.data_table[i].pos.y > 32000.0f) || (sEffectSsInfo.data_table[i].pos.y < -32000.0f) || - (sEffectSsInfo.data_table[i].pos.z > 32000.0f) || (sEffectSsInfo.data_table[i].pos.z < -32000.0f)) { + if ((sEffectSsInfo.data_table[i].pos.x > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.x < BGCHECK_Y_MIN) || + (sEffectSsInfo.data_table[i].pos.y > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.y < BGCHECK_Y_MIN) || + (sEffectSsInfo.data_table[i].pos.z > BGCHECK_Y_MAX) || + (sEffectSsInfo.data_table[i].pos.z < BGCHECK_Y_MIN)) { EffectSS_Delete(&sEffectSsInfo.data_table[i]); } else { EffectSS_DrawParticle(globalCtx, i); diff --git a/src/code/z_en_hy.c b/src/code/z_en_hy_code.c similarity index 58% rename from src/code/z_en_hy.c rename to src/code/z_en_hy_code.c index e0c487262..6b16cc91c 100644 --- a/src/code/z_en_hy.c +++ b/src/code/z_en_hy_code.c @@ -3,78 +3,79 @@ * Description: Unused System for NPCs (includes animation, door interaction, blinking, pathing, and collider helpers) */ -#include "global.h" +#include "z_en_hy_code.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "objects/object_aob/object_aob.h" +#include "objects/object_bba/object_bba.h" +#include "objects/object_bji/object_bji.h" +#include "objects/object_boj/object_boj.h" +#include "objects/object_os_anime/object_os_anime.h" -extern AnimationHeader D_0600007C; -extern AnimationHeader D_0600066C; -extern AnimationHeader D_0600071C; -extern AnimationHeader D_060008C0; -extern AnimationHeader D_06000AB0; -extern AnimationHeader D_06000FDC; -extern AnimationHeader D_06001494; -extern AnimationHeader D_06001908; -extern AnimationHeader D_06001EE0; -extern AnimationHeader D_06005DC4; -extern AnimationHeader D_06005D9C; -extern AnimationHeader D_0600DED8; -extern AnimationHeader D_0600F920; -extern AnimationHeader D_0600FC1C; -extern AnimationHeader D_0600FEE4; -extern AnimationHeader D_06010330; - -static ActorAnimationEntryS animations[] = { - { &D_0600007C, 1.0f, 0, -1, 0, 0 }, { &D_06001494, 1.0f, 0, -1, 0, 0 }, { &D_06001494, 1.0f, 0, -1, 0, -8 }, - { &D_06001908, 1.0f, 0, -1, 0, 0 }, { &D_06001908, 1.0f, 0, -1, 0, -8 }, { &D_060008C0, 1.0f, 0, -1, 0, 0 }, - { &D_06005DC4, 1.0f, 0, -1, 0, 0 }, { &D_06000FDC, 1.0f, 0, -1, 0, 0 }, { &D_06000AB0, 1.0f, 0, -1, 0, -8 }, - { &D_0600066C, 1.0f, 0, -1, 0, 0 }, { &D_0600071C, 1.0f, 0, -1, 0, 0 }, { &D_06001EE0, 1.0f, 0, -1, 0, 0 }, - { &D_0600DED8, 1.5f, 0, -1, 2, 0 }, { &D_0600F920, 1.5f, 0, -1, 2, 0 }, { &D_0600FC1C, 1.0f, 0, -1, 0, 0 }, - { &D_0600FEE4, 1.0f, 0, -1, 0, 0 }, { &D_06010330, 1.0f, 0, -1, 0, 0 }, { &D_0600FC1C, 1.0f, 0, -1, 0, -8 }, - { &D_0600FEE4, 1.0f, 0, -1, 0, -8 }, { &D_06010330, 1.0f, 0, -1, 0, -8 }, { &D_06005D9C, 1.0f, 0, -1, 0, -8 }, +static AnimationInfoS sAnimations[] = { + { &gMamamuYanUnusedIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001494, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_001908, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_0008C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gBbaIdleHoldingBagAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_bji_Anim_000FDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_bji_Anim_000AB0, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_bji_Anim_00066C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00071C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_os_anime_Anim_001EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00DED8, 1.5f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_boj_Anim_00F920, 1.5f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_boj_Anim_00FC1C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00FEE4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_010330, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_boj_Anim_00FC1C, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_00FEE4, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_010330, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, + { &object_boj_Anim_005D9C, 1.0f, 0, -1, ANIMMODE_LOOP, -8 }, }; -s8 D_801BC3F0[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; +s8 gEnHyBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2 }; -s8 D_801BC400[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13, 0 }; +s8 gEnHyBodyPartsIndex[] = { 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13 }; -u8 D_801BC410[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +u8 gEnHyShadowSize[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 frameCount; s32 isChanged = false; - if (animIndex >= 0 && animIndex <= 20) { + if (animIndex >= ENHY_ANIMATION_AOB_0 && animIndex < ENHY_ANIMATION_MAX) { isChanged = true; - frameCount = animations[animIndex].frameCount; + frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(&animations[animIndex].animationSeg->common); + frameCount = Animation_GetLastFrame(&sAnimations[animIndex].animation->common); } - Animation_Change(skelAnime, animations[animIndex].animationSeg, animations[animIndex].playbackSpeed, - animations[animIndex].frame, frameCount, animations[animIndex].mode, - animations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return isChanged; } -//! @TODO: Return Door instance when c and h files are split -Actor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { - Actor* nearestDoor = NULL; +EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) { + EnDoor* nearestDoor = NULL; Actor* doorIter = NULL; - Actor* door; f32 dist; + EnDoor* door; s32 isSetup = false; f32 minDist = 0.0f; do { doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); - door = doorIter; - dist = Actor_DistanceBetweenActors(actor, door); + door = (EnDoor*)doorIter; + dist = Actor_DistanceBetweenActors(actor, &door->dyna.actor); if (!isSetup || (dist < minDist)) { nearestDoor = door; minDist = dist; isSetup = true; } - doorIter = door->next; + doorIter = door->dyna.actor.next; } while (doorIter != NULL); if (1) {} @@ -111,50 +112,52 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) { s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) { s32 isInitialized = false; - if ((func_8013D8DC(enHy->animObjIndex, globalCtx) == 1) && (func_8013D8DC(enHy->unk190, globalCtx) == 1) && - (func_8013D8DC(enHy->unk191, globalCtx) == 1) && (func_8013D8DC(enHy->unk192, globalCtx) == 1)) { - enHy->actor.objBankIndex = enHy->unk192; + if ((SubS_IsObjectLoaded(enHy->animObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->headObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->skelUpperObjIndex, globalCtx) == true) && + (SubS_IsObjectLoaded(enHy->skelLowerObjIndex, globalCtx) == true)) { + enHy->actor.objBankIndex = enHy->skelLowerObjIndex; isInitialized = true; ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->actor.objBankIndex].segment); SkelAnime_InitFlex(globalCtx, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable, - 16); + ENHY_LIMB_MAX); EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); } + return isInitialized; } -//! @TODO: Should just take EnDoor instead of actor when c and h are split -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, Actor* door, s16 arg3, s16 arg4) { +void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4) { s32 pad; - s8 sp3B; + s8 animIndex; Vec3f offset; f32 phi_f0; - Actor_OffsetOfPointInActorCoords(door, &offset, &enHy->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; - sp3B = ((s8)phi_f0 < 0) ? 0 : 2; - EnHy_ChangeObjectAndAnim(enHy, globalCtx, (sp3B == 0) ? arg3 : arg4); + animIndex = ((s8)phi_f0 < 0) ? 0 : 2; + EnHy_ChangeObjectAndAnim(enHy, globalCtx, (animIndex == 0) ? arg3 : arg4); enHy->skelAnime.baseTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.moveFlags |= 3; AnimationContext_SetMoveActor(globalCtx, &enHy->actor, &enHy->skelAnime, 1.0f); - ((EnDoor*)door)->unk_1A1 = 1; - ((EnDoor*)door)->unk_1A0 = sp3B; + door->unk_1A1 = 1; + door->animIndex = animIndex; } s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) { s32 ret = false; s16 yaw; - Actor* door; + EnDoor* door; s32 pad; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg3, arg4); - yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->world.pos); + yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); enHy->actor.world.pos.x += arg5 * Math_SinS(yaw); enHy->actor.world.pos.z += arg5 * Math_CosS(yaw); enHy->actor.world.rot.y = -yaw; @@ -168,18 +171,18 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3 s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { s32 ret = false; s32 pad; - Actor* door; + EnDoor* door; enHy->curPoint = 0; - if (func_8013D68C(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) { door = EnHy_FindNearestDoor(&enHy->actor, globalCtx); if (door != NULL) { ret = true; func_800F0BB4(enHy, globalCtx, door, arg2, arg3); - enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->world.pos); + enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); enHy->actor.world.rot.y = enHy->actor.shape.rot.y; enHy->actor.gravity = 0.0f; - enHy->actor.flags &= ~1; + enHy->actor.flags &= ~ACTOR_FLAG_1; } } return ret; @@ -187,16 +190,16 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) { s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex) { enHy->actor.gravity = gravity; - enHy->actor.flags |= 1; + enHy->actor.flags |= ACTOR_FLAG_1; EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); enHy->curPoint++; - return 0; + return false; } s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) { EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex); enHy->curPoint--; - return 0; + return false; } s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { @@ -206,12 +209,14 @@ s32 EnHy_MoveForwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint++; if (enHy->curPoint >= enHy->path->count) { reachedEnd = true; } } + return reachedEnd; } @@ -222,12 +227,14 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) { Math_SmoothStepToF(&enHy->actor.speedXZ, speedTarget, 0.4f, 1000.0f, 0.0f); rotStep = enHy->actor.speedXZ * 400.0f; - if (func_8013D68C(enHy->path, enHy->curPoint, &curPointPos) && func_8013D768(&enHy->actor, &curPointPos, rotStep)) { + if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &curPointPos) && + SubS_MoveActorToPoint(&enHy->actor, &curPointPos, rotStep)) { enHy->curPoint--; if (enHy->curPoint < 0) { reachedEnd = true; } } + return reachedEnd; } @@ -258,14 +265,15 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG; } - enHy->isLeftFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->leftFootPos, distAboveThreshold); + enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold); if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - enHy->isRightFootOnGround = isFootOnGround = func_8013DB90(globalCtx, &enHy->rightFootPos, distAboveThreshold); + enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold); if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) { Actor_PlaySfxAtPos(&enHy->actor, sfxId); } - return 0; + + return false; } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 9dda61d3f..08fcba8c2 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -30,13 +30,22 @@ const ActorInit En_Item00_InitVars = { }; static ColliderCylinderInit sCylinderInit = { - { COLTYPE_NONE, AT_NONE, AC_ON | AT_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER }, - { ELEMTYPE_UNK0, - { 0x00000000, 0x00, 0x00 }, - { 0x00000010, 0x00, 0x00 }, - TOUCH_NONE | TOUCH_SFX_NORMAL, - BUMP_ON, - OCELEM_NONE }, + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AT_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000010, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 30, 0, { 0, 0, 0 } }, }; @@ -1132,7 +1141,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 spawnedActor->actor.world.rot.y = Rand_ZeroOne() * 40000.0f; Actor_SetScale(&spawnedActor->actor, 0.0f); spawnedActor->actionFunc = func_800A6780; - spawnedActor->actor.flags = spawnedActor->actor.flags | 0x10; + spawnedActor->actor.flags = spawnedActor->actor.flags | ACTOR_FLAG_10; if ((spawnedActor->actor.params != ITEM00_SMALL_KEY) && (spawnedActor->actor.params != ITEM00_HEART_PIECE) && (spawnedActor->actor.params != ITEM00_HEART_CONTAINER)) { diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index c6ee50d87..e22b5f351 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -14,10 +14,10 @@ void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx) { SkelCurveLimb** limbs; - SkelCurveLimbList* limbList = (SkelCurveLimbList*)Lib_SegmentedToVirtual(limbListSeg); + SkelCurveLimbList* limbList = Lib_SegmentedToVirtual(limbListSeg); skelCurve->limbCount = limbList->limbCount; - skelCurve->limbList = (SkelCurveLimb**)Lib_SegmentedToVirtual(limbList->limbs); + skelCurve->limbList = Lib_SegmentedToVirtual(limbList->limbs); skelCurve->transforms = ZeldaArena_Malloc(sizeof(*skelCurve->transforms) * skelCurve->limbCount); @@ -100,7 +100,7 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) { - SkelCurveLimb* limb = (SkelCurveLimb*)Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); + SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index 2cf05e02a..379ebda1d 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -29,13 +29,13 @@ ColliderCylinderInit sFireObjCollisionInit = { { 18, 67, 0, { 0, 0, 0 } }, }; -FireObjLightParams sFireObjLightParams[2] = { - { 255, 255, 0, 255, 128, 255, 0, 0 }, - { 0, 200, 128, 128, 0, 127, 127, 0 }, +FireObjColors sFireObjColors[] = { + { { 255, 255, 0, 255 }, 128, { 255, 0, 0 } }, }; -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos); -void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire); +FireObjLightParams sFireObjLightParams[] = { + { 200, { 128, 128, 0 }, { 127, 127, 0 } }, +}; void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) { fire->size = init->size; @@ -43,7 +43,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit fire->dynamicSizeStep = init->dynamicSizeStep; fire->state = init->state; fire->sizeGrowsCos2 = init->sizeGrowsCos2; - fire->unk27 = init->unkA; + fire->colorsIndex = init->colorsIndex; fire->flags = init->flags; fire->xScale = 0.0f; fire->yScale = 0.0f; @@ -53,7 +53,7 @@ void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInit } void FireObj_SetState(FireObj* fire, f32 dynamicSizeStep, u8 newState) { - fire->state = newState & 0xFF; + fire->state = newState; if (fire->state == FIRE_STATE_3) { fire->yScale = 0.0f; fire->xScale = 0.0f; @@ -75,11 +75,11 @@ void FireObj_StepSize(FireObj* fire) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_2); } } else if ((fire->state == FIRE_STATE_1) && (Math_StepToF(&fire->dynamicSize, 0.0f, fire->dynamicSizeStep) != 0)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 3); + FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if (fire->sizeGrowsCos2 == 1) { if ((fire->state == FIRE_STATE_0) || (fire->state == FIRE_STATE_1)) { - fire->xScale = (1.0f - Math_CosS((fire->dynamicSize * fire->dynamicSize * 16384.0f))) * fire->size; + fire->xScale = (1.0f - Math_CosS(SQ(fire->dynamicSize) * 0x4000)) * fire->size; fire->yScale = fire->dynamicSize * fire->size; } else { fire->yScale = fire->dynamicSize * fire->size; @@ -96,7 +96,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { Player* player = GET_PLAYER(globalCtx); WaterBox* waterBox; f32 waterY; - s32 sp40 = 0; + s32 sp40 = false; u8 nextState; Vec3f dist; @@ -115,16 +115,16 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { } if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) && WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) && - ((fire->yScale * ((void)0, 6500.0f)) < (waterY - fire->position.y))) { // Fake but IDK what else + (waterY - fire->position.y > 6500.0f * fire->yScale)) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3); } if ((fire->flags & 2) && (player->itemActionParam == PLAYER_AP_STICK)) { Math_Vec3f_Diff(&player->swordInfo[0].tip, &fire->position, &dist); if (Math3D_LengthSquared(&dist) < 400.0f) { - sp40 = 1; + sp40 = true; } } - if (sp40 != 0) { + if (sp40) { if (fire->state == FIRE_STATE_3) { if (player->unk_B28 > 0) { FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0); @@ -140,7 +140,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) { void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { s32 pad; - FireObjLightParams* lightParams = &sFireObjLightParams[fire->unk27]; + FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex]; if (fire->state != FIRE_STATE_3) { Vec3s vec; @@ -151,13 +151,13 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, lightParams->unk4, lightParams->primColor.r, lightParams->primColor.g, - lightParams->primColor.b, lightParams->primColor.a); + gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g, + fireColors->primColor.b, fireColors->primColor.a); - gDPSetEnvColor(POLY_XLU_DISP++, lightParams->envColor.r, lightParams->envColor.g, lightParams->envColor.b, 0); + gDPSetEnvColor(POLY_XLU_DISP++, fireColors->envColor.r, fireColors->envColor.g, fireColors->envColor.b, 0); vec.x = 0; - vec.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000; + vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000; vec.z = 0; Matrix_SetStateRotationAndTranslation(fire->position.x, fire->position.y, fire->position.z, &vec); Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY); @@ -168,45 +168,35 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) { } } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly -void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* param_3, Vec3f* pos) { - FireObjLightParams* objectParams = &sFireObjLightParams[*param_3]; +void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* paramsIndex, Vec3f* pos) { + FireObjLightParams* objectParams = &sFireObjLightParams[*paramsIndex]; - Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->primColor.g, - objectParams->primColor.b, objectParams->primColor.a, objectParams->primColor.r); - light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, (LightInfo*)&light->lightInfo); - light->unk12 = *param_3; + Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->color.r, objectParams->color.g, + objectParams->color.b, objectParams->radius); + light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &light->lightInfo); + light->lightParamsIndex = *paramsIndex; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_InitLight.s") -#endif void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light); } -#ifdef NON_EQUIVALENT -// Accesses data incorrectly void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) { - FireObjLightParams* lightParams = &sFireObjLightParams[light->unk12]; + FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex]; s16 radius; if (fire->state == FIRE_STATE_3) { - Lights_PointSetColorAndRadius((LightInfo*)&light->lightInfo, 0, 0, 0, -1); + Lights_PointSetColorAndRadius(&light->lightInfo, 0, 0, 0, -1); } else { radius = ((fire->yScale * 140.0f * fire->sizeInv) + 60.0f); - Lights_PointGlowSetInfo((LightInfo*)&light->lightInfo, fire->position.x, - (fire->position.y + (fire->yScale * 6500.0f)), fire->position.z, - ((s32)(Rand_ZeroOne() * lightParams->envColor.r) + lightParams->primColor.b), - ((s32)(Rand_ZeroOne() * lightParams->envColor.g) + lightParams->primColor.a), - ((s32)(Rand_ZeroOne() * lightParams->envColor.b) + lightParams->unk4), radius); + Lights_PointGlowSetInfo(&light->lightInfo, fire->position.x, (fire->position.y + (fire->yScale * 6500.0f)), + fire->position.z, + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.r) + lightParams->color.r), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.g) + lightParams->color.g), + ((s32)(Rand_ZeroOne() * lightParams->maxColorAdj.b) + lightParams->color.b), radius); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fireobj/FireObj_UpdateLight.s") -#endif void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) { FireObj* fire2 = fire; @@ -218,7 +208,7 @@ void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* in fire2->collision.dim.radius = (fire->size * 4000.0f) + 2.5f; fire2->collision.dim.height = fire->size * 16000.0f; fire->collision.dim.yShift = fire->size * -1728.0f; - FireObj_InitLight(globalCtx, &fire->light, &init->unkC, &fire->position); + FireObj_InitLight(globalCtx, &fire->light, &init->lightParamsIndex, &fire->position); } void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) { @@ -235,14 +225,14 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) { EnArrow* arrow = (EnArrow*)fire->collision.base.ac; FireObj_UpdateStateTransitions(globalCtx, fire); - if (fire->state == 3) { - if ((fire->collision.base.acFlags & 2) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) { - FireObj_SetState(fire, fire->dynamicSizeStep, 0); + 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); } - } else if ((fire->collision.base.acFlags & 2) && (arrow->actor.update != NULL) && + } else if ((fire->collision.base.acFlags & AC_HIT) && (arrow->actor.update != NULL) && (arrow->actor.id == ACTOR_EN_ARROW)) { arrow->actor.params = 0; - arrow->unk_1C0 = 0x800; + arrow->collider.info.toucher.dmgFlags = 0x800; } fire->collision.dim.pos.x = fire->position.x; fire->collision.dim.pos.y = fire->position.y; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 5b885b653..62d55bc00 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -67,14 +67,14 @@ void GameOver_Update(GlobalContext* globalCtx) { break; case GAMEOVER_DEATH_FADE_OUT: if (func_801A8A50(1) != NA_BGM_GAME_OVER) { - func_80169F78(globalCtx); + func_80169F78(&globalCtx->state); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; } gSaveContext.nextTransition = 2; gSaveContext.save.playerData.health = 48; gameOverCtx->state++; - if (gSaveContext.save.inventory.items[SLOT(ITEM_MASK_DEKU)] == ITEM_MASK_DEKU) { + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; gSaveContext.save.equippedMask = PLAYER_MASK_NONE; } diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index b6d46eba1..c3c616669 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index 7f4d43784..bc7dcd646 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,9 +1,145 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s") +s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 }; +f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f }; +f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s") +void func_800F4A10(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Init.s") + func_8013EE24(); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Destroy.s") + pauseCtx->unk_206 = 0; + pauseCtx->unk_200 = 1; + pauseCtx->eye.x = sKaleidoSetupEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = D_801BDB00[pauseCtx->pageIndex]; + pauseCtx->unk_27E = -40; + + for (i = 0; i < ARRAY_COUNT(pauseCtx->worldMapPoints); i++) { + pauseCtx->worldMapPoints[i] = 0; + } + + if (pauseCtx->state == 1) { + for (i = 0; i < 11; i++) { + if ((gSaveContext.save.mapsVisited >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + } + } + } else { + for (i = 9; i >= 0; i--) { + if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { + pauseCtx->worldMapPoints[i] = 1; + pauseCtx->unk_238[4] = i; + } + } + + if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { + pauseCtx->unk_238[4] = 4; + } + } + + YREG(11) = -0x00C8; + YREG(12) = -0x3840; + YREG(13) = 0x2710; + YREG(14) = 0x2710; + YREG(15) = 0x2710; + YREG(16) = -0x00BE; + YREG(17) = -0x06D6; + YREG(18) = -0x0B90; + YREG(19) = 0x06E0; + YREG(20) = 0; + YREG(21) = -0x0622; + YREG(22) = -0x0C44; + YREG(23) = 0x0622; + YREG(24) = -0x0622; + YREG(25) = -0x005A; + YREG(26) = -0x3840; +} + +void KaleidoSetup_Update(GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + PauseContext* pauseCtx = &globalCtx->pauseCtx; + + if (CHECK_BTN_ALL(input->cur.button, BTN_R)) { + if (msgCtx && msgCtx) {} + } + + if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) { + if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) { + if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { + if (!Play_InCsMode(globalCtx) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { + if ((globalCtx->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) { + if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { + if (!(globalCtx->actorCtx.unk5 & 2) && !(globalCtx->actorCtx.unk5 & 4)) { + if ((globalCtx->actorCtx.unk268 == 0) && + CHECK_BTN_ALL(input->press.button, BTN_START)) { + gSaveContext.unk_3F26 = gSaveContext.unk_3F22; + pauseCtx->unk_2B9 = 0; + pauseCtx->state = 1; + func_800F4A10(globalCtx); + pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + func_801A3A7C(1); + } + + if (pauseCtx->state == 1) { + Game_SetFramerateDivisor(&globalCtx->state, 2); + if (ShrinkWindow_GetLetterboxTarget() != 0) { + ShrinkWindow_SetLetterboxTarget(0); + } + func_801A3AEC(1); + } + } + } + } + } + } + } + } +} + +void KaleidoSetup_Init(GlobalContext* globalCtx) { + PauseContext* pauseCtx = &globalCtx->pauseCtx; + s32 pad[2]; + + bzero(pauseCtx, sizeof(PauseContext)); + + pauseCtx->pageIndex = PAUSE_0; + + pauseCtx->unk_21C = 160.0f; + pauseCtx->unk_218 = 160.0f; + pauseCtx->unk_214 = 160.0f; + pauseCtx->unk_210 = 160.0f; + + pauseCtx->eye.x = -64.0f; + pauseCtx->unk_20C = 936.0f; + pauseCtx->unk_220 = -314.0f; + + pauseCtx->unk_238[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_258 = 11; + pauseCtx->unk_25A = 0; + + pauseCtx->cursorItem[PAUSE_0] = 999; + pauseCtx->cursorItem[PAUSE_1] = XREG(94) + 3; + pauseCtx->cursorItem[PAUSE_2] = 999; + pauseCtx->cursorItem[PAUSE_3] = 999; + + pauseCtx->unk_268[PAUSE_0] = 0; + pauseCtx->unk_268[PAUSE_1] = XREG(94) + 3; + + pauseCtx->unk_284 = 2; + pauseCtx->unk_2A0 = -1; + pauseCtx->unk_2BA = 320; + pauseCtx->unk_2BC = 40; + pauseCtx->unk_29E = 100; + + View_Init(&pauseCtx->view, globalCtx->state.gfxCtx); +} + +void KaleidoSetup_Destroy(GlobalContext* globalCtx) { +} diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 6221e0910..ad66fe4a1 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -8,7 +8,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5954.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5A8C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_LerpWeight.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800F5B10.s") @@ -64,7 +64,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB010.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB320.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FB388.s") diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 84eb8c051..aaf4bc7d9 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -371,7 +371,7 @@ void Math_Vec3f_DistXYZAndStoreNormDiff(Vec3f* a, Vec3f* b, f32 scale, Vec3f* de f32 Math_Vec3f_DistXYZ(Vec3f* a, Vec3f* b) { Vec3f diff; Math_Vec3f_Diff(b, a, &diff); - return sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)); + return sqrtf(SQXYZ(diff)); } f32 Math_Vec3f_DistXYZAndStoreDiff(Vec3f* a, Vec3f* b, Vec3f* dest) { @@ -578,7 +578,7 @@ void Math_ApproachZeroF(f32* pValue, f32 scale, f32 maxStep) { *pValue = *pValue - f0; } -s32 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { +s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step, s16 minStep) { s16 stepSize = 0; s16 diff = target - *pValue; diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index d9bb32bd3..73ba326b5 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -1,14 +1,16 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "interface/parameter_static/parameter_static.h" +#include "prevent_bss_reordering.h" -static s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; -static s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; -static s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; -static s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; -static s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; -static s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; +s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsPrimFactors[3][3] = { { 0, 0, 0 }, { 0, 120, -50 }, { -155, 30, 205 } }; +s16 sHeartsEnvFactors[3][3] = { { 0, 0, 0 }, { 205, -40, -60 }, { -50, -40, 195 } }; +s16 sHeartsDDPrimColors[3][3] = { { 255, 255, 255 }, { 255, 190, 0 }, { 100, 100, 255 } }; +s16 sHeartsDDEnvColors[3][3] = { { 200, 0, 0 }, { 255, 0, 0 }, { 0, 0, 255 } }; +s16 sHeartsDDPrimFactors[3][3] = { { 0, 0, 0 }, { 0, -65, -255 }, { -155, -155, 0 } }; +s16 sHeartsDDEnvFactors[3][3] = { { 0, 0, 0 }, { 55, 0, 0 }, { -200, 0, 255 } }; s16 sBeatingHeartsDDPrim[3]; s16 sBeatingHeartsDDEnv[3]; @@ -397,9 +399,8 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (Player_InCsMode(&globalCtx->state) == 0 && (globalCtx->pauseCtx.state == 0) && - (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && func_801690CC(globalCtx) == 0) { - // Player_InCsMode and func_801690CC : Check if in Cutscene + if (!Player_InCsMode(&globalCtx->state) && (globalCtx->pauseCtx.state == 0) && + (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(globalCtx)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 858a7186e..2b0db8ad4 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,6 +1,8 @@ #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" +LightsBuffer sLightsBuffer; + void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type) { info->type = type; info->params.point.x = x; @@ -128,6 +130,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global Vec3f posF; Vec3f adjustedPos; u32 pad; + if (radiusF > 0) { posF.x = params->point.x; posF.y = params->point.y; @@ -373,7 +376,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { LightNode* light = globalCtx->lightCtx.listHead; while (light != NULL) { - LightPoint* params = (LightPoint*)&light->info->params; + LightPoint* params = &light->info->params.point; if (light->info->type == LIGHT_POINT_GLOW) { Vec3f pos; @@ -413,8 +416,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { dl = func_8012C7FC(POLY_XLU_DISP); - gSPSetOtherMode(dl++, G_SETOTHERMODE_H, 4, 4, - 0x00000080); //! This doesn't resolve to any of the macros in gdi.h + gDPSetDither(dl++, G_CD_NOISE); gDPSetCombineLERP(dl++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); @@ -423,7 +425,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { do { if (light->info->type == LIGHT_POINT_GLOW) { - params = (LightPoint*)&light->info->params; + params = &light->info->params.point; if (params->drawGlow) { f32 scale = SQ((f32)params->radius) * 2e-6f; diff --git a/src/code/z_message.c b/src/code/z_message.c index 84f2ab951..83fd51b4d 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,14 +1,111 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147520.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147564.s") +s16 D_801D02D8[15] = { + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE5, ACTOR_OCEFF_WIPE5, // Sonata of Awakening Effect, Sonata of Awakening Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE7, // Song of Time Effect, Song of Healing Effect + ACTOR_OCEFF_WIPE2, ACTOR_OCEFF_WIPE6, // Epona's Song Effect, Song of Soaring Effect + ACTOR_OCEFF_STORM, ACTOR_OCEFF_SPOT, // Song of Storms Effect II [?], Sun's Song Effect + ACTOR_OCEFF_WIPE, ACTOR_OCEFF_WIPE, // Song of Time Effect, Song of Time Effect + ACTOR_OCEFF_WIPE4 // Scarecrow's Song Effect +}; +s32 D_801D02F8[15] = { 0,1,2,3,4,0,1,0,0,0,0,0,1,1,0 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147624.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147734.s") +extern u16 D_801C6AB8[]; +extern u16 D_801C6B28[]; +extern s16 D_801D02D8[]; +extern s32 D_801D02F8[]; +extern s16 D_801F6B0C; +extern s16 D_801F6B0E; +extern s16 D_801F6B10; +extern s16 D_801F6B12; +extern s16 D_801F6B14; +extern s16 D_801F6B16; +extern s16 D_801F6B18; +extern s16 D_801F6B1A; +extern s16 D_801F6B1C; +extern s16 D_801F6B1E; +extern s16 D_801F6B20; +extern s16 D_801F6B22; +extern MessageTableEntry D_801C6B98[]; +extern MessageTableEntry D_801CFB08[]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801477B4.s") +void func_80147520(void) { + D_801CFC98 = 0xFF; + D_801CFCA4[0] = D_801CFCA4[1] = D_801CFCA4[2] = D_801CFCA4[3] = D_801CFCA4[4] = D_801CFCA4[5] = D_801CFCA4[6] = + D_801CFCA4[7] = D_801CFCA4[8] = 0; +} + +void func_80147564(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk1204A[0] = 0xBD; + msgCtx->unk1204A[1] = 0xB8; + msgCtx->unk1204A[2] = 0xB3; + msgCtx->unk1204A[3] = 0xAE; + msgCtx->unk1204A[4] = 0xA9; + func_80147520(); + D_801F6B0C = 0x50; + D_801F6B10 = 0x96; + D_801F6B0E = 0xFF; + D_801F6B12 = 0xA; + D_801F6B16 = 0xA; + D_801F6B14 = 0xA; + D_801F6B18 = 0xFF; + D_801F6B1C = 0xFF; + D_801F6B1A = 0x32; + D_801F6B1E = 0xA; + D_801F6B22 = 0xA; + D_801F6B20 = 0xA; +} + +s32 Message_ShouldAdvance(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(globalCtx); + + if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) { + if (CHECK_BTN_ALL(controller->press.button, BTN_A)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + if (CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP)) { + play_sound(NA_SE_SY_MESSAGE_PASS); + } + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* controller = CONTROLLER1(globalCtx); + + if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) { + return CHECK_BTN_ALL(controller->press.button, BTN_A); + } else { + return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || + CHECK_BTN_ALL(controller->press.button, BTN_CUP); + } +} + +void func_801477B4(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + if (globalCtx->msgCtx.unk11F10 != 0) { + msgCtx->unk12023 = 2; + msgCtx->msgMode = 0x43; + msgCtx->unk12020 = 0; + play_sound(NA_SE_PL_WALK_GROUND - SFX_FLAG); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80147818.s") @@ -16,9 +113,51 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148558.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#ifdef NON_MATCHING +void func_80148B98(GlobalContext* globalCtx, u8 arg1) { + static s16 held = 0; + MessageContext* msgCtx = &globalCtx->msgCtx; + Input* curInput = CONTROLLER1(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148CBC.s") + if ((curInput->rel.stick_y > 29) && held == 0) { + held = 1; + msgCtx->choiceIndex--; + if (msgCtx->choiceIndex > 128) { + msgCtx->choiceIndex = 0; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else if ((curInput->rel.stick_y < -29) && held == 0) { + held = 1; + msgCtx->choiceIndex++; + if (msgCtx->choiceIndex > arg1) { + msgCtx->choiceIndex = arg1; + } else { + play_sound(NA_SE_SY_CURSOR); + } + return; + } else { + if (ABS_ALT(curInput->rel.stick_y) < 30) { + held = 0; + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s") +#endif + +void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11FF4 = 0x30; + if (arg2 == 1) { + msgCtx->unk11FF6 = msgCtx->unk11FFE[1 + msgCtx->choiceIndex]; + } else { + msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex]; + } + func_80147818(globalCtx, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s") @@ -34,7 +173,33 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149EBC.s") +void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTable; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTable; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149F74.s") @@ -44,9 +209,43 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CC14.s") +void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CCB4.s") + Font_LoadChar(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +// Message_LoadRupees JPN ? +void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 t = *decodedBufPos; + s32 k = *offset; + f32 f = *arg3; + + Font_LoadChar(globalCtx, 0x838B, k); // 0x838b = ル in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x838B; + t += 1; + Font_LoadChar(globalCtx, 0x8373, k); // 0x8373 = ピ in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x8373; + t += 1; + Font_LoadChar(globalCtx, 0x815C, k); // Ox815C = ― in JISX0213 + k += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.wchar[t] = 0x815C; + + f += 16.0f * msgCtx->unk12098 * 3.0f; + *decodedBufPos = t; + *offset = k; + *arg3 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CDF0.s") @@ -54,7 +253,62 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D304.s") +#ifdef NON_EQUIVALENT +extern u16* D_801D0188; +extern s16* D_801D0250; + +void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) { + f32 sp3C; + s16 temp_s0; + s16 temp_s1; + s16 temp_s1_2; + s16 temp_s6; + s32 temp_s2; + s32 temp_s2_2; + u16* temp_v0; + s16 phi_v0; + s16 phi_s0; + s16 phi_s1; + s32 phi_s2; + s16 phi_s1_2; + s32 phi_s2_2; + + temp_s1 = *arg3; + temp_s2 = *arg1; + sp3C = *arg2; + if ((func_8010A0A4(arg0) != 0) || (arg0->sceneNum == 0x4F)) { + phi_v0 = 0xA; + } else { + phi_v0 = arg0->pauseCtx.unk_238[4]; + } + temp_s6 = *(&D_801D0250 + (phi_v0 * 2)); + phi_s0 = 0; + phi_s1_2 = temp_s1; + phi_s2_2 = temp_s2; + if ((s32)temp_s6 > 0) { + phi_s1 = temp_s1; + phi_s2 = temp_s2; + do { + temp_v0 = (phi_v0 * 0x12) + &D_801D0188 + (phi_s0 * 2); + (arg0 + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0; + Font_LoadChar(arg0, *temp_v0, phi_s2); + temp_s0 = phi_s0 + 1; + temp_s1_2 = phi_s1 + 1; + temp_s2_2 = phi_s2 + 0x80; + phi_s0 = temp_s0; + phi_s1 = temp_s1_2; + phi_s2 = temp_s2_2; + phi_s1_2 = temp_s1_2; + phi_s2_2 = temp_s2_2; + } while ((s32)temp_s0 < (s32)temp_s6); + } + *arg3 = phi_s1_2 - 1; + *arg1 = phi_s2_2; + *arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * arg0->msgCtx.unk12098)); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D62C.s") +#endif #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D7B4.s") @@ -64,46 +318,239 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801518B0.s") +void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* Actor) { + MessageContext* msgCtx = &globalCtx->msgCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151938.s") + msgCtx->ocarinaAction = 0xFFFF; + func_80150D08(globalCtx, textId); + msgCtx->unkActor = Actor; + msgCtx->msgMode = 1; + msgCtx->unk12023 = 0; + msgCtx->unk12024 = 0; + globalCtx->msgCtx.ocarinaMode = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151A68.s") +void func_80151938(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151BB4.s") + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + msgCtx->msgMode = 5; + msgCtx->unk12023 = 8; + msgCtx->unk12024 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151C9C.s") + if (interfaceCtx->unk_222 == 0) { + if (textId != 0x1B93) { + Interface_SetDoAction(globalCtx, 0x10); + } else if (textId != 0xF8) { + Interface_SetDoAction(globalCtx, 6); + } + } + msgCtx->unk1203C = msgCtx->unk1203A; + + if (globalCtx->pauseCtx.unk_1F0 != 0) { + msgCtx->unk12004 = 0x22; + msgCtx->unk12006 = 0x15E; + func_80149C18(globalCtx); + msgCtx->unk12023 = 1; + } +} + +void func_80151A68(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + + msgCtx->unk11F10 = 0; + func_80150D08(globalCtx, textId); + func_80150A84(globalCtx); + func_8015B198(globalCtx); + msgCtx->msgMode = 0x45; + msgCtx->unk12024 = 0; + msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0; + msgCtx->unk12023 = 0x1E; + + // Day/Dawn/Night.. Messages + if ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId < 0x1BB7)) { + XREG(74) = 0x6A; + XREG(75) = 0; + XREG(77) = 0x58; + XREG(76) = 0x44; + } else { + XREG(74) = 0x42; + XREG(75) = 0x1E; + XREG(77) = 0x3C; + XREG(76) = 0x1C; + msgCtx->unk11F1A[0] = msgCtx->unk11F1A[1] = msgCtx->unk11F1A[2] = 0; + Interface_ChangeAlpha(1); + } +} + +void func_80151BB4(GlobalContext* globalCtx, u8 arg1) { + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 temp = arg1; + + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } else if (arg1 >= 20) { + if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + msgCtx->unk120B2[msgCtx->unk120B1] = temp; + msgCtx->unk120B1++; + } + } +} + +u32 func_80151C9C(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + u8 flag; + + while (true) { + if (msgCtx->unk120B1 == 0) { + return 0; + } + msgCtx->unk120B1--; + + if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & + (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { + flag = gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]; + gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = + flag | (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]); + play_sound(NA_SE_SY_SCHEDULE_WRITE); + return 1; + } + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152434.s") +void func_80152434(GlobalContext* globalCtx, u16 arg2) { + globalCtx->msgCtx.unk12046 = 0; + func_80151DA4(globalCtx, arg2); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152464.s") +void func_80152464(GlobalContext* globalCtx, u16 arg1) { + globalCtx->msgCtx.unk12046 = 1; + func_80151DA4(globalCtx, arg1); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015268C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152C64.s") +void func_80152C64(View* view) { + SET_FULLSCREEN_VIEWPORT(view); + func_8013FBC8(view); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152EC0.s") +// Spawn song effect? +void func_80152EC0(GlobalContext* globalCtx) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Player* player = GET_PLAYER(globalCtx); + + if (1) {} + if ((msgCtx->songPlayed < 0x17) && (msgCtx->songPlayed != 0xE) && + ((msgCtx->ocarinaAction < 0x43) || (msgCtx->ocarinaAction >= 0x47))) { + msgCtx->unk120B0 = 1; + if (msgCtx->songPlayed != 0x16) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, D_801D02F8[msgCtx->songPlayed]); + return; + } + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x, + player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152FB8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153E7C.s") +void func_80153E7C(GlobalContext* globalCtx, void* arg1) { + if ((gSaveContext.options.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) { + func_8014ADBC(globalCtx, arg1); + return; + } + if (globalCtx->msgCtx.unk12090 != 0) { + func_8015E7EC(globalCtx, arg1); + return; + } + func_8015966C(globalCtx, arg1, 0); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153EF0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801541D4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80156758.s") +void func_80156758(GlobalContext* globalCtx) { + Gfx* nextDisplayList; + Gfx* polyOpa; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + polyOpa = POLY_OPA_DISP; + nextDisplayList = Graph_GfxPlusOne(polyOpa); + gSPDisplayList(OVERLAY_DISP++, nextDisplayList); + + if ((globalCtx->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(globalCtx)) { + func_801541D4(globalCtx, &nextDisplayList); + } + + gSPEndDisplayList(nextDisplayList++); + Graph_BranchDlist(polyOpa, nextDisplayList); + POLY_OPA_DISP = nextDisplayList; + CLOSE_DISPS(gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801586A4.s") +void func_801586A4(GlobalContext* globalCtx) { + globalCtx->msgCtx.messageEntryTableNes = D_801C6B98; + globalCtx->msgCtx.messageTableStaff = D_801CFB08; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_Init.s") +void Message_Init(GlobalContext* globalCtx) { + Font* font; + MessageContext* messageCtx = &globalCtx->msgCtx; + + func_801586A4(globalCtx); + globalCtx->msgCtx.ocarinaMode = 0; + messageCtx->msgMode = 0; + messageCtx->unk11F10 = 0; + messageCtx->currentTextId = 0; + messageCtx->unk12020 = 0; + messageCtx->choiceIndex = 0; + messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0; + messageCtx->unk1201E = 0xFF; + View_Init(&messageCtx->view, globalCtx->state.gfxCtx); + messageCtx->unk11EF8 = THA_AllocEndAlign16(&globalCtx->state.heap, 0x13C00); + font = &globalCtx->msgCtx.font; + Font_LoadOrderedFont(&globalCtx->msgCtx.font); + font->unk_11D88 = 0; + messageCtx->unk12090 = messageCtx->unk12092 = 0; + messageCtx->unk12094 = 0; + messageCtx->unk1209C = 0; + messageCtx->unk120A0 = 0; + messageCtx->unk12068 = 0x34; + messageCtx->unk1206A = 0x24; + messageCtx->unk120B0 = 0; + messageCtx->unk120BE = 0; + messageCtx->unk120C0 = 0; + messageCtx->unk120C2 = 0; + messageCtx->unk120C4 = 0; + messageCtx->unk120C8 = 0; + messageCtx->unk120CA = 0; + messageCtx->unk120CC = 0; + messageCtx->unk120CE = 0; + messageCtx->unk120D0 = 0; + messageCtx->unk120D2 = 0; + messageCtx->unk120D4 = 0; + messageCtx->unk120D6 = 0; +} diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 4767810fb..1de839d68 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -1,18 +1,280 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_801588D0.s") +#if 0 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158988.s") +//fontWidth +extern f32 D_801D0470[159]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158A24.s") +//rupeesTextLocalization +u8 D_801D06F0[4][8] = { { "rupee(s)" }, //EN + { "rubin(e)" }, //DE + { "rubis" }, //FR + { "rupia(s)" } //SPA + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158C04.s") +// rupeesTextLength +u8 D_801D0710[4] = {8,8,5,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158D98.s") +//TextArea +char D_801D0714[11][16] = { + "Great Bay Coast", + "Zora Cape", + "Snowhead", + "Mountain Village", + "Clock Town", + "Milk Road", + "Woodfall", + "Southern Swamp", + "Ikana Canyon", + "Stone Tower", + "Entrance" + }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80158FB0.s") +//TextAreaLength +s16 D_801D07C4[11] = {15,9,8,16,10,9,8,14,12,11,8}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_8015926C.s") +#endif + +extern f32 D_801D0470[159]; +extern u8 D_801D06F0[4][8]; +extern u8 D_801D0710[4]; +extern u8 D_801D0714[11][16]; +extern s16 D_801D07C4[11]; + +void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageEntryTableNes; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } + + msgEntry = msgCtx->messageEntryTableNes; + foundSegment = msgEntry->segment; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; +} + +void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s32 temp1 = *offset; + f32 temp2 = *arg3; + + Font_LoadCharNES(globalCtx, codePointIndex, temp1); + msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex; + temp1 += FONT_CHAR_TEX_SIZE; + temp2 += (16.0f * msgCtx->unk12098); + *offset = temp1; + *arg3 = temp2; +} + +void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = 0x20; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + + f += 16.0f * msgCtx->unk12098 * 6.0f; + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u8 j; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + + for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) { + Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.options.language - 1][j], o); + msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.options.language - 1][j]; + o += FONT_CHAR_TEX_SIZE; + p++; + } + + p--; + f += 16.0f * msgCtx->unk12098 * (D_801D0710[gSaveContext.options.language - 1] + 1); + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + + msgCtx->decodedBuffer.schar[p] = ' '; + p++; + Font_LoadCharNES(globalCtx, 'R', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'R'; + p++; + Font_LoadCharNES(globalCtx, 'u', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'u'; + p++; + Font_LoadCharNES(globalCtx, 'p', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'p'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + p++; + Font_LoadCharNES(globalCtx, 'e', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 'e'; + + if (singular != 1) { + p++; + Font_LoadCharNES(globalCtx, 's', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = 's'; + f += 16.0f * msgCtx->unk12098 * 6.0f; + } else { + f += 16.0f * msgCtx->unk12098 * 5.0f; + } + + *decodedBufPos = p; + *offset = o; + *arg3 = f; +} + +void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg3; + u32 dayTime; + s16 digits[4]; + f32 timeInMinutes; + s32 day; + s16 i; + + if (arg1 == 0xCF) { + day = gSaveContext.save.day; + dayTime = 0x40000 - ((day % 5) << 16) - (u16)(-0x4000 + gSaveContext.save.time); + } else { + dayTime = 0x10000 - (u16)(-0x4000 + gSaveContext.save.time); + } + timeInMinutes = TIME_TO_MINUTES_F(dayTime); + + digits[0] = 0; + digits[1] = (timeInMinutes / 60.0f); + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + digits[2] = 0; + digits[3] = (s32)timeInMinutes % 60; + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(globalCtx, digits[i] + '0', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = digits[i] + '0'; + p++; + if (i == 1) { + Font_LoadCharNES(globalCtx, ':', o); + o += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[p] = ':'; + p++; + } + } + + f += 5.0f * (16.0f * msgCtx->unk12098); + *decodedBufPos = p - 1; + *offset = o; + *arg3 = f; +} + +void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s16* decodedBufPos) { + MessageContext* msgCtx = &globalCtx->msgCtx; + s16 p = *decodedBufPos; + s32 o = *offset; + f32 f = *arg2; + s16 i; + u8 currentChar; + s16 currentArea; + s16 stringLimit; + + if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) { + currentArea = 10; + } else { + currentArea = globalCtx->pauseCtx.unk_238[4]; + } + stringLimit = D_801D07C4[currentArea]; + + for (i = 0; i < stringLimit; i++) { + msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i]; + currentChar = msgCtx->decodedBuffer.schar[p]; + if (currentChar != ' ') { + Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o); + o += FONT_CHAR_TEX_SIZE; + } + currentChar = msgCtx->decodedBuffer.schar[p]; + p++; + f += (D_801D0470[currentChar - ' '] * msgCtx->unk12098); + } + + p--; + f += (stringLimit - 1) * (16.0f * msgCtx->unk12098); + *decodedBufPos = p; + *offset = o; + *arg2 = f; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80159438.s") diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c index 2dd698690..6620f88d5 100644 --- a/src/code/z_message_staff.c +++ b/src/code/z_message_staff.c @@ -1,6 +1,27 @@ #include "global.h" +#include "message_data_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E750.s") +void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) { + MessageContext* msgCtx = &globalCtx->msgCtx; + Font* font = &msgCtx->font; + MessageTableEntry* msgEntry = msgCtx->messageTableStaff; + const char* segment = msgEntry->segment; + const char* foundSegment; + const char* nextSegment; + + while (msgEntry->textId != 0xFFFF) { + if (msgEntry->textId == textId) { + foundSegment = msgEntry->segment; + font->charBuf[font->unk_11D88][0] = msgEntry->typePos; + msgEntry++; + nextSegment = msgEntry->segment; + font->messageStart = foundSegment - segment; + font->messageEnd = nextSegment - foundSegment; + return; + } + msgEntry++; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_message_staff/func_8015E7EC.s") diff --git a/src/code/z_olib.c b/src/code/z_olib.c index c44fac276..6f1cdbc55 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -66,7 +66,7 @@ Vec3f* OLib_Vec3fDistNormalize(Vec3f* dest, Vec3f* a, Vec3f* b) { v1.y = b->y - a->y; v1.z = b->z - a->z; - dist = OLib_ClampMinDist(sqrtf(SQ(v1.x) + SQ(v1.y) + SQ(v1.z)), 0.01f); + dist = OLib_ClampMinDist(sqrtf(SQXYZ(v1)), 0.01f); v2.x = v1.x / dist; v2.y = v1.y / dist; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 23a891ab4..13545820e 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -603,8 +603,8 @@ void Interface_NewDay(GlobalContext* globalCtx, s32 day) { // i is used to store sceneId for (i = 0; i < 120; i++) { gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; - gSaveContext.save.permanentSceneFlags[i].swch0 = gSaveContext.cycleSceneFlags[i].swch0; - gSaveContext.save.permanentSceneFlags[i].swch1 = gSaveContext.cycleSceneFlags[i].swch1; + 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; } @@ -1494,7 +1494,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { return ITEM_NONE; } else if ((item >= ITEM_SHIELD_HERO) && (item <= ITEM_SHIELD_MIRROR)) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != (u16)(item - ITEM_SHIELD_HERO + 1)) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != (u16)(item - ITEM_SHIELD_HERO + 1)) { SET_EQUIP_VALUE(EQUIP_SHIELD, item - ITEM_SHIELD_HERO + 1); Player_SetEquipmentData(globalCtx, player); return ITEM_NONE; @@ -1894,10 +1894,10 @@ void Inventory_UnequipItem(s16 item) { } } -s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u8 oldItem, u8 newItem) { +s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u8 oldItem, u8 newItem) { u8 i; - for (i = 0; i < ARRAY_COUNT(gSaveContext.save.inventory.items); i++) { + for (i = 0; i < 24; i++) { if (gSaveContext.save.inventory.items[i] == oldItem) { gSaveContext.save.inventory.items[i] = newItem; @@ -2432,7 +2432,7 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (msgCtx->msgMode == 0) && (globalCtx->gameOverCtx.state == 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) { - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { if ((gSaveContext.save.playerData.magic == 0) || ((func_801242DC(globalCtx) >= 2) && (func_801242DC(globalCtx) < 5)) || (((gSaveContext.save.equips.buttonItems[0][1]) != ITEM_LENS) && @@ -2474,7 +2474,7 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (msgCtx->msgMode == 0) && (globalCtx->gameOverCtx.state == 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) { - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { interfaceCtx->unk_258--; if (interfaceCtx->unk_258 == 0) { if (!(gSaveContext.save.weekEventReg[0xE] & 8)) { @@ -2496,7 +2496,7 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && (msgCtx->msgMode == 0) && (globalCtx->gameOverCtx.state == 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) { - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { interfaceCtx->unk_258--; if (interfaceCtx->unk_258 == 0) { if (!(gSaveContext.save.weekEventReg[0xE] & 8)) { @@ -4356,11 +4356,11 @@ void Interface_Update(GlobalContext* globalCtx) { D_801BF8DC = func_801242DC(globalCtx); if (D_801BF8DC == 1) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_TUNIC) == 2) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TUNIC) == 2) { D_801BF8DC = 0; } } else if ((func_801242DC(globalCtx) >= 2) && (func_801242DC(globalCtx) < 5)) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_TUNIC) == 3) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TUNIC) == 3) { D_801BF8DC = 0; } } diff --git a/src/code/z_play.c b/src/code/z_play.c index 7e0e018c7..aa360934e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -58,7 +58,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801690CC.s") +s32 Play_InCsMode(GlobalContext* globalCtx) { + return (globalCtx->csCtx.state != 0) || Player_InCsMode(&globalCtx->state); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s") @@ -74,70 +76,290 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169474.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801694DC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CreateSubCamera.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetActiveCameraIndex.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetActiveCamId.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169590.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeStatus.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169600.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearCamera.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169668.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_ClearAllSubCameras.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCamera.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEye.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016981C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetAtEyeUp.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169940.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetFov.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169988.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraSetRoll.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801699D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CopyCamera.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169A50.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169AC0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraChangeSetting.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169AFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169BC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CameraGetUID.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169BF8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169C64.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169C84.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s") +/** + * Converts the number of a scene to its "original" equivalent, the default version of the area which the player first + * enters. + */ +s16 Play_GetOriginalSceneNumber(s16 sceneNum) { + // Inverted Stone Tower Temple -> Stone Tower Temple + if (sceneNum == SCENE_INISIE_R) { + return SCENE_INISIE_N; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169D40.s") + // Purified Southern Swamp -> Poisoned Sothern Swamp + if (sceneNum == SCENE_20SICHITAI2) { + return SCENE_20SICHITAI; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169DCC.s") + // Spring Mountain Village -> Winter Mountain Village + if (sceneNum == SCENE_10YUKIYAMANOMURA2) { + return SCENE_10YUKIYAMANOMURA; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169E6C.s") + // Spring Goron Village -> Winter Goron Village + if (sceneNum == SCENE_11GORONNOSATO2) { + return SCENE_11GORONNOSATO; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169ECC.s") + // Spring Path to Goron Village -> Winter Path to Goron Village + if (sceneNum == SCENE_17SETUGEN2) { + return SCENE_17SETUGEN; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169EFC.s") + // Inverted Stone Tower -> Stone Tower + if (sceneNum == SCENE_F41) { + return SCENE_F40; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169F78.s") + return sceneNum; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FDC.s") +/** + * Copies the flags set in ActorContext over to the current scene's CycleSceneFlags, usually using the original scene + * number. Exception for Inverted Stone Tower Temple, which uses its own. + */ +void Play_SaveCycleSceneFlags(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + CycleSceneFlags* cycleSceneFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169FFC.s") + cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)]; + cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest; + cycleSceneFlags->switch0 = globalCtx->actorCtx.flags.switches[0]; + cycleSceneFlags->switch1 = globalCtx->actorCtx.flags.switches[1]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/FrameAdvance_IsEnabled.s") + if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple + cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A02C.s") + cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0]; + cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A0AC.s") +void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams, + Vec3f* pos, s16 yaw) { + GlobalContext* globalCtx = (GlobalContext*)gameState; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A168.s") + gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF); + gSaveContext.respawn[respawnMode].roomIndex = roomIndex; + gSaveContext.respawn[respawnMode].pos = *pos; + gSaveContext.respawn[respawnMode].yaw = yaw; + gSaveContext.respawn[respawnMode].playerParams = playerParams; + gSaveContext.respawn[respawnMode].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A178.s") +void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerParams) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_8016A268.s") + if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos + Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex), + globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos, + player->actor.shape.rot.y); + } +} + +// Override respawn data in Sakon's Hideout +void func_80169ECC(GlobalContext* globalCtx) { + if (globalCtx->sceneNum == SCENE_SECOM) { + globalCtx->nextEntranceIndex = 0x2060; + gSaveContext.respawnFlag = -7; + } +} + +// Gameplay_TriggerVoidOut ? +// Used by Player, Ikana_Rotaryroom, Bji01, Kakasi, LiftNuts, Test4, Warptag, WarpUzu, Roomtimer +void func_80169EFC(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2]; + gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = globalCtx->actorCtx.flags.collectible[1]; + gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2]; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex; + gSaveContext.respawnFlag = 1; + func_80169ECC(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; +} + +// Gameplay_LoadToLastEntrance ? +// Used by game_over and Test7 +void func_80169F78(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex; + gSaveContext.respawnFlag = -1; + func_80169ECC(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; +} + +// Gameplay_TriggerRespawn ? +// Used for void by Wallmaster, Deku Shrine doors. Also used by Player, Kaleido, DoorWarp1 +void func_80169FDC(GameState* gameState) { + func_80169F78(gameState); +} + +// Used by Kankyo to determine how to change the lighting, e.g. for game over. +s32 func_80169FFC(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + return globalCtx->roomCtx.currRoom.mesh->type0.type != 1; +} + +s32 FrameAdvance_IsEnabled(GameState* gameState) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + + return globalCtx->frameAdvCtx.enabled != 0; +} + +// Unused, unchanged from OoT, which uses it only in one Camera function. +/** + * @brief Tests if \p actor is a door and the sides are different rooms. + * + * @param[in] gameState GameState, promoted to globalCtx inside. + * @param[in] actor Actor to test. + * @param[out] yaw Facing angle of the actor, or reverse if in the back room. + * @return true if \p actor is a door and the sides are in different rooms, false otherwise + */ +s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + TransitionActorEntry* transitionActor; + s8 frontRoom; + + if (actor->category != ACTORCAT_DOOR) { + return false; + } + + transitionActor = &globalCtx->doorCtx.transitionActorList[(u16)actor->params >> 10]; + frontRoom = transitionActor->sides[0].room; + if (frontRoom == transitionActor->sides[1].room) { + return false; + } + + if (frontRoom == actor->room) { + *yaw = actor->shape.rot.y; + } else { + *yaw = actor->shape.rot.y + 0x8000; + } + + return true; +} + +// Unused +/** + * @brief Tests if \p pos is underwater. + * + * @param[in] globalCtx GlobalContext + * @param[in] pos position to test + * @return true if inside a waterbox and not above a void. + */ +s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) { + WaterBox* waterBox; + CollisionPoly* poly; + Vec3f waterSurfacePos; + s32 bgId; + + waterSurfacePos = *pos; + + if ((WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, + &waterBox) == true) && + (pos->y < waterSurfacePos.y) && + (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) { + return true; + } else { + return false; + } +} + +// z_demo and EnTest4 +// This data appears to be a boolean. It is only set by Play_Init. +s32 func_8016A168(void) { + return D_801D0D50; +} + +// A mapping from playerActorCsIds to sGlobalCamDataSettings indices. +extern s16 D_801D0D64[]; +// s16 D_801D0D64[] = { -3, -2, -4, -5, -7, -11, -8, -9, -6, -16 }; + +// Used by Player +/** + * Extract the common actor cutscene ids used by Player from the scene and set the actor cutscene ids in + * globalCtx->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) + */ +void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCsId) { + GlobalContext* globalCtx = (GlobalContext*)gameState; + s32 i; + s16* curPlayerActorCsId = globalCtx->playerActorCsIds; + s16* phi_s1 = D_801D0D64; + + for (i = 0; i < ARRAY_COUNT(globalCtx->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) { + ActorCutscene* actorCutscene; + s32 curActorCsId; + + *curPlayerActorCsId = -1; + + for (curActorCsId = startActorCsId; curActorCsId != -1; curActorCsId = actorCutscene->additionalCutscene) { + actorCutscene = ActorCutscene_GetCutscene(curActorCsId); + + if (actorCutscene->csCamSceneDataId == *phi_s1) { + if ((actorCutscene->csCamSceneDataId == -3) && + (actorCutscene->priority == 700)) { // override ocarina cs priority + actorCutscene->priority = 550; + } + *curPlayerActorCsId = curActorCsId; + break; + } + } + } +} + +// These regs are used by Gameplay_Draw, and several actors, purpose as yet unclear. +void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) { + MREG(64) = arg1; + MREG(65) = arg2; + MREG(66) = arg3; + MREG(67) = arg4; + MREG(68) = arg5; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Init.s") diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 69e2f4dae..7ed1ce5ce 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -1,11 +1,60 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160A90.s") +#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) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160AF8.s") +ActorFunc sPlayerCallInitFunc; +ActorFunc sPlayerCallDestroyFunc; +ActorFunc sPlayerCallUpdateFunc; +ActorFunc sPlayerCallDrawFunc; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160B40.s") +void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160B80.s") +const ActorInit Player_InitVars = { + ACTOR_PLAYER, + ACTORCAT_PLAYER, + FLAGS, + GAMEPLAY_KEEP, + sizeof(Player), + (ActorFunc)PlayerCall_Init, + (ActorFunc)PlayerCall_Destroy, + (ActorFunc)PlayerCall_Update, + (ActorFunc)PlayerCall_Draw, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_call/func_80160BC0.s") +void Player_Init(Actor* thisx, GlobalContext* globalCtx); +void Player_Destroy(Actor* thisx, GlobalContext* globalCtx); +void Player_Update(Actor* thisx, GlobalContext* globalCtx); +void Player_Draw(Actor* thisx, GlobalContext* globalCtx); + +void PlayerCall_InitFuncPtrs(void) { + sPlayerCallInitFunc = KaleidoManager_GetRamAddr(Player_Init); + sPlayerCallDestroyFunc = KaleidoManager_GetRamAddr(Player_Destroy); + sPlayerCallUpdateFunc = KaleidoManager_GetRamAddr(Player_Update); + sPlayerCallDrawFunc = KaleidoManager_GetRamAddr(Player_Draw); +} + +void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + PlayerCall_InitFuncPtrs(); + sPlayerCallInitFunc(thisx, globalCtx); +} + +void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallDestroyFunc(thisx, globalCtx); +} + +void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallUpdateFunc(thisx, globalCtx); +} + +void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx) { + KaleidoScopeCall_LoadPlayer(); + sPlayerCallDrawFunc(thisx, globalCtx); +} diff --git a/src/code/z_quake.c b/src/code/z_quake.c index d38746bf4..ee4fa3a6d 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -137,7 +137,7 @@ QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) { __osMemset(req, 0, sizeof(QuakeRequest)); req->camera = camera; - req->cameraPtrsIdx = camera->thisIdx; + req->camId = camera->camId; req->callbackIdx = callbackIdx; req->isShakePerpendicular = true; req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx; @@ -326,10 +326,10 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { req = &sQuakeRequest[idx]; if (req->callbackIdx != 0) { - if (globalCtx->cameraPtrs[req->cameraPtrsIdx] == NULL) { + if (globalCtx->cameraPtrs[req->camId] == NULL) { Quake_Remove(req); } else { - eq = (camera->thisIdx != req->camera->thisIdx); + eq = (camera->camId != req->camera->camId); absSpeedDiv = ABS(req->speed) / (f32)0x8000; if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) { Quake_Remove(req); diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 09e026e8f..f4ffd43c1 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1222,8 +1222,6 @@ Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s3 return displayList; } -#ifdef NON_MATCHING -// Regalloc differences, minor reorderings void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b) { Gfx* masterGfx; void* zbuffer; @@ -1269,7 +1267,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g gDPSetRenderMode(&masterGfx[3], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[4], (GPACK_RGBA5551(255, 255, 240, 0) << 16) | GPACK_RGBA5551(255, 255, 240, 0)); gSPDisplayList(&masterGfx[5], D_0E000000.clearFillRect); - gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, zbuffer); + gDPSetColorImage(&masterGfx[6], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); gSPEndDisplayList(&masterGfx[7]); } @@ -1328,9 +1326,6 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g CLOSE_DISPS(gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_rcp/func_8012CF0C.s") -#endif void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { if ((R_PAUSE_MENU_MODE < 2) && (D_801F6D10 < 2)) { diff --git a/src/code/z_room.c b/src/code/z_room.c index 1685acc80..7579c6200 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -29,7 +29,7 @@ void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) { } mesh = &room->mesh->type0; - meshParams = (RoomMeshType0Params*)Lib_SegmentedToVirtual(mesh->paramsStart); + meshParams = Lib_SegmentedToVirtual(mesh->paramsStart); for (i = 0; i < mesh->count; i++) { if ((flags & 1) && (meshParams->opaqueDl != NULL)) { gSPDisplayList(gfxCtx->polyOpa.p++, meshParams->opaqueDl); @@ -75,12 +75,10 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s") -#ifdef NON_MATCHING s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) { - size_t size; - - // XXX: this should use a branch-likely if (roomCtx->unk31 == 0) { + s32 size; + roomCtx->prevRoom = roomCtx->currRoom; roomCtx->currRoom.num = index; roomCtx->currRoom.segment = NULL; @@ -101,9 +99,6 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_StartRoomTransition.s") -#endif s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { if (roomCtx->unk31 == 1) { @@ -119,7 +114,7 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) { if (((globalCtx->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) && (globalCtx->sceneNum != SCENE_IKNINSIDE)) { - globalCtx->envCtx.unk_C3 = 0xff; + globalCtx->envCtx.lightSettingOverride = 0xff; globalCtx->envCtx.unk_E0 = 0; } func_800FEAB0(); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 5675fc074..8a9bdd4e7 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -13,8 +13,7 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) { } if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { - objectCtx->status[objectCtx->num + 1].segment = - (void*)ALIGN16((u32)objectCtx->status[objectCtx->num].segment + size); + objectCtx->status[objectCtx->num + 1].segment = ALIGN16((u32)objectCtx->status[objectCtx->num].segment + size); } objectCtx->num++; @@ -152,7 +151,7 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C || - (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[1].playerParams == 0x0CFF)) { + (gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0x0CFF)) { // Skull Kid Object Object_Spawn(&globalCtx->objectCtx, OBJECT_STK); return; @@ -172,14 +171,14 @@ void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x01: Actor List void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->numSetupActors = (u16)cmd->actorList.num; - globalCtx->setupActorList = (ActorEntry*)Lib_SegmentedToVirtual(cmd->actorList.segment); - globalCtx->actorCtx.unkC = (u16)0; + globalCtx->numSetupActors = cmd->actorList.num; + globalCtx->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment); + globalCtx->actorCtx.unkC = 0; } // SceneTableEntry Header Command 0x02: List of cameras for actor cutscenes void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->unk_18858 = (UNK_PTR)Lib_SegmentedToVirtual(cmd->csCameraList.segment); + globalCtx->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment); } // SceneTableEntry Header Command 0x03: Collision Header @@ -187,21 +186,21 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { CollisionHeader* colHeaderTemp; CollisionHeader* colHeader; - colHeaderTemp = (CollisionHeader*)Lib_SegmentedToVirtual(cmd->colHeader.segment); + colHeaderTemp = Lib_SegmentedToVirtual(cmd->colHeader.segment); colHeader = colHeaderTemp; - colHeader->vtxList = (Vec3s*)Lib_SegmentedToVirtual(colHeaderTemp->vtxList); - colHeader->polyList = (CollisionPoly*)Lib_SegmentedToVirtual(colHeader->polyList); + colHeader->vtxList = Lib_SegmentedToVirtual(colHeaderTemp->vtxList); + colHeader->polyList = Lib_SegmentedToVirtual(colHeader->polyList); if (colHeader->surfaceTypeList != NULL) { - colHeader->surfaceTypeList = (SurfaceType*)Lib_SegmentedToVirtual(colHeader->surfaceTypeList); + colHeader->surfaceTypeList = Lib_SegmentedToVirtual(colHeader->surfaceTypeList); } if (colHeader->cameraDataList != NULL) { - colHeader->cameraDataList = (void*)Lib_SegmentedToVirtual(colHeader->cameraDataList); + colHeader->cameraDataList = Lib_SegmentedToVirtual(colHeader->cameraDataList); } if (colHeader->waterBoxes != NULL) { - colHeader->waterBoxes = (WaterBox*)Lib_SegmentedToVirtual(colHeader->waterBoxes); + colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes); } BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); @@ -210,12 +209,12 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x04: Room List void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->numRooms = cmd->roomList.num; - globalCtx->roomList = (RomFile*)Lib_SegmentedToVirtual(cmd->roomList.segment); + globalCtx->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment); } // SceneTableEntry Header Command 0x06: Entrance List void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupEntranceList = (EntranceEntry*)Lib_SegmentedToVirtual(cmd->entranceList.segment); + globalCtx->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment); } // SceneTableEntry Header Command 0x07: Special Files @@ -248,19 +247,21 @@ void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0A: Mesh Header void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.currRoom.mesh = (RoomMesh*)Lib_SegmentedToVirtual(cmd->mesh.segment); + globalCtx->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment); } // SceneTableEntry Header Command 0x0B: Object List void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { - s32 i, j, k; + s32 i; + s32 j; + s32 k; ObjectStatus* firstObject; ObjectStatus* status; ObjectStatus* status2; s16* objectEntry; void* nextPtr; - objectEntry = (s16*)Lib_SegmentedToVirtual(cmd->objectList.segment); + objectEntry = Lib_SegmentedToVirtual(cmd->objectList.segment); k = 0; i = globalCtx->objectCtx.spawnedObjectCount; status = &globalCtx->objectCtx.status[i]; @@ -305,7 +306,7 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0C: Light List void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { s32 i; - LightInfo* lightInfo = (LightInfo*)Lib_SegmentedToVirtual(cmd->lightList.segment); + LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment); for (i = 0; i < cmd->lightList.num; i++) { LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo); @@ -315,14 +316,13 @@ void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x0D: Path List void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupPathList = (Path*)Lib_SegmentedToVirtual(cmd->pathList.segment); + globalCtx->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment); } // SceneTableEntry Header Command 0x0E: Transition Actor List void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->doorCtx.numTransitionActors = cmd->transiActorList.num; - globalCtx->doorCtx.transitionActorList = - (TransitionActorEntry*)Lib_SegmentedToVirtual((void*)cmd->transiActorList.segment); + globalCtx->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment); func_80105818(globalCtx, globalCtx->doorCtx.numTransitionActors, globalCtx->doorCtx.transitionActorList); } @@ -334,7 +334,7 @@ void Door_InitContext(GameState* state, DoorContext* doorCtx) { // SceneTableEntry Header Command 0x0F: Environment Light Settings List void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num; - globalCtx->envCtx.lightSettingsList = (void*)Lib_SegmentedToVirtual(cmd->lightSettingList.segment); + globalCtx->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment); } /** @@ -374,8 +374,8 @@ void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x12: Skybox Disables void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->envCtx.unk_15 = cmd->skyboxDisables.unk4; - globalCtx->envCtx.unk_16 = cmd->skyboxDisables.unk5; + globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4; + globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5; } // SceneTableEntry Header Command 0x10: Time Settings @@ -440,7 +440,7 @@ void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x13: Exit List void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupExitList = (u16*)Lib_SegmentedToVirtual(cmd->exitList.segment); + globalCtx->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment); } // SceneTableEntry Header Command 0x09: Undefined @@ -468,11 +468,11 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { SceneCmd* altHeader; if (gSaveContext.sceneSetupIndex) { - altHeaderList = (SceneCmd**)Lib_SegmentedToVirtual(cmd->altHeaders.segment); + altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment); altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; if (altHeader != NULL) { - Scene_ProcessHeader(globalCtx, (SceneCmd*)Lib_SegmentedToVirtual(altHeader)); + Scene_ProcessHeader(globalCtx, Lib_SegmentedToVirtual(altHeader)); (cmd + 1)->base.code = 0x14; } } @@ -480,14 +480,13 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { // SceneTableEntry Header Command 0x17: Cutscene List void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->csCtx.sceneCsCount = (u8)cmd->base.data1; - globalCtx->csCtx.sceneCsList = (CutsceneEntry*)Lib_SegmentedToVirtual((void*)cmd->base.data2); + globalCtx->csCtx.sceneCsCount = cmd->base.data1; + globalCtx->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2); } // SceneTableEntry Header Command 0x1B: Actor Cutscene List void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) { - ActorCutscene_Init(globalCtx, (ActorCutscene*)Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), - cmd->cutsceneActorList.num); + ActorCutscene_Init(globalCtx, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num); } // SceneTableEntry Header Command 0x1C: Mini Maps diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 57e2930a2..f7f71a2dd 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" s32 sMatAnimStep; @@ -115,7 +114,7 @@ void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* p * Generates a displaylist that sets the prim and env color, and stores it in the provided segment ID. */ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) { - Gfx* colorDList = (Gfx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* colorDList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -142,13 +141,10 @@ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* p */ void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; - F3DPrimColor* primColor; + F3DPrimColor* primColor = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColor; - s32 curFrame; + s32 curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; - primColor = (F3DPrimColor*)Lib_SegmentedToVirtual(colorAnimParams->primColors); - - curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; primColor += curFrame; envColor = (colorAnimParams->envColors != NULL) ? (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors) + curFrame @@ -170,10 +166,10 @@ s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm) { */ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params; - F3DPrimColor* primColorMax; + F3DPrimColor* primColorMax = Lib_SegmentedToVirtual(colorAnimParams->primColors); F3DEnvColor* envColorMax; - u16* keyFrames; - s32 curFrame; + u16* keyFrames = Lib_SegmentedToVirtual(colorAnimParams->keyFrames); + s32 curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; s32 endFrame; s32 relativeFrame; // relative to the start frame s32 startFrame; @@ -184,9 +180,6 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para F3DEnvColor envColorResult; s32 i; - primColorMax = (F3DPrimColor*)Lib_SegmentedToVirtual(colorAnimParams->primColors); - keyFrames = (u16*)Lib_SegmentedToVirtual(colorAnimParams->keyFrames); - curFrame = sMatAnimStep % colorAnimParams->keyFrameLength; keyFrames++; i = 1; @@ -212,7 +205,7 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para primColorResult.lodFrac = AnimatedMat_Lerp(primColorMin->lodFrac, primColorMax->lodFrac, norm); if (colorAnimParams->envColors) { - envColorMax = (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors); + envColorMax = Lib_SegmentedToVirtual(colorAnimParams->envColors); envColorMax += i; envColorMin = envColorMax - 1; envColorResult.r = AnimatedMat_Lerp(envColorMin->r, envColorMax->r, norm); @@ -371,8 +364,8 @@ void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, */ void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* params) { AnimatedMatTexCycleParams* texAnimParams = params; - void** texList = (void**)Lib_SegmentedToVirtual(texAnimParams->textureList); - u8* texId = (u8*)Lib_SegmentedToVirtual(texAnimParams->textureIndexList); + void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList); + u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList); s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength; void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]); @@ -409,9 +402,9 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f do { segment = matAnim->segment; segmentAbs = ((segment < 0) ? -segment : segment) + 7; - matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, (void*)Lib_SegmentedToVirtual(matAnim->params)); + matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, Lib_SegmentedToVirtual(matAnim->params)); matAnim++; - } while (segment > -1); + } while (segment >= 0); } } @@ -727,7 +720,7 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) { BgCheck_UnsetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } - dList = (Gfx*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); + dList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18); AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims); diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 194ee5083..5bfca86d9 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -2,6 +2,7 @@ * File: z_shrink_window.c * 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" ShrinkWindowContext gShrinkWindowContext; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 8ebb2ca67..8ad36c891 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define ANIM_INTERP 1 @@ -8,10 +7,10 @@ s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); -void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animationSeg); +void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation); void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* linkAnimetionEntrySeg, - f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate); +void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, + f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); static AnimationEntryCallback sAnimationLoadDone[] = { @@ -1074,13 +1073,13 @@ void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s /** * Requests moving an actor according to the translation of its root limb */ -void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 actor3) { +void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_MOVEACTOR); if (entry != NULL) { entry->data.move.actor = actor; entry->data.move.skelAnime = skelAnime; - entry->data.move.unk08 = actor3; + entry->data.move.unk08 = arg3; } } @@ -1577,7 +1576,7 @@ void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel /** * Initializes a skeleton with SkinLimbs to a looping animation, dynamically allocating the frame tables. */ -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation) { SkeletonHeader* skeletonHeader; @@ -1829,8 +1828,8 @@ void Animation_PlayOnce(SkelAnime* skelAnime, AnimationHeader* animation) { * animation. Negative morph frames start the new animation immediately, modified by the pose immediately before the * animation change. */ -void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 morphFrames) { - Animation_Change(skelAnime, animationSeg, 1.0f, 0, Animation_GetLastFrame(&animationSeg->common), ANIMMODE_ONCE, +void Animation_MorphToPlayOnce(SkelAnime* skelAnime, AnimationHeader* animation, f32 morphFrames) { + Animation_Change(skelAnime, animation, 1.0f, 0, Animation_GetLastFrame(&animation->common), ANIMMODE_ONCE, morphFrames); } @@ -1862,9 +1861,9 @@ void Animation_MorphToLoop(SkelAnime* skelAnime, AnimationHeader* animation, f32 /** * Immediately changes to an animation that loops at the specified speed. */ -void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playbackSpeed) { - Animation_Change(skelAnime, animation, playbackSpeed, 0.0f, Animation_GetLastFrame(&animation->common), - ANIMMODE_LOOP, 0.0f); +void Animation_PlayLoopSetSpeed(SkelAnime* skelAnime, AnimationHeader* animation, f32 playSpeed) { + Animation_Change(skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common), ANIMMODE_LOOP, + 0.0f); } /** diff --git a/src/code/z_skin.c b/src/code/z_skin.c index f031b007f..808a00da0 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -1,23 +1,273 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137970.s") +// 60 is an arbitrary number which specifies the max amount of limbs per skeleton this system supports +MtxF gSkinLimbMatrices[60]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137B34.s") +static s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137EBC.s") +void Skin_UpdateVertices(MtxF* mtx, SkinVertex* skinVertices, SkinLimbModif* modifEntry, Vtx* vtxBuf, Vec3f* pos) { + SkinVertex* vertexEntry; + Vtx* vtx; + Vec3f wTemp; + Vec3f normal; + Vec3f sp44; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80137F58.s") + wTemp.x = mtx->wx; + wTemp.y = mtx->wy; + wTemp.z = mtx->wz; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138050.s") + mtx->wx = 0.0f; + mtx->wy = 0.0f; + mtx->wz = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138228.s") + for (vertexEntry = skinVertices; vertexEntry < &skinVertices[modifEntry->vtxCount]; vertexEntry++) { + vtx = &vtxBuf[vertexEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138258.s") + vtx->n.ob[0] = pos->x; + vtx->n.ob[1] = pos->y; + vtx->n.ob[2] = pos->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013828C.s") + sp44.x = vertexEntry->normX; + sp44.y = vertexEntry->normY; + sp44.z = vertexEntry->normZ; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_801382C4.s") + SkinMatrix_Vec3fMtxFMultXYZ(mtx, &sp44, &normal); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_80138300.s") + vtx->n.n[0] = normal.x; + vtx->n.n[1] = normal.y; + vtx->n.n[2] = normal.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_8013835C.s") + mtx->wx = wTemp.x; + mtx->wy = wTemp.y; + mtx->wz = wTemp.z; +} + +void Skin_ApplyLimbModifications(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3) { + s32 modifCount; + SkinLimb** skeleton; + s32 pad; + SkinAnimatedLimbData* data; + s32 pad2[5]; + SkinLimbModif* modif; + SkinLimbVtx* vtxEntry; + s32 pad3; + s32 transformCount; + f32 scale; + SkinVertex* skinVertices; + Vec3f sp88; + Vtx* vtxBuf; + SkinTransformation* limbTransformations; + Vec3f spDC; + Vec3f spD0; + SkinTransformation* transformationEntry; + SkinLimb* limb; + SkinLimbModif* modifications; + + OPEN_DISPS(gfxCtx); + + skeleton = (SkinLimb**)Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + limb = (SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]); + data = Lib_SegmentedToVirtual(limb->segment); + modifications = (SkinLimbModif*)Lib_SegmentedToVirtual(data->limbModifications); + + vtxEntry = &skin->vtxTable[limbIndex]; + + vtxBuf = vtxEntry->buf[vtxEntry->index]; + modifCount = data->limbModifCount; + + for (modif = modifications; modif < &modifications[modifCount]; modif++) { + Vec3f spAC; + Vec3f spA0; + + skinVertices = (SkinVertex*)Lib_SegmentedToVirtual(modif->skinVertices); + limbTransformations = (SkinTransformation*)Lib_SegmentedToVirtual(modif->limbTransformations); + transformCount = modif->transformCount; + + if (transformCount == 1) { + spAC.x = limbTransformations[0].x; + spAC.y = limbTransformations[0].y; + spAC.z = limbTransformations[0].z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[limbTransformations[0].limbIndex], &spAC, &spDC); + } else if (arg3) { + transformationEntry = &limbTransformations[modif->unk_04]; + + spA0.x = transformationEntry->x; + spA0.y = transformationEntry->y; + spA0.z = transformationEntry->z; + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &spA0, &spDC); + } else { + spDC.x = 0.0f; + spDC.y = 0.0f; + spDC.z = 0.0f; + + for (transformationEntry = limbTransformations; transformationEntry < &limbTransformations[transformCount]; + transformationEntry++) { + scale = transformationEntry->scale * 0.01f; + + sp88.x = transformationEntry->x; + sp88.y = transformationEntry->y; + sp88.z = transformationEntry->z; + + SkinMatrix_Vec3fMtxFMultXYZ(&gSkinLimbMatrices[transformationEntry->limbIndex], &sp88, &spD0); + + spDC.x += spD0.x * scale; + spDC.y += spD0.y * scale; + spDC.z += spD0.z * scale; + } + } + + Skin_UpdateVertices(&gSkinLimbMatrices[limbTransformations[modif->unk_04].limbIndex], skinVertices, modif, + vtxBuf, &spDC); + } + + gSPSegment(POLY_OPA_DISP++, 0x08, vtxEntry->buf[vtxEntry->index]); + + vtxEntry->index = (vtxEntry->index == 0); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_ANIMATED, of the skeleton `skin` at index `limbIndex` + * The vertices of this limb are modified dynamically + */ +void Skin_DrawAnimatedLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, s32 arg3, s32 drawFlags) { + SkinLimb** skeleton; + s32 pad[3]; + SkinAnimatedLimbData* data; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + data = Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyLimbModifications(gfxCtx, skin, limbIndex, arg3); + } + + gSPDisplayList(POLY_OPA_DISP++, data->dlist); + + CLOSE_DISPS(gfxCtx); +} + +/** + * Draw a limb of type SKIN_LIMB_TYPE_NORMAL, of the skeleton `skin` at index `limbIndex` + */ +void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dListOverride, s32 drawFlags) { + Gfx* gfx = dListOverride; + SkinLimb** skeleton; + + OPEN_DISPS(gfxCtx); + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (dListOverride == NULL) { + gfx = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment; + } + + if (gfx != NULL) { + Mtx* mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &gSkinLimbMatrices[limbIndex]); + + if (mtx != NULL) { + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gfx); + gSPPopMatrix(POLY_OPA_DISP++, G_MTX_MODELVIEW); + gDPPipeSync(POLY_OPA_DISP++); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + s32 i; + SkinLimb** skeleton; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_TRANSFORMS)) { + Skin_ApplyAnimTransformations(skin, gSkinLimbMatrices, actor, setTranslation); + } + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + + if (!(drawFlags & SKIN_DRAW_FLAG_CUSTOM_MATRIX)) { + Mtx* mtx; + + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &skin->mtx); + if (mtx == NULL) { + goto close_disps; + } + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + for (i = 0; i < skin->skeletonHeader->limbCount; i++) { + s32 shouldDraw = true; + s32 segmentType; + + if (overrideLimbDraw != NULL) { + shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin); + } + + segmentType = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType; + + if (segmentType == SKIN_LIMB_TYPE_ANIMATED && shouldDraw) { + Skin_DrawAnimatedLimb(gfxCtx, skin, i, arg6, drawFlags); + } else if (segmentType == SKIN_LIMB_TYPE_NORMAL && shouldDraw) { + Skin_DrawLimb(gfxCtx, skin, i, NULL, drawFlags); + } + } + + if (postDraw != NULL) { + postDraw(actor, globalCtx, skin); + } + +close_disps:; + CLOSE_DISPS(gfxCtx); +} + +// allows specifying postDraw and setTranslation +void func_80138228(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, NULL, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw and setTranslation +void func_80138258(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); +} + +// allows specifying OverrideLimbDraw, postDraw, setTranslation, and arg6 +void func_8013828C(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); +} + +// allows specifying all variables +void func_801382C4(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, + SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { + Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); +} + +void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst) { + MtxF mtxf; + + SkinMatrix_MtxFMtxFMult(&skin->mtx, &gSkinLimbMatrices[limbIndex], &mtxf); + SkinMatrix_Vec3fMtxFMultXYZ(&mtxf, offset, dst); +} + +void Skin_GetVertexPos(Skin* skin, s32 limbIndex, s32 vtxIndex, Vec3f* dst) { + Vec3f pos; + Vtx* vtx = &skin->vtxTable[limbIndex].buf[skin->vtxTable[0].index][vtxIndex]; + + pos.x = vtx->n.ob[0]; + pos.y = vtx->n.ob[1]; + pos.z = vtx->n.ob[2]; + SkinMatrix_Vec3fMtxFMultXYZ(&skin->mtx, &pos, dst); +} diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index 22a1c637f..d45b9bc25 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.c @@ -1,13 +1,204 @@ #include "global.h" +#include "z64skin.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138410.s") +void Skin_Setup(Skin* skin) { + skin->skeletonHeader = NULL; + skin->limbCount = 0; + skin->vtxTable = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138424.s") +/** + * Initialises the Vtx buffers used for limb at index `limbIndex` + */ +void Skin_InitAnimatedLimb(GameState* gameState, Skin* skin, s32 limbIndex) { + s32 i; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual(((SkinLimb*)Lib_SegmentedToVirtual(skeleton[limbIndex]))->segment); + SkinLimbModif* limbModifications = Lib_SegmentedToVirtual(animatedLimbData->limbModifications); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_8013859C.s") + for (i = 0; i < ARRAY_COUNT(skin->vtxTable->buf); i++) { + Vtx* vertices = skin->vtxTable[limbIndex].buf[i]; + SkinLimbModif* modifEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_80138700.s") + for (modifEntry = limbModifications; modifEntry < &limbModifications[animatedLimbData->limbModifCount]; + modifEntry++) { + SkinVertex* skinVertices = Lib_SegmentedToVirtual(modifEntry->skinVertices); + SkinVertex* skinVtxEntry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801387D4.s") + for (skinVtxEntry = skinVertices; skinVtxEntry < &skinVertices[modifEntry->vtxCount];) { + Vtx* vtx = &vertices[skinVtxEntry->index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_801388E4.s") + skinVtxEntry++; + + vtx->n.flag = 0; + vtx->n.tc[0] = skinVtxEntry[-1].s; + vtx->n.tc[1] = skinVtxEntry[-1].t; + vtx->n.a = skinVtxEntry[-1].alpha; + } + } + } +} + +/** + * Initializes a skin skeleton to looping animation, dynamically allocating the frame tables, + * and dynamically allocating and initialising the Vtx and SkinLimbVtx buffers for its animated limbs + */ +void Skin_Init(GameState* gameState, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader) { + s32 limbCount; + s32 i; + SkinLimb** skeleton; + SkeletonHeader* virtSkelHeader = Lib_SegmentedToVirtual(skeletonHeader); + + skin->limbCount = virtSkelHeader->limbCount; + skin->skeletonHeader = virtSkelHeader; + limbCount = skin->skeletonHeader->limbCount; + + skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + skin->vtxTable = ZeldaArena_Malloc(limbCount * sizeof(SkinLimbVtx)); + + for (i = 0; i < limbCount; i++) { + SkinLimbVtx* vtxEntry = &skin->vtxTable[i]; + + if ((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType != SKIN_LIMB_TYPE_ANIMATED) || + (((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment == NULL)) { + vtxEntry->index = 0; + + vtxEntry->buf[0] = NULL; + vtxEntry->buf[1] = NULL; + } else { + SkinAnimatedLimbData* animatedLimbData = + Lib_SegmentedToVirtual((((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segment)); + + { s32 tmp; } + + vtxEntry->index = 0; + vtxEntry->buf[0] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + vtxEntry->buf[1] = ZeldaArena_Malloc(animatedLimbData->totalVtxCount * sizeof(Vtx)); + + Skin_InitAnimatedLimb(gameState, skin, i); + } + } + + SkelAnime_InitSkin(gameState, &skin->skelAnime, skeletonHeader, animationHeader); +} + +/** + * Frees the dynamically allocated Vtx and SkinLimbVtx buffers and tables + */ +void Skin_Free(GameState* gameState, Skin* skin) { + if (skin->vtxTable != NULL) { + s32 i; + + for (i = 0; i < skin->limbCount; i++) { + if (skin->vtxTable[i].buf[0] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[0]); + skin->vtxTable[i].buf[0] = NULL; + } + if (skin->vtxTable[i].buf[1] != NULL) { + ZeldaArena_Free(skin->vtxTable[i].buf[1]); + skin->vtxTable[i].buf[1] = NULL; + } + } + + if (skin->vtxTable != NULL) { + ZeldaArena_Free(skin->vtxTable); + } + + SkelAnime_Free(&skin->skelAnime, (GlobalContext*)gameState); + } +} + +s32 func_801387D4(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parentIndex, u8 limbIndex) { + s32 pad; + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[limbIndex]); + MtxF* mtx; + s32 ret; + MtxF sp28; + + if (parentIndex == LIMB_DONE) { + SkinMatrix_GetClear(&mtx); + } else { + mtx = &limbMatrices[(s32)parentIndex]; + } + + SkinMatrix_MtxFMtxFMult(mtx, &limbMatrices[limbIndex], &sp28); + SkinMatrix_MtxFCopy(&sp28, &limbMatrices[limbIndex]); + + if (limb->child != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, limbIndex, limb->child); + if (ret) { + return ret; + } + } + + if (limb->sibling != LIMB_DONE) { + ret = func_801387D4(skin, skeleton, limbMatrices, parentIndex, limb->sibling); + if (ret) { + return ret; + } + } + + return false; +} + +/** + * Recursively applies matrix tranformations to each limb + */ +s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation) { + s32 i; + s32 pad; + f32 yRot; + f32 xRot; + f32 zRot; + s32 ret; + f32 yTransl; + f32 xTransl; + f32 zTransl; + SkinLimb** skeleton = Lib_SegmentedToVirtual(skin->skeletonHeader->segment); + Vec3s* jointRot = skin->skelAnime.jointTable; + + jointRot++; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + + if (setTranslation) { + jointRot--; + xTransl = jointRot->x; + yTransl = jointRot->y; + zTransl = jointRot->z; + jointRot++; + + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, xTransl, yTransl, zTransl); + } else { + SkinMatrix_SetRotateRPYTranslate(limbMatrices, xRot, yRot, zRot, 0.0f, 0.0f, 0.0f); + } + + jointRot++; + + for (i = 1; i < skin->skeletonHeader->limbCount; i++) { + SkinLimb* limb = Lib_SegmentedToVirtual(skeleton[i]); + + xTransl = limb->jointPos.x; + yTransl = limb->jointPos.y; + zTransl = limb->jointPos.z; + xRot = jointRot->x; + yRot = jointRot->y; + zRot = jointRot->z; + jointRot++; + SkinMatrix_SetRotateRPYTranslate(&limbMatrices[i], xRot, yRot, zRot, xTransl, yTransl, zTransl); + } + + SkinMatrix_SetScaleRotateYRPTranslate( + &skin->mtx, actor->scale.x, actor->scale.y, actor->scale.z, actor->shape.rot.x, actor->shape.rot.y, + actor->shape.rot.z, actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), + actor->world.pos.z); + + ret = func_801387D4(skin, Lib_SegmentedToVirtual(skin->skeletonHeader->segment), limbMatrices, LIMB_DONE, 0); + if (!ret) { + return ret; + } + + return false; +} diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 4eb327921..f85f33f0a 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -114,21 +114,19 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, s16 y; f32 distance; CollisionPoly* poly; - Camera* camera; + Camera* camera = GET_ACTIVE_CAM(globalCtx); Actor* actors[2]; s32 ret = 0; s32 bgId; - camera = GET_ACTIVE_CAM(globalCtx); - distance = OLib_Vec3fDist(pos, &camera->eye); if ((distance < distanceMin) || (distanceMax < distance)) { func_8013A41C(0x3F); ret = 0x3F; } - x = func_8013A504(func_800DFCB4(camera) + rot->x); - y = func_8013A504(func_800DFCDC(camera) - (s16)(rot->y - 0x7FFF)); + x = func_8013A504(Camera_GetCamDirPitch(camera) + rot->x); + y = func_8013A504(Camera_GetCamDirYaw(camera) - BINANG_SUB(rot->y, 0x7FFF)); if ((0 < angleError) && ((angleError < x) || (angleError < y))) { func_8013A41C(0x3E); ret |= 0x3E; @@ -137,7 +135,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance); x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85; y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67; - if ((x < 0) || (0x96 < x) || (y < 0) || (0x69 < y)) { + if ((x < 0) || (150 < x) || (y < 0) || (105 < y)) { func_8013A41C(0x3D); ret |= 0x3D; } diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c index 5b5b2f5f0..05dcd9811 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -1,67 +1,1676 @@ #include "global.h" +#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A10.s") +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages); +void func_80147314(SramContext* sramCtx, s32 fileNum); +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143A54.s") +#define CHECK_NEWF(newf) \ + ((newf)[0] != 'Z' || (newf)[1] != 'E' || (newf)[2] != 'L' || (newf)[3] != 'D' || (newf)[4] != 'A' || \ + (newf)[5] != '3') -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143AC4.s") +// default scene flags (?) +// indices of subarray: +// - 0: switch0 +// - 1: switch1 +// - 2: chest +// - 3: collectible +u32 D_801C5FC0[SCENE_MAX][4] = { + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI2 + { 0, 0, 0, 0 }, // SCENE_UNSET_1 + { 0, 0, 0, 0 }, // SCENE_UNSET_2 + { 0, 0, 0, 0 }, // SCENE_UNSET_3 + { 0, 0, 0, 0 }, // SCENE_UNSET_4 + { 0, 0, 0, 0 }, // SCENE_UNSET_5 + { 0, 0, 0, 0 }, // SCENE_UNSET_6 + { 0, 0, 0, 0xC04 }, // SCENE_KAKUSIANA + { 0, 0, 0, 0 }, // SCENE_SPOT00 + { 0, 0, 0, 0 }, // SCENE_UNSET_9 + { 0, 0, 0, 0 }, // SCENE_WITCH_SHOP + { 0, 0, 0, 0x80000000 }, // SCENE_LAST_BS + { 0, 0, 0, 0x80000000 }, // SCENE_HAKASHITA + { 0, 0, 0, 0 }, // SCENE_AYASHIISHOP + { 0, 0, 0, 0 }, // SCENE_UNSET_E + { 0, 0, 0, 0 }, // SCENE_UNSET_F + { 0, 0, 0, 0 }, // SCENE_OMOYA + { 0, 0, 0, 0 }, // SCENE_BOWLING + { 0, 0, 0, 0 }, // SCENE_SONCHONOIE + { 0x100000, 0, 0, 0x40000002 }, // SCENE_IKANA + { 0, 0, 0, 0 }, // SCENE_KAIZOKU + { 0, 0, 0, 0 }, // SCENE_MILK_BAR + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_N + { 2, 0, 0, 0 }, // SCENE_TAKARAYA + { 0x4000000, 0, 0, 0 }, // SCENE_INISIE_R + { 0, 0, 0, 0 }, // SCENE_OKUJOU + { 0xF, 0, 0, 0 }, // SCENE_OPENINGDAN + { 0x70B000, 0, 0, 0 }, // SCENE_MITURIN + { 0, 0, 0, 0 }, // SCENE_13HUBUKINOMITI + { 0, 0x80000000, 0, 0x400 }, // SCENE_CASTLE + { 0, 0, 0, 0 }, // SCENE_DEKUTES + { 0, 0, 0, 0x80000000 }, // SCENE_MITURIN_BS + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MIZU + { 0x1A00020, 0, 0, 0 }, // SCENE_HAKUGIN + { 0x400, 0, 0, 0 }, // SCENE_ROMANYMAE + { 0, 0, 0, 0x1000 }, // SCENE_PIRATE + { 0, 0, 0, 0 }, // SCENE_SYATEKI_MORI + { 0, 0, 0, 2 }, // SCENE_SINKAI + { 0x400, 0, 0, 0 }, // SCENE_YOUSEI_IZUMI + { 0, 0, 0, 0 }, // SCENE_KINSTA1 + { 0, 0, 0, 0x80000000 }, // SCENE_KINDAN2 + { 0, 0, 0, 0 }, // SCENE_TENMON_DAI + { 0, 0, 0, 2 }, // SCENE_LAST_DEKU + { 0, 0, 0, 0x40000000 }, // SCENE_22DEKUCITY + { 0, 0, 0, 0 }, // SCENE_KAJIYA + { 0x10, 0, 0, 0 }, // SCENE_00KEIKOKU + { 3, 0, 0, 0 }, // SCENE_POSTHOUSE + { 0, 0, 0, 0 }, // SCENE_LABO + { 0, 0, 0, 0x80000000 }, // SCENE_DANPEI2TEST + { 0, 0, 0, 0 }, // SCENE_UNSET_31 + { 0, 0, 0, 0 }, // SCENE_16GORON_HOUSE + { 0, 0, 0, 0 }, // SCENE_33ZORACITY + { 0, 0, 0, 0 }, // SCENE_8ITEMSHOP + { 0, 0, 0, 0 }, // SCENE_F01 + { 0, 0, 0, 0x80000000 }, // SCENE_INISIE_BS + { 0x100400, 0, 0, 0x22 }, // SCENE_30GYOSON + { 0x400, 0, 0, 0x80 }, // SCENE_31MISAKI + { 0, 0, 0, 0 }, // SCENE_TAKARAKUJI + { 0, 0, 0, 0 }, // SCENE_UNSET_3A + { 0x400, 0, 0, 0 }, // SCENE_TORIDE + { 0, 0, 0, 0 }, // SCENE_FISHERMAN + { 0, 0, 0, 0 }, // SCENE_GORONSHOP + { 0, 0, 0, 0 }, // SCENE_DEKU_KING + { 0, 0, 0, 2 }, // SCENE_LAST_GORON + { 0, 0, 0, 0x80000002 }, // SCENE_24KEMONOMITI + { 0, 0, 0, 0 }, // SCENE_F01_B + { 0, 0, 0, 0 }, // SCENE_F01C + { 0, 0, 0, 0 }, // SCENE_BOTI + { 0, 0, 0, 0x80000000 }, // SCENE_HAKUGIN_BS + { 0xC00, 0, 0, 0x40000000 }, // SCENE_20SICHITAI + { 0x102, 0, 0, 0x400 }, // SCENE_21MITURINMAE + { 0, 0, 0, 2 }, // SCENE_LAST_ZORA + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO2 + { 0x70, 0, 0, 0 }, // SCENE_SEA + { 0, 0, 0, 0 }, // SCENE_35TAKI + { 0, 0, 0, 0 }, // SCENE_REDEAD + { 0, 0, 0, 0x40000000 }, // SCENE_BANDROOM + { 0, 0, 0, 0x40000000 }, // SCENE_11GORONNOSATO + { 0, 0, 0, 0 }, // SCENE_GORON_HAKA + { 0, 0, 0, 0 }, // SCENE_SECOM + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA + { 0, 0, 0, 0 }, // SCENE_TOUGITES + { 0, 0, 0, 0 }, // SCENE_DANPEI + { 0, 0, 0, 0 }, // SCENE_IKANAMAE + { 0, 0, 0, 0 }, // SCENE_DOUJOU + { 0, 0, 0, 0 }, // SCENE_MUSICHOUSE + { 0, 0, 0, 0 }, // SCENE_IKNINSIDE + { 0, 0, 0, 0 }, // SCENE_MAP_SHOP + { 0x400, 0, 0, 0 }, // SCENE_F40 + { 0x400, 0, 0, 0 }, // SCENE_F41 + { 0x100000, 0, 0, 0x80000000 }, // SCENE_10YUKIYAMANOMURA2 + { 0, 0, 0, 0x100 }, // SCENE_14YUKIDAMANOMITI + { 0x400, 0, 0, 0 }, // SCENE_12HAKUGINMAE + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN + { 0, 0, 0, 0x80 }, // SCENE_17SETUGEN2 + { 0, 0, 0, 0x80000000 }, // SCENE_SEA_BS + { 0, 0, 0, 0x400 }, // SCENE_RANDOM + { 0, 0, 0, 0 }, // SCENE_YADOYA + { 0, 0, 0, 0 }, // SCENE_KONPEKI_ENT + { 1, 0, 0, 0 }, // SCENE_INSIDETOWER + { 0, 0, 0, 0 }, // SCENE_26SARUNOMORI + { 0, 0, 0, 0 }, // SCENE_LOST_WOODS + { 0, 0, 0, 2 }, // SCENE_LAST_LINK + { 0, 0, 0, 0 }, // SCENE_SOUGEN + { 0, 0, 0, 0 }, // SCENE_BOMYA + { 0, 0, 0, 0 }, // SCENE_KYOJINNOMA + { 0, 0, 0, 0 }, // SCENE_KOEPONARACE + { 0, 0, 0, 0 }, // SCENE_GORONRACE + { 1, 0, 0, 0 }, // SCENE_TOWN + { 0, 0, 0, 0 }, // SCENE_ICHIBA + { 0, 0, 0, 0x400 }, // SCENE_BACKTOWN + { 0x100000, 0, 0, 0x400 }, // SCENE_CLOCKTOWER + { 0, 0, 1, 0 }, // SCENE_ALLEY +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80143B0C.s") +// Related to weekEventReg +u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.weekEventReg)] = { + 0xFFFC, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0, 0xC000, 0xC00, 0, 0xC0, 0, 0x300, + 0x3000, 0xC000, 0xC00, 0, 0, 0, 0, 0, 0, 0xC00C, 0xC00C, 0xC008, 3, + 0x3000, 0, 0, 0, 0xFF00, 0xC3F, 0x3F, 0, 0, 0xCFFF, 0, 0, 0xC00, + 0xC00, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0x20, + 0, 0x300C, 0x3000, 0, 0xC, 0xC0, 0, 0xFF0, 0x300, 0, 0, 0xC00, 0, + 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC0, 0, 0xC000, 0, 3, + 0, 0xC000, 0, 0xC0, 0x300, 0, 0, 0, 0xC000, 0xFFF0, 0, 0, 0x300, + 0, 0xC000, 0xF0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s") +// used in other files +s32 D_801C6798[] = { + 0x00000020, 0x00001470, 0x000028C0, 0x00003D10, 0x00005160, 0x000065B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s") +u8 D_801C67B0[24] = { + ITEM_NONE, ITEM_BOW, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_BOMB, ITEM_BOMBCHU, + ITEM_STICK, ITEM_NUT, ITEM_BEAN, ITEM_NONE, ITEM_POWDER_KEG, ITEM_PICTO_BOX, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144628.s") +s32 D_801C67C8[] = { 0, 0x40, 0x80, 0xC0, 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_GenerateRandomSaveFields.s") +s32 D_801C67E8[] = { 0x300, 0x380 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144890.s") +s32 D_801C67F0[] = { 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_InitDebugSave.s") +s32 D_801C6810[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144A94.s") +s32 D_801C6818[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80144E78.s") +s32 D_801C6838[] = { 1, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_8014546C.s") +s32 D_801C6840[] = { 0x100, 0x180, 0x200, 0x280 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80145698.s") +s32 D_801C6850[] = { 0x80, 0x80, 0x80, 0x80, 0x300, 0x380, 1, 1 }; +s32 D_801C6870[] = { + sizeof(Save), + sizeof(Save), + sizeof(Save), + sizeof(Save), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), + offsetof(SaveContext, fileNum), +}; + +u8 D_801C6890[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 }; + +u16 D_801F6AF0; +u8 D_801F6AF2; + +void Sram_ActivateOwl(u8 owlId) { + gSaveContext.save.playerData.owlActivationFlags = + ((void)0, gSaveContext.save.playerData.owlActivationFlags) | (u16)gBitFlags[owlId]; + + if (gSaveContext.save.playerData.unk_20 == 0xFF) { + gSaveContext.save.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 = 6000; // 60 seconds + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | 0x27; + gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF) | 0xA0000; + + gSaveContext.save.dekuPlaygroundHighScores[0] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[1] = 7500; // 75 seconds + gSaveContext.save.dekuPlaygroundHighScores[2] = 7600; // 76 seconds +} + +/** + * Clears specific weekEventReg flags. Used by the "Dawn of the First Day" message + */ +void Sram_ClearFlagsAtDawnOfTheFirstDay(void) { + // Unconfirmed: "Link the Goron Claims His Reservation: 4:30 PM" + gSaveContext.save.weekEventReg[55] &= (u8)~2; + // Unconfirmed: "Postman fleeing town" + gSaveContext.save.weekEventReg[90] &= (u8)~1; + // Unconfirmed: "Postman is about to flee" + gSaveContext.save.weekEventReg[89] &= (u8)~0x40; + // Unconfirmed: "Postman has delivered priority mail" + gSaveContext.save.weekEventReg[89] &= (u8)~8; + // Unconfirmed: "Postman showing priority mail to Madame" + gSaveContext.save.weekEventReg[85] &= (u8)~0x80; +} + +/** + * Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene + */ +void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { + s16 sceneNum; + s32 j; + s32 i; + u8 temp; + u8 temp2; + + gSaveContext.save.daySpeed = 0; + gSaveContext.save.daysElapsed = 0; + 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; + } + + sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum); + Play_SaveCycleSceneFlags(&globalCtx->state); + + globalCtx->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2]; + globalCtx->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0]; + globalCtx->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1]; + globalCtx->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3]; + globalCtx->actorCtx.flags.clearedRoom = 0; + + for (i = 0; i < SCENE_MAX; i++) { + gSaveContext.cycleSceneFlags[i].switch0 = ((void)0, gSaveContext.cycleSceneFlags[i].switch0) & D_801C5FC0[i][0]; + gSaveContext.cycleSceneFlags[i].switch1 = ((void)0, gSaveContext.cycleSceneFlags[i].switch1) & D_801C5FC0[i][1]; + gSaveContext.cycleSceneFlags[i].chest = ((void)0, gSaveContext.cycleSceneFlags[i].chest) & D_801C5FC0[i][2]; + 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].unk_18 = 0; + } + + for (; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { + gSaveContext.cycleSceneFlags[i].chest = 0; + gSaveContext.cycleSceneFlags[i].switch0 = 0; + gSaveContext.cycleSceneFlags[i].switch1 = 0; + gSaveContext.cycleSceneFlags[i].clearedRoom = 0; + gSaveContext.cycleSceneFlags[i].collectible = 0; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.maskMaskBit); i++) { + gSaveContext.maskMaskBit[i] = 0; + } + + if (gSaveContext.save.weekEventReg[84] & 0x20) { + Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + } + + for (i = 0; i < ARRAY_COUNT(D_801C66D0); i++) { + u16 phi_v1_3 = D_801C66D0[i]; + + 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]); + } + phi_v1_3 >>= 2; + } + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) { + gSaveContext.eventInf[i] = 0; + } + + gSaveContext.eventInf[7] &= (u8)~1; + gSaveContext.eventInf[7] &= (u8)~2; + gSaveContext.eventInf[7] &= (u8)~4; + gSaveContext.eventInf[7] &= (u8)~8; + gSaveContext.eventInf[7] &= (u8)~0x10; + + if (gSaveContext.save.playerData.rupees != 0) { + gSaveContext.eventInf[7] |= 1; + } + + if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { + temp2 = INV_CONTENT(ITEM_BOMB); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 2; + } + } + if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { + temp2 = INV_CONTENT(ITEM_NUT); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 4; + } + } + if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { + temp2 = INV_CONTENT(ITEM_STICK); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 8; + } + } + if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { + temp2 = INV_CONTENT(ITEM_BOW); + if (AMMO(temp2) != 0) { + gSaveContext.eventInf[7] |= 0x10; + } + } + + for (i = 0; i < ARRAY_COUNT(D_801C67B0); i++) { + if (D_801C67B0[i] != ITEM_NONE) { + if ((gSaveContext.save.inventory.items[i] != ITEM_NONE) && (i != SLOT_PICTO_BOX)) { + temp2 = gSaveContext.save.inventory.items[i]; + AMMO(temp2) = 0; + } + } + } + + 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) { + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE); + Interface_LoadItemIconImpl(globalCtx, j); + } + } + gSaveContext.save.inventory.items[i] = ITEM_BOTTLE; + } + } + } + + REMOVE_QUEST_ITEM(QUEST_UNK_19); + + if (gSaveContext.save.playerData.health < 0x30) { + gSaveContext.save.playerData.health = 0x30; + } + + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) < 3) { + SET_EQUIP_VALUE(EQUIP_SWORD, 1); + + if (CUR_FORM == 0) { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } else { + if ((STOLEN_ITEM_1 >= ITEM_SWORD_GILDED) || (STOLEN_ITEM_2 >= ITEM_SWORD_GILDED)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_SWORD, 3); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + } + } + } + + if ((STOLEN_ITEM_1 == ITEM_SWORD_GREAT_FAIRY) || (STOLEN_ITEM_2 == ITEM_SWORD_GREAT_FAIRY)) { + INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) = ITEM_SWORD_GREAT_FAIRY; + } + + if (STOLEN_ITEM_1 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + if (STOLEN_ITEM_2 == ITEM_BOTTLE) { + temp = SLOT(ITEM_BOTTLE); + for (i = 0; i < 6; i++) { + if (gSaveContext.save.inventory.items[temp + i] == ITEM_NONE) { + gSaveContext.save.inventory.items[temp + i] = ITEM_BOTTLE; + break; + } + } + } + + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); + + Inventory_DeleteItem(ITEM_OCARINA_FAIRY, SLOT_TRADE_DEED); + Inventory_DeleteItem(ITEM_SLINGSHOT, SLOT_TRADE_KEY_MAMA); + Inventory_DeleteItem(ITEM_LONGSHOT, SLOT_TRADE_COUPLE); + + for (j = 1; j < 4; j++) { + if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) { + SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE); + Interface_LoadItemIconImpl(globalCtx, j); + } + } + + gSaveContext.save.skullTokenCount &= ~0xFFFF0000; + gSaveContext.save.skullTokenCount &= ~0x0000FFFF; + gSaveContext.save.unk_EC4 = 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; + + Sram_ClearHighscores(); + + for (i = 0; i < 8; i++) { + gSaveContext.save.inventory.dungeonItems[i] &= (u8)~1; + gSaveContext.save.inventory.dungeonKeys[i] = 0; + gSaveContext.save.inventory.strayFairies[i] = 0; + } + + gSaveContext.save.playerData.rupees = 0; + gSaveContext.save.unk_F65 = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; + gSaveContext.rupeeAccumulator = 0; + + func_800F3B2C(globalCtx); +} + +void Sram_IncrementDay(void) { + if (CURRENT_DAY <= 3) { + gSaveContext.save.day++; + 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; + + // Unconfirmed: "Bombers Hide & Seek started on Day 1???" + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + // Unconfirmed: "Bombers Hide & Seek in Progress" + gSaveContext.save.weekEventReg[85] &= (u8)~2; +} + +u16 Sram_CalcChecksum(void* data, size_t count) { + u8* dataPtr = data; + u16 chkSum = 0; + + while (count-- > 0) { + chkSum += *dataPtr; + dataPtr++; + } + return chkSum; +} + +// Resets `Save` substruct +void Sram_ResetSave(void) { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.equippedMask = 0; + gSaveContext.save.isFirstCycle = false; + gSaveContext.save.unk_06 = 0; + gSaveContext.save.linkAge = 0; + gSaveContext.save.isNight = false; + gSaveContext.save.daySpeed = 0; + gSaveContext.save.snowheadCleared = 0; + 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)); +} + +/** + * Initializes with random values the following fields: + * - lotteryCodes + * - spiderHouseMaskOrder + * - bomberCode + */ +void Sram_GenerateRandomSaveFields(void) { + s32 randBombers; + s16 sp2A; + s16 pad; + s16 i; + s16 j; + s32 k; + s16 randSpiderHouse; + + 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); + + // Needed to match... + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) {} + } + + i = 0; + sp2A = Rand_S16Offset(0, 16) & 3; + k = 6; + while (i != k) { + randSpiderHouse = Rand_S16Offset(0, 16) & 3; + if (sp2A != randSpiderHouse) { + gSaveContext.save.spiderHouseMaskOrder[i] = randSpiderHouse; + i++; + sp2A = randSpiderHouse; + } + } + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + gSaveContext.save.bomberCode[0] = randBombers; + + i = 1; + while (i != 5) { + k = false; + + do { + randBombers = Rand_S16Offset(0, 6); + } while (randBombers <= 0 || randBombers >= 6); + + sp2A = 0; + do { + if (randBombers == gSaveContext.save.bomberCode[sp2A]) { + k = true; + } + sp2A++; + } while (sp2A < i); + + if (k == false) { + gSaveContext.save.bomberCode[i] = randBombers; + i++; + } + } +} + +SavePlayerData sSaveDefaultPlayerData = { + { '\0', '\0', '\0', '\0', '\0', '\0' }, // newf + 0, // deaths + { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName " " + 0x30, // healthCapacity + 0x30, // health + 0, // magicLevel + 0x30, // magic + 0, // rupees + 0, // swordHealth + 0, // tatlTimer + 0, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0x0000, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDefaultItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_SWORD_KOKIRI, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + { ITEM_UNK_FD, ITEM_NONE, ITEM_NONE, ITEM_NONE }, + }, + { + { SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + { SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE }, + }, + 0x11, +}; + +Inventory sSaveDefaultInventory = { + // items + { + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + }, + // ammo + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // upgrades + 0x120000, + // questItems + 0, + // dungeonItems + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dungeonKeys + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDefaultChecksum = 0; + +/** + * Initialize new save. + * This save has an empty inventory with 3 hearts, sword and shield. + */ +void Sram_InitNewSave(void) { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = 0; + 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)); + + gSaveContext.save.horseData.scene = 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.nextCutsceneIndex = 0; + gSaveContext.save.playerData.magicLevel = 0; + Sram_GenerateRandomSaveFields(); +} + +SavePlayerData sSaveDebugPlayerData = { + { 'Z', 'E', 'L', 'D', 'A', '3' }, // newf + 0x0000, // deaths + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, // playerName "LINK " + 0x80, // healthCapacity + 0x80, // health + 0, // magicLevel + 0x30, // magic + 0x32, // rupees + 0x64, // swordHealth + 0, // tatlTimer + 1, // magicAcquired + 0, // doubleMagic + 0, // doubleDefense + 0, // unk_1F + 0xFF, // unk_20 + 0, // owlActivationFlags + 0xFF, // unk_24 + SCENE_SPOT00, // savedSceneNum +}; + +ItemEquips sSaveDebugItemEquips = { + { + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_POTION_RED, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_GORON, ITEM_OCARINA }, + { ITEM_SWORD_KOKIRI, ITEM_BOW, ITEM_MASK_ZORA, ITEM_OCARINA }, + { ITEM_NUT, ITEM_NUT, ITEM_MASK_DEKU, ITEM_OCARINA }, + }, + { + { SLOT_OCARINA, SLOT_BOW, SLOT_BOTTLE_2, SLOT_OCARINA }, + { SLOT_OCARINA, SLOT_MAGIC_BEANS, SLOT_MASK_GORON, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_POWDER_KEG, SLOT_MASK_ZORA, SLOT_BOMBCHU }, + { SLOT_OCARINA, SLOT_BOW, SLOT_MASK_DEKU, SLOT_BOMBCHU }, + }, + 0x11, +}; + +Inventory sSaveDebugInventory = { + // items + { + ITEM_OCARINA, + ITEM_BOW, + ITEM_ARROW_FIRE, + ITEM_ARROW_ICE, + ITEM_ARROW_LIGHT, + ITEM_MOON_TEAR, + ITEM_BOMB, + ITEM_BOMBCHU, + ITEM_STICK, + ITEM_NUT, + ITEM_BEAN, + ITEM_ROOM_KEY, + ITEM_POWDER_KEG, + ITEM_PICTO_BOX, + ITEM_LENS, + ITEM_HOOKSHOT, + ITEM_SWORD_GREAT_FAIRY, + ITEM_LETTER_TO_KAFEI, + ITEM_BOTTLE, + ITEM_POTION_RED, + ITEM_POTION_GREEN, + ITEM_POTION_BLUE, + ITEM_NONE, + ITEM_NONE, + ITEM_MASK_POSTMAN, + ITEM_MASK_ALL_NIGHT, + ITEM_MASK_BLAST, + ITEM_MASK_STONE, + ITEM_MASK_GREAT_FAIRY, + ITEM_MASK_DEKU, + ITEM_MASK_KEATON, + ITEM_MASK_BREMEN, + ITEM_MASK_BUNNY, + ITEM_MASK_DON_GERO, + ITEM_MASK_SCENTS, + ITEM_MASK_GORON, + ITEM_MASK_ROMANI, + ITEM_MASK_CIRCUS_LEADER, + ITEM_MASK_KAFEIS_MASK, + ITEM_MASK_COUPLE, + ITEM_MASK_TRUTH, + ITEM_MASK_ZORA, + ITEM_MASK_KAMARO, + ITEM_MASK_GIBDO, + ITEM_MASK_GARO, + ITEM_MASK_CAPTAIN, + ITEM_MASK_GIANT, + ITEM_MASK_FIERCE_DEITY, + }, + // ammo + { 1, 30, 1, 1, 1, 1, 30, 30, 30, 30, 1, 1, 1, 1, 30, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, + // upgrades + 0x120009, + // questItems + (1 << QUEST_SONG_SONATA) | (1 << QUEST_SONG_LULLABY) | (1 << QUEST_SONG_BOSSA_NOVA) | (1 << QUEST_SONG_ELEGY) | + (1 << QUEST_SONG_OATH) | (1 << QUEST_SONG_TIME) | (1 << QUEST_SONG_HEALING) | (1 << QUEST_SONG_EPONA) | + (1 << QUEST_SONG_SOARING) | (1 << QUEST_SONG_STORMS) | (1 << QUEST_BOMBERS_NOTEBOOK) | + (1 << QUEST_SONG_LULLABY_INTRO), + // dungeonItems + { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + // dungeonKeys + { 8, 8, 8, 8, 8, 8, 8, 8, 8, 0 }, + // strayFairies + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + // dekuPlaygroundPlayerName + { + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + // "LINK " + { 0x15, 0x12, 0x17, 0x14, 0x3E, 0x3E, 0x3E, 0x3E }, + }, +}; + +u16 sSaveDebugChecksum = 0; + +u8 D_801C6A48[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_MASK_FIERCE_DEITY, +}; + +u8 D_801C6A50[] = { + SLOT_MASK_FIERCE_DEITY, SLOT_MASK_GORON, SLOT_MASK_ZORA, SLOT_MASK_DEKU, SLOT_MASK_FIERCE_DEITY, +}; + +/** + * Initialize debug save. This is also used on the Title Screen + * This save has a mostly full inventory, every mask and 10 hearts. + * + * Some noteable flags that are set: + * TODO: Investigate the flags + */ +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)); + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + BUTTON_ITEM_EQUIP(0, 2) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; + C_SLOT_EQUIP(0, 2) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; + } + + gSaveContext.save.hasTatl = true; + + gSaveContext.save.horseData.scene = 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.entranceIndex = 0x1C00; + gSaveContext.save.isFirstCycle = true; + + // + gSaveContext.save.weekEventReg[0x0F] |= 0x20; + // Unconfirmed: "Entered South Clock Town" + gSaveContext.save.weekEventReg[0x3B] |= 0x04; + // Unconfirmed: "Tatl's Second Cycle Text?" + gSaveContext.save.weekEventReg[0x1F] |= 0x04; + + gSaveContext.cycleSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1; + gSaveContext.save.playerData.magicLevel = 0; + + Sram_GenerateRandomSaveFields(); +} + +// Unused +void func_80144A94(SramContext* sramCtx) { + s32 i; + s32 cutscene = gSaveContext.save.cutscene; + + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]) != + 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1], + D_801C67F0[gSaveContext.fileNum * 2 + 1]); + } + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + if (CHECK_NEWF(gSaveContext.save.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; + + 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; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + D_801BDAA0 = 1; + D_801BDA9C = 0; + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; +} + +u16 D_801C6A58[] = { 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30 }; + +#ifdef NON_MATCHING +// Small regalloc between v0/t6/t7 +void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { + s32 i; + s32 pad; + s32 phi_t1; + s32 pad1[2]; + s32 fileNum; + + if (gSaveContext.unk_3F3F) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + if (gSaveContext.fileNum == 0xFF) { + func_80185968(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]); + } else if (fileChooseCtx->unk_2446A[gSaveContext.fileNum] != 0) { + phi_t1 = gSaveContext.fileNum + 2; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } else { + phi_t1 = gSaveContext.fileNum; + phi_t1 *= 2; + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) { + func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]); + } + } + + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]); + + if (CHECK_NEWF(gSaveContext.save.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; + + if (!gSaveContext.save.isOwlSave) { + 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; + } + + for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { + gSaveContext.unk_3DD0[i] = 0; + gSaveContext.unk_3DE0[i] = 0; + gSaveContext.unk_3E18[i] = 0; + gSaveContext.unk_3E50[i] = 0; + gSaveContext.unk_3E88[i] = 0; + gSaveContext.unk_3EC0[i] = 0; + } + + if (gSaveContext.save.isFirstCycle) { + gSaveContext.save.entranceIndex = 0xD800; + gSaveContext.save.day = 0; + gSaveContext.save.time = 0x3FFF; + } else { + gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.nextCutsceneIndex = 0; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + } + } else { + gSaveContext.save.entranceIndex = D_801C6A58[gSaveContext.save.owlSaveLocation]; + if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x84A0 && (gSaveContext.save.weekEventReg[20] & 2)) { + // Unconfirmed weekEventReg: "Woodfall Temple Prison Entrance raised / Water cleansed" + gSaveContext.save.entranceIndex = 0xCA0; + } else if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x9A80 && + (gSaveContext.save.weekEventReg[33] & 0x80)) { + // Unconfirmed weekEventReg: "Mountain Village Unfrozen" + gSaveContext.save.entranceIndex = 0xAE80; + } + + 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; + } + + if (gSaveContext.save.unk_F65) { + Lib_MemCpy(gScarecrowSpawnSongPtr, gSaveContext.save.scarecrowsSong, + sizeof(gSaveContext.save.scarecrowsSong)); + + for (i = 0; i != ARRAY_COUNT(gSaveContext.save.scarecrowsSong); i++) {} + } + + fileNum = gSaveContext.fileNum; + func_80147314(sramCtx, fileNum); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_OpenSave.s") +#endif + +// Similar to func_80145698, but accounts for owl saves? +void func_8014546C(SramContext* sramCtx) { + s32 i; + + 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.checksum = 0; + gSaveContext.save.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.checksum = 0; + gSaveContext.save.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)); + } + } +} + +/** + * Save permanent scene flags, calculate checksum, copy save context to the save buffer + */ +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.checksum = 0; + gSaveContext.save.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)); + } +} + +// Verifies save and use backup if corrupted? +#ifdef NON_EQUIVALENT +void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 sp7A; + // u16 sp78; + u16 sp76; + // u16 sp74; + u16 sp6E; //! + // s32 sp68; + // u16 sp66; + u16 phi_s2; //! + u16 sp64; + // s32 sp60; + // s32 sp5C; + // s32 sp58; + // u32 new_var; + u16 phi_s2_3; + // s16 fakevar; + + u16 temp_s2; + u16 temp_v0_2; + u16 phi_a0; // maskCount + + if (gSaveContext.unk_3F3F) { + D_801F6AF0 = gSaveContext.save.time; + D_801F6AF2 = gSaveContext.unk_3F3F; + sp64 = 0; + + for (sp76 = 0; sp76 < 5; sp76++, sp64 += 2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + phi_s2 = false; + sp6E = 0; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64])) { + sp6E = 1; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + } + + if (sp76 < 2) { + fileChooseCtx->unk_24468[sp76] = 0; + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + } 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_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)) { + sp6E = 1; + if (CHECK_NEWF2(gSaveContext.save.playerData.newf)) {} + + phi_s2 = false; + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + 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 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.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; + 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; + sp7A = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); + } + + if (CHECK_NEWF(gSaveContext.save.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)); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]); + } + } + } else if (sp76 < 4) { + fileChooseCtx->unk_24468[sp76] = 0; + + if (!CHECK_NEWF(fileChooseCtx->newf2[(s32)sp76])) { // TODO: Needed? + if (phi_s2) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, + D_801C6870[sp64]); // TODO: Needed? + } else { + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + temp_s2 = gSaveContext.save.checksum; + + gSaveContext.save.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)) { + sp6E = 1; + if ((gSaveContext.save.playerData.newf[0] == 'Z') && + (gSaveContext.save.playerData.newf[1] == 'E')) { + phi_s2 = false; + } + + if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) { + phi_s2 = true; + } + + 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 != Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]))) { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + sp6E = 999; + } + } + } + + gSaveContext.save.checksum = 0; + gSaveContext.save.checksum = + Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { + fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + } + + if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { + fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + + for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { + phi_s2 += 0; // TODO: Needed? + fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + } + + fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; + fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; + fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + + for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { + if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { + phi_a0++; + } + } + fileChooseCtx->maskCount[sp76] = phi_a0; + fileChooseCtx->heartPieceCount[sp76] = + ((gSaveContext.save.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; + 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; + sp7A = Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64]); + } + + if (CHECK_NEWF(gSaveContext.save.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]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } + } else { + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]); + func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]); + } + } else { + if (phi_s2) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } else { + Lib_MemCpy(&gSaveContext.options, sramCtx->saveBuf, sizeof(SaveOptions)); + if (gSaveContext.options.optionId != 0xA51D) { + gSaveContext.options.optionId = 0xA51D; + gSaveContext.options.language = 1; + gSaveContext.options.audioSetting = 0; + gSaveContext.options.languageSetting = 0; + gSaveContext.options.zTargetSetting = 0; + } + } + func_801A3D98(gSaveContext.options.audioSetting); + } + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; + } + + gSaveContext.options.language = 1; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_801457CC.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146580.s") +void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 fileNum) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s32 pad; + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileNum]) { + func_80147314(sramCtx, fileNum); + fileChooseCtx->unk_2446A[fileNum] = 0; + } + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} + +#ifdef NON_MATCHING +// v0/v1 +void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + FileChooseContext* fileChooseCtx = fileChooseCtx2; + u16 i; + s16 maskCount; + + if (gSaveContext.unk_3F3F) { + if (fileChooseCtx->unk_2446A[fileChooseCtx->unk_2448E]) { + func_80147414(sramCtx, fileChooseCtx->unk_2448E, fileChooseCtx->fileNum); + fileChooseCtx->unk_24410[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24424[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->unk_24438[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->unk_24440[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24456[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_2444C[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_2445C[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24464[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_2446A[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->unk_24470[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24476[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->unk_2447A[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->unk_2447E[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + // clear buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + // read to buffer + func_80185968(sramCtx->saveBuf, D_801C67C8[fileChooseCtx->unk_2448E * 2], + D_801C67F0[fileChooseCtx->unk_2448E * 2]); + + if (1) {} + func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileChooseCtx->unk_2448E * 2 + 1], + D_801C67F0[fileChooseCtx->unk_2448E * 2 + 1]); + if (1) {} + + // copy buffer to save context + Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); + + fileChooseCtx->unk_2440C[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + } + + fileChooseCtx->healthCapacity[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->fileNum] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->fileNum] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + // = CUR_UPG_VALUE(UPG_WALLET); + fileChooseCtx->unk_24474[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; + + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } + + fileChooseCtx->maskCount[fileChooseCtx->fileNum] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->fileNum] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } + + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146628.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146AA0.s") +void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { + s32 phi_v0; + u16 i; + FileChooseContext* fileChooseCtx = fileChooseCtx2; + s16 maskCount; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146DF8.s") + if (gSaveContext.unk_3F3F) { + Sram_InitNewSave(); + if (fileChooseCtx->unk_24480 == 0) { + gSaveContext.save.cutscene = 0xFFF0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146E40.s") + for (phi_v0 = 0; phi_v0 < ARRAY_COUNT(gSaveContext.save.playerData.playerName); phi_v0++) { + gSaveContext.save.playerData.playerName[phi_v0] = + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][phi_v0]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_Alloc.s") + 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'; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EBC.s") + gSaveContext.save.checksum = Sram_CalcChecksum(&gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146EE8.s") + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.save, sizeof(Save)); + Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146F5C.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.newf); i++) { + fileChooseCtx->newf[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.newf[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147008.s") + fileChooseCtx->unk_2440C[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.deaths; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147020.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { + fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147068.s") + fileChooseCtx->healthCapacity[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.healthCapacity; + fileChooseCtx->health[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.health; + fileChooseCtx->unk_24454[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.dungeonKeys[9]; + fileChooseCtx->unk_24444[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.questItems; + fileChooseCtx->unk_24458[fileChooseCtx->unk_24480] = gSaveContext.save.time; + fileChooseCtx->unk_24460[fileChooseCtx->unk_24480] = gSaveContext.save.day; + fileChooseCtx->unk_24468[fileChooseCtx->unk_24480] = gSaveContext.save.isOwlSave; + fileChooseCtx->rupees[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.rupees; + fileChooseCtx->unk_24474[fileChooseCtx->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147138.s") + for (i = 0, maskCount = 0; i < 24; i++) { + if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { + maskCount++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147150.s") + fileChooseCtx->maskCount[fileChooseCtx->unk_24480] = maskCount; + fileChooseCtx->heartPieceCount[fileChooseCtx->unk_24480] = + (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147198.s") + gSaveContext.save.time = D_801F6AF0; + gSaveContext.unk_3F3F = D_801F6AF2; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147314.s") +void func_80146DF8(SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + // TODO: macros for languages + gSaveContext.options.language = 1; + Lib_MemCpy(sramCtx->saveBuf, &gSaveContext.options, sizeof(SaveOptions)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80147414.s") +void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { + if (&gSaveContext.save) {} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s") + func_801A3D98(gSaveContext.options.audioSetting); +} + +void Sram_Alloc(GameState* gamestate, SramContext* sramCtx) { + if (gSaveContext.unk_3F3F) { + sramCtx->saveBuf = THA_AllocEndAlign16(&gamestate->heap, SAVE_BUFFER_SIZE); + sramCtx->status = 0; + } +} + +/** + * Synchronous flash write + */ +void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + func_80185F64(sramCtx->saveBuf, curPage, numPages); +} + +/** + * Saves the game on the very first time Player enters South Clock Town from the Clock Tower + */ +void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) { + s32 pad[2]; + SramContext* sramCtx = &globalCtx->sramCtx; + + gSaveContext.save.isFirstCycle = true; + gSaveContext.save.isOwlSave = false; + func_80145698(sramCtx); + func_80185F64(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C6818[gSaveContext.fileNum * 2]); +} + +/** + * Saves when beating the game, after showing the "Dawn of the New Day" message + */ +void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) { + s32 cutscene = gSaveContext.save.cutscene; + s32 day; + u16 time = gSaveContext.save.time; + + day = gSaveContext.save.day; + + // Unconfirmed: "Obtained Fierce Deity Mask?" + gSaveContext.save.weekEventReg[84] &= (u8)~0x20; + + Sram_SaveEndOfCycle(globalCtx); + func_8014546C(&globalCtx->sramCtx); + + gSaveContext.save.day = day; + gSaveContext.save.time = time; + gSaveContext.save.cutscene = cutscene; + func_80185F64(globalCtx->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], + D_801C67F0[gSaveContext.fileNum * 2]); +} + +void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 1; +} + +void func_80147020(SramContext* sramCtx) { + // async flash write + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 2; +} + +void func_80147068(SramContext* sramCtx) { + if (sramCtx->status == 2) { + if (func_80185EC4() != 0) { // if task running + if (func_80185F04() == 0) { // wait for task done + // task success + sramCtx->status = 4; + } else { + // task failure + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + } +} + +void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages) { + sramCtx->curPage = curPage; + sramCtx->numPages = numPages; + sramCtx->status = 6; +} + +void func_80147150(SramContext* sramCtx) { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages); + + sramCtx->unk_18 = osGetTime(); + sramCtx->status = 7; +} + +void func_80147198(SramContext* sramCtx) { + if (sramCtx->status == 7) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } else { + func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages); + sramCtx->status = 8; + } + } + } else if (sramCtx->status == 8) { + if (func_80185EC4() != 0) { // Is task running + if (func_80185F04() == 0) { // Wait for task done + sramCtx->status = 4; + } else { + sramCtx->status = 4; + } + } + } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + sramCtx->status = 0; + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + gSaveContext.save.isOwlSave = false; + gSaveContext.save.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)); + } +} + +void func_80147314(SramContext* sramCtx, s32 fileNum) { + s32 pad; + + 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.checksum = 0; + gSaveContext.save.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]); + func_80146EBC(sramCtx, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2]); + + 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'; +} + +void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2) { + s32 pad; + + // Clear save buffer + bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); + + // Read save file + if (func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]) != 0) { + // If failed, read backup save file + func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2 + 1]); + } + + // Copy buffer to save context + Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum)); + + func_80146EBC(sramCtx, D_801C6840[arg2 * 2], D_801C6850[arg2 * 2]); + func_80146EBC(sramCtx, D_801C6840[arg2 * 2 + 1], D_801C6850[arg2 * 2]); +} + +void Sram_nop8014750C(UNK_TYPE4 arg0) { +} diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 764b3525f..c36365d48 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -6,10 +6,18 @@ #include "global.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +s16 sPathDayFlags[] = { 0x40, 0x20, 0x10, 8, 4, 2, 1, 0 }; + +#include "code/sub_s/sub_s.c" + +Vec3f D_801C5DB0 = { 1.0f, 1.0f, 1.0f }; + +s32 D_801C5DBC[] = { 0, 1 }; // Unused + /** - * Finds the first EnDoor instance with unk_1A4 == 5 and the specified unk_1A5. + * Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag. */ -EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { +EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) { Actor* actor = NULL; EnDoor* door; @@ -21,7 +29,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 unk_1A5) { break; } - if ((door->unk_1A4 == 5) && (door->unk_1A5 == (u8)unk_1A5)) { + if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)switchFlag)) { break; } @@ -154,7 +162,9 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AD9C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AED4.s") +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { + *flags = (*flags & ~unsetBits) | setBits; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s") @@ -168,7 +178,21 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BB34.s") +Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { + Path* path; + s32 i = 0; + + do { + path = &globalCtx->setupPathList[pathIndex]; + if (i >= max) { + break; + } + pathIndex = path->unk1; + i++; + } while (pathIndex != 0xFF); + + return path; +} /** * Finds the nearest actor instance of a specified Id and category to an actor. @@ -205,17 +229,109 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat return closestActor; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BC6C.s") +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index) { + s32 endFrame; + s32 startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BD40.s") + animations += index; + endFrame = animations->frameCount; + if (animations->frameCount < 0) { + endFrame = Animation_GetLastFrame(&animations->animation->common); + } + startFrame = animations->startFrame; + if (startFrame >= endFrame || startFrame < 0) { + return false; + } + if (animations->playSpeed < 0.0f) { + SWAP(s32, endFrame, startFrame); + } + Animation_Change(skelAnime, animations->animation, animations->playSpeed, startFrame, endFrame, animations->mode, + animations->morphFrames); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013BEDC.s") +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 count = path->count; + s32 index = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; + + Math_Vec3s_ToVec3f(&point, &points[index]); + + if (index == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (index == count - 1) { + diffX = points[count - 1].x - points[count - 2].x; + diffZ = points[count - 1].z - points[count - 2].z; + } else { + diffX = points[index + 1].x - points[index - 1].x; + diffZ = points[index + 1].z - points[index - 1].z; + } + + func_8017B7F8(&point, RADF_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; + } + + return reached; +} + +Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) { + Path* path = NULL; + s32 found = false; + s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) + + ((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) / 60) * 60) / + 30; + s32 day = CURRENT_DAY; + + if (pathIndex == max) { + return NULL; + } + + while (pathIndex != 0xFF) { + path = &globalCtx->setupPathList[pathIndex]; + if (sPathDayFlags[day] & path->unk2) { + found = true; + break; + } + pathIndex = path->unk1; + } + + if (found == true) { + *startPointIndex = time; + *startPointIndex = CLAMP(*startPointIndex, 0, path->count - 1); + } else { + *startPointIndex = 0; + } + + return path; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C8B8.s") +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; + + if ((path == NULL) || (pointIndex >= path->count) || (pointIndex < 0)) { + return false; + } + + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; + return true; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C964.s") @@ -229,21 +345,80 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D2E0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D5E8.s") +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) { + return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D648.s") +Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max) { + return (pathIndex != max) ? &globalCtx->setupPathList[pathIndex] : NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D68C.s") +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) { + Vec3s* point; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D720.s") + if (path == NULL) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D768.s") + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D83C.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D8DC.s") +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq) { + f32 diffX = vecA->x - vecB->x; + f32 diffZ = vecA->z - vecB->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D924.s") + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} + +/** + * Returns true when the actor has reached the inputed point + */ +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep) { + Vec3f offsetBefore; + Vec3f offsetAfter; + f32 distSqBefore; + f32 distSqAfter; + + Actor_OffsetOfPointInActorCoords(actor, &offsetBefore, point); + Math_SmoothStepToS(&actor->world.rot.y, SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqBefore), 4, + rotStep, 1); + actor->shape.rot.y = actor->world.rot.y; + Actor_MoveWithGravity(actor); + Actor_OffsetOfPointInActorCoords(actor, &offsetAfter, point); + SubS_GetDistSqAndOrientPoints(point, &actor->world.pos, &distSqAfter); + return ((offsetBefore.z > 0.0f) && (offsetAfter.z <= 0.0f)) ? true : false; +} + +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* distSq) { + Vec3s* point; + f32 diffX = 0.0f; + f32 diffZ = 0.0f; + + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[pointIndex]; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; + } + + *distSq = SQ(diffX) + SQ(diffZ); + return Math_Atan2S(diffX, diffZ); +} + +s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) { + return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true; +} + +s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx) { + return Object_GetIndex(&globalCtx->objectCtx, id); +} /** * Finds the first actor instance of a specified Id and category. @@ -262,31 +437,256 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC return actor; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013D9C8.s") +s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) { + s32 i; + u32 frames = globalCtx->gameplayFrames; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DB90.s") + for (i = 0; i < numLimbs; i++) { + limbRotTableY[i] = (i * 50 + 0x814) * frames; + limbRotTableZ[i] = (i * 50 + 0x940) * frames; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DC40.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s") +s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) { + CollisionPoly* outPoly; + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCE0.s") + posA = posB = *pos; + posB.y += distAbove; + return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, + &bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DE04.s") +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) { + Path* path = &paths[pathIndex]; + Vec3s* point = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[pointIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DF3C.s") + dst->x = point->x; + dst->y = point->y; + dst->z = point->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E054.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E07C.s") +u8 SubS_GetPathCount(Path* paths, s32 index) { + Path* path = &paths[index]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s") + return path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E1C8.s") +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, + Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, + u8 flags) { + Path* path; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E2D4.s") + actorPath->setupPathList = globalCtx->setupPathList; + actorPath->pathIndex = pathIndex; + path = &paths[pathIndex]; + actorPath->points = Lib_SegmentedToVirtual(path->points); + actorPath->count = path->count; + actorPath->begPointIndex = begPointIndex; + if (endPointIndex == 0) { + actorPath->endPointIndex = actorPath->count - 1; + } else if (endPointIndex > 0) { + actorPath->endPointIndex = endPointIndex; + } else { + //! @bug: endPointIndex is negative, subtraction causes result to be past the end + actorPath->endPointIndex = (actorPath->count - endPointIndex) - 1; + } + actorPath->curPointIndex = curPointIndex; + actorPath->curPoint.x = actorPath->points[0].x; + actorPath->curPoint.y = actorPath->points[0].y; + actorPath->curPoint.z = actorPath->points[0].z; + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + actorPath->worldPos = worldPos; + actorPath->actor = actor; + actorPath->flags = flags; + actorPath->prevFlags = flags; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E3B8.s") +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, + ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, + ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) { + s32 shouldSetNextPoint; + s32 reupdate; + + actorPath->computePointInfoFunc = computePointInfoFunc; + actorPath->updateActorInfoFunc = updateActorInfoFunc; + actorPath->moveFunc = moveFunc; + actorPath->setNextPointFunc = setNextPointFunc; + actorPath->flags &= ~ACTOR_PATHING_REACHED_TEMPORARY; + reupdate = false; + if (actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS) { + if (!(actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS)) { + actorPath->curPointIndex--; + } + } else if (actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS) { + actorPath->curPointIndex++; + } + do { + shouldSetNextPoint = false; + if (actorPath->computePointInfoFunc != NULL) { + actorPath->computePointInfoFunc(globalCtx, actorPath); + } + if (actorPath->updateActorInfoFunc != NULL) { + shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath); + } + if (shouldSetNextPoint) { + if (actorPath->setNextPointFunc != NULL) { + reupdate = actorPath->setNextPointFunc(globalCtx, actorPath); + } + } else if (actorPath->moveFunc != NULL) { + reupdate = actorPath->moveFunc(globalCtx, actorPath); + } + } while (reupdate); + actorPath->prevFlags = actorPath->flags; + return false; +} + +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Vec3f diff; + + actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x; + actorPath->curPoint.y = actorPath->points[actorPath->curPointIndex].y + actorPath->pointOffset.y; + actorPath->curPoint.z = actorPath->points[actorPath->curPointIndex].z + actorPath->pointOffset.z; + diff.x = actorPath->curPoint.x - actorPath->worldPos->x; + diff.y = actorPath->curPoint.y - actorPath->worldPos->y; + diff.z = actorPath->curPoint.z - actorPath->worldPos->z; + actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z); + actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff); + actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x); + actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y); + actorPath->rotToCurPoint.z = 0; +} + +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithGravity(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithoutGravityReverse(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) { + s32 reupdate = true; + + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + if (!(actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS)) { + if (actorPath->curPointIndex >= actorPath->endPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->begPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags |= ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex++; + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + } else { + if (actorPath->begPointIndex >= actorPath->curPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->endPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags &= ~ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex--; + } + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + return reupdate; +} + +void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, + s32* curIndex) { + AnimationSpeedInfo* animation = &animations[nextIndex]; + f32 startFrame = skelAnime->curFrame; + f32 endFrame; + f32 morphFrames; + + if ((*curIndex < 0) || (nextIndex == *curIndex)) { + morphFrames = 0.0f; + if (*curIndex < 0) { + startFrame = 0.0f; + } + } else { + morphFrames = animation->morphFrames; + if (nextIndex != *curIndex) { + startFrame = 0.0f; + } + } + if (animation->playSpeed >= 0.0f) { + endFrame = Animation_GetLastFrame(&animation->animation->common); + } else { + startFrame = Animation_GetLastFrame(&animation->animation->common); + endFrame = 0.0f; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, startFrame, endFrame, animation->mode, + morphFrames); + *curIndex = nextIndex; +} + +s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type) { + s32 isStarted = false; + + if ((curCutscene != -1) && (ActorCutscene_GetCurrentIndex() == curCutscene)) { + ActorCutscene_Stop(curCutscene); + ActorCutscene_SetIntentToPlay(nextCutscene); + } else if (ActorCutscene_GetCanPlayNext(nextCutscene)) { + switch (type) { + case SUBS_CUTSCENE_SET_UNK_LINK_FIELDS: + ActorCutscene_StartAndSetUnkLinkFields(nextCutscene, actor); + break; + case SUBS_CUTSCENE_NORMAL: + ActorCutscene_Start(nextCutscene, actor); + break; + case SUBS_CUTSCENE_SET_FLAG: + ActorCutscene_StartAndSetFlag(nextCutscene, actor); + break; + } + isStarted = true; + } else { + ActorCutscene_SetIntentToPlay(nextCutscene); + } + + return isStarted; +} + +s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { + s16 cs; + s32 i; + + for (i = 0; i < numCutscenes; i++) { + cutscenes[i] = -1; + } + + cs = actor->cutscene; + i = 0; + + while (cs != -1) { + // Note: Infinite loop if numCutscenes is less than possible additional cutscenes + if (i < numCutscenes) { + cutscenes[i] = cs; + cs = ActorCutscene_GetAdditionalCutscene(cs); + i++; + } + } + + return i; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E4B0.s") diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index cf90bc75b..edba06fc2 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -1,14 +1,13 @@ -#include "prevent_bss_reordering.h" #include "ultra64.h" #include "global.h" -static s32 framDeviceInfo[4]; -static OSIoMesg framDeviceInfoQuery; -static OSMesgQueue __osFlashMessageQ; -static OSPiHandle __osFlashHandler; -static OSMesg __osFlashMsgBuf; -static s32 __osFlashVersion; -static UNK_TYPE1 D_801FD0FC[0x14]; +s32 framDeviceInfo[4]; +OSIoMesg framDeviceInfoQuery; +OSMesgQueue __osFlashMessageQ; +OSPiHandle __osFlashHandler; +OSMesg __osFlashMsgBuf; +s32 __osFlashVersion; +UNK_TYPE1 D_801FD0FC[0x14]; typedef enum { FLASH_OLD, 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 1b60a4147..009405238 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_link_child/object_link_child.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ArmsHook*)thisx) @@ -108,7 +108,7 @@ void ArmsHook_DetachHookFromActor(ArmsHook* this) { s32 ArmsHook_CheckForCancel(ArmsHook* this) { Player* player = (Player*)this->actor.parent; if (func_801240C8(player)) { - if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & 0x100)) || + if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & ACTOR_FLAG_100)) || ((player->stateFlags1 & 0x4000080))) { this->timer = 0; ArmsHook_DetachHookFromActor(this); @@ -170,7 +170,8 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } else { if (this->actor.child != NULL) { f32 sp94 = Actor_DistanceBetweenActors(&this->actor, grabbed); - f32 sp90 = sqrtf(SQ(this->unk1FC.x) + SQ(this->unk1FC.y) + SQ(this->unk1FC.z)); + f32 sp90 = sqrtf(SQXYZ(this->unk1FC)); + Math_Vec3f_Diff(&grabbed->world.pos, &this->unk1FC, &this->actor.world.pos); if (50.0f < (sp94 - sp90)) { ArmsHook_DetachHookFromActor(this); @@ -217,8 +218,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } else { Math_Vec3f_Diff(&bodyDistDiffVec, &newPos, &player->actor.velocity); - player->actor.world.rot.x = - Math_FAtan2F(sqrtf(SQ(bodyDistDiffVec.x) + SQ(bodyDistDiffVec.z)), -bodyDistDiffVec.y); + player->actor.world.rot.x = Math_FAtan2F(sqrtf(SQXZ(bodyDistDiffVec)), -bodyDistDiffVec.y); } if (phi_f16 < 50.0f) { ArmsHook_DetachHookFromActor(this); 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 a0f11082c..0b9bedbb8 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -5,8 +5,9 @@ */ #include "z_arrow_fire.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowFire*)thisx) @@ -15,19 +16,10 @@ void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80920440(ArrowFire* this, GlobalContext* globalCtx); -void func_8092058C(ArrowFire* this, GlobalContext* globalCtx); -void func_809207A0(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx); +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx); -void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc); - -#if 0 -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80922230 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x08000000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, - { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, -}; +#include "overlays/ovl_Arrow_fire/ovl_Arrow_Fire.c" const ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, @@ -41,29 +33,264 @@ const ActorInit Arrow_Fire_InitVars = { (ActorFunc)ArrowFire_Draw, }; -#endif +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x08000000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; -extern ColliderQuadInit D_80922230; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), +}; -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +s32 sUnused; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_SetupAction.s") +void ArrowFire_SetupAction(ArrowFire* this, ArrowFireActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Init.s") +void ArrowFire_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowFire_SetupAction(this, FireArrow_ChargeAndWait); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 160; + this->timer = 0; + this->screenFillIntensity = 0.0f; + Collider_InitAndSetQuad(globalCtx, &this->collider1, &this->actor, &sQuadInit); + Collider_InitAndSetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920440.s") +void ArrowFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/FireArrow_Lerp.s") + func_80115D5C(&globalCtx->state); + Collider_DestroyQuad(globalCtx, &this->collider1); + Collider_DestroyQuad(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_8092058C.s") +void FireArrow_ChargeAndWait(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_809207A0.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Update.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/func_80920948.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_FIRE - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Fire/ArrowFire_Draw.s") + // if arrow has no parent, player has fired the arrow + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowFire_SetupAction(this, FireArrow_Fly); + this->alpha = 255; + } +} + +void FireArrow_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} + +void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) { + f32 offset; + f32 scale; + u16 timer; + + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } + + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + offset = (this->timer - 8) * (1.0f / 24.0f); + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } + if (this->timer >= 13) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } +} + +void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad; + s32 pad2; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + + if (this->height < 1.0f) { + this->height = 1.0f; + } + + FireArrow_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_FRAME); + ArrowFire_SetupAction(this, FireArrow_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowFire_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowFire* this = (ArrowFire*)thisx; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void FireArrow_SetQuadVerticies(ArrowFire* this) { + static Vec3f D_80922284 = { 100.0f, 700.0f, 0.0f }; + static Vec3f D_80922290 = { 400.0f, 27.0f, 0.0f }; + static Vec3f D_8092229C = { -100.0f, 700.0f, 0.0f }; + static Vec3f D_809222A8 = { -400, 27.0f, 0.0f }; + static Vec3f D_809222B4 = { 0.0f, 700.0f, 100.0f }; + static Vec3f D_809222C0 = { 0.0f, 27.0f, 400.0f }; + static Vec3f D_809222CC = { 0.0f, 700.0f, -100.0f }; + static Vec3f D_809222D8 = { 0.0f, 27.0f, -400.0f }; + Vec3f sp44; + Vec3f sp38; + Vec3f sp2C; + Vec3f sp20; + + Matrix_MultiplyVector3fByState(&D_80922284, &sp44); + Matrix_MultiplyVector3fByState(&D_80922290, &sp38); + Matrix_MultiplyVector3fByState(&D_8092229C, &sp2C); + Matrix_MultiplyVector3fByState(&D_809222A8, &sp20); + Collider_SetQuadVertices(&this->collider1, &sp44, &sp38, &sp2C, &sp20); + Matrix_MultiplyVector3fByState(&D_809222B4, &sp44); + Matrix_MultiplyVector3fByState(&D_809222C0, &sp38); + Matrix_MultiplyVector3fByState(&D_809222CC, &sp2C); + Matrix_MultiplyVector3fByState(&D_809222D8, &sp20); + Collider_SetQuadVertices(&this->collider2, &sp44, &sp38, &sp2C, &sp20); +} + +void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* arrow; + ArrowFire* this = THIS; + u32 frames = globalCtx->state.frames; + s32 pad; + + arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 40.0f) & 0xFF, 0, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); + + Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + + if (this->timer != 0) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + FireArrow_SetQuadVerticies(this); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 255 - ((frames * 2) % 256), 0, 64, 32, 1, + 255 - (frames % 256), 511 - ((frames * 10) % 512), 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, gFireArrowModelDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h index bf1143cd9..5f9617c65 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h @@ -8,12 +8,19 @@ struct ArrowFire; typedef void (*ArrowFireActionFunc)(struct ArrowFire*, GlobalContext*); typedef struct ArrowFire { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x114]; - /* 0x0258 */ ArrowFireActionFunc actionFunc; - /* 0x025C */ char unk_25C[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderQuad collider1; + /* 0x1C4 */ ColliderQuad collider2; + /* 0x244 */ Vec3f firedPos; + /* 0x250 */ f32 height; + /* 0x254 */ f32 screenFillIntensity; + /* 0x258 */ ArrowFireActionFunc actionFunc; + /* 0x25C */ s16 radius; + /* 0x25E */ u16 timer; + /* 0x260 */ u8 alpha; } ArrowFire; // size = 0x264 + extern const ActorInit Arrow_Fire_InitVars; #endif // Z_ARROW_FIRE_H 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 75002f17e..8a402dfbe 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -7,7 +7,7 @@ #include "z_arrow_ice.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowIce*)thisx) @@ -17,7 +17,6 @@ void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx); void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx); -void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx); void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx); #include "overlays/ovl_Arrow_Ice/ovl_Arrow_Ice.c" @@ -94,7 +93,6 @@ void ArrowIce_LerpFiredPosition(Vec3f* firedPos, Vec3f* icePos, f32 scale) { void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { f32 scale; - f32 offset; u16 timer; if (this->actor.projectedW < 50.0f) { @@ -111,12 +109,12 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { this->timer--; if (this->timer >= 8) { - offset = ((this->timer - 8) * (1.0f / 24.0f)); + f32 offset = ((this->timer - 8) * (1.0f / 24.0f)); + offset = SQ(offset); this->radius = (((1.0f - offset) * scale) + 10.0f); - this->height += ((2.0f - this->height) * 0.1f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); if (this->timer < 16) { - if (1) {} this->alpha = ((this->timer * 35) - 280); } } @@ -228,11 +226,11 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, sIceArrowDL); + gSPDisplayList(POLY_XLU_DISP++, gIceArrowMaterialDL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - (stateFrames * 5) % 512, 0, 128, 32, 1, 511 - (stateFrames * 10) % 512, 511 - (stateFrames * 10) % 512, 4, 16)); - gSPDisplayList(POLY_XLU_DISP++, sIceArrowVtxDL); + gSPDisplayList(POLY_XLU_DISP++, gIceArrowModelDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 b31185726..ac8eb1ae9 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -5,8 +5,9 @@ */ #include "z_arrow_light.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((ArrowLight*)thisx) @@ -15,13 +16,11 @@ void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx); void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809243AC(ArrowLight* this, GlobalContext* globalCtx); -void func_809244F8(ArrowLight* this, GlobalContext* globalCtx); -void func_809246C4(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx); +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx); -void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc); +#include "overlays/ovl_Arrow_Light/ovl_Arrow_Light.c" -#if 0 const ActorInit Arrow_Light_InitVars = { ACTOR_ARROW_LIGHT, ACTORCAT_ITEMACTION, @@ -34,34 +33,198 @@ const ActorInit Arrow_Light_InitVars = { (ActorFunc)ArrowLight_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809260A0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_STOP), }; -#endif +static s32 sUnused; -extern InitChainEntry D_809260A0[]; +void ArrowLight_SetupAction(ArrowLight* this, ArrowLightActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -// there are uses of D_0E000000.fillRect (appearing as D_0E0002E0) in this file -extern GfxMasterList D_0E000000; +void ArrowLight_Init(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = (ArrowLight*)thisx; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->radius = 0; + this->height = 1.0f; + ArrowLight_SetupAction(this, ArrowLight_Charge); + Actor_SetScale(&this->actor, 0.01f); + this->alpha = 130; + this->timer = 0; + this->screenFillIntensity = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/D_809260B0.s") +void ArrowLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + (void)"消滅"; // Unreferenced in retail, means "Disappearance" +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_SetupAction.s") +void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Init.s") + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Destroy.s") + if (this->radius < 10) { + this->radius++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809243AC.s") + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244A0.s") + func_800B9010(&this->actor, NA_SE_PL_ARROW_CHARGE_LIGHT - SFX_FLAG); + if (arrow->actor.parent == NULL) { + this->firedPos = this->actor.world.pos; + this->radius = 10; + ArrowLight_SetupAction(this, ArrowLight_Fly); + this->alpha = 255; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809244F8.s") +void ArrowLight_Lerp(Vec3f* firedPos, Vec3f* pos, f32 scale) { + VEC3F_LERPIMPDST(firedPos, firedPos, pos, scale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/func_809246C4.s") +void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { + f32 scale; + u16 timer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Update.s") + if (this->actor.projectedW < 50.0f) { + scale = 10.0f; + } else if (this->actor.projectedW > 950.0f) { + scale = 310.0f; + } else { + scale = this->actor.projectedW; + scale = ((scale - 50.0f) * (1.0f / 3.0f)) + 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Arrow_Light/ArrowLight_Draw.s") + timer = this->timer; + if (timer != 0) { + this->timer--; + if (this->timer >= 8) { + f32 offset = (this->timer - 8) * (1.0f / 24.0f); + + offset = SQ(offset); + this->radius = (((1.0f - offset) * scale) + 10.0f); + this->height = F32_LERPIMP(this->height, 2.0f, 0.1f); + if (this->timer < 16) { + this->alpha = (this->timer * 35) - 280; + } + } + } + if (this->timer >= 9) { + if (this->screenFillIntensity < 1.0f) { + this->screenFillIntensity += 0.25f; + } + } else { + if (this->screenFillIntensity > 0.0f) { + this->screenFillIntensity -= 0.125f; + } + } + if (this->timer < 8) { + this->alpha = 0; + } + if (this->timer == 0) { + this->timer = 255; + Actor_MarkForDeath(&this->actor); + return; + } +} + +void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { + EnArrow* arrow = (EnArrow*)this->actor.parent; + s32 pad[2]; + + if ((arrow == NULL) || (arrow->actor.update == NULL)) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.world.pos = arrow->actor.world.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + this->height = Math_Vec3f_DistXYZ(&this->firedPos, &this->actor.world.pos) * (1.0f / 24.0f); + if (this->height < 1.0f) { + this->height = 1.0f; + } + + ArrowLight_Lerp(&this->firedPos, &this->actor.world.pos, 0.05f); + + if (arrow->unk_261 & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_EXPLOSION_LIGHT); + ArrowLight_SetupAction(this, ArrowLight_Hit); + this->timer = 32; + this->alpha = 255; + return; + } + if (arrow->unk_260 < 34) { + if (this->alpha < 35) { + Actor_MarkForDeath(&this->actor); + return; + } + this->alpha -= 25; + } +} + +void ArrowLight_Update(Actor* thisx, GlobalContext* globalCtx) { + ArrowLight* this = THIS; + + if ((globalCtx->msgCtx.msgMode == 0xE) || (globalCtx->msgCtx.msgMode == 0x12)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc(this, globalCtx); +} + +void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ArrowLight* this = (ArrowLight*)thisx; + u32 frames = globalCtx->state.frames; + EnArrow* arrow = (EnArrow*)this->actor.parent; + + if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { + Actor* transform = (arrow->unk_261 & 2) ? &this->actor : &arrow->actor; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(transform->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(transform->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(transform->shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + if (this->screenFillIntensity > 0.0f) { + POLY_XLU_DISP = func_8012BFC4(POLY_XLU_DISP); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s32)(this->screenFillIntensity * 30.0f) & 0xFF, + (s32)(40.0f * this->screenFillIntensity) & 0xFF, 0, + (s32)(150.0f * this->screenFillIntensity) & 0xFF); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_DISABLE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_DISABLE); + gSPDisplayList(POLY_XLU_DISP++, D_0E000000.fillRect); + } + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, this->alpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 0, 128); + + Matrix_InsertRotation(0x4000, 0, 0, MTXMODE_APPLY); + if (this->timer != 0) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(0.0f, 1500.0f, 0.0f, MTXMODE_APPLY); + } + Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 511 - ((frames * 5) % 512), 0, 4, 32, 1, + 511 - ((frames * 10) % 512), 511 - ((frames * 30) % 512), 8, 16)); + gSPDisplayList(POLY_XLU_DISP++, gLightArrowModelDL); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h index ef462cfde..7b3f3088f 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.h @@ -8,11 +8,17 @@ struct ArrowLight; typedef void (*ArrowLightActionFunc)(struct ArrowLight*, GlobalContext*); typedef struct ArrowLight { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ ArrowLightActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 radius; + /* 0x146 */ u16 timer; + /* 0x148 */ u8 alpha; + /* 0x14C */ Vec3f firedPos; + /* 0x158 */ f32 height; + /* 0x15C */ f32 screenFillIntensity; + /* 0x160 */ ArrowLightActionFunc actionFunc; } ArrowLight; // size = 0x164 + extern const ActorInit Arrow_Light_InitVars; #endif // Z_ARROW_LIGHT_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 c67eece3d..b2fe546cf 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -5,8 +5,17 @@ */ #include "z_bg_breakwall.h" +#include "objects/object_omoya_obj/object_omoya_obj.h" +#include "objects/object_yukimura_obj/object_yukimura_obj.h" +#include "objects/object_keikoku_obj/object_keikoku_obj.h" +#include "objects/object_posthouse_obj/object_posthouse_obj.h" +#include "objects/object_kumo30/object_kumo30.h" +#include "objects/object_mnk/object_mnk.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/object_spot11_obj/object_spot11_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgBreakwall*)thisx) @@ -14,80 +23,418 @@ void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc); +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx); +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx); +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx); +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx); +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx); +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Breakwall_InitVars = { - ACTOR_BG_BREAKWALL, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(BgBreakwall), - (ActorFunc)BgBreakwall_Init, - (ActorFunc)NULL, - (ActorFunc)BgBreakwall_Update, - (ActorFunc)NULL, + ACTOR_BG_BREAKWALL, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(BgBreakwall), (ActorFunc)BgBreakwall_Init, + (ActorFunc)NULL, (ActorFunc)BgBreakwall_Update, (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B82E0[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ Gfx* unk_08; + /* 0x0C */ AnimatedMaterial* unk_0C; + /* 0x10 */ CollisionHeader* unk_10; + /* 0x14 */ BgBreakwallUnkFunc unk_14; + /* 0x18 */ BgBreakwallUnkFunc2 unk_18; + /* 0x1C */ ActorFunc unk_1C; +} BgBreakwallStruct; + +BgBreakwallStruct D_808B8140[] = { + { OBJECT_OMOYA_OBJ, object_omoya_obj_DL_0001A0, NULL, NULL, NULL, func_808B7380, func_808B77D0, NULL }, + { OBJECT_YUKIMURA_OBJ, object_yukimura_obj_DL_000F98, object_yukimura_obj_DL_000EB0, + object_yukimura_obj_Matanimheader_002090, NULL, func_808B73C4, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0027D8, NULL, object_keikoku_obj_Matanimheader_004290, NULL, + func_808B73FC, func_808B77D0, NULL }, + { OBJECT_KEIKOKU_OBJ, object_keikoku_obj_DL_0044A8, NULL, NULL, NULL, func_808B736C, func_808B77D0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_000A50, NULL, NULL, NULL, func_808B7410, func_808B77E0, NULL }, + { OBJECT_POSTHOUSE_OBJ, object_posthouse_obj_DL_001870, NULL, NULL, &object_posthouse_obj_Colheader_002948, + func_808B7460, func_808B782C, NULL }, + { OBJECT_KUMO30, NULL, object_kumo30_DL_002A40, object_kumo30_Matanimheader_003368, NULL, func_808B74A8, + func_808B78A4, func_808B7A90 }, + { OBJECT_KUMO30, NULL, NULL, object_kumo30_Matanimheader_002890, NULL, func_808B736C, func_808B78DC, + func_808B7B54 }, + { OBJECT_MNK, object_mnk_DL_000F58, NULL, object_mnk_Matanimheader_002E28, &object_mnk_Colheader_0033E8, + func_808B74D8, func_808B7914, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AB10, object_ikninside_obj_Matanimheader_00BCC8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_KAIZOKU_OBJ, object_kaizoku_obj_DL_00AD50, NULL, NULL, &object_kaizoku_obj_Colheader_00B868, func_808B736C, + func_808B77D0, NULL }, + { OBJECT_IKNINSIDE_OBJ, NULL, object_ikninside_obj_DL_00AEC0, object_ikninside_obj_Matanimheader_00BCB8, NULL, + func_808B751C, func_808B7A10, func_808B7D34 }, + { OBJECT_SPOT11_OBJ, object_spot11_obj_DL_0013F0, NULL, NULL, &object_spot11_obj_Colheader_001EB8, func_808B736C, + func_808B77D0, NULL }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_808B82F0[] = { + { 255, 230, 240, 255 }, + { 255, 255, 255, 255 }, + { 255, 230, 220, 255 }, + { 80, 120, 160, 255 }, +}; -extern InitChainEntry D_808B82E0[]; +Color_RGBA8 D_808B8300[] = { + { 140, 60, 70, 255 }, + { 50, 150, 150, 255 }, + { 140, 60, 50, 255 }, + { 30, 40, 160, 255 }, +}; -extern UNK_TYPE D_06000A50; +Color_RGBA8 D_808B8310[] = { + { 210, 160, 180, 255 }, + { 120, 150, 160, 255 }, + { 210, 170, 160, 255 }, + { 70, 100, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_SetupAction.s") +Color_RGBA8 D_808B8320[] = { + { 255, 240, 255, 255 }, + { 255, 255, 255, 255 }, + { 255, 255, 240, 255 }, + { 150, 170, 180, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B736C.s") +Color_RGBA8 D_808B8330[] = { + { 60, 20, 40, 255 }, + { 0, 50, 50, 255 }, + { 60, 30, 30, 255 }, + { 0, 20, 30, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7380.s") +Color_RGBA8 D_808B8340[] = { + { 160, 120, 140, 255 }, + { 100, 160, 150, 255 }, + { 160, 150, 120, 255 }, + { 60, 110, 110, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73C4.s") +void BgBreakwall_SetupAction(BgBreakwall* this, BgBreakwallActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B73FC.s") +s32 func_808B736C(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7410.s") +s32 func_808B7380(BgBreakwall* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.day >= 2) && !(gSaveContext.save.weekEventReg[22] & 1)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7460.s") +s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx) { + return (gSaveContext.save.weekEventReg[33] & 0x80) || (gSaveContext.save.weekEventReg[21] & 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74A8.s") +s32 func_808B73FC(BgBreakwall* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B74D8.s") +s32 func_808B7410(BgBreakwall* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = NULL; + } + Actor_SetScale(&this->dyna.actor, 0.1f); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B751C.s") +s32 func_808B7460(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.scale.x = 0.1f; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Init.s") +s32 func_808B74A8(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B767C.s") +s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[9] & 0x80) || (gSaveContext.save.weekEventReg[23] & 0x20)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B76CC.s") +s32 func_808B751C(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77D0.s") + if ((BGBREAKWALL_SWITCHFLAG(&this->dyna.actor) != 0x7F) && + !Flags_GetSwitch(globalCtx, BGBREAKWALL_SWITCHFLAG(&this->dyna.actor))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B77E0.s") + func_800FEA50(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B782C.s") + if (gSaveContext.save.isNight) { + this->unk_15E = 0; + } else { + this->unk_15E = 255; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78A4.s") +void BgBreakwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* sp24 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B78DC.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_15C = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7914.s") + if ((this->unk_15C < 0) || !sp24->unk_14(this, globalCtx)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A10.s") + BgBreakwall_SetupAction(this, func_808B76CC); + this->switchFlag = BGBREAKWALL_SWITCHFLAG(&this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/BgBreakwall_Update.s") +void BgBreakwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7A90.s") + if (temp_s1->unk_10 != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7B54.s") +void func_808B76CC(BgBreakwall* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_15C)) { + BgBreakwallStruct* temp_s1 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7D34.s") + this->dyna.actor.objBankIndex = this->unk_15C; + this->dyna.actor.draw = BgBreakwall_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Breakwall/func_808B7FE4.s") + if (((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_7) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_9) && + ((BGBREAKWALL_GET_F(&this->dyna.actor)) != BGBREAKWALL_F_11)) { + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + } + + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + + if (temp_s1->unk_0C != NULL) { + temp_s1->unk_0C = Lib_SegmentedToVirtual(temp_s1->unk_0C); + } + + if (temp_s1->unk_10 != NULL) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, temp_s1->unk_10); + } + + BgBreakwall_SetupAction(this, temp_s1->unk_18); + this->dyna.actor.destroy = BgBreakwall_Destroy; + } +} + +void func_808B77D0(BgBreakwall* this, GlobalContext* globalCtx) { +} + +void func_808B77E0(BgBreakwall* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->dyna.actor.draw = BgBreakwall_Draw; + } else { + this->dyna.actor.draw = NULL; + } +} + +void func_808B782C(BgBreakwall* this, GlobalContext* globalCtx) { + f32 phi_f0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = 0.1f; + } + Math_SmoothStepToF(&this->dyna.actor.scale.x, phi_f0, 0.2f, 0.3f, 0.06f); +} + +void func_808B78A4(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_808B78DC(BgBreakwall* this, GlobalContext* globalCtx) { + Actor_SetScale(&this->dyna.actor, 3.5f); + func_800B9010(&this->dyna.actor, NA_SE_EV_TORNADE - SFX_FLAG); +} + +void func_808B7914(BgBreakwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + Vec3f sp24; + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp30.x = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.x - 55.0f); + sp30.y = this->dyna.actor.world.pos.y + 70.0f; + sp30.z = Rand_ZeroFloat(80.0f) + (this->dyna.actor.world.pos.z - 130.0f); + + sp24.x = 0.0f; + sp24.y = 0.5f; + sp24.z = 0.0f; + + EffectSsIceSmoke_Spawn(globalCtx, &sp30, &sp24, &gZeroVec3f, -200 - (s32)(Rand_ZeroOne() * 50.0f)); + } +} + +void func_808B7A10(BgBreakwall* this, GlobalContext* globalCtx) { + if (gSaveContext.save.isNight) { + if (this->unk_15E < 245) { + this->unk_15E += 10; + } else { + this->unk_15E = 255; + } + } else if (this->unk_15E > 10) { + this->unk_15E -= 10; + } else { + this->unk_15E = 0; + } +} + +void BgBreakwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_808B7A90(Actor* thisx, GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_808B82F0, &sp2C); + func_800FE7A8(D_808B8300, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7B54(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + Color_RGBA8 sp50; + Color_RGBA8 sp4C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_800FE7A8(D_808B8310, &sp50); + func_800FE7A8(D_808B8330, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_posthouse_obj_DL_000A50); + + func_800FE7A8(D_808B8320, &sp50); + func_800FE7A8(D_808B8340, &sp4C); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp50.r, sp50.g, sp50.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp4C.r, sp4C.g, sp4C.b, 255); + gSPDisplayList(POLY_XLU_DISP++, object_kumo30_DL_000C98); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_808B7D34(Actor* thisx, GlobalContext* globalCtx) { + BgBreakwall* this = THIS; + s32 sp48; + s32 tempA; + s32 tempB; + s32 tempC; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp48 = 255 - this->unk_15E; + + tempA = (((sp48 * 245) + (this->unk_15E * 255)) & 0xFF00) >> 8; + tempB = (((sp48 * 145) + (this->unk_15E * 85)) & 0xFF00) >> 8; + tempC = (((sp48 * 135) + (this->unk_15E * 55)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, tempA, tempB, tempC)); + + tempA = (((sp48 * 255) + (this->unk_15E * 150)) & 0xFF00) >> 8; + tempB = (((sp48 * 255) + (this->unk_15E * 100)) & 0xFF00) >> 8; + tempC = (((sp48 * 255) + (this->unk_15E * 75)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0A, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, tempA, tempA, tempB, tempC)); + + tempA = (((sp48 * 185) + (this->unk_15E * 140)) & 0xFF00) >> 8; + tempB = (((sp48 * 235) + (this->unk_15E * 45)) & 0xFF00) >> 8; + + gSPSegment(POLY_XLU_DISP++, 0x0B, Gfx_PrimColor(globalCtx->state.gfxCtx, 255, 255, 255, tempA, tempB)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void BgBreakwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgBreakwall* this = THIS; + BgBreakwallStruct* temp_s2 = &D_808B8140[BGBREAKWALL_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (temp_s2->unk_0C != NULL) { + AnimatedMat_Draw(globalCtx, temp_s2->unk_0C); + } + + if (temp_s2->unk_1C != NULL) { + temp_s2->unk_1C(&this->dyna.actor, globalCtx); + } + + if (temp_s2->unk_04 != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, temp_s2->unk_04); + } + + if (temp_s2->unk_08 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, temp_s2->unk_08); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h index 279aba17b..322929344 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.h @@ -6,10 +6,23 @@ struct BgBreakwall; typedef void (*BgBreakwallActionFunc)(struct BgBreakwall*, GlobalContext*); +typedef s32 (*BgBreakwallUnkFunc)(struct BgBreakwall*, GlobalContext*); +typedef void (*BgBreakwallUnkFunc2)(struct BgBreakwall*, GlobalContext*); + +#define BGBREAKWALL_GET_F(thisx) ((thisx)-> params & 0xF) +#define BGBREAKWALL_SWITCHFLAG(thisx) (((thisx)-> params & 0xFE00) >> 9) + +enum { + /* 7 */ BGBREAKWALL_F_7 = 7, + /* 9 */ BGBREAKWALL_F_9 = 9, + /* 11 */ BGBREAKWALL_F_11 = 11, +}; typedef struct BgBreakwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ s8 unk_15C; + /* 0x015D */ u8 switchFlag; + /* 0x015E */ u8 unk_15E; /* 0x0160 */ BgBreakwallActionFunc actionFunc; } BgBreakwall; // size = 0x164 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 82e9c8a15..c5613248a 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 @@ -6,7 +6,7 @@ #include "z_bg_crace_movebg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgCraceMovebg*)thisx) 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 a504db3f9..09876c350 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 @@ -7,7 +7,7 @@ #include "z_bg_ctower_gear.h" #include "objects/object_ctower_rot/object_ctower_rot.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgCtowerGear*)thisx) @@ -163,8 +163,8 @@ void BgCtowerGear_Update(Actor* thisx, GlobalContext* globalCtx) { void BgCtowerGear_UpdateOrgan(Actor* thisx, GlobalContext* globalCtx) { BgCtowerGear* this = THIS; - if (func_800EE29C(globalCtx, 0x68)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x68)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 104)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 104)]->action) { case 1: this->dyna.actor.draw = NULL; func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); 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 d12c26b8a..53ddd7b81 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 @@ -7,7 +7,7 @@ #include "z_bg_ctower_rot.h" #include "objects/object_ctower_rot/object_ctower_rot.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgCtowerRot*)thisx) @@ -91,7 +91,7 @@ void BgCtowerRot_CorridorRotate(BgCtowerRot* this, GlobalContext* globalCtx) { rotZtmp = CLAMP_MAX(1100.0f - offset.z, 1000.0f); rotZ = rotZtmp; } - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 17); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 17); this->dyna.actor.shape.rot.z = rotZ * 16.384f; if (globalCtx->csCtx.frames == 132) { play_sound(NA_SE_SY_SPIRAL_DASH); diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c index 00219105b..1aada9272 100644 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c +++ b/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.c @@ -6,7 +6,7 @@ #include "z_bg_danpei_movebg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDanpeiMovebg*)thisx) 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 9f2e18d9c..07693307b 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 @@ -5,6 +5,7 @@ */ #include "z_bg_dblue_balance.h" +#include "objects/object_dblue_object/object_dblue_object.h" #define FLAGS 0x00000000 @@ -15,11 +16,19 @@ void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B82DC4(BgDblueBalance* this); void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx); +void func_80B83344(BgDblueBalance* this); void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B833A8(BgDblueBalance* this); void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx); +void func_80B83518(Actor* thisx, GlobalContext* globalCtx); +void func_80B83758(Actor* thisx, GlobalContext* globalCtx); + +AnimatedMaterial* D_80B83C70; +AnimatedMaterial* D_80B83C74; -#if 0 const ActorInit Bg_Dblue_Balance_InitVars = { ACTOR_BG_DBLUE_BALANCE, ACTORCAT_BG, @@ -32,56 +41,689 @@ const ActorInit Bg_Dblue_Balance_InitVars = { (ActorFunc)BgDblueBalance_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B83A98[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ u32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ ActorFunc unk_14; + /* 0x18 */ ActorFunc unk_18; +} BgDblueBalanceStruct2; + +BgDblueBalanceStruct2 D_80B83A20[] = { + { + object_dblue_object_DL_00B8F8, + &object_dblue_object_Colheader_00BC08, + 0x10, + 360.0f, + 300.0f, + BgDblueBalance_Update, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00BF48, + &object_dblue_object_Colheader_00C180, + 0x10, + 210.0f, + 190.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_00C4B8, + &object_dblue_object_Colheader_00C700, + 0x10, + 180.0f, + 180.0f, + func_80B8330C, + BgDblueBalance_Draw, + }, + { + object_dblue_object_DL_001E68, + &object_dblue_object_Colheader_002E78, + 0x30, + 1500.0f, + 1500.0f, + func_80B83518, + func_80B83758, + }, +}; + +s8 D_80B83A90[] = { + 0, + 4, +}; +s8 D_80B83A94[] = { + 0, + 2, + 4, + 6, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80B823B0(BgDblueBalance* this) { + s32 pad; + Vec3f sp28; -extern InitChainEntry D_80B83A98[]; + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -extern UNK_TYPE D_0600CD10; -extern UNK_TYPE D_0600CE00; -extern UNK_TYPE D_0600D110; + sp28.x = -138.28f; + sp28.y = 0.0f; + sp28.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B823B0.s") + if (this->unk_15C != NULL) { + Matrix_MultiplyVector3fByState(&sp28, &this->unk_15C->dyna.actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82454.s") + sp28.x = 138.28f; + if (this->unk_160 != NULL) { + Matrix_MultiplyVector3fByState(&sp28, &this->unk_160->dyna.actor.world.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8259C.s") +s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp58 = true; + BgDblueBalance* balance; + Vec3f sp48; + Vec3f sp3C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8264C.s") + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B828E4.s") + sp48.x = -138.28f; + sp48.y = 0.0f; + sp48.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8296C.s") + Matrix_MultiplyVector3fByState(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82B00.s") + this->unk_15C = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x100); + if (this->unk_15C == NULL) { + sp58 = false; + } else { + balance = this->unk_15C; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Init.s") + sp48.x = 138.28f; + Matrix_MultiplyVector3fByState(&sp48, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Destroy.s") + this->unk_160 = (BgDblueBalance*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_DBLUE_BALANCE, sp3C.x, + sp3C.y, sp3C.z, 0, this->dyna.actor.shape.rot.y, 0, 0x200); + if (this->unk_160 == NULL) { + sp58 = false; + } else { + balance = this->unk_160; + balance->unk_164 = this; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DC4.s") + return sp58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B82DE0.s") +void func_80B8259C(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Update.s") + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.z, &sp2C, &sp30)) { + this->dyna.actor.depthInWater = sp2C - this->dyna.actor.world.pos.y; + this->unk_228 = sp2C; + if ((this->dyna.actor.depthInWater < 150.0f) && (this->dyna.actor.depthInWater > -150.0f)) { + this->unk_182 = true; + } else { + this->unk_182 = false; + } + } else { + this->unk_182 = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8330C.s") +void func_80B8264C(BgDblueBalance* this) { + s32 pad; + s32 i; + BgDblueBalanceStruct* phi_s0; + Vec3f sp78; + f32 temp_f0; + s16 phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83344.s") + if (this->unk_170 != 0) { + if (this->unk_183 < 8) { + this->unk_183 = 0; + } else { + this->unk_183 -= 7; + } + } else { + if (this->unk_183 > 250) { + this->unk_183 = 255; + } else { + this->unk_183 += 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B8335C.s") + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833A8.s") + for (i = 0, phi_s0 = &this->unk_188[0], phi_s2 = 0; i < ARRAY_COUNT(this->unk_188); + i++, phi_s2 += 0x2000, phi_s0++) { + phi_s0->unk_0C = this->dyna.actor.shape.rot.x + phi_s2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B833C4.s") + Matrix_StatePush(); + Matrix_InsertXRotation_s(phi_s0->unk_0C, MTXMODE_NEW); + Matrix_InsertTranslation(-545.0f, 0.0f, 270.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&sp78); + Matrix_StatePop(); + Matrix_MultiplyVector3fByState(&sp78, &phi_s0->unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83518.s") + temp_f0 = (sp78.z - 135.0f); + if (sp78.z > 135.0f) { + temp_f0 *= 1.8962963f; + if (temp_f0 > 255.0f) { + phi_s0->unk_0E = 0xFF; + phi_s0->unk_10 = 0.1f; + } else if (temp_f0 < 1.0f) { + phi_s0->unk_0E = 0; + phi_s0->unk_10 = 0.0f; + } else { + phi_s0->unk_0E = temp_f0; + phi_s0->unk_10 = temp_f0 * 0.000390625f; + } + } else { + phi_s0->unk_0E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/BgDblueBalance_Draw.s") +void func_80B828E4(BgDblueBalance* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)) && (this->unk_17D <= 0)) { + if (this->unk_183 >= 252) { + this->unk_183 = 255; + } else { + this->unk_183 += 3; + } + } else if (this->unk_183 < 7) { + this->unk_183 = 0; + } else { + this->unk_183 -= 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Balance/func_80B83758.s") +void func_80B8296C(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2) { + s32 i; + Vec3f sp60; + f32 temp_f0; + f32 temp_f20 = arg2 * 2; + + for (i = 0; i < ARRAY_COUNT(D_80B83A90); i++) { + sp60.x = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->x; + sp60.y = arg1->y; + sp60.z = ((Rand_ZeroOne() - 0.5f) * temp_f20) + arg1->z; + EffectSsGRipple_Spawn(globalCtx, &sp60, 500, 2000, D_80B83A90[i]); + } + + for (i = 0; i < ARRAY_COUNT(D_80B83A94); i++) { + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if (Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + + sp60.x = (temp_f20 * arg2) + arg1->x; + sp60.y = arg1->y; + + temp_f0 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0); + if (Rand_Next() > 0) { + temp_f20 = -temp_f20; + } + sp60.z = (temp_f20 * arg2) + arg1->z; + + EffectSsGRipple_Spawn(globalCtx, &sp60, 400, 800, D_80B83A94[i]); + } +} + +s32 func_80B82B00(s16 arg0, s16 arg1, s16 arg2) { + if (arg0 < arg1) { + return (arg0 < arg2 && arg1 >= arg2); + } + return (arg0 < arg2 || arg1 >= arg2); +} + +void BgDblueBalance_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp2C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + s32 pad2; + s32 sp24 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.flags = D_80B83A20[sp2C].unk_08; + this->dyna.actor.uncullZoneScale = D_80B83A20[sp2C].unk_0C; + this->dyna.actor.uncullZoneDownward = D_80B83A20[sp2C].unk_10; + this->dyna.actor.update = D_80B83A20[sp2C].unk_14; + this->dyna.actor.draw = D_80B83A20[sp2C].unk_18; + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B83A20[sp2C].unk_04); + + if (sp2C == 3) { + D_80B83C70 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00CE00); + } else if (sp2C == 0) { + D_80B83C74 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00D250); + } + + if (sp2C == 0) { + if (sp24 != 0) { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_174 = -0x1C72; + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_174 = 0x1C72; + } + func_80B82454(this, globalCtx); + func_80B8259C(this, globalCtx); + func_80B82DC4(this); + } else if (sp2C == 3) { + this->unk_16C = sp24; + this->unk_170 = sp24; + if (sp24 != 0) { + func_80B83344(this); + } else { + this->unk_178 = 0x1F4; + func_80B833A8(this); + } + } +} + +void BgDblueBalance_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + s32 sp1C = BGDBLUEBALANCE_GET_300(&this->dyna.actor); + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + + if (sp1C == 0) { + if (this->unk_15C != NULL) { + this->unk_15C->unk_164 = NULL; + } + if (this->unk_160 != NULL) { + this->unk_160->unk_164 = NULL; + } + } else if (sp1C == 1) { + if (this->unk_164 != NULL) { + this->unk_164->unk_15C = NULL; + } + } else if (sp1C == 2) { + if (this->unk_164 != NULL) { + this->unk_164->unk_160 = NULL; + } + } +} + +void func_80B82DC4(BgDblueBalance* this) { + this->unk_17D = 20; + this->actionFunc = func_80B82DE0; +} + +void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + f32 sp88 = Math_CosS(this->dyna.actor.shape.rot.z * 2.2499313f); + Actor* actor = &this->dyna.actor; + s32 pad2; + s16 abs; + s32 phi_a0; + s32 phi_a1; + f32 phi_f2; + f32 temp2; + Vec3f sp60; + BgDblueBalance* sp5C; + Vec3f sp50; + s32 pad3; + Vec3f sp40; + BgDblueBalance* sp3C; + Vec3f sp30; + + if (Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + if (this->unk_17D > 0) { + this->unk_17D--; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -300.0f) - 60; + } + } else { + BgDblueBalance* balance1 = this->unk_160; + BgDblueBalance* balance2 = this->unk_15C; + + phi_a0 = 0; + phi_a1 = 1; + this->unk_17D = 20; + if (balance1 != NULL) { + if (balance1->unk_181 != 0) { + phi_a0 = 4; + } else if (balance1->unk_180 != 0) { + phi_a0 = 2; + } + } + + if (balance2 != NULL) { + if (balance2->unk_181 != 0) { + phi_a1 = 5; + } else if (balance2->unk_180 != 0) { + phi_a1 = 3; + } + } + + if (phi_a0 < phi_a1) { + this->unk_174 = 0x1C72; + this->unk_176 = (s32)(sp88 * 370.0f) + 80; + } else { + this->unk_174 = -0x1C72; + this->unk_176 = (s32)(sp88 * -160.0f) - 80; + } + } + + if (this->dyna.actor.shape.rot.z == this->unk_174) { + this->unk_178 = 0; + this->unk_17C = 0; + return; + } + + abs = this->dyna.actor.shape.rot.z - this->unk_174; + abs = ABS_ALT(abs); + + if ((this->unk_17C > 0) && (abs < 0x7D0)) { + phi_a0 = 3; + } else { + phi_a0 = 40; + this->unk_17C = 0; + } + + if (this->unk_176 >= 0) { + this->unk_178 += phi_a0; + if (this->unk_176 < this->unk_178) { + this->unk_178 = this->unk_176; + } + } else { + this->unk_178 -= phi_a0; + if (this->unk_178 < this->unk_176) { + this->unk_178 = this->unk_176; + } + } + + phi_f2 = this->unk_178; + temp2 = this->unk_17A; + if ((phi_f2 * temp2) <= 0.0f) { + func_801A7328(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG); + } + + phi_f2 *= 0.0022222223f; + phi_f2 = fabsf(phi_f2); + if (phi_f2 > 1.0f) { + phi_f2 = 1.0f; + } + + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_SEESAW_INCLINE - SFX_FLAG, phi_f2 + 1.0f); + actor->shape.rot.z += this->unk_178; + + if (this->dyna.actor.shape.rot.z > 0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = 0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp5C = this->unk_15C; + Matrix_StatePush(); + Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(45.0f, &sp60); + Matrix_StatePop(); + + sp50.x = sp5C->dyna.actor.world.pos.x + sp60.x; + sp50.y = this->unk_228; + sp50.z = sp5C->dyna.actor.world.pos.z + sp60.z; + + func_80B8296C(globalCtx, &sp50, 70.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = 0x1C72; + this->unk_178 = 0; + } + } else if (this->dyna.actor.shape.rot.z < -0x1C71) { + if (this->unk_17C < 2) { + actor->shape.rot.z = -0x1C71; + this->unk_178 *= -0.6f; + this->unk_17C++; + if (this->unk_182) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_WATER_BOUND); + sp3C = this->unk_160; + Matrix_StatePush(); + Matrix_RotateY(BINANG_ADD(this->dyna.actor.shape.rot.y, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(30.0f, &sp40); + Matrix_StatePop(); + + sp30.x = sp3C->dyna.actor.world.pos.x + sp40.x; + sp30.y = this->unk_228; + sp30.z = sp3C->dyna.actor.world.pos.z + sp40.z; + + func_80B8296C(globalCtx, &sp30, 47.0f); + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SEESAW_BOUND); + } + } else { + this->dyna.actor.shape.rot.z = -0x1C72; + this->unk_178 = 0; + } + } + func_80B823B0(this); +} + +void BgDblueBalance_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_17A = this->unk_178; + + this->actionFunc(this, globalCtx); + + func_80B828E4(this, globalCtx); +} + +void func_80B8330C(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_180 = DynaPolyActor_IsInSwitchPressedState(&this->dyna); + this->unk_181 = DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna); +} + +void func_80B83344(BgDblueBalance* this) { + this->unk_178 = 0; + this->actionFunc = func_80B8335C; +} + +void func_80B8335C(BgDblueBalance* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor))) { + this->unk_178 = -0x14; + func_80B833A8(this); + } +} + +void func_80B833A8(BgDblueBalance* this) { + this->unk_186 = 0; + this->unk_187 = 0; + this->actionFunc = func_80B833C4; +} + +void func_80B833C4(BgDblueBalance* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s16 sp26; + s16 sp24; + + if (this->unk_170 != 0) { + if ((this->unk_16C == 0) && (this->unk_17F == 0)) { + this->unk_17F = 1; + } + + if (this->unk_186 != 0) { + if (this->unk_178 >= 0x50) { + this->unk_178 -= 5; + } + } + } else { + this->unk_187 = Math_StepToS(&this->unk_178, 0x1F4, 5); + } + + sp26 = this->dyna.actor.shape.rot.x; + this->dyna.actor.shape.rot.x += this->unk_178; + sp24 = this->dyna.actor.shape.rot.x; + if (sp24) {} + + if (this->unk_170 != 0) { + if (this->unk_186 != 0) { + if (func_80B82B00(sp26, sp24, this->unk_184)) { + sp28 = true; + } + } else if (this->unk_187 != 0) { + if (func_80B82B00(sp26, sp24, 0x2097)) { + this->unk_184 = -0x8000; + this->unk_186 = 1; + } else if (func_80B82B00(sp26, sp24, -0x5F69)) { + this->unk_184 = 0; + this->unk_186 = 1; + } + } + } + + func_80B8264C(this); + + if (sp28) { + this->dyna.actor.shape.rot.x = this->unk_184; + func_80B83344(this); + } +} + +void func_80B83518(Actor* thisx, GlobalContext* globalCtx) { + BgDblueBalance* this = THIS; + + this->unk_170 = Flags_GetSwitch(globalCtx, BGDBLUEBALANCE_GET_7F(&this->dyna.actor)); + + this->actionFunc(this, globalCtx); + + if (this->unk_17F == 2) { + this->unk_17E--; + if (this->unk_17E <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + 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); + this->unk_17F = 2; + this->unk_17E = 0x50; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + this->unk_16C = this->unk_170; +} + +void BgDblueBalance_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + BgDblueBalanceStruct2* ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + BgDblueBalance* sp38; + Gfx* gfx; + + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (!(BGDBLUEBALANCE_GET_300(&this->dyna.actor)) && (this->unk_160 != NULL)) { + AnimatedMat_Draw(globalCtx, D_80B83C74); + sp38 = this->unk_160; + Matrix_SetStateRotationAndTranslation(sp38->dyna.actor.world.pos.x, sp38->dyna.actor.world.pos.y, + sp38->dyna.actor.world.pos.z, &sp38->dyna.actor.shape.rot); + Matrix_InsertTranslation(30.0f, 15.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(sp38->dyna.actor.scale.x, sp38->dyna.actor.scale.y, sp38->dyna.actor.scale.z, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(gfx++, 0, 0, 0, this->unk_183); + gSPDisplayList(gfx++, object_dblue_object_DL_00D110); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueBalance* this = THIS; + f32 temp_f0; + Gfx* gfx; + s32 i; + BgDblueBalanceStruct* ptr; + BgDblueBalanceStruct2* ptr2; + s32 temp; + + if (this->unk_178 != 0) { + if (this->unk_178 == 0x1F4) { + temp_f0 = 1.0f; + } else { + temp_f0 = this->unk_178 * 0.002f; + temp_f0 = CLAMP(temp_f0, 0.0f, 1.0f); + } + func_8019FB0C(&this->dyna.actor.projectedPos, NA_SE_EV_SMALL_WATER_WHEEL - SFX_FLAG, temp_f0, 0x20); + } + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + ptr2 = &D_80B83A20[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + + if (this->unk_183 != 0) { + AnimatedMat_Draw(globalCtx, D_80B83C70); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + + for (i = 0, ptr = &this->unk_188[0]; i < ARRAY_COUNT(this->unk_188); i++, ptr++) { + if (ptr->unk_0E != 0) { + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_0C, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_10, ptr->unk_10, ptr->unk_10, MTXMODE_APPLY); + + temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; + gDPSetEnvColor(gfx++, 0, 0, 0, temp); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + } + } + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} 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 8750f4077..16eed26e3 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 @@ -7,11 +7,41 @@ struct BgDblueBalance; typedef void (*BgDblueBalanceActionFunc)(struct BgDblueBalance*, GlobalContext*); +#define BGDBLUEBALANCE_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEBALANCE_GET_300(thisx) (((thisx)->params >> 8) & 3) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ u8 unk_0E; + /* 0x10 */ f32 unk_10; +} BgDblueBalanceStruct; // size = 0x14 + typedef struct BgDblueBalance { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ struct BgDblueBalance* unk_15C; + /* 0x0160 */ struct BgDblueBalance* unk_160; + /* 0x0164 */ struct BgDblueBalance* unk_164; /* 0x0168 */ BgDblueBalanceActionFunc actionFunc; - /* 0x016C */ char unk_16C[0xC0]; + /* 0x016C */ s32 unk_16C; + /* 0x0170 */ s32 unk_170; + /* 0x0174 */ s16 unk_174; + /* 0x0176 */ s16 unk_176; + /* 0x0178 */ s16 unk_178; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s8 unk_17C; + /* 0x017D */ s8 unk_17D; + /* 0x017E */ s8 unk_17E; + /* 0x017F */ s8 unk_17F; + /* 0x0180 */ s8 unk_180; + /* 0x0181 */ s8 unk_181; + /* 0x0182 */ s8 unk_182; + /* 0x0183 */ u8 unk_183; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s8 unk_186; + /* 0x0187 */ s8 unk_187; + /* 0x0188 */ BgDblueBalanceStruct unk_188[8]; + /* 0x0228 */ f32 unk_228; } BgDblueBalance; // size = 0x22C extern const ActorInit Bg_Dblue_Balance_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c index 977c3ed8b..af6ed5fa2 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Elevator/z_bg_dblue_elevator.c @@ -6,7 +6,7 @@ #include "z_bg_dblue_elevator.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDblueElevator*)thisx) 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 aa4a32581..3a12f286d 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 @@ -5,8 +5,10 @@ */ #include "z_bg_dblue_movebg.h" +#include "objects/object_dblue_object/object_dblue_object.h" +#include "overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgDblueMovebg*)thisx) @@ -15,7 +17,33 @@ void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A670(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2B1A0(BgDblueMovebg* this, GlobalContext* globalCtx); +void func_80A2B274(Actor* thisx, GlobalContext* globalCtx); +void func_80A2B308(Actor* thisx, GlobalContext* globalCtx); + +BgDblueMovebg* D_80A2BBF0; + +typedef struct { + u8 unk_00; + u8 unk_01; +} BgDblueMovebgUnkStruct; + +BgDblueMovebgUnkStruct D_80A2BBF4; + +u8 D_80A2B870[][2] = { + { 0x01, 0x01 }, { 0x01, 0x00 }, { 0x02, 0x03 }, { 0x02, 0x01 }, { 0x02, 0x02 }, { 0x02, 0x00 }, { 0x03, 0x07 }, + { 0x03, 0x03 }, { 0x03, 0x05 }, { 0x03, 0x01 }, { 0x03, 0x06 }, { 0x03, 0x02 }, { 0x03, 0x04 }, { 0x03, 0x00 }, +}; + const ActorInit Bg_Dblue_Movebg_InitVars = { ACTOR_BG_DBLUE_MOVEBG, ACTORCAT_BG, @@ -28,46 +56,813 @@ const ActorInit Bg_Dblue_Movebg_InitVars = { (ActorFunc)BgDblueMovebg_Draw, }; -#endif +Gfx* D_80A2B8AC[] = { + NULL, + object_dblue_object_DL_0069D8, + NULL, + NULL, + NULL, + NULL, + object_dblue_object_DL_004848, + object_dblue_object_DL_0061B8, + NULL, + NULL, + NULL, + NULL, +}; -extern UNK_TYPE D_06004848; -extern UNK_TYPE D_060052B8; -extern UNK_TYPE D_06008778; +Gfx* D_80A2B8DC[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_DL_00CAA0, NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A29A80.s") +CollisionHeader* D_80A2B90C[] = { + NULL, + &object_dblue_object_Colheader_006EA8, + NULL, + NULL, + NULL, + &object_dblue_object_Colheader_00D3DC, + &object_dblue_object_Colheader_005D28, + &object_dblue_object_Colheader_00714C, + &object_dblue_object_Colheader_00AED0, + &object_dblue_object_Colheader_00AED0, + NULL, + NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Init.s") +AnimatedMaterial* D_80A2B93C[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_Matanimheader_00CC18, NULL, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Destroy.s") +s16 D_80A2B96C[] = { 0, 0x16C, -0x16C, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A128.s") +s16 D_80A2B974[] = { -1, -1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A1E0.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A32C.s") +Vec3f D_80A2B988 = { 1785.0f, 0.0f, 220.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A444.s") +s32 func_80A29A80(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + s32 sp2C = 1; + s32 val; + s32 val2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A670.s") + if (arg2 < 14) { + val = D_80A2B870[arg2][0]; + val2 = D_80A2B870[arg2][1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A688.s") + while (val--) { + if ((1 << val) & val2) { + if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } + } else { + sp2C = 0; + switch (arg2) { + case 14: + if (!Flags_GetSwitch(globalCtx, arg1)) { + sp2C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A714.s") + if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3)) { + sp2C += 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2A7F8.s") + case 15: + if (!Flags_GetSwitch(globalCtx, arg1) || + (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3))) { + sp2C = 1; + } + break; + } + } + return sp2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2AAB8.s") +void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueMovebg* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2ABD0.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2AED0.s") + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + if (D_80A2BBF4.unk_00 != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_170 = this->dyna.actor.room; + this->dyna.actor.room = -1; + D_80A2BBF4.unk_00 = 1; + this->unk_171 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + } else if (this->unk_160 == 6) { + if (D_80A2BBF4.unk_01 != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + this->unk_171 = this->dyna.actor.world.rot.z; + this->unk_170 = this->dyna.actor.room; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + D_80A2BBF4.unk_01 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B1A0.s") + if (D_80A2B90C[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80A2B90C[this->unk_160]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Update.s") + this->unk_164 = D_80A2B8AC[this->unk_160]; + this->unk_168 = D_80A2B8DC[this->unk_160]; + this->unk_16C = D_80A2B93C[this->unk_160]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B274.s") + SubS_FillCutscenesList(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/func_80A2B308.s") + switch (this->unk_160) { + case 1: + this->unk_1C4 = this->dyna.actor.world.rot.x; + this->unk_1C8 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + this->unk_17E = 0; + this->unk_184 = 0.0f; + if (Flags_GetSwitch(globalCtx, this->unk_1C0)) { + this->unk_18C = 0x384; + } else { + this->unk_18C = 0; + } + this->dyna.actor.shape.rot.y += (s16)((this->unk_18C / 10.0f) * (0x10000 / 360.0f)); + this->actionFunc = func_80A2A714; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Movebg/BgDblueMovebg_Draw.s") + case 6: + this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + this->unk_1CC = D_80A2B96C[this->unk_178]; + this->unk_1CE = this->unk_1CC; + this->actionFunc = func_80A2A1E0; + break; + + case 7: + this->unk_1C4 = this->dyna.actor.world.rot.x; + this->unk_1C8 = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + if (Flags_GetSwitch(globalCtx, this->unk_1C0)) { + Actor_MarkForDeath(&this->dyna.actor); + break; + } + this->unk_18C = 0; + 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->actionFunc = func_80A2A32C; + break; + + case 8: + case 9: + 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]; + } + this->unk_178 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + this->unk_1CC = D_80A2B96C[this->unk_178]; + this->unk_1CE = this->unk_1CC; + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledX(2240.0f, &this->unk_190); + Matrix_GetStateTranslationAndScaledX(-10.0f, &this->unk_19C); + Math_Vec3f_Sum(&this->unk_190, &this->dyna.actor.world.pos, &this->unk_190); + Math_Vec3f_Sum(&this->unk_19C, &this->dyna.actor.world.pos, &this->unk_19C); + D_80A2BBF0 = this; + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->actionFunc = func_80A2AED0; + break; + + case 10: + this->actionFunc = func_80A2B1A0; + break; + + case 11: + this->unk_1CC = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + D_80A2BBF0 = this; + this->dyna.actor.flags |= ACTOR_FLAG_20; + this->dyna.actor.update = Actor_Noop; + this->dyna.actor.draw = func_80A2B274; + break; + } +} + +void BgDblueMovebg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + Audio_StopSfxByPos(&this->unk_1A8); + } +} + +void func_80A2A128(BgDblueMovebg* this, GlobalContext* globalCtx) { + Actor* phi_s0 = NULL; + + while (true) { + phi_s0 = SubS_FindActor(globalCtx, phi_s0, ACTORCAT_BG, ACTOR_OBJ_HUNSUI); + if (phi_s0 != NULL) { + if ((OBJHUNSUI_GET_F000(phi_s0) == 5) && (phi_s0->update != NULL)) { + this->unk_2F8[1] = phi_s0; + } else if ((OBJHUNSUI_GET_F000(phi_s0) == 6) && (phi_s0->update != NULL)) { + this->unk_2F8[0] = phi_s0; + } + phi_s0 = phi_s0->next; + } + + if (phi_s0 == NULL) { + break; + } + } +} + +void func_80A2A1E0(BgDblueMovebg* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + + if (temp_v0 != this->unk_178) { + switch (temp_v0) { + case 1: + case 2: + this->unk_17E = 40; + break; + + case 0: + case 3: + this->unk_17E = 15; + break; + } + } + this->unk_178 = temp_v0; + + if (this->unk_17E <= 0) { + this->unk_1CE = D_80A2B96C[temp_v0]; + } else { + this->unk_17E--; + } + + Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); + this->dyna.actor.shape.rot.y += this->unk_1CC; + + if (globalCtx->roomCtx.currRoom.num == 0) { + this->unk_164 = object_dblue_object_DL_004848; + } else if (globalCtx->roomCtx.currRoom.num == 8) { + this->unk_164 = NULL; + } + + if (globalCtx->roomCtx.currRoom.num != this->unk_170) { + if (globalCtx->roomCtx.currRoom.num != this->unk_171) { + if ((globalCtx->roomCtx.prevRoom.num != this->unk_170) && + (globalCtx->roomCtx.prevRoom.num != this->unk_171)) { + D_80A2BBF4.unk_01 = 0; + Actor_MarkForDeath(&this->dyna.actor); + } + } + } +} + +void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + f32 phi_f0; + s32 phi_v1; + + if (this->dyna.pushForce != 0.0f) { + this->unk_18E = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + this->unk_184 = this->dyna.actor.xzDistToPlayer; + + if (this->dyna.pushForce >= 0.0f) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + if (BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y) > 0) { + phi_v0 = -1; + } else { + phi_v0 = 1; + } + this->unk_17E = phi_v0 * phi_f0; + + phi_v1 = false; + if (this->unk_17E > 0) { + phi_v1 = true; + } + + if (phi_v1) { + this->unk_180 = func_800F2178(this->unk_1B6[0]); + this->unk_1D2 = this->unk_1B6[0]; + this->unk_172 |= 8; + this->actionFunc = func_80A2A444; + } else { + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } +} + +void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20; + Player* temp_a3; + s16 temp_v0; + + this->unk_188++; + this->unk_188 = CLAMP_MAX(this->unk_188, 5); + + 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; + + if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + player->actor.world.pos.x = + (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; + player->actor.world.pos.z = + (Math_CosS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.z; + } else { + this->unk_184 = 0.0f; + } + + if (sp20) { + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + Flags_SetSwitch(globalCtx, this->unk_1C0); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + + if (!(this->unk_174 & 1) && (this->unk_172 & 1)) { + func_801000CC(NA_SE_EV_PIPE_STREAM_START); + } + func_80A2A670(this, globalCtx); + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_COCK_SWITCH_ROLL - SFX_FLAG); + } +} + +void func_80A2A670(BgDblueMovebg* this, GlobalContext* globalCtx) { + this->actionFunc = func_80A2A688; +} + +void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx) { + this->unk_180--; + if (this->unk_180 <= 0) { + ActorCutscene_Stop(this->unk_1B6[0]); + } + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 60.0f, 2.0f) && + (this->unk_180 <= 0)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_80A2A714(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + f32 phi_f0; + + if (this->dyna.pushForce != 0.0f) { + this->unk_18E = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + this->unk_184 = this->dyna.actor.xzDistToPlayer; + if (this->dyna.pushForce >= 0.0f) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + if (BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y) > 0) { + phi_v0 = -1; + } else { + phi_v0 = 1; + } + 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_172 |= 8; + this->actionFunc = func_80A2A7F8; + } +} + +void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp28; + s16 sp26; + s32 temp; + + this->unk_188++; + this->unk_188 = CLAMP_MAX(this->unk_188, 5); + + 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; + + if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + player->actor.world.pos.x = + (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; + player->actor.world.pos.z = + (Math_CosS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.z; + } else { + this->unk_184 = 0.0f; + } + + if (sp28) { + temp = (this->unk_18C + sp26 + 3600) % 3600; + + if ((temp == 900) || (temp == 2700)) { + Flags_SetSwitch(globalCtx, this->unk_1C0); + } else { + Flags_UnsetSwitch(globalCtx, this->unk_1C0); + } + + player->stateFlags1 |= 0x20; + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + this->unk_18C = (this->unk_18C + sp26 + 3600) % 3600; + this->unk_188 = 0; + this->unk_18A = 0; + this->unk_17E = 0; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP); + + if (func_80A29A80(globalCtx, this->unk_1C8, this->unk_1C4)) { + this->unk_172 |= 1; + } else { + this->unk_172 &= ~1; + } + + if (!(this->unk_174 & 1) && (this->unk_172 & 1)) { + func_801000CC(NA_SE_EV_PIPE_STREAM_START); + } + + this->unk_174 = this->unk_172; + this->unk_1D0 = 17; + this->actionFunc = func_80A2AAB8; + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_COCK_SWITCH_ROLL - SFX_FLAG); + } +} + +void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp18; + + if (this->unk_180-- <= 0) { + ActorCutscene_Stop(this->unk_1B6[0]); + } + + sp18 = false; + if ((this->unk_1D0 > 0) && ((D_80A2B974[0] >= 0) || (D_80A2B974[1] >= 0))) { + if (ActorCutscene_GetCurrentIndex() != -1) { + sp18 = true; + } + } + + if (!sp18 && (this->unk_180 <= 0)) { + this->unk_1D0--; + + if (this->unk_1D0 == 1) { + this->dyna.pushForce = 0.0f; + player->stateFlags1 |= 0x20; + player->stateFlags2 &= ~0x10; + } + + if (this->unk_1D0 <= 0) { + player->stateFlags1 &= ~0x20; + this->actionFunc = func_80A2A714; + } + } +} + +void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { + Vec3f spAC; + f32 temp_f0; + f32 temp_f20; + s32 phi_v0; + s32 i; + s32 j; + + for (i = 0; i < ARRAY_COUNT(this->unk_2F8); i++) { + if (this->unk_2F8[i] == NULL) { + func_80A2A128(this, globalCtx); + continue; + } + + for (j = 0; j < ARRAY_COUNT(this->unk_1D8[0]); j++) { + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + (j * 0x2000), MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_80A2B988, &spAC); + Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spAC); + Math_Vec3f_Copy(&this->unk_238[i][j], &spAC); + temp_f20 = spAC.y - this->unk_2F8[i]->world.pos.y; + temp_f0 = Math_Vec3f_DistXZ(&this->unk_2F8[i]->world.pos, &spAC); + + if ((this->unk_300[i][j] != 0) && (temp_f20 <= 12.0f) && (temp_f20 >= 0.0f) && (temp_f0 <= 60.0f)) { + phi_v0 = 1; + } else { + phi_v0 = 1; + phi_v0 = (s64)phi_v0; + if (((temp_f20 >= 0.0f) && ((temp_f20 > 0.0f) || (temp_f0 > 60.f))) || + ((temp_f20 < 0.0f) && ((temp_f20 < -150.0f) || (temp_f0 > 40.0f)))) { + phi_v0 = 0; + } + } + + if (phi_v0) { + this->unk_300[i][j] = i + 1; + Math_StepToF(&this->unk_1F8[i][j], 1.0f, 0.2f); + Math_StepToS(&this->unk_1D8[i][j], 255, 20); + } else { + this->unk_300[i][j] = 0; + Math_StepToF(&this->unk_1F8[i][j], 0.0f, 0.01f); + Math_StepToS(&this->unk_1D8[i][j], 0, 20); + } + } + } +} + +void func_80A2AED0(BgDblueMovebg* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp_v0_3; + + if (globalCtx->roomCtx.currRoom.num != this->unk_170) { + if (globalCtx->roomCtx.currRoom.num != this->unk_171) { + if ((globalCtx->roomCtx.prevRoom.num != this->unk_170) && + (globalCtx->roomCtx.prevRoom.num != this->unk_171)) { + D_80A2BBF4.unk_00 = 0; + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } + } + + temp_v0_3 = func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC); + if (temp_v0_3 != this->unk_178) { + switch (temp_v0_3) { + case 1: + case 2: + this->unk_1D2 = this->unk_1B6[0]; + this->unk_17E = 40; + break; + + case 0: + case 3: + this->unk_1D2 = this->unk_1B6[1]; + this->unk_17E = 15; + break; + } + this->unk_172 |= 8; + } + this->unk_178 = temp_v0_3; + + if (!(this->unk_172 & 8)) { + if (this->unk_17E <= 0) { + this->unk_1CE = D_80A2B96C[temp_v0_3]; + } else { + this->unk_17E--; + } + } + + Math_StepToS(&this->unk_1CC, this->unk_1CE, 12); + this->dyna.actor.shape.rot.x += this->unk_1CC; + + if (this->unk_160 == 8) { + if (globalCtx->roomCtx.currRoom.num == 8) { + func_80A2ABD0(this, globalCtx); + this->unk_172 |= 0x20; + } else { + this->unk_172 &= ~0x20; + } + } + + if (globalCtx->roomCtx.currRoom.num == 0) { + this->unk_164 = object_dblue_object_DL_008778; + } else if (globalCtx->roomCtx.currRoom.num == 8) { + this->unk_164 = object_dblue_object_DL_00A528; + } + + if (this == D_80A2BBF0) { + Vec3f sp54; + f32 sp50; + + if (Math3D_PointDistToLine2D(globalCtx->view.eye.x, globalCtx->view.eye.z, this->unk_190.x, this->unk_190.z, + this->unk_19C.x, this->unk_19C.z, &sp54.x, &sp54.z, &sp50)) { + sp54.y = this->dyna.actor.world.pos.y; + } else { + if (Math_Vec3f_DistXYZ(&globalCtx->view.eye, &this->unk_190) <= + Math_Vec3f_DistXYZ(&globalCtx->view.eye, &this->unk_19C)) { + Math_Vec3f_Copy(&sp54, &this->unk_190); + } else { + Math_Vec3f_Copy(&sp54, &this->unk_19C); + } + } + + SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &sp54, &this->unk_1A8); + this->unk_1D4 = ABS(this->unk_1CC) / 364.0f; + } +} + +void func_80A2B1A0(BgDblueMovebg* this, GlobalContext* globalCtx) { + switch (func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)) { + case 1: + this->dyna.actor.shape.rot.z = this->dyna.actor.home.rot.z; + break; + + case 2: + this->dyna.actor.shape.rot.z = BINANG_ROT180(this->dyna.actor.home.rot.z); + break; + } +} + +void BgDblueMovebg_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_172 & 8) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->unk_1D2, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + this->unk_172 &= ~8; + } + } +} + +void func_80A2B274(Actor* thisx, GlobalContext* globalCtx) { + BgDblueMovebg* this = THIS; + s16 temp_v1; + + if (this != D_80A2BBF0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + temp_v1 = D_80A2B96C[func_80A29A80(globalCtx, this->unk_1C0, this->unk_1BC)]; + if (temp_v1 != 0) { + if (temp_v1 > 0) { + func_8019FC20(&this->dyna.actor.projectedPos, NA_SE_EV_DUMMY_WATER_WHEEL_RR - SFX_FLAG); + } else { + func_8019FC20(&this->dyna.actor.projectedPos, NA_SE_EV_DUMMY_WATER_WHEEL_LR - SFX_FLAG); + } + } +} + +void func_80A2B308(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueMovebg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_164); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgDblueMovebg* this = THIS; + s32 i; + s32 j; + Gfx* gfx; + Gfx* gfx2; + + Matrix_StatePush(); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_160 == 9) || (this->unk_160 == 8) || (this->dyna.actor.flags & ACTOR_FLAG_40)) { + if (this->unk_16C != NULL) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(this->unk_16C)); + } + + if ((this->unk_164 != 0) || (this->unk_160 == 6)) { + gfx2 = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + + gSPMatrix(&gfx2[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_160 == 6) { + gSPDisplayList(&gfx2[1], object_dblue_object_DL_0052B8); + if (this->unk_164 != 0) { + gSPDisplayList(&gfx2[2], this->unk_164); + POLY_OPA_DISP = &gfx2[3]; + } else { + POLY_OPA_DISP = &gfx2[2]; + } + } else { + gSPDisplayList(&gfx2[1], this->unk_164); + POLY_OPA_DISP = &gfx2[2]; + } + } + + if (this->unk_168 != NULL) { + gfx = func_8012C2B4(POLY_XLU_DISP); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], this->unk_168); + + POLY_XLU_DISP = &gfx[2]; + } + } + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if ((this->unk_160 == 8) && (this->unk_172 & 0x20)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_dblue_object_Matanimheader_00CE00)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + gfx = func_8012C2B4(POLY_XLU_DISP); + + for (i = 0; i < ARRAY_COUNT(this->unk_1D8[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_1D8); j++) { + if (this->unk_1D8[j][i] > 0) { + if (this->unk_1F8[j][i] > 0.1f) { + gSPSegment( + gfx++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, + (s32)(((globalCtx->gameplayFrames % 128) * -9.0f) / this->unk_1F8[j][i]), + 0x20, 0x20, 1, 0, 0, 0x20, 0x20)); + } + Matrix_StatePush(); + Matrix_InsertXRotation_s(i * 0x2000, MTXMODE_APPLY); + Matrix_InsertTranslation(1785.0f, 0.0f, 270.0f, MTXMODE_APPLY); + if (j != 0) { + Matrix_InsertZRotation_s(-0x8000, MTXMODE_APPLY); + } + Matrix_Scale(this->unk_1F8[j][i] * this->dyna.actor.scale.x, + this->unk_1F8[j][i] * this->dyna.actor.scale.y, + this->unk_1F8[j][i] * this->dyna.actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(gfx++, 255, 255, 255, this->unk_1D8[j][i]); + gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + + Matrix_StatePop(); + } + } + } + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if ((this->unk_160 == 9) || (this->unk_160 == 8)) { + if (this->unk_1CC >= 0) { + func_8019FB0C(&this->unk_1A8, NA_SE_EV_BIG_WATER_WHEEL_RR - SFX_FLAG, this->unk_1D4, 32); + } else { + func_8019FB0C(&this->unk_1A8, NA_SE_EV_BIG_WATER_WHEEL_LR - SFX_FLAG, this->unk_1D4, 32); + } + } +} 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 aeef09c87..b48776238 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 @@ -7,11 +7,52 @@ struct BgDblueMovebg; typedef void (*BgDblueMovebgActionFunc)(struct BgDblueMovebg*, GlobalContext*); +#define BGDBLUEMOVEBG_GET_F(thisx) ((thisx)->params & 0xF) +#define BGDBLUEMOVEBG_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) +#define BGDBLUEMOVEBG_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) + +#define BGDBLUEMOVEBG_F_8 8 + typedef struct BgDblueMovebg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgDblueMovebgActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x210]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgDblueMovebgActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ Gfx* unk_164; + /* 0x168 */ Gfx* unk_168; + /* 0x16C */ TexturePtr unk_16C; + /* 0x170 */ s8 unk_170; + /* 0x171 */ s8 unk_171; + /* 0x172 */ u16 unk_172; + /* 0x174 */ u16 unk_174; + /* 0x178 */ s32 unk_178; + /* 0x17C */ UNK_TYPE1 unk17C[2]; + /* 0x17E */ s16 unk_17E; + /* 0x180 */ s16 unk_180; + /* 0x184 */ f32 unk_184; + /* 0x188 */ s16 unk_188; + /* 0x18A */ s16 unk_18A; + /* 0x18C */ s16 unk_18C; + /* 0x18E */ s16 unk_18E; + /* 0x190 */ Vec3f unk_190; + /* 0x19C */ Vec3f unk_19C; + /* 0x1A8 */ Vec3f unk_1A8; + /* 0x1B4 */ UNK_TYPE1 unk1B4[2]; + /* 0x1B6 */ s16 unk_1B6[2]; + /* 0x1BC */ s32 unk_1BC; + /* 0x1C0 */ s32 unk_1C0; + /* 0x1C4 */ s32 unk_1C4; + /* 0x1C8 */ s32 unk_1C8; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ s16 unk_1D0; + /* 0x1D2 */ s16 unk_1D2; + /* 0x1D4 */ f32 unk_1D4; + /* 0x1D8 */ s16 unk_1D8[2][8]; + /* 0x1F8 */ f32 unk_1F8[2][8]; + /* 0x238 */ Vec3f unk_238[2][8]; + /* 0x2F8 */ Actor* unk_2F8[2]; + /* 0x300 */ u8 unk_300[2][8]; + /* 0x310 */ UNK_TYPE1 unk310[0x60]; } BgDblueMovebg; // size = 0x370 extern const ActorInit Bg_Dblue_Movebg_InitVars; 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 fac369ac6..cd3b8a9d6 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 @@ -5,8 +5,9 @@ */ #include "z_bg_dblue_waterfall.h" +#include "objects/object_dblue_object/object_dblue_object.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgDblueWaterfall*)thisx) @@ -15,12 +16,15 @@ void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx); void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx); +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx); void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Dblue_Waterfall_InitVars = { ACTOR_BG_DBLUE_WATERFALL, ACTORCAT_PROP, @@ -33,69 +37,596 @@ const ActorInit Bg_Dblue_Waterfall_InitVars = { (ActorFunc)BgDblueWaterfall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B85370 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00CBFBB0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00CBFBB0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 740, -740, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B853A8[] = { +Color_RGBA8 D_80B8539C = { 200, 255, 255, 255 }; +Color_RGBA8 D_80B853A0 = { 200, 200, 200, 0 }; + +s32 func_80B83C80(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 0.0000010000001f) { + return false; + } + + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + + return true; +} + +s32 func_80B83D04(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 phi_v1; + s32 sp18 = BGDBLUEWATERFALL_GET_100(&this->actor); + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + phi_v1 = true; + } else { + phi_v1 = false; + } + return phi_v1 ^ sp18; +} + +s32 func_80B83D58(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + if (Flags_GetSwitch(globalCtx, BGDBLUEWATERFALL_GET_7F(&this->actor))) { + return false; + } + return true; +} + +void func_80B83D94(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 != sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83E1C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20 = BGDBLUEWATERFALL_GET_7F(&this->actor); + s32 sp1C = BGDBLUEWATERFALL_GET_100(&this->actor); + s32 phi_v0; + + if (Flags_GetSwitch(globalCtx, sp20)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (phi_v0 == sp1C) { + if (phi_v0) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + } +} + +void func_80B83EA4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 i; + s32 temp_s1; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + Vec3f spA4; + Vec3f sp98; + s32 phi_s3; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + f32 temp_f0_2; + f32 temp_f20; + + spB0.x = this->collider.info.bumper.hitPos.x; + spB0.y = this->collider.info.bumper.hitPos.y; + spB0.z = this->collider.info.bumper.hitPos.z; + + sp98.x = spB0.x - this->actor.world.pos.x; + sp98.y = 0.0f; + sp98.z = spB0.z - this->actor.world.pos.z; + + if (!func_80B83C80(&sp98, &spA4)) { + Math_Vec3f_Copy(&spA4, &gZeroVec3f); + } + + sp98.y = 0.0f; + spBC.y = -1.4f; + + for (i = 0, phi_s3 = 0; i < 15; i++, phi_s3 += 0x1111) { + temp_s1 = (s32)(Rand_ZeroOne() * 4369.0f) + phi_s3; + temp_f0_2 = Rand_ZeroOne(); + temp_f20 = 1.0f - SQ(temp_f0_2); + + sp98.x = Math_SinS(temp_s1) * temp_f20; + sp98.z = Math_CosS(temp_s1) * temp_f20; + temp_f20 *= 5.0f; + + spD4.x = (sp98.x * temp_f20) + spB0.x; + spD4.y = ((Rand_ZeroOne() * 16.0f) - 8.0f) + spB0.y; + spD4.z = (sp98.z * temp_f20) + spB0.z; + + spC8.x = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.x * 3.0f) + (sp98.x * 5.0f)); + spC8.y = (Rand_ZeroOne() * 10.0f) + 5.0f; + spC8.z = ((2.0f * Rand_ZeroOne()) - 1.0f) + ((spA4.z * 3.0f) + (sp98.z * 5.0f)); + + spBC.x = spC8.x * -0.02f; + spBC.z = spC8.z * -0.02f; + + EffectSsEnIce_Spawn(globalCtx, &spD4, (Rand_ZeroOne() * 0.3f) + 0.1f, &spC8, &spBC, &D_80B8539C, + &D_80B853A0, 30); + } + } +} + +void func_80B841A0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + Vec3f sp94; + s32 i; + f32 temp_f0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + s32 temp_s3; + s32 phi_s2; + + if (this->collider.info.bumperFlags & BUMP_HIT) { + temp_f22 = this->collider.info.bumper.hitPos.x; + temp_f24 = this->collider.info.bumper.hitPos.y; + temp_f26 = this->collider.info.bumper.hitPos.z; + + for (i = 0, phi_s2 = 0; i < 10; i++, phi_s2 += 0x1999) { + temp_s3 = (s32)(Rand_ZeroOne() * 6553.0f) + phi_s2; + temp_f0 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f0)) * 14.0f; + + sp94.x = (Math_SinS(temp_s3) * temp_f20) + temp_f22; + sp94.y = ((Rand_ZeroOne() * 20.0f) - 10.0f) + temp_f24; + sp94.z = (Math_CosS(temp_s3) * temp_f20) + temp_f26; + + EffectSsGSplash_Spawn(globalCtx, &sp94, NULL, NULL, 0, 250); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_REFLECTION_WATER); + } +} + +void func_80B84348(BgDblueWaterfall* this, GlobalContext* globalCtx, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, + f32 arg7, s32 arg8) { + static s16 D_80B853A4 = 0; + s32 pad; + f32 spB8 = 1.0f / arg8; + s32 i; + f32 spB0 = this->actor.world.pos.y + arg3; + s32 pad2; + f32 temp_f22; + f32 temp_f24; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + f32 temp_f26; + f32 temp_f20; + + for (i = 0; i < arg8; i++) { + D_80B853A4 += 0x4E20; + + temp_f20 = Math_SinS(D_80B853A4); + temp_f24 = (Rand_ZeroOne() * (arg2 - arg3)) + (spB8 * i); + temp_f22 = Math_CosS(D_80B853A4); + temp_f26 = ((Rand_ZeroOne() * 0.8f) + 0.2f) * arg4; + + sp8C.x = temp_f20 * temp_f26; + sp8C.y = (Rand_ZeroOne() * 4.0f) + arg5; + sp8C.z = temp_f22 * temp_f26; + + sp80.x = sp8C.x * -0.016f; + sp80.y = sp8C.y * -0.015f; + sp80.z = sp8C.z * -0.016f; + + sp98.x = (temp_f20 * 50.0f) + this->actor.world.pos.x; + sp98.y = temp_f24 + spB0; + sp98.z = (temp_f22 * 50.0f) + this->actor.world.pos.z; + + EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (Rand_ZeroOne() * arg7) + arg6); + } +} + +void func_80B84568(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* sp40; + WaterBox* sp3C; + s32 sp38; + f32 sp34 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp40, &sp38, &this->actor, &this->actor.world.pos); + f32 sp30; + + if (WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &sp3C)) { + if (sp30 < sp34) { + this->unk_198 = sp34; + } else { + this->unk_198 = sp30; + } + } else { + this->unk_198 = sp34; + } +} + +void func_80B84610(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f sp34; + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1A7 <= 0) { + this->unk_1A7 = 16; + } else { + this->unk_1A7 -= (s8)((u32)Rand_Next() >> 0x1F); + } + + if (this->unk_1A7 >= 6) { + this->unk_1A8 += Rand_ZeroOne() * 0.1f; + if (this->unk_1A8 > 0.5f) { + this->unk_1A8 = 0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } else { + this->unk_1A8 -= Rand_ZeroOne() * 0.2f; + if (this->unk_1A8 > -0.5f) { + this->unk_1A8 = -0.5f; + } else { + this->unk_1A8 = this->unk_1A8; + } + } + + Matrix_StatePush(); + Matrix_RotateY(BINANG_ADD(this->actor.yawTowardsPlayer, 0x4000), MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(this->unk_1A8, &sp34); + Matrix_StatePop(); + + player->actor.world.pos.x += sp34.x; + player->actor.world.pos.z += sp34.z; + if (this && this && this) {} + player->unk_B80 = 8.0f; + player->unk_B84 = this->actor.yawTowardsPlayer; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgDblueWaterfall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; -extern ColliderCylinderInit D_80B85370; -extern InitChainEntry D_80B853A8[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = 0; -extern UNK_TYPE D_0600B280; -extern UNK_TYPE D_0600B448; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83C80.s") + this->unk_190 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00B448); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D04.s") + Actor_SetFocus(&this->actor, -100.0f); + func_80B84568(this, globalCtx); + func_80B8484C(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D58.s") +void BgDblueWaterfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83D94.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83E1C.s") +void func_80B8484C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = func_80B83D04(this, globalCtx); + s32 sp1C = this->actor.home.rot.z * 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B83EA4.s") + if (temp) { + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->collider.dim.radius = 55; + this->collider.dim.height = 150; + this->collider.dim.yShift = -150; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->collider.dim.radius = 50; + this->collider.dim.height = 740; + this->collider.dim.yShift = -740; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B841A0.s") + if ((sp1C != 0) && !func_80B83D58(&this->actor, globalCtx)) { + this->unk_19C = sp1C; + } else { + this->unk_19C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84348.s") + this->unk_1A3 = false; + this->actionFunc = func_80B84928; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84568.s") +void func_80B84928(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = func_80B83D04(this, globalCtx); + s32 sp2C = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp28 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84610.s") + if (sp2C) { + this->collider.base.acFlags &= ~AC_HIT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Init.s") + if ((sp30 == 0) && (this->collider.base.ocFlags2 & OC2_HIT_PLAYER)) { + func_80B84610(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Destroy.s") + if (this->unk_19C > 0) { + this->unk_19C--; + if (this->unk_19C == 0) { + if (sp30 != 0) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + sp28 = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B8484C.s") + if (!sp28) { + if (sp2C) { + if (sp30 != 0) { + func_80B83EA4(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800) { + this->unk_1A4 = this->actor.cutscene; + func_80B84AD4(this, globalCtx); + } + } else { + func_80B841A0(this, globalCtx); + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x1000) { + this->unk_1A4 = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + func_80B84AD4(this, globalCtx); + } + } + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84928.s") +void func_80B84AD4(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->actionFunc = func_80B84AEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AD4.s") +void func_80B84AEC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84AEC.s") + if (ActorCutscene_GetCanPlayNext(this->unk_1A4)) { + sp20 = func_80B83D04(this, globalCtx); + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1A4, &this->actor); + this->unk_1A3 = true; + if (sp20) { + func_80B83D94(this, globalCtx); + func_80B84EF0(this, globalCtx); + } else { + func_80B83E1C(this, globalCtx); + func_80B84B9C(this, globalCtx); + } + } else { + ActorCutscene_SetIntentToPlay(this->unk_1A4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84B9C.s") +void func_80B84B9C(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 255; + this->unk_19F = 0; + this->unk_1A0 = 0; + this->actionFunc = func_80B84BCC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84BCC.s") +void func_80B84BCC(BgDblueWaterfall* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84EF0.s") + this->unk_19C--; + if (this->unk_19C > 0) { + s32 sp38 = this->unk_19C & 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/func_80B84F20.s") + if (this->unk_19C > 56) { + func_80B84348(this, globalCtx, 0.0f, -5500.0f, 0.4f, -15.0f, 370.0f, 100.0f, 6); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Update.s") + if (!sp38) { + if ((this->unk_19C < 24) && (this->unk_19C > 10)) { + if (this->unk_198 > -32000.0f) { + func_80B84348(this, globalCtx, (this->unk_198 - this->actor.world.pos.y) + 50.0f, + (this->unk_198 - this->actor.world.pos.y), 7.0f, -1.0f, 280.0f, 100.0f, 3); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dblue_Waterfall/BgDblueWaterfall_Draw.s") + if (this->unk_19C > 50) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 0.6f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 40) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.0f, -12.0f, 370.0f, 100.0f, 2); + } else if (this->unk_19C > 20) { + func_80B84348(this, globalCtx, 0.0f, -400.0f, 1.8f, -12.0f, 370.0f, 100.0f, 2); + } + } + + if (this->unk_19E > 6) { + this->unk_19E -= 6; + } else { + this->unk_19E = 0; + } + + if (this->unk_19C >= 55) { + if (this->unk_1A0 < 205) { + this->unk_1A0 += 50; + } else { + this->unk_1A0 = 255; + } + } else if (this->unk_19C >= 36) { + if (this->unk_1A0 >= 16) { + this->unk_1A0 -= 15; + } else { + this->unk_1A0 = 0; + } + } else { + this->unk_1A0 = 0; + } + + if (this->unk_19C < 60) { + if (this->unk_19F < 245) { + this->unk_19F += 10; + } else { + this->unk_19F = 255; + } + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void func_80B84EF0(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C = 60; + this->unk_19E = 0; + this->unk_19F = 255; + this->unk_1A0 = 0; + this->actionFunc = func_80B84F20; +} + +void func_80B84F20(BgDblueWaterfall* this, GlobalContext* globalCtx) { + this->unk_19C--; + + if (this->unk_19C > 0) { + if (this->unk_19C >= 58) { + func_80B84348(this, globalCtx, 100.0f, -100.0f, 4.0f, -6.0f, 370.0f, 100.0f, 0xC); + } + + if (this->unk_19C < 50) { + if (this->unk_19E < 250) { + this->unk_19E += 5; + } else { + this->unk_19E = 255; + } + } + + if (this->unk_19F >= 6) { + this->unk_19F -= 5; + } else { + this->unk_19F = 0; + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + } else { + if (this->unk_1A3) { + ActorCutscene_Stop(this->unk_1A4); + } + func_80B8484C(this, globalCtx); + } +} + +void BgDblueWaterfall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDblueWaterfall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgDblueWaterfall_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgDblueWaterfall* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_19E > 0) { + s32 sp38 = this->unk_19E * 0.49803922f; + + AnimatedMat_Draw(globalCtx, this->unk_190); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x8A, 255, 255, 255, sp38); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_00B280); + } + + if (this->unk_19F > 0) { + if (this->unk_19F < 255) { + gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003358); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x09, D_801AEFA0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x9B, 255, 255, 255, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dblue_object_DL_003358); + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_19F); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003250); + } + + if (this->unk_1A0 > 0) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_1A0); + gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003770); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 eb12538fc..0fa908629 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 @@ -7,11 +7,25 @@ struct BgDblueWaterfall; typedef void (*BgDblueWaterfallActionFunc)(struct BgDblueWaterfall*, GlobalContext*); +#define BGDBLUEWATERFALL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define BGDBLUEWATERFALL_GET_100(thisx) (((thisx)->params >> 8) & 1) + typedef struct BgDblueWaterfall { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ AnimatedMaterial* unk_190; /* 0x0194 */ BgDblueWaterfallActionFunc actionFunc; - /* 0x0198 */ char unk_198[0x14]; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ u8 unk_19E; + /* 0x019F */ u8 unk_19F; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ UNK_TYPE1 unk1A1[2]; + /* 0x01A3 */ s8 unk_1A3; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ UNK_TYPE1 unk1A6[1]; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ f32 unk_1A8; } BgDblueWaterfall; // size = 0x1AC extern const ActorInit Bg_Dblue_Waterfall_InitVars; diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 1423328a1..4e9bf5c63 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -6,7 +6,7 @@ #include "z_bg_dy_yoseizo.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((BgDyYoseizo*)thisx) 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 e916d005c..1e8c369fb 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 @@ -5,8 +5,9 @@ */ #include "z_bg_f40_block.h" +#include "objects/object_f40_obj/object_f40_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Block*)thisx) @@ -15,7 +16,16 @@ void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx); +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx); + const ActorInit Bg_F40_Block_InitVars = { ACTOR_BG_F40_BLOCK, ACTORCAT_BG, @@ -28,55 +38,340 @@ const ActorInit Bg_F40_Block_InitVars = { (ActorFunc)BgF40Block_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4668[] = { +static Vec3f D_80BC4620[] = { + { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, + { -1.0f, 0.0f, 0.0f }, { 0.0f, -1.0f, 0.0f }, { 0.0f, 0.0f, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +s32 func_80BC3980(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -extern InitChainEntry D_80BC4668[]; + this->unk_160 = 0; + this->unk_164 = 0; -extern UNK_TYPE D_060043D0; -extern UNK_TYPE D_06004640; + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3980.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3A2C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3B00.s") +s32 func_80BC3A2C(BgF40Block* this, GlobalContext* globalCtx) { + Vec3s* points; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3CA4.s") + this->unk_160 = this->path->count - 1; + this->unk_164 = this->path->count - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3D08.s") + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + if (this->path != NULL) { + points = Lib_SegmentedToVirtual(this->path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4038.s") + this->dyna.actor.world.pos.x = points->x; + this->dyna.actor.world.pos.y = points->y; + this->dyna.actor.world.pos.z = points->z; + } + } else { + this->path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Init.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Destroy.s") +s32 func_80BC3B00(BgF40Block* this) { + s32 pad; + Path* path; + Vec3s* points; + Vec3f sp28; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC41AC.s") + if (this->path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4228.s") + if (this->unk_160 == this->unk_164) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4344.s") + path = this->path; + points = Lib_SegmentedToVirtual(path->points); + points += this->unk_164; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4380.s") + sp28.x = points->x; + sp28.y = points->y; + sp28.z = points->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC43CC.s") + if (this->unk_168 == 6) { + sp24.x = sp28.x - this->dyna.actor.world.pos.x; + sp24.y = sp28.y - this->dyna.actor.world.pos.y; + sp24.z = sp28.z - this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4448.s") + if (sp24.x > 10.0f) { + this->unk_168 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC44F4.s") + if (sp24.y > 10.0f) { + this->unk_168 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4530.s") + if (sp24.z > 10.0f) { + this->unk_168 = 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC457C.s") + if (sp24.x < -10.0f) { + this->unk_168 = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Update.s") + if (sp24.y < -10.0f) { + this->unk_168 = 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Draw.s") + if (sp24.z < -10.0f) { + this->unk_168 = 5; + } + } + + if (Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &sp28, this->dyna.actor.speedXZ) <= 0.0f) { + this->unk_168 = 6; + this->unk_160 = this->unk_164; + return true; + } + return false; +} + +s32 func_80BC3CA4(BgF40Block* this) { + if (this->dyna.actor.cutscene == -1) { + return true; + } + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + return true; + } + + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + return false; +} + +s32 func_80BC3D08(BgF40Block* this, GlobalContext* globalCtx, s32 arg2) { + CollisionPoly* sp54; + Vec3f sp48; + Vec3f sp3C; + Vec3f sp30; + + if (this->unk_168 == 6) { + return false; + } + + if (arg2 != 0) { + sp48.x = + (D_80BC4620[this->unk_168].x * ((800.0f * this->dyna.actor.scale.x) - (this->dyna.actor.speedXZ * 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))) + + 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))) + + 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; + } 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); + } + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp48, &sp3C, &sp30, &sp54, true)) { + if (arg2 == 0) { + this->dyna.actor.world.pos.x -= sp3C.x - sp30.x; + this->dyna.actor.world.pos.y -= sp3C.y - sp30.y; + this->dyna.actor.world.pos.z -= sp3C.z - sp30.z; + } + return true; + } + + return false; +} + +void func_80BC4038(BgF40Block* this) { + s32 temp = this->unk_160; + + this->unk_160 = this->unk_164; + this->unk_164 = temp; + this->unk_168 = 6; +} + +void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_obj_Colheader_004640); + + if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { + this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; + } else { + this->path = NULL; + } + + if (this->path != NULL) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4530; + this->dyna.actor.speedXZ = 40.0f; + func_80BC3A2C(this, globalCtx); + } else { + this->actionFunc = func_80BC4380; + this->dyna.actor.speedXZ = 20.0f; + func_80BC3980(this, globalCtx); + } + } else { + this->actionFunc = func_80BC457C; + } + this->unk_168 = 6; +} + +void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC44F4; + } + } else { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 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); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC41AC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + return; + } + + switch (this->unk_168) { + case 0: + case 3: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_X - SFX_FLAG); + break; + + case 1: + case 4: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Y - SFX_FLAG); + break; + + case 2: + case 5: + func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Z - SFX_FLAG); + break; + } +} + +void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4228; + } +} + +void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC4344; + } +} + +void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3D08(this, globalCtx, 1)) { + if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + func_80BC4038(this); + this->actionFunc = func_80BC4344; + } + } else { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3B00(this)) { + this->dyna.actor.speedXZ = 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); + } + } + + if (func_80BC3D08(this, globalCtx, 0)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->actionFunc = func_80BC43CC; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F); + } +} + +void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx) { + if (func_80BC3CA4(this)) { + this->actionFunc = func_80BC4448; + } +} + +void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) { + this->actionFunc = func_80BC44F4; + } +} + +void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx) { +} + +void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Block* this = THIS; + + this->actionFunc(this, globalCtx); + + Math_Vec3f_Copy(&this->dyna.actor.focus.pos, &this->dyna.actor.world.pos); +} + +void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_f40_obj_DL_0043D0); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h index 92b1d1e9e..cf9dfb03b 100644 --- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h +++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h @@ -7,9 +7,15 @@ struct BgF40Block; typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, GlobalContext*); +#define BGF40BLOCK_GET_PATH(thisx) (((thisx)->params & 0x1FC) >> 2) +#define BGF40BLOCK_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct BgF40Block { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x28]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ Path* path; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; /* 0x016C */ BgF40BlockActionFunc actionFunc; } BgF40Block; // size = 0x170 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 fb8736181..7805a6e54 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 @@ -6,7 +6,7 @@ #include "z_bg_f40_flift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Flift*)thisx) 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 45cfbf74c..5278a4b73 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 @@ -5,8 +5,9 @@ */ #include "z_bg_f40_switch.h" +#include "objects/object_f40_switch/object_f40_switch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Switch*)thisx) @@ -15,13 +16,13 @@ void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx); void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BC4B20(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4B94(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4BB8(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4C68(BgF40Switch* this, GlobalContext* globalCtx); -void func_80BC4D30(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx); +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_F40_Switch_InitVars = { ACTOR_BG_F40_SWITCH, ACTORCAT_SWITCH, @@ -34,37 +35,159 @@ const ActorInit Bg_F40_Switch_InitVars = { (ActorFunc)BgF40Switch_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC4E04[] = { +s32 sBgF40SwitchGlobalsInitialized = false; +u32 sBgF40SwitchLastUpdateFrame; + +/* + * Updates all instances of this actor in the current room, unless it's already been called this frame. + */ +void BgF40Switch_CheckAll(BgF40Switch* this, GlobalContext* globalCtx) { + if (globalCtx->gameplayFrames != sBgF40SwitchLastUpdateFrame) { + u32 pressedSwitchFlags[4] = { 0 }; + u32 pad; + s32 switchFlag; + s32 isPressed; + Actor* actor; + BgF40Switch* actorAsSwitch; + u32 inCsMode = Player_InCsMode(&globalCtx->state); + + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + 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); + 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. + if (isPressed || inCsMode) { + actorAsSwitch->switchReleaseDelay = 6; + } else { + if (actorAsSwitch->switchReleaseDelay > 0) { + actorAsSwitch->switchReleaseDelay--; + } else { + actorAsSwitch->isPressed = isPressed; + } + } + } else { + // No delay when pressing switch, or releasing from a not-fully-pressed state. + actorAsSwitch->isPressed = isPressed; + } + if (actorAsSwitch->isPressed) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(&actorAsSwitch->dyna.actor); + if (switchFlag >= 0 && switchFlag < 0x80) { + pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] |= 1 << (switchFlag & 0x1F); + if (!actorAsSwitch->wasPressed && actorAsSwitch->actionFunc == BgF40Switch_IdleUnpressed && + !Flags_GetSwitch(globalCtx, switchFlag)) { + actorAsSwitch->isInitiator = true; + } + } + } + } + } + for (actor = globalCtx->actorCtx.actorLists[ACTORCAT_SWITCH].first; actor != NULL; actor = actor->next) { + if (actor->id == ACTOR_BG_F40_SWITCH && actor->room == this->dyna.actor.room && actor->update != 0) { + switchFlag = BGF40SWITCH_GET_SWITCHFLAG(actor); + if (switchFlag >= 0 && switchFlag < 0x80 && Flags_GetSwitch(globalCtx, switchFlag) && + !(pressedSwitchFlags[(switchFlag & ~0x1F) >> 5] & (1 << (switchFlag & 0x1F)))) { + Flags_UnsetSwitch(globalCtx, switchFlag); + } + } + } + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 123, ICHAIN_STOP), }; -#endif +void BgF40Switch_Init(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -extern InitChainEntry D_80BC4E04[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + 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_LoadMesh(globalCtx, &this->dyna, &object_f40_switch_Colheader_000118); + if (!sBgF40SwitchGlobalsInitialized) { + sBgF40SwitchLastUpdateFrame = globalCtx->gameplayFrames; + sBgF40SwitchGlobalsInitialized = true; + } +} -extern UNK_TYPE D_06000118; -extern UNK_TYPE D_06000438; +void BgF40Switch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC47B0.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Init.s") +void BgF40Switch_Unpress(BgF40Switch* this, GlobalContext* globalCtx) { + 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); + this->actionFunc = BgF40Switch_IdleUnpressed; + this->dyna.actor.scale.y = 0.165f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Destroy.s") +void BgF40Switch_IdlePressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isPressed) { + this->actionFunc = BgF40Switch_Unpress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B20.s") +void BgF40Switch_Press(BgF40Switch* this, GlobalContext* globalCtx) { + 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); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + if (this->isInitiator) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->isInitiator = false; + } + this->actionFunc = BgF40Switch_IdlePressed; + this->dyna.actor.scale.y = 0.0165f; + this->switchReleaseDelay = 6; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4B94.s") +void BgF40Switch_WaitToPress(BgF40Switch* this, GlobalContext* globalCtx) { + if (!this->isInitiator || this->dyna.actor.cutscene == -1) { + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + } else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->actionFunc = BgF40Switch_Press; + if (this->isInitiator) { + Flags_SetSwitch(globalCtx, BGF40SWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4BB8.s") +void BgF40Switch_IdleUnpressed(BgF40Switch* this, GlobalContext* globalCtx) { + if (this->isPressed) { + this->actionFunc = BgF40Switch_WaitToPress; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4C68.s") +void BgF40Switch_Update(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/func_80BC4D30.s") + BgF40Switch_CheckAll(this, globalCtx); + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Update.s") +void BgF40Switch_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgF40Switch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Switch/BgF40Switch_Draw.s") + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000438); + Gfx_DrawDListOpa(globalCtx, object_f40_switch_DL_000390); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h index 8b4f2b679..8d4e64603 100644 --- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h +++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h @@ -5,11 +5,18 @@ struct BgF40Switch; +#define BGF40SWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef void (*BgF40SwitchActionFunc)(struct BgF40Switch*, GlobalContext*); typedef struct BgF40Switch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x20]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it + /* 0x015E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly. + /* 0x015F */ s8 wasPressed; // used as temporary during update function + // true if this switch is the one that initiated a state change; false if this switch is changing as a result of another switch tied to the same flag. + // this is a temporary flag related to something currently happening, not a permanent property of the switch. + /* 0x0160 */ s8 isInitiator; /* 0x0164 */ BgF40SwitchActionFunc actionFunc; } BgF40Switch; // size = 0x168 diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c index 672ba1f46..9d84f191c 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c @@ -6,7 +6,7 @@ #include "z_bg_f40_swlift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgF40Swlift*)thisx) 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 8bfdc7a2f..307d0fd0a 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 @@ -7,7 +7,7 @@ #include "z_bg_fu_kaiten.h" #include "objects/object_fu_kaiten/object_fu_kaiten.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgFuKaiten*)thisx) 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 15ac358ca..a8d54222d 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 @@ -6,7 +6,7 @@ #include "z_bg_fu_mizu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgFuMizu*)thisx) 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 dee311742..d064a3cb4 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 @@ -7,7 +7,7 @@ #include "z_bg_goron_oyu.h" #include "objects/object_oyu/object_oyu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgGoronOyu*)thisx) @@ -91,7 +91,7 @@ void func_80B401F8(BgGoronOyu* this, GlobalContext* globalCtx) { if (dist.x >= 0.0f && dist.x <= this->waterBoxXLength && dist.z >= 0.0f && dist.z <= this->waterBoxZLength && fabsf(dist.y) < 100.0f && player->actor.depthInWater > 12.0f) { - Actor_PickUp(&this->dyna.actor, globalCtx, 0xBA, this->dyna.actor.xzDistToPlayer, + Actor_PickUp(&this->dyna.actor, globalCtx, GI_MAX, this->dyna.actor.xzDistToPlayer, fabsf(this->dyna.actor.playerHeightRel)); } } diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index 1f39ce6ba..576388d5c 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 @@ -7,7 +7,7 @@ #include "z_bg_haka_curtain.h" #include "objects/object_haka_obj/object_haka_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakaCurtain*)thisx) @@ -125,9 +125,9 @@ void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx) { BgHakaCurtain* this = THIS; CsCmdActorAction* actorAction; - if (func_800EE29C(globalCtx, 0x1D5)) { - actorAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D5)]; - if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 469)) { + actorAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 469)]; + if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->action == 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 862cf1611..7cb4aab5e 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 @@ -47,7 +47,7 @@ void BgHakaTomb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_haka_obj_Colheader_000EE8); - func_8013E3B8(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_FillCutscenesList(&this->dyna.actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); func_80BD6624(this); } @@ -83,15 +83,15 @@ void func_80BD66AC(BgHakaTomb* this, GlobalContext* globalCtx) { s16 temp; if (Flags_GetClear(globalCtx, this->dyna.actor.room)) { - this->dyna.actor.flags |= 9; + this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } if (!func_80BD6638(&temp, this->cutscenes, 1) && (temp < 0) && Flags_GetClear(globalCtx, this->dyna.actor.room)) { - this->dyna.actor.flags |= 1; + this->dyna.actor.flags |= ACTOR_FLAG_1; if (this->dyna.actor.isTargeted) { func_80BD6754(this); } } else { - this->dyna.actor.flags &= ~1; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; } } @@ -100,7 +100,7 @@ void func_80BD6754(BgHakaTomb* this) { } void func_80BD6768(BgHakaTomb* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->dyna.actor, this->cutscenes[0], -1, 0)) { + if (SubS_StartActorCutscene(&this->dyna.actor, this->cutscenes[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { BgHakaTomb_SetupDoNothing(this); } } 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 4061745f7..1f0030d28 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 @@ -5,6 +5,7 @@ */ #include "z_bg_hakugin_bombwall.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" #define FLAGS 0x00000000 @@ -15,7 +16,16 @@ void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx); +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx); +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx); +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx); +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx); + const ActorInit Bg_Hakugin_Bombwall_InitVars = { ACTOR_BG_HAKUGIN_BOMBWALL, ACTORCAT_BG, @@ -28,48 +38,404 @@ const ActorInit Bg_Hakugin_Bombwall_InitVars = { (ActorFunc)BgHakuginBombwall_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABCF80 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000008, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000008, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 80, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ABD040[] = { +Color_RGBA8 D_80ABCFAC = { 210, 210, 210, 255 }; +Color_RGBA8 D_80ABCFB0 = { 140, 140, 140, 255 }; + +Vec3f D_80ABCFB4 = { 0.0f, 0.33f, 0.0f }; + +typedef struct { + /* 0x00 */ CollisionHeader* unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ BgHakuginBombwallUnkFunc unk_20; + /* 0x24 */ BgHakuginBombwallUnkFunc2 unk_24; + /* 0x28 */ BgHakuginBombwallUnkFunc2 unk_28; + /* 0x2C */ s32 unk_2C; +} BgHakuginBombwallStruct; // size = 0x30 + +BgHakuginBombwallStruct D_80ABCFC0[] = { + { + &object_hakugin_obj_Colheader_009768, + object_hakugin_obj_DL_009658, + 70.0f, + 600.0f, + 400.0f, + 80, + 80, + 0x8, + 4225.0f, + func_80ABCB5C, + func_80ABBFC0, + func_80ABC58C, + 6, + }, + { + &object_hakugin_obj_Colheader_009AF0, + object_hakugin_obj_DL_0099A8, + 10.0f, + 600.0f, + 300.0f, + 50, + 20, + 0x408, + 4225.0f, + func_80ABCC00, + func_80ABC2E0, + func_80ABC7FC, + 18, + }, +}; + +s32 D_80ABD020[] = { -73, -40, -8, 24, 57 }; + +Vec3f D_80ABD034 = { 0.0f, 3.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +#ifdef NON_MATCHING +// Breaks relocs +void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 temp; + Vec3f spF0; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + s32 pad; + s16 phi_s1; + s16 phi_s0; + s32 i; + s32 j; + + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + + for (i = 0; i < 6; i++) { + temp = i + 1; + for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { + spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); + spD8.y = ((Rand_ZeroOne() - 0.5f) * 15.0f) + (temp * 26.666666f); + spD8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + + spCC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (spD8.x * 0.07777778f); + spCC.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + spCC.z = spD8.z * 0.3f; + + Matrix_MultiplyVector3fByState(&spD8, &spF0); + Matrix_MultiplyVector3fByState(&spCC, &spE4); + + spF0.x += this->dyna.actor.world.pos.x; + spF0.y += this->dyna.actor.world.pos.y; + spF0.z += this->dyna.actor.world.pos.z; + + if ((Rand_Next() % 4) == 0) { + phi_s0 = 32; + } else { + phi_s0 = 64; + } + + if (Rand_Next() > 0) { + phi_s0 |= 1; + phi_s1 = 1; + func_800B0E48(globalCtx, &spF0, &gZeroVec3f, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + ((u32)Rand_Next() >> 0x1B) + 70, ((u32)Rand_Next() >> 0x1A) + 60); + } else { + phi_s1 = 0; + } + + EffectSsKakera_Spawn(globalCtx, &spF0, &spE4, &spF0, -550, phi_s0, 30, 0, 0, + (s32)(Rand_ZeroOne() * 22.0f) + 5, phi_s1, 0, 50, -1, OBJECT_HAKUGIN_OBJ, + object_hakugin_obj_DL_009830); + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") #endif -extern ColliderCylinderInit D_80ABCF80; -extern InitChainEntry D_80ABD040[]; +void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + s16 phi_s2; + s16 phi_v0; + s16 phi_v1; + s16 phi_t0; + s16 temp_s1; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; -extern UNK_TYPE D_06009830; + for (i = 0, phi_s2 = 0; i < 25; i++, phi_s2 += 0x4E20) { + temp_f20 = (25 - i) * 2.4f; + temp_f22 = Math_SinS(phi_s2) * temp_f20; + temp_f24 = Math_CosS(phi_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABBFC0.s") + spC8.x = this->dyna.actor.world.pos.x + temp_f22; + spC8.y = this->dyna.actor.world.pos.y; + spC8.z = this->dyna.actor.world.pos.z + temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC2E0.s") + spBC.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f22 * 0.13333334f); + spBC.y = (Rand_ZeroOne() * 17.0f) + 7.0f; + spBC.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + (temp_f24 * 0.13333334f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC58C.s") + temp_s1 = (Rand_Next() & 3) + (i >> 2) + 4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABC7FC.s") + if ((Rand_Next() % 4) == 0) { + phi_v0 = 32; + } else { + phi_v0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Init.s") + if (temp_s1 >= 8) { + phi_v0 |= 1; + phi_v1 = 1; + phi_t0 = -550; + } else { + phi_v1 = 0; + phi_t0 = -400; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Destroy.s") + EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_t0, phi_v0, 30, 0, 0, temp_s1, phi_v1, 0, 50, -1, + OBJECT_HAKUGIN_OBJ, object_hakugin_obj_DL_009830); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCB5C.s") + if ((i & 1) == 0) { + func_800B0E48(globalCtx, &spC8, &D_80ABD034, &D_80ABCFB4, &D_80ABCFAC, &D_80ABCFB0, + ((u32)Rand_Next() >> 0x1B) + 60, ((u32)Rand_Next() >> 0x1A) + 50); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCC00.s") +void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + Vec3f sp9C; + s32 i; + s16 phi_s1; + f32 temp_f20; + f32 temp_f22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCCE4.s") + spA8.y = 0.0f; + spB4.y = 0.3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCD98.s") + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/func_80ABCE60.s") + for (i = 0, phi_s1 = 0; i < 21; i++, phi_s1 += 0x618) { + temp_f20 = Math_SinS(phi_s1); + temp_f22 = Math_CosS(phi_s1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Update.s") + sp9C.x = (i - 10) * 9.0f; + sp9C.y = (Rand_ZeroOne() * 40.0f) + 15.0f; + sp9C.z = temp_f20 * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Bombwall/BgHakuginBombwall_Draw.s") + spA8.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * -12.0f); + spA8.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 16.0f); + + spB4.x = spA8.x * -0.09f; + spB4.z = spA8.z * -0.09f; + + Matrix_MultiplyVector3fByState(&sp9C, &spC0); + Matrix_MultiplyVector3fByState(&spA8, &spCC); + Matrix_MultiplyVector3fByState(&spB4, &spD8); + + spC0.x += this->dyna.actor.world.pos.x; + spC0.y += this->dyna.actor.world.pos.y; + spC0.z += this->dyna.actor.world.pos.z; + + func_800B0E48(globalCtx, &spC0, &spCC, &spD8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, + ((u32)Rand_Next() >> 0x1B) + 60); + } +} + +void func_80ABC7FC(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s0; + s32 i; + + spAC.y = 0.0f; + spB8.y = 0.3f; + + for (i = 0, phi_s0 = 0; i < 20; i++, phi_s0 += 0xCCC) { + temp_f20 = Math_SinS(phi_s0); + temp_f22 = Math_CosS(phi_s0); + temp_f24 = Rand_ZeroOne() * 60.0f; + + spA0.x = (temp_f22 * temp_f24) + this->dyna.actor.world.pos.x; + spA0.y = (Rand_ZeroOne() * 20.0f) + this->dyna.actor.world.pos.y; + spA0.z = (temp_f20 * temp_f24) + this->dyna.actor.world.pos.z; + + spAC.x = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f20 * 15.0f); + spAC.z = ((Rand_ZeroOne() - 0.5f) * 7.0f) + (temp_f22 * 15.0f); + + spB8.x = spAC.x * -0.095f; + spB8.z = spAC.z * -0.095f; + + func_800B0E48(globalCtx, &spA0, &spAC, &spB8, &D_80ABCFAC, &D_80ABCFB0, ((u32)Rand_Next() >> 0x1A) + 60, + ((u32)Rand_Next() >> 0x1B) + 60); + } +} + +void BgHakuginBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginBombwall* this = THIS; + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_00); + + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->collider.dim.radius = ptr->unk_14; + this->collider.dim.height = ptr->unk_16; + this->collider.info.bumper.dmgFlags = ptr->unk_18; + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + + Actor_SetFocus(&this->dyna.actor, ptr->unk_08); + this->dyna.actor.uncullZoneScale = ptr->unk_0C; + this->dyna.actor.uncullZoneDownward = ptr->unk_10; + this->actionFunc = func_80ABCCE4; +} + +void BgHakuginBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +s32 func_80ABCB5C(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); + return true; + } + } + } + return false; +} + +s32 func_80ABCC00(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + s32 pad; + + if (this->collider.base.acFlags & AC_HIT) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if (this->collider.base.ac != NULL) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->collider.base.ac->world.pos) < + D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)].unk_1C) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, + NA_SE_EV_WALL_BROKEN); + return true; + } + } + } else if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + label:; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 50, NA_SE_EV_WALL_BROKEN); + return true; + } + } + return false; +} + +void func_80ABCCE4(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + if (ptr->unk_20(&this->dyna.actor, globalCtx)) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_80ABCD98; + } else { + this->collider.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80ABCD98(BgHakuginBombwall* this, GlobalContext* globalCtx) { + s32 pad; + + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ptr->unk_24(this, globalCtx); + this->dyna.actor.draw = NULL; + this->unk_1AC = 20; + Flags_SetSwitch(globalCtx, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor)); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80ABCE60; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80ABCE60(BgHakuginBombwall* this, GlobalContext* globalCtx) { + BgHakuginBombwallStruct* ptr = &D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(&this->dyna.actor)]; + + this->unk_1AC--; + if (this->unk_1AC <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } else if (this->unk_1AC == ptr->unk_2C) { + ptr->unk_28(this, globalCtx); + } +} + +void BgHakuginBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginBombwall* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgHakuginBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_80ABCFC0[BGHAKUGIN_BOMBWALL_100(thisx)].unk_04); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h index 8522fd15c..869741214 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/z_bg_hakugin_bombwall.h @@ -6,12 +6,17 @@ struct BgHakuginBombwall; typedef void (*BgHakuginBombwallActionFunc)(struct BgHakuginBombwall*, GlobalContext*); +typedef s32 (*BgHakuginBombwallUnkFunc)(Actor*, GlobalContext*); +typedef void (*BgHakuginBombwallUnkFunc2)(struct BgHakuginBombwall*, GlobalContext*); + +#define BGHAKUGIN_BOMBWALL_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define BGHAKUGIN_BOMBWALL_100(thisx) (((thisx)->params >> 8) & 1) typedef struct BgHakuginBombwall { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ BgHakuginBombwallActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgHakuginBombwallActionFunc actionFunc; + /* 0x1AC */ s32 unk_1AC; } BgHakuginBombwall; // size = 0x1B0 extern const ActorInit Bg_Hakugin_Bombwall_InitVars; 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 52e1e5614..b61f66bb6 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 @@ -6,7 +6,7 @@ #include "z_bg_hakugin_elvpole.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginElvpole*)thisx) 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 77e2aa660..1ad88f3f8 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 @@ -4,10 +4,12 @@ * Description: Snowhead Temple Central Pillar */ +#include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "prevent_bss_reordering.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgHakuginPost*)thisx) @@ -87,7 +89,7 @@ static InitChainEntry sInitChain[] = { }; void func_80A9ACD0(BgHakuginPostUnkStruct* arg0) { - bzero((void*)arg0, sizeof(BgHakuginPostUnkStruct)); + bzero(arg0, sizeof(BgHakuginPostUnkStruct)); } void func_80A9ACF0(void) { 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 f4ca155bd..f5e035be7 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 @@ -5,8 +5,9 @@ */ #include "z_bg_hakugin_switch.h" +#include "objects/object_goronswitch/object_goronswitch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgHakuginSwitch*)thisx) @@ -15,7 +16,27 @@ void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15E78(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B160DC(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B161A0(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16244(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B163C4(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16400(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16494(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B16520(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B165A0(BgHakuginSwitch* this, GlobalContext* globalCtx); +void func_80B165E0(BgHakuginSwitch* this, GlobalContext* globalCtx); + +u32 D_80B16AF0; + const ActorInit Bg_Hakugin_Switch_InitVars = { ACTOR_BG_HAKUGIN_SWITCH, ACTORCAT_SWITCH, @@ -28,84 +49,489 @@ const ActorInit Bg_Hakugin_Switch_InitVars = { (ActorFunc)BgHakuginSwitch_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B16860 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 60, 10, 180, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B16904[] = { +typedef struct { + /* 0x00 */ f32 unk_0; + /* 0x04 */ f32 unk_4; + /* 0x08 */ f32 unk_8; + /* 0x0C */ f32 unk_C; + /* 0x10 */ Gfx* unk_10; + /* 0x14 */ u8 unk_14; +} BgHakuginSwitchStruct; + +BgHakuginSwitchStruct D_80B1688C[] = { + { -156.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0xB4 }, + { -60.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0x32 }, + { -60.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_000268, 0x31 }, + { -120.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_0007D8, 0x3A }, + { -156.0f, -178.0f, 6.0f, 10.0f, object_goronswitch_DL_0007D8, 0xB4 }, +}; + +static InitChainEntry sInitChain1[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 130, ICHAIN_STOP), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B16910[] = { +static InitChainEntry sInitChain2[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 260, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 360, ICHAIN_STOP), }; -#endif +void func_80B15790(BgHakuginSwitch* this, u16 sfxId) { + if (this->unk_1B2 <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, sfxId); + } +} -extern ColliderCylinderInit D_80B16860; -extern InitChainEntry D_80B16904[]; -extern InitChainEntry D_80B16910[]; +void func_80B157C4(BgHakuginSwitch* this, u16 arg1) { + if (this->unk_1B2 <= 0) { + func_800B9010(&this->dyna.actor, arg1); + } +} -extern UNK_TYPE D_060005C8; +void BgHakuginSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitch* this = THIS; + s32 sp34 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); + s32 sp30; + s32 pad2; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15790.s") + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp30 = true; + } else { + sp30 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B157C4.s") + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_goronswitch_Colheader_0005C8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Init.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Destroy.s") + this->unk_1B2 = 15; + if (!BGHAKUGINSWITCH_GET_10(&this->dyna.actor)) { + Actor_ProcessInitChain(&this->dyna.actor, sInitChain1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15A4C.s") + this->dyna.actor.scale.x = 0.07f; + this->dyna.actor.scale.y = 0.016f; + this->dyna.actor.scale.z = 0.07f; + this->collider.dim.radius = 46; + this->collider.dim.yShift = 0x1D; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15A68.s") + this->unk_1A8 = object_goronswitch_DL_000268; + this->unk_1B8 = this->dyna.actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15B1C.s") + if (sp34 == 0) { + this->unk_1BA = -1; + } else { + this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15B74.s") + if (sp30) { + func_80B16494(this, globalCtx); + } else { + func_80B16244(this, globalCtx); + } + } else { + if (D_80B1688C[sp34].unk_14 & 4) { + sp28 = true; + } else { + sp28 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15E0C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15E78.s") + this->unk_1A8 = D_80B1688C[sp34].unk_10; + this->unk_1B8 = this->dyna.actor.cutscene; + this->unk_1BA = ActorCutscene_GetAdditionalCutscene(this->unk_1B8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15F3C.s") + if (sp30 == sp28) { + func_80B15F3C(this, globalCtx); + } else { + func_80B15B1C(this, globalCtx); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B15F88.s") + this->unk_1C8 = 1.0f / this->dyna.actor.scale.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B1606C.s") +void BgHakuginSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginSwitch* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B160DC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16180.s") +void func_80B15A4C(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2) { + this->unk_1B4 = func; + this->unk_1BC = arg2; + this->actionFunc = func_80B15A68; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B161A0.s") +void func_80B15A68(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 sp18 = !(s->unk_14 & 0x40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16244.s") + if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { + if (sp18) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + this->unk_1BF = 40; + } + this->unk_1B4(this, globalCtx); + } else if (sp18) { + ActorCutscene_SetIntentToPlay(this->unk_1BC); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B162AC.s") +void func_80B15B1C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B163C4.s") + this->dyna.actor.world.pos.y = s->unk_0 + this->dyna.actor.home.pos.y; + this->unk_1C0 = 1; + this->unk_1B0 = 480; + this->actionFunc = func_80B15B74; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16400.s") +void func_80B15B74(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp38 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 pad2; + s32 sp2C; + s32 sp28; + s32 sp24; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16494.s") + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp2C = 1; + } else { + sp2C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B16520.s") + if (sp38->unk_14 & 4) { + sp28 = 1; + } else { + sp28 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B165A0.s") + sp24 = false; + sp20 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/func_80B165E0.s") + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp24 = true; + sp20 = sp28; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Update.s") + if (this->unk_1B0 > 0) { + this->unk_1B0--; + if (sp38->unk_14 & 8) { + func_800B9038(&this->dyna.actor, this->unk_1B0); + if (this->unk_1B0 == 0) { + sp24 = true; + sp20 = sp28; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Switch/BgHakuginSwitch_Draw.s") + if (sp2C == sp28) { + if ((sp38->unk_14 & 0xFF) & 0x10) { + if (D_80B16AF0 < globalCtx->gameplayFrames) { + sp24 = true; + } + } else { + sp24 = true; + } + } + + if (sp24) { + if (sp20 == 1) { + Flags_SetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } else if (sp20 == 0) { + Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + + D_80B16AF0 = globalCtx->gameplayFrames; + + if (sp38->unk_14 & 0x10) { + func_80B15A4C(this, func_80B15E0C, this->unk_1B8); + } else { + func_80B15E0C(this, globalCtx); + } + } else if (!(sp38->unk_14 & 1)) { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B15E0C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if ((s->unk_14 & 0x80)) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_ON); + } + this->unk_1C0 = 0; + this->actionFunc = func_80B15E78; +} + +void func_80B15E78(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + 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)) { + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + func_80B15F3C(this, globalCtx); + } else if (!(sp20->unk_14 & 0x80)) { + func_80B157C4(this, NA_SE_EV_STONE_STATUE_OPEN - SFX_FLAG); + } +} + +void func_80B15F3C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + this->dyna.actor.world.pos.y = s->unk_4 + this->dyna.actor.home.pos.y; + this->unk_1C0 = 0; + this->actionFunc = func_80B15F88; +} + +void func_80B15F88(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 phi_a0; + BgHakuginSwitchStruct* sp18 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + s32 phi_v1; + + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + phi_a0 = true; + } else { + phi_a0 = false; + } + + if (sp18->unk_14 & 4) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (phi_a0 != phi_v1) { + if ((sp18->unk_14 & 0xFF) & 0x20) { + if (D_80B16AF0 < globalCtx->gameplayFrames) { + func_80B15A4C(this, func_80B1606C, this->unk_1BA); + } + } else { + func_80B1606C(this, globalCtx); + } + } +} + +void func_80B1606C(BgHakuginSwitch* this, GlobalContext* globalCtx) { + BgHakuginSwitchStruct* s = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (s->unk_14 & 0x80) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_OFF); + } + this->unk_1C0 = 1; + this->actionFunc = func_80B160DC; +} + +void func_80B160DC(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitchStruct* sp18 = &D_80B1688C[BGHAKUGINSWITCH_GET_7(&this->dyna.actor)]; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, sp18->unk_0 + this->dyna.actor.home.pos.y, sp18->unk_8)) { + func_80B15B1C(this, globalCtx); + } else if (!(sp18->unk_14 & 0x80)) { + func_80B157C4(this, NA_SE_EV_PILLAR_UP_FAST - SFX_FLAG); + } +} + +void func_80B16180(BgHakuginSwitch* this, BgHakuginSwitchUnkFunc func, s32 arg2, s32 arg3) { + this->unk_1B4 = func; + this->unk_1BE = arg2; + this->unk_1BC = arg3; + this->actionFunc = func_80B161A0; +} + +void func_80B161A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_1BC)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_1BC, &this->dyna.actor); + if (this->unk_1BE != 0) { + Flags_SetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } else { + Flags_UnsetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor)); + } + this->unk_1BF = 50; + this->unk_1B4(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->unk_1BC); + } +} + +void func_80B16244(BgHakuginSwitch* this, GlobalContext* globalCtx) { + this->unk_1C0 = 1; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + if ((BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) && + (this->dyna.actor.category != ACTORCAT_SWITCH)) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 0); + } + this->actionFunc = func_80B162AC; +} + +void func_80B162AC(BgHakuginSwitch* this, GlobalContext* globalCtx) { + s32 sp34 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 sp30 = BGHAKUGINSWITCH_GET_7(&this->dyna.actor); + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + if (sp34) { + this->collider.base.acFlags &= ~AC_HIT; + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp24 = true; + sp28 = true; + } + } + + if (sp30 == 1) { + if (Flags_GetSwitch(globalCtx, BGHAKUGINSWITCH_GET_SWITCHFLAG(&this->dyna.actor))) { + sp24 = true; + } + } + + if (sp24) { + if (sp28) { + func_80B16180(this, func_80B163C4, 1, this->unk_1B8); + } else { + func_80B163C4(this, globalCtx); + } + } else { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B163C4(BgHakuginSwitch* this, GlobalContext* globalCtx) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_ON); + this->unk_1C0 = 0; + this->actionFunc = func_80B16400; +} + +void func_80B16400(BgHakuginSwitch* this, GlobalContext* globalCtx) { + 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)) { + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + } + func_80B16494(this, globalCtx); + } +} + +void func_80B16494(BgHakuginSwitch* this, GlobalContext* globalCtx) { + this->unk_1C0 = 0; + this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (1800.0f * this->dyna.actor.scale.y)) + 2.0f; + if ((BGHAKUGINSWITCH_GET_7(&this->dyna.actor) == BGHAKUGINSWITCH_GET_7_1) && + (this->dyna.actor.category != ACTORCAT_PROP)) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, ACTORCAT_PROP); + } + this->actionFunc = func_80B16520; +} + +void func_80B16520(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (!Flags_GetSwitch(globalCtx, 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); + } else { + func_80B165A0(this, globalCtx); + } + } +} + +void func_80B165A0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + func_80B15790(this, NA_SE_EV_STONE_SWITCH_OFF); + this->unk_1C0 = 1; + this->actionFunc = func_80B165E0; +} + +void func_80B165E0(BgHakuginSwitch* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 6.0f)) { + func_80B16244(this, globalCtx); + } +} + +void BgHakuginSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgHakuginSwitch* this = THIS; + f32 sp24; + + if (this->unk_1B2 > 0) { + this->unk_1B2--; + } + + if (this->unk_1BF > 0) { + if ((this->actionFunc != func_80B15A68) && (this->actionFunc != func_80B161A0)) { + this->unk_1BF--; + if (this->unk_1BF == 0) { + ActorCutscene_Stop(this->unk_1BC); + } + } + } + + this->actionFunc(this, globalCtx); + + sp24 = this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y; + + if (this->unk_1C0 != 0) { + f32 phi_f0; + + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + phi_f0 = (sp24 - -10.0f) * -0.21f; + } else { + phi_f0 = (sp24 - -3.0f) * -0.08f; + } + this->unk_1C4 += phi_f0; + this->unk_1C4 *= 0.75f; + this->dyna.actor.shape.yOffset += this->unk_1C4 * this->unk_1C8; + } else { + this->unk_1C4 += sp24 * -0.11f; + this->unk_1C4 *= 0.75f; + this->dyna.actor.shape.yOffset += this->unk_1C4 * this->unk_1C8; + this->dyna.actor.shape.yOffset = CLAMP_MAX(this->dyna.actor.shape.yOffset, 0.0f); + } + } else { + Math_StepToF(&this->dyna.actor.shape.yOffset, 0.0f, 2.0f * this->unk_1C8); + this->unk_1C4 = 0.0f; + } +} + +void BgHakuginSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginSwitch* this = THIS; + + Gfx_DrawDListOpa(globalCtx, this->unk_1A8); +} 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 58cbfed68..cc1363965 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 @@ -6,12 +6,30 @@ struct BgHakuginSwitch; typedef void (*BgHakuginSwitchActionFunc)(struct BgHakuginSwitch*, GlobalContext*); +typedef void (*BgHakuginSwitchUnkFunc)(struct BgHakuginSwitch*, GlobalContext*); + +#define BGHAKUGINSWITCH_GET_7(thisx) ((thisx)->params & 7) +#define BGHAKUGINSWITCH_GET_10(thisx) (((thisx)->params >> 4) & 1) +#define BGHAKUGINSWITCH_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +#define BGHAKUGINSWITCH_GET_7_1 1 typedef struct BgHakuginSwitch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x68]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; + /* 0x01A8 */ Gfx* unk_1A8; /* 0x01AC */ BgHakuginSwitchActionFunc actionFunc; - /* 0x01B0 */ char unk_1B0[0x1C]; + /* 0x01B0 */ s16 unk_1B0; + /* 0x01B2 */ s8 unk_1B2; + /* 0x01B4 */ BgHakuginSwitchUnkFunc unk_1B4; + /* 0x01B8 */ s16 unk_1B8; + /* 0x01BA */ s16 unk_1BA; + /* 0x01BC */ s16 unk_1BC; + /* 0x01BE */ s8 unk_1BE; + /* 0x01BF */ s8 unk_1BF; + /* 0x01C0 */ s8 unk_1C0; + /* 0x01C4 */ f32 unk_1C4; + /* 0x01C8 */ f32 unk_1C8; } BgHakuginSwitch; // size = 0x1CC extern const ActorInit Bg_Hakugin_Switch_InitVars; 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 8ad7b2905..e3270fb6e 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -6,7 +6,7 @@ #include "z_bg_icefloe.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIcefloe*)thisx) 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 360e8b897..9d2fd67d9 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 @@ -6,7 +6,7 @@ #include "z_bg_ikana_block.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaBlock*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h index 48e65613f..112e4ad00 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h @@ -11,7 +11,12 @@ typedef struct BgIkanaBlock { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x1C]; /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ char unk_164[0x1C]; + /* 0x0164 */ char unk_164[0xC]; + /* 0x0170 */ f32 unk_170; + /* 0x0174 */ char unk_174[0x8]; + /* 0x017C */ u8 unk_17C; + /* 0x017D */ char unk_17D[0x1]; + /* 0x017E */ u8 unk_17E; } BgIkanaBlock; // size = 0x180 extern const ActorInit Bg_Ikana_Block_InitVars; 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 b1a0a19c1..f183a7164 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 @@ -6,7 +6,7 @@ #include "z_bg_ikana_bombwall.h" -#define FLAGS 0x10000000 +#define FLAGS (ACTOR_FLAG_10000000) #define THIS ((BgIkanaBombwall*)thisx) 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 1b222a2f8..2fb508c79 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 @@ -6,7 +6,7 @@ #include "z_bg_ikana_dharma.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaDharma*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c index 6b72aba38..de45de35b 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.c @@ -6,7 +6,7 @@ #include "z_bg_ikana_mirror.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaMirror*)thisx) diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c index 55c87bafa..d0ec42522 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.c @@ -69,9 +69,9 @@ void BgIkanaRay_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, collision, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); - this->animatedTextures = (AnimatedMaterial*)Lib_SegmentedToVirtual(object_ikana_obj_Matanimheader_001228); + this->animatedTextures = Lib_SegmentedToVirtual(object_ikana_obj_Matanimheader_001228); - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } else { BgIkanaRay_SetDeactivated(this); @@ -87,20 +87,20 @@ void BgIkanaRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { void BgIkanaRay_SetDeactivated(BgIkanaRay* this) { this->actor.draw = NULL; - this->actor.flags |= 0x10; - this->update = BgIkanaRay_UpdateCheckForActivation; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = BgIkanaRay_UpdateCheckForActivation; } void BgIkanaRay_UpdateCheckForActivation(BgIkanaRay* this, GlobalContext* globalCtx) { - if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (Flags_GetSwitch(globalCtx, BGIKANARAY_GET_SWITCH_FLAG(&this->actor))) { BgIkanaRay_SetActivated(this); } } void BgIkanaRay_SetActivated(BgIkanaRay* this) { this->actor.draw = BgIkanaRay_Draw; - this->actor.flags &= ~0x10; - this->update = BgIkanaRay_UpdateActivated; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actionFunc = BgIkanaRay_UpdateActivated; } void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx) { @@ -110,7 +110,7 @@ void BgIkanaRay_UpdateActivated(BgIkanaRay* this, GlobalContext* globalCtx) { void BgIkanaRay_Update(Actor* thisx, GlobalContext* globalCtx) { BgIkanaRay* this = THIS; - this->update(this, globalCtx); + this->actionFunc(this, globalCtx); } void BgIkanaRay_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h index d17fbeed9..7c8d8c369 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Ray/z_bg_ikana_ray.h @@ -5,11 +5,15 @@ struct BgIkanaRay; +typedef void (*BgIkanaRayActionFunc)(struct BgIkanaRay*, GlobalContext*); + +#define BGIKANARAY_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) + typedef struct BgIkanaRay { /* 0x000 */ Actor actor; /* 0x144 */ ColliderCylinder collision; /* 0x190 */ AnimatedMaterial* animatedTextures; - /* 0x194 */ void (*update)(struct BgIkanaRay*, GlobalContext*); + /* 0x194 */ BgIkanaRayActionFunc actionFunc; } BgIkanaRay; // size = 0x198 extern const ActorInit Bg_Ikana_Ray_InitVars; 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 f4263f783..a3b234392 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 @@ -5,8 +5,11 @@ */ #include "z_bg_ikana_rotaryroom.h" +#include "overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h" +#include "overlays/actors/ovl_En_Torch2/z_en_torch2.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIkanaRotaryroom*)thisx) @@ -16,8 +19,19 @@ void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx); void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx); +void func_80B818B4(BgIkanaRotaryroom* this); +void func_80B818C8(Actor* thisx, GlobalContext* globalCtx); +void func_80B81978(BgIkanaRotaryroom* this); +void func_80B8198C(Actor* thisx, GlobalContext* globalCtx); +void func_80B819DC(BgIkanaRotaryroom* this); +void func_80B819F0(Actor* thisx, GlobalContext* globalCtx); +void func_80B81A64(BgIkanaRotaryroom* this); +void func_80B81A80(Actor* thisx, GlobalContext* globalCtx); +void func_80B81B84(BgIkanaRotaryroom* this); +void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx); +void func_80B81DAC(BgIkanaRotaryroom* this); +void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Ikana_Rotaryroom_InitVars = { ACTOR_BG_IKANA_ROTARYROOM, ACTORCAT_BG, @@ -30,108 +44,959 @@ const ActorInit Bg_Ikana_Rotaryroom_InitVars = { (ActorFunc)BgIkanaRotaryroom_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_80B820E0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit1[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { -3450, 450, 0 }, 60 }, 100 }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { 3450, 450, 0 }, 60 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B82128 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 2, D_80B820E0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit1, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B82138[1] = { +static ColliderJntSphElementInit sJntSphElementsInit2[1] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00002000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00002000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 0, { { -3750, 1200, 0 }, 60 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B8215C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_80B82138, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B82214[] = { +Vec3f D_80B8216C = { 225.0f, -280.0f, -210.0f }; + +Vec3f D_80B82178 = { -255.0f, -280.0f, 210.0f }; + +typedef struct { + /* 0x00 */ s8 unk_00; + /* 0x01 */ s8 unk_01; + /* 0x04 */ Vec3f unk_04; +} BgIkanaRotaryroomStruct4; // size = 0x10 + +BgIkanaRotaryroomStruct4 D_80B82184[2][2] = { + { { 0, 0, { -375.0f, -170.0f, 0.0f } }, { 0, 0, { 375.0f, -170.0f, 0.0f } } }, + { { 0, 0, { -435.0f, -180.0f, 0.0f } }, { 0, 1, { 435.0f, -180.0f, 0.0f } } }, +}; + +Vec3s D_80B821C4[] = { + { -150, 194, -120 }, { -120, 194, -30 }, { -150, 194, 120 }, { 120, 194, 120 }, { 180, 194, 30 }, + { 150, 194, -90 }, { 60, 194, -120 }, { -60, 194, 90 }, { 30, 194, 120 }, { 49, 194, -105 }, +}; + +f32 D_80B82200[] = { 64.0f, 66.0f, 66.0f, 30.0f, 41.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +CollisionHeader* D_80B82218[] = { &object_ikana_obj_Colheader_006368, &object_ikana_obj_Colheader_0084F8 }; -extern ColliderJntSphElementInit D_80B820E0[2]; -extern ColliderJntSphInit D_80B82128; -extern ColliderJntSphElementInit D_80B82138[1]; -extern ColliderJntSphInit D_80B8215C; -extern InitChainEntry D_80B82214[]; +void func_80B802E0(BgIkanaRotaryroom* this) { + s32 pad; -extern UNK_TYPE D_060048A0; -extern UNK_TYPE D_06007B68; + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B802E0.s") + Collider_UpdateSpheres(0, &this->collider); + if (!BGIKANAROTARYROOM_GET_1(&this->dyna.actor)) { + Collider_UpdateSpheres(1, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80358.s") +void func_80B80358(Vec3f* arg0) { + arg0->x += (arg0->x >= 0.0f) ? 0.5f : -0.5f; + arg0->y += (arg0->y >= 0.0f) ? 0.5f : -0.5f; + arg0->z += (arg0->z >= 0.0f) ? 0.5f : -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80440.s") + arg0->x = (s32)arg0->x; + arg0->y = (s32)arg0->y; + arg0->z = (s32)arg0->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80550.s") +void func_80B80440(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp50; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80778.s") + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); + } + Matrix_GetStateTranslation(&sp50); + func_80B80358(&sp50); + this->unk_204.unk_00 = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, 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); + Matrix_StatePop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80894.s") +void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + s32 spC8 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + s32 spC4; + s32 pad2; + Vec3f spB4; + Actor* actor; + s32 i; + BgIkanaRotaryroomStruct4* ptr; + MtxF sp68; + Vec3s sp60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80C88.s") + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + spC4 = 1; + } else { + spC4 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B80F08.s") + actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + Matrix_StatePush(); + sp60.x = BINANG_ROT180(this->dyna.actor.home.rot.x); + sp60.y = this->dyna.actor.home.rot.y; + sp60.z = this->dyna.actor.home.rot.z; + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &sp60); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81010.s") + while (actor != NULL) { + if (actor->id == ACTOR_DOOR_SHUTTER) { + Math_Vec3f_Diff(&actor->world.pos, &this->dyna.actor.world.pos, &spB4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81234.s") + for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { + ptr = &D_80B82184[spC8][i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B814B8.s") + if ((Math3D_Vec3fDistSq(&spB4, &D_80B82184[spC8][i].unk_04) < SQ(250.0f)) && + ((ptr->unk_00 ^ spC4) && (ptr->unk_01 == 0U))) { + Matrix_StatePush(); + Matrix_InsertTranslation(spB4.x, spB4.y, spB4.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y - this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x - this->dyna.actor.home.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z - this->dyna.actor.home.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslation(&actor->world.pos); + func_80B80358(&actor->world.pos); + Matrix_CopyCurrentState(&sp68); + func_8018219C(&sp68, &actor->shape.rot, 0); + Matrix_StatePop(); + } + } + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81570.s") + Matrix_StatePop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B816A4.s") +BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* globalCtx, Actor* arg2) { + s32 i; + Vec3f sp68; + s32 pad[2]; + s32 temp_s3 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + BgIkanaRotaryroomStruct4* sp58 = NULL; + BgIkanaRotaryroomStruct4* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Init.s") + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Destroy.s") + if (arg2->id == ACTOR_DOOR_SHUTTER) { + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B818B4.s") + for (i = 0; i < ARRAY_COUNT(D_80B82184); i++) { + ptr = &D_80B82184[temp_s3][i]; + if ((ptr->unk_01 == 0) && + (Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot), + Matrix_MultiplyVector3fByState(&ptr->unk_04, &sp68), + (Math3D_Vec3fDistSq(&arg2->world.pos, &sp68) < SQ(250.0f)))) { + sp58 = ptr; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B818C8.s") + Matrix_StatePop(); + } + return sp58; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81978.s") +void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[7]; + Actor* actor = this->unk_204.unk_00; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B8198C.s") + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B819DC.s") + Matrix_InsertZRotation_s(-this->dyna.actor.shape.rot.z, MTXMODE_NEW); + Matrix_InsertXRotation_s(-this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateY(-this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertTranslation(-this->dyna.actor.world.pos.x, -this->dyna.actor.world.pos.y, + -this->dyna.actor.world.pos.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B819F0.s") + if (actor != NULL) { + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81A64.s") + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_204.unk_04); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81A80.s") + Matrix_StatePop(); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81B84.s") + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + this->unk_248[i].unk_00 = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81BA0.s") + actor = globalCtx->actorCtx.actorLists[ACTORCAT_DOOR].first; + i = 0; + while (actor != NULL) { + if (func_80B80778(this, globalCtx, actor) && (i < 2)) { + this->unk_248[i].unk_00 = actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81DAC.s") + Matrix_StatePush(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/func_80B81DC8.s") + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_248[i].unk_04); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Update.s") + Matrix_StatePop(); + i++; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Rotaryroom/BgIkanaRotaryroom_Draw.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + this->unk_2D0[i].unk_00 = NULL; + } + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + i = 0; + while (actor != NULL) { + if ((actor->id == ACTOR_EN_TORCH2) && (actor->update != NULL) && (i < ARRAY_COUNT(this->unk_2D0))) { + this->unk_2D0[i].unk_00 = actor; + + Matrix_StatePush(); + + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_2D0[i].unk_04); + + Matrix_StatePop(); + i++; + } + actor = actor->next; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + this->unk_3E0[i].unk_00 = NULL; + } + + actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; + i = 0; + while (actor != NULL) { + if ((actor->update != NULL) && (actor->id != ACTOR_EN_WATER_EFFECT) && (i < ARRAY_COUNT(this->unk_3E0))) { + this->unk_3E0[i].unk_00 = actor; + this->unk_3E0[i].unk_44 = actor->shape.rot; + this->unk_3E0[i].unk_4C = 0.0f; + + Matrix_StatePush(); + + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_3E0[i].unk_04); + + Matrix_StatePop(); + i++; + } + actor = actor->next; + } + + actor = &GET_PLAYER(globalCtx)->actor; + if (actor->update != NULL) { + this->unk_520.unk_40 = actor->shape.rot; + + Matrix_StatePush(); + + Matrix_InsertTranslation(actor->world.pos.x, actor->world.pos.y, actor->world.pos.z, MTXMODE_APPLY); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&this->unk_520.unk_00); + + Matrix_StatePop(); + } + + Matrix_StatePop(); +} + +void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[5]; + BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; + Player* player; + Actor* ptr; + Actor* ptr2; + Actor* ptr3; + s32 i; + MtxF sp3C; + + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + if (ikanaBlock != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_204.unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ikanaBlock->actor.world.pos); + func_80B80358(&ikanaBlock->actor.world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ikanaBlock->actor.shape.rot, 0); + + Matrix_StatePop(); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + ptr = this->unk_248[i].unk_00; + if (ptr != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_248[i].unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ptr->world.pos); + func_80B80358(&ptr->world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ptr->shape.rot, 0); + + Matrix_StatePop(); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr2 = this->unk_2D0[i].unk_00; + if (ptr2 != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_2D0[i].unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ptr2->world.pos); + func_80B80358(&ptr2->world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ptr2->shape.rot, 0); + + Matrix_StatePop(); + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr3 = this->unk_3E0[i].unk_00; + if (ptr3 != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_3E0[i].unk_04, MTXMODE_APPLY); + Matrix_GetStateTranslation(&ptr3->world.pos); + func_80B80358(&ptr3->world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &ptr3->shape.rot, 0); + + Matrix_StatePop(); + } + } + + player = GET_PLAYER(globalCtx); + if (player != NULL) { + Matrix_StatePush(); + + Matrix_InsertMatrix(&this->unk_520.unk_00, MTXMODE_APPLY); + Matrix_GetStateTranslation(&player->actor.world.pos); + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + func_80B80358(&player->actor.world.pos); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &player->actor.shape.rot, 0); + + Matrix_StatePop(); + player->actor.freezeTimer = 2; + } + + Matrix_StatePop(); +} + +s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + BgIkanaBlock* sp40 = (BgIkanaBlock*)this->unk_204.unk_00; + Vec3f sp34; + Vec3f sp28; + s32 sp24 = false; + + if (sp40 != NULL) { + Matrix_StatePush(); + + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_InsertTranslation(D_80B82178.x, D_80B82178.y, D_80B82178.z, MTXMODE_APPLY); + Matrix_GetStateTranslation(&sp34); + Matrix_SetStateRotationAndTranslation(sp40->actor.world.pos.x, sp40->actor.world.pos.y + sp40->unk_170, + sp40->actor.world.pos.z, &sp40->actor.shape.rot); + Matrix_GetStateTranslation(&sp28); + + Matrix_StatePop(); + + if (Math3D_Vec3fDistSq(&sp34, &sp28) < 3.0f) { + if (!Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + sp24 = true; + } + Flags_SetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor)); + } + } + return sp24; +} + +void func_80B81010(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; + s32 temp_s2; + s32 phi_s7; + s32 i; + Actor* ptr; + Vec3f sp84; + BgIkanaRotaryroomStruct2* ptr2; + CollisionPoly* sp7C; + s32 sp78; + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + phi_s7 = true; + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr = this->unk_3E0[i].unk_00; + ptr2 = &this->unk_3E0[i]; + + if (ptr != NULL) { + temp_s2 = Math_ScaledStepToS(&ptr->shape.rot.x, ptr2->unk_44.x, 0xBB8) & 1; + temp_s2 &= Math_ScaledStepToS(&ptr->shape.rot.y, ptr2->unk_44.y, 0xBB8); + temp_s2 &= Math_ScaledStepToS(&ptr->shape.rot.z, ptr2->unk_44.z, 0xBB8); + + ptr2->unk_4C -= 2.0f; + if (ptr2->unk_4C < -30.0f) { + ptr2->unk_4C = -30.0f; + } + + Math_Vec3f_Copy(&ptr->prevPos, &ptr->world.pos); + + ptr->world.pos.y += ptr2->unk_4C; + + sp84.x = ptr->prevPos.x; + sp84.y = ptr->prevPos.y + 50.0f; + sp84.z = ptr->prevPos.z; + + temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp7C, &sp78, NULL, &sp84); + if (ptr->world.pos.y <= temp_f0) { + ptr->world.pos.y = temp_f0; + } else { + temp_s2 = false; + } + + if (temp_s2) { + ptr2->unk_00 = NULL; + } else { + phi_s7 = false; + } + } + } + + if (phi_s7) { + this->unk_578 = NULL; + } + } else { + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr = this->unk_3E0[i].unk_00; + if (ptr != NULL) { + ptr->shape.rot = this->unk_3E0[i].unk_44; + Math_Vec3f_Copy(&ptr->prevPos, &ptr->world.pos); + } + } + this->unk_578 = NULL; + } +} + +void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + BgIkanaRotaryroomStruct3* ptr; + s32 sp64; + Vec3f sp58; + Vec3f sp4C; + f32 temp_f0; + f32 sp44 = D_80B82200[player->transformation] * 0.5f; + CollisionPoly* sp40; + s32 sp3C; + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (player == NULL) { + return; + } + + ptr = &this->unk_520; + + if (player->actor.freezeTimer > 0) { + sp58.x = ptr->unk_4C.x; + sp58.y = ptr->unk_4C.y + 50.0f; + sp58.z = ptr->unk_4C.z; + + sp64 = Math_ScaledStepToS(&player->actor.shape.rot.x, ptr->unk_40.x, 2000) & 1; + sp64 &= Math_ScaledStepToS(&player->actor.shape.rot.y, ptr->unk_40.y, 2000); + sp64 &= Math_ScaledStepToS(&player->actor.shape.rot.z, ptr->unk_40.z, 2000); + + ptr->unk_48 = ptr->unk_48 - 2.1f; + ptr->unk_48 = ptr->unk_48 * 0.98f; + if (ptr->unk_48 < -30.0f) { + ptr->unk_48 = -30.0f; + } + ptr->unk_4C.y += ptr->unk_48; + + Matrix_StatePush(); + + Matrix_RotateY(player->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(player->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(player->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(sp44, &sp4C); + + Matrix_StatePop(); + + temp_f0 = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &sp40, &sp3C, NULL, &sp58); + if (ptr->unk_4C.y <= temp_f0) { + ptr->unk_4C.y = temp_f0; + } else { + sp64 = 0; + } + + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + + player->actor.world.pos.x = ptr->unk_4C.x - sp4C.x; + player->actor.world.pos.y = (ptr->unk_4C.y - sp4C.y) + sp44; + player->actor.world.pos.z = ptr->unk_4C.z - sp4C.z; + + if (sp64 != 0) { + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + this->unk_57C = NULL; + } else { + player->actor.freezeTimer = 2; + } + } + } else { + if (player != NULL) { + player->actor.shape.rot = this->unk_520.unk_40; + Math_Vec3f_Copy(&player->actor.home.pos, &player->actor.world.pos); + } + this->unk_57C = NULL; + } +} + +void func_80B814B8(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCurrentIndex() == this->dyna.actor.cutscene) { + if (player->actor.bgCheckFlags & 0x100) { + func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); + func_80169EFC(&globalCtx->state); + func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92); + globalCtx->unk_18845 = 1; + play_sound(NA_SE_OC_ABYSS); + this->actionFunc = NULL; + } + } else { + this->actionFunc = NULL; + } +} + +void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp70; + Vec3f sp64; + s32 pad; + s32 pad2; + + Matrix_StatePush(); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + + for (i = 0; i < ARRAY_COUNT(D_80B821C4); i++) { + sp64.x = D_80B821C4[i].x; + sp64.y = D_80B821C4[i].y; + sp64.z = D_80B821C4[i].z; + + Matrix_MultiplyVector3fByState(&sp64, &sp70); + + sp70.x += this->dyna.actor.world.pos.x; + sp70.y += this->dyna.actor.world.pos.y; + sp70.z += this->dyna.actor.world.pos.z; + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, sp70.x, sp70.y, sp70.z, 0, 0, 0, 1); + } + + Matrix_StatePop(); +} + +s32 func_80B816A4(BgIkanaRotaryroom* this) { + s32 i; + s32 count = 0; + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + if (this->unk_3E0[i].unk_00 != NULL) { + count++; + } + } + + return count; +} + +void BgIkanaRotaryroom_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaRotaryroom* this = THIS; + s32 sp34 = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + this->dyna.actor.shape.rot.x = -0x8000; + } else { + this->dyna.actor.shape.rot.x = 0; + } + + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B82218[sp34]); + + Collider_InitJntSph(globalCtx, &this->collider); + if (!sp34) { + Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit1, this->colliderElements); + } else { + Collider_SetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit2, this->colliderElements); + } + + func_80B802E0(this); + + if (sp34 == true) { + this->unk_1FC = Lib_SegmentedToVirtual(&object_ikana_obj_Matanimheader_007B68); + } + + if (!sp34) { + func_80B80440(this, globalCtx); + } else { + func_80B81570(this, globalCtx); + } + + func_80B80550(this, globalCtx); + func_80B818B4(this); +} + +void BgIkanaRotaryroom_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80B818B4(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B818C8; +} + +void func_80B818C8(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 sp20; + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + sp20 = BGIKANAROTARYROOM_GET_FE(&this->dyna.actor); + if (Flags_GetSwitch(globalCtx, sp20)) { + Flags_UnsetSwitch(globalCtx, sp20); + } else { + Flags_SetSwitch(globalCtx, sp20); + } + func_80B81978(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B81978(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B8198C; +} + +void func_80B8198C(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + + if (this->unk_204.unk_00 == NULL) { + func_80B819DC(this); + } else if (((BgIkanaBlock*)this->unk_204.unk_00)->unk_17C & 1) { + ((BgIkanaBlock*)this->unk_204.unk_00)->unk_17C |= 8; + func_80B819DC(this); + } +} + +void func_80B819DC(BgIkanaRotaryroom* this) { + this->unk_200 = func_80B819F0; +} + +void func_80B819F0(Actor* thisx, GlobalContext* globalCtx) { + 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(globalCtx, &this->dyna.actor, 7); + } + func_80B81A64(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B81A64(BgIkanaRotaryroom* this) { + this->unk_584 = 25; + this->unk_200 = func_80B81A80; +} + +void func_80B81A80(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 pad; + s32 i; + BgIkanaRotaryroomStruct1* ptr; + + func_800B9010(thisx, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + this->unk_584--; + + if (this->unk_584 <= 0) { + if (1) {} + if (1) {} + if (1) {} + if (1) {} + func_80B80894(this, globalCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr = &this->unk_2D0[i]; + if (ptr->unk_00 != NULL) { + ((EnTorch2*)ptr->unk_00)->state = 3; + } + } + + func_80B81B84(this); + } else if (this->unk_584 == 15) { + s16 sp26 = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(sp26, 0x7B30); + Quake_SetQuakeValues(sp26, 6, 0, 100, 0); + Quake_SetCountdown(sp26, 22); + } +} + +void func_80B81B84(BgIkanaRotaryroom* this) { + this->unk_584 = 0x2001; + this->unk_200 = func_80B81BA0; +} + +void func_80B81BA0(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 sp30 = 0; + s32 i; + + func_800B9010(&this->dyna.actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + + if (this->unk_584 > 0) { + this->unk_584--; + } + + thisx->shape.rot.x += 0x1F4; + + if (!(this->unk_584 & 7)) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x7B30); + Quake_SetQuakeValues(quake, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); + Quake_SetCountdown(quake, 15); + } + + if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_FE(&this->dyna.actor))) { + if (this->dyna.actor.shape.rot.x < 0) { + this->dyna.actor.shape.rot.x = -0x8000; + sp30 = 1; + } + } else if (this->dyna.actor.shape.rot.x >= 0) { + this->dyna.actor.shape.rot.x = 0; + sp30 = 1; + } + + func_80B80C88(this, globalCtx); + + if (sp30 != 0) { + Player* player = GET_PLAYER(globalCtx); + BgIkanaRotaryroomStruct1* ptr; + BgIkanaBlock* block = (BgIkanaBlock*)this->unk_204.unk_00; + + if (block != NULL) { + block->unk_17C &= ~8; + block->unk_17C |= 4; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr = &this->unk_2D0[i]; + if (ptr->unk_00 != NULL) { + ((EnTorch2*)ptr->unk_00)->state = 4; + } + } + + this->unk_520.unk_48 = 0.0f; + this->unk_520.unk_4C.x = player->actor.world.pos.x; + this->unk_520.unk_4C.y = player->actor.world.pos.y - D_80B82200[player->transformation]; + this->unk_520.unk_4C.z = player->actor.world.pos.z; + + if (func_80B816A4(this) > 0) { + this->unk_578 = func_80B81010; + } + + this->unk_57C = func_80B81234; + this->actionFunc = func_80B814B8; + func_80B802E0(this); + func_80B81DAC(this); + } +} + +void func_80B81DAC(BgIkanaRotaryroom* this) { + this->unk_584 = 20; + this->unk_200 = func_80B81DC8; +} + +void func_80B81DC8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgIkanaRotaryroom* this = THIS; + + if (this->unk_584 > 10) { + func_800B9010(&this->dyna.actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + } + this->unk_584--; + + if (this->unk_584 <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + func_80B818B4(this); + } else if (this->unk_584 == 19) { + s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + + Quake_SetSpeed(quake, 0x4E20); + Quake_SetQuakeValues(quake, 5, 0, 40, 60); + Quake_SetCountdown(quake, 17); + } +} + +void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + BgIkanaRotaryroomStruct1* ptr; + BgIkanaRotaryroomStruct1* ptr2; + BgIkanaRotaryroomStruct2* ptr3; + s32 i; + + if ((this->unk_204.unk_00 != NULL) && (this->unk_204.unk_00->update == NULL)) { + this->unk_204.unk_00 = NULL; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_248); i++) { + ptr = &this->unk_248[i]; + if ((ptr->unk_00 != NULL) && (ptr->unk_00->update == NULL)) { + ptr->unk_00 = NULL; + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { + ptr2 = &this->unk_2D0[i]; + if ((ptr2->unk_00 != NULL) && (ptr2->unk_00->update == NULL)) { + ptr2->unk_00 = NULL; + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3E0); i++) { + ptr3 = &this->unk_3E0[i]; + if ((ptr3->unk_00 != NULL) && (ptr3->unk_00->update == NULL)) { + ptr3->unk_00 = NULL; + } + } + + if (func_80B80F08(this, globalCtx)) { + if (this->unk_204.unk_00 != NULL) { + ((BgIkanaBlock*)this->unk_204.unk_00)->unk_17E = 1; + } + } + + this->unk_200(&this->dyna.actor, globalCtx); + + if (this->unk_578 != NULL) { + this->unk_578(this, globalCtx); + } + + if (this->unk_57C != NULL) { + this->unk_57C(this, globalCtx); + } + + if (this->actionFunc != NULL) { + this->actionFunc(this, globalCtx); + } +} + +void BgIkanaRotaryroom_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgIkanaRotaryroom* this = THIS; + s32 param = BGIKANAROTARYROOM_GET_1(&this->dyna.actor); + + if (!param) { + Gfx_DrawDListOpa(globalCtx, object_ikana_obj_DL_0048A0); + Gfx_DrawDListXlu(globalCtx, object_ikana_obj_DL_004710); + } else { + AnimatedMat_Draw(globalCtx, this->unk_1FC); + Gfx_DrawDListOpa(globalCtx, object_ikana_obj_DL_007448); + Gfx_DrawDListXlu(globalCtx, object_ikana_obj_DL_007360); + } +} diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h index d446d5e92..1e27fb485 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.h @@ -6,12 +6,47 @@ struct BgIkanaRotaryroom; typedef void (*BgIkanaRotaryroomActionFunc)(struct BgIkanaRotaryroom*, GlobalContext*); +typedef void (*BgIkanaRotaryroomUnkFunc)(Actor*, GlobalContext*); +typedef void (*BgIkanaRotaryroomUnkFunc2)(struct BgIkanaRotaryroom*, GlobalContext*); + +#define BGIKANAROTARYROOM_GET_1(thisx) ((thisx)->params & 1) +#define BGIKANAROTARYROOM_GET_FE(thisx) (((thisx)->params >> 1) & 0x7F) +#define BGIKANAROTARYROOM_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ MtxF unk_04; +} BgIkanaRotaryroomStruct1; // size = 0x44 + +typedef struct { + /* 0x00 */ Actor* unk_00; + /* 0x04 */ MtxF unk_04; + /* 0x44 */ Vec3s unk_44; + /* 0x4C */ f32 unk_4C; +} BgIkanaRotaryroomStruct2; // size = 0x50 + +typedef struct { + /* 0x00 */ MtxF unk_00; + /* 0x40 */ Vec3s unk_40; + /* 0x48 */ f32 unk_48; + /* 0x4C */ Vec3f unk_4C; +} BgIkanaRotaryroomStruct3; // size = 0x58 typedef struct BgIkanaRotaryroom { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x43C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderJntSph collider; + /* 0x017C */ ColliderJntSphElement colliderElements[2]; + /* 0x01FC */ AnimatedMaterial* unk_1FC; + /* 0x0200 */ BgIkanaRotaryroomUnkFunc unk_200; + /* 0x0204 */ BgIkanaRotaryroomStruct1 unk_204; + /* 0x0248 */ BgIkanaRotaryroomStruct1 unk_248[2]; + /* 0x02D0 */ BgIkanaRotaryroomStruct1 unk_2D0[4]; + /* 0x03E0 */ BgIkanaRotaryroomStruct2 unk_3E0[4]; + /* 0x0520 */ BgIkanaRotaryroomStruct3 unk_520; + /* 0x0578 */ BgIkanaRotaryroomUnkFunc2 unk_578; + /* 0x057C */ BgIkanaRotaryroomUnkFunc2 unk_57C; /* 0x0580 */ BgIkanaRotaryroomActionFunc actionFunc; - /* 0x0584 */ char unk_584[0x4]; + /* 0x0584 */ s16 unk_584; } BgIkanaRotaryroom; // size = 0x588 extern const ActorInit Bg_Ikana_Rotaryroom_InitVars; 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 d37d09abf..16060bbd2 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 @@ -7,7 +7,7 @@ #include "z_bg_ikana_shutter.h" #include "objects/object_ikana_obj/object_ikana_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkanaShutter*)thisx) 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 2145a3a27..7e05d6977 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 @@ -7,7 +7,7 @@ #include "z_bg_iknin_susceil.h" #include "objects/object_ikninside_obj/object_ikninside_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIkninSusceil*)thisx) @@ -56,7 +56,7 @@ s32 func_80C0A740(BgIkninSusceil* this, GlobalContext* globalCtx) { Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); - return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.y) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); + return (D_80C0B0E8.x < offset.z) && (offset.z < D_80C0B0E8.z) && (offset.x > -240.0f) && (offset.x < D_80C0B0E4); } void func_80C0A804(BgIkninSusceil* this, GlobalContext* globalCtx) { 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 3b3b21172..a09bcba87 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -6,7 +6,7 @@ #include "z_bg_ikninside.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIkninside*)thisx) 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 67d95a2e4..92a109925 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 @@ -6,7 +6,7 @@ #include "z_bg_iknv_doukutu.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIknvDoukutu*)thisx) 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 84ca4f990..023b4b706 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 @@ -7,7 +7,7 @@ #include "z_bg_iknv_obj.h" #include "objects/object_iknv_obj/object_iknv_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgIknvObj*)thisx) @@ -64,8 +64,8 @@ void BgIknvObj_Init(Actor* thisx, GlobalContext* globalCtx) { case IKNV_OBJ_WATERWHEEL: this->displayListPtr = object_iknv_obj_DL_013058; this->actionFunc = BgIknvObj_UpdateWaterwheel; - this->dyna.actor.flags |= 0x100000; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_100000; + this->dyna.actor.flags |= ACTOR_FLAG_10; break; case IKNV_OBJ_RAISED_DOOR: this->displayListPtr = object_iknv_obj_DL_011880; @@ -131,8 +131,8 @@ void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, GlobalContext* globalCtx) { func_800B9010(&this->dyna.actor, NA_SE_EV_WOOD_WATER_WHEEL - SFX_FLAG); } - if ((globalCtx->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 4) && - (globalCtx->csCtx.frames == 0x5D7)) { + if ((globalCtx->csCtx.state != 0) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 4) && (globalCtx->csCtx.frames == 1495)) { func_8019F128(NA_SE_EV_DOOR_UNLOCK); } } @@ -162,7 +162,7 @@ void func_80BD7ED8(BgIknvObj* this, GlobalContext* globalCtx) { } void func_80BD7F4C(BgIknvObj* this, GlobalContext* globalCtx) { - if (gSaveContext.save.time > 0xD000) { + if (gSaveContext.save.time > CLOCK_TIME(19, 30)) { this->actionFunc = func_80BD7ED8; } if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.save.weekEventReg[58] & 0x80)) { 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 152240528..0ef40499e 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -5,8 +5,9 @@ */ #include "z_bg_ingate.h" +#include "objects/object_sichitai_obj/object_sichitai_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgIngate*)thisx) @@ -15,7 +16,16 @@ void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx); void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId); +s32 func_80953BEC(BgIngate* this); +void func_80953B40(BgIngate* this); +void func_80953F8C(BgIngate* this, GlobalContext* globalCtx); +void func_80953F9C(BgIngate* this, GlobalContext* globalCtx); +void func_809541B8(BgIngate* this, GlobalContext* globalCtx); +void func_809542A0(BgIngate* this, GlobalContext* globalCtx); +void func_80954340(BgIngate* this, GlobalContext* globalCtx); +void func_809543D4(BgIngate* this, GlobalContext* globalCtx); + const ActorInit Bg_Ingate_InitVars = { ACTOR_BG_INGATE, ACTORCAT_BG, @@ -28,41 +38,355 @@ const ActorInit Bg_Ingate_InitVars = { (ActorFunc)BgIngate_Draw, }; -#endif +/** + * @brief Searches for an actor based on the parameters given to the function. Returns Actor* of actor found or NULL + * + * @param this + * @param globalCtx + * @param actorCat - Category of Actor + * @param actorId - ID of actor to search for + * @return Actor* + */ +Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; + Actor* tempActor; -extern UNK_TYPE D_060006B0; -extern UNK_TYPE D_060016DC; + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953A90.s") + if ((foundActor == NULL) || (((this != (BgIngate*)foundActor)) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953B40.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953BEC.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953DA8.s") +void func_80953B40(BgIngate* this) { + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953E38.s") + if (!(gSaveContext.eventInf[3] & 0x20)) { + this->unk180 = 0xFA0; + this->unk168 = 4; + } else { + this->unk180 = 0x7D0; + this->unk168 = 1; + } + temp = this->unk164->count - 2; + this->unk184 = this->unk180 / temp; + this->unk188 = 2; + this->unk18C = 0; + this->unk160 &= ~0x1; + this->unk160 &= ~0x2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953EA4.s") +s32 func_80953BEC(BgIngate* this) { + f32 sp74[265]; + Vec3f sp68; + Vec3f sp5C; + Vec3f unkVec; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F14.s") + func_8013AF00(sp74, 3, this->unk164->count + 3); + if (!(this->unk160 & 1)) { + unkVec = gZeroVec3f; + func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, + &unkVec, this->unk168); + this->unk160 |= 1; + } else { + unkVec = this->unk170; + } + this->dyna.actor.world.pos.x = unkVec.x; + this->dyna.actor.world.pos.z = unkVec.z; + this->unk170 = gZeroVec3f; + if (func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, + &this->unk170, this->unk168) != 0) { + this->unk160 |= 2; + } else { + sp68 = this->dyna.actor.world.pos; + sp5C = this->unk170; + yaw = Math_Vec3f_Yaw(&sp68, &sp5C); + this->dyna.actor.world.rot.y = yaw; + this->dyna.actor.shape.rot.y = yaw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F8C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80953F9C.s") +s32 func_80953DA8(BgIngate* this, GlobalContext* globalCtx) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809541B8.s") + if (gSaveContext.eventInf[3] & 0x20) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + } else { + gSaveContext.eventInf[4] |= 2; + } + func_800DFAC8(camera, 47); + globalCtx->unk_1887C = 0x63; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809542A0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_80954340.s") +void func_80953E38(GlobalContext* globalCtx) { + func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/func_809543D4.s") + if (!(gSaveContext.eventInf[3] & 0x20)) { + gSaveContext.eventInf[4] &= (u8)~2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Init.s") + globalCtx->unk_1887C = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Destroy.s") +void func_80953EA4(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Update.s") + func_800B7298(globalCtx, &this->dyna.actor, 0x3A); + player->unk_3A0.x = this->dyna.actor.world.pos.x; + player->unk_3A0.z = this->dyna.actor.world.pos.z; + this->unk160 &= ~0x4; + this->unk16A = 0x1E; + this->actionFunc = func_80954340; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ingate/BgIngate_Draw.s") +void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.shape.rot.y = this->dyna.actor.shape.rot.y; + player->actor.world.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; + player->actor.focus.rot.y = player->actor.shape.rot.y; + this->unk160 |= 0x10; + func_80953DA8(this, globalCtx); + if (this->unk164 != NULL) { + func_80953B40(this); + } + this->unk16E = -1; + this->actionFunc = func_80953F9C; +} + +void func_80953F8C(BgIngate* this, GlobalContext* globalCtx) { +} + +void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + if (!(gSaveContext.eventInf[4] & 1)) { + + if (!(gSaveContext.eventInf[3] & 0x20) && (this->unk160 & 0x10) && (this->unk16C == 0)) { + this->dyna.actor.textId = 0x9E3; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->unk160 &= ~0x10; + } + + if (this->unk160 & 2) { + + if (this->unk164->unk1 != 0xFF) { + func_80953E38(globalCtx); + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->dyna.actor.textId = 0x9E4; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->unk16C += 1; + gSaveContext.save.weekEventReg[90] |= 0x40; + this->actionFunc = func_809543D4; + } else { + + if (!(gSaveContext.eventInf[3] & 0x20)) { + gSaveContext.eventInf[4] &= (u8)~2; + } else { + gSaveContext.eventInf[4] |= 1; + } + this->actionFunc = func_809542A0; + } + } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->unk164 != NULL)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); + func_80953BEC(this); + } + } + if (ActorCutscene_GetCurrentIndex() != this->unk16E) { + if (ActorCutscene_GetCurrentIndex() != -1) { + func_800DFAC8(camera, 1); + player->stateFlags1 |= 0x20; + globalCtx->actorCtx.unk5 &= ~0x4; + } else { + func_800DFAC8(camera, 47); + player->stateFlags1 &= ~0x20; + } + } + this->unk16E = ActorCutscene_GetCurrentIndex(); +} + +void func_809541B8(BgIngate* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk160 & 0x4) { + if ((player->transformation == PLAYER_FORM_HUMAN) && (player->actor.bgCheckFlags & 1) && + (this->dyna.actor.xzDistToPlayer < 40.0f)) { + if (this->dyna.actor.playerHeightRel > 15.0f) { + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->dyna.actor.textId = 0x9E6; + Message_StartTextbox(globalCtx, this->dyna.actor.textId, NULL); + this->actionFunc = func_809543D4; + } + } + } else if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->unk160 |= 4; + } +} + +void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[5] & 1) { + globalCtx->nextEntranceIndex = 0xA820; + gSaveContext.eventInf[5] &= (u8)~1; + } else { + globalCtx->nextEntranceIndex = 0xA810; + } + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + this->actionFunc = func_80953F8C; + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_800FE498(); +} + +void func_80954340(BgIngate* this, GlobalContext* globalCtx) { + if (!DECR(this->unk16A)) { + if (this->unk164 != NULL) { + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + func_80953F14(this, globalCtx); + func_800FE484(); + } + } +} + +void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); + + if (((talkState == 4) || (talkState == 5)) && Message_ShouldAdvance(globalCtx)) { + switch (this->dyna.actor.textId) { + case 0x9E4: + this->dyna.actor.textId = 0x9E5; + func_80151938(globalCtx, this->dyna.actor.textId); + break; + case 0x9E5: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk160 &= ~0x4; + this->actionFunc = func_809541B8; + func_800FE498(); + func_8019F208(); + } else { + if (this->unk164 != NULL) { + this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + } + func_80953F14(this, globalCtx); + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_8019F230(); + } + func_801477B4(globalCtx); + break; + case 0x9E6: + if (globalCtx->msgCtx.choiceIndex == 0) { + func_80953EA4(this, globalCtx); + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_8019F208(); + } else { + this = this; + func_800B7298(globalCtx, &this->dyna.actor, 6); + this->unk160 &= ~0x4; + this->actionFunc = func_809541B8; + func_800FE498(); + func_8019F230(); + } + func_801477B4(globalCtx); + break; + } + } +} + +void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgIngate* this = THIS; + s32 phi_a2; + Vec3s* sp38; + Vec3f sp2C; + Vec3f sp20; + + if (BgIngate_FindActor(this, globalCtx, ACTORCAT_BG, ACTOR_BG_INGATE) == NULL) { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gSichitaiBoatCol); + this->unk160 = 0; + this->unk160 |= 0x8; + this->unk160 |= 0x10; + Actor_SetScale(&this->dyna.actor, 1.0f); + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->dyna.actor.room = -1; + if (gSaveContext.save.weekEventReg[20] & 2) { + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + } + if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.save.weekEventReg[90] & 0x40)) { + phi_a2 = 1; + this->unk16C = 1; + this->actionFunc = func_809541B8; + } else { + phi_a2 = 0; + if (globalCtx->curSpawn == 6) { + func_80953F14(this, globalCtx); + if (gSaveContext.eventInf[3] & 0x20) { + Interface_InitMinigame(globalCtx); + } else { + gSaveContext.eventInf[4] |= 2; + } + } else { + this->actionFunc = func_80953F8C; + } + } + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + if (this->unk164 != NULL) { + sp38 = Lib_SegmentedToVirtual(this->unk164->points); + Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); + Math_Vec3s_ToVec3f(&sp20, &sp38[1]); + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&sp2C, &sp20); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + this->dyna.actor.world.pos.x = sp2C.x; + this->dyna.actor.world.pos.y = -15.0f; + this->dyna.actor.world.pos.z = sp2C.z; + } + this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + } else { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgIngate_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgIngate* this = THIS; + + if (this->unk160 & 8) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void BgIngate_Update(Actor* thisx, GlobalContext* globalCtx) { + BgIngate* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgIngate_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gSichitaiBoat); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 8daa69d91..08d062e6c 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -7,11 +7,23 @@ struct BgIngate; typedef void (*BgIngateActionFunc)(struct BgIngate*, GlobalContext*); +#define BGINGATE_GET_FF(thisx) ((thisx)->params & 0xFF) + typedef struct BgIngate { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgIngateActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x30]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgIngateActionFunc actionFunc; + /* 0x160 */ u16 unk160; + /* 0x164 */ Path* unk164; + /* 0x168 */ s16 unk168; + /* 0x16A */ s16 unk16A; + /* 0x16C */ s16 unk16C; + /* 0x16E */ s16 unk16E; + /* 0x170 */ Vec3f unk170; + /* 0x17C */ f32 unk17C; + /* 0x180 */ s32 unk180; + /* 0x184 */ s32 unk184; + /* 0x188 */ s32 unk188; + /* 0x18C */ s32 unk18C; } BgIngate; // size = 0x190 extern const ActorInit Bg_Ingate_InitVars; 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 620d55d38..9ae16fb1c 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 @@ -7,7 +7,7 @@ #include "z_bg_inibs_movebg.h" #include "objects/object_inibs_object/object_inibs_object.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgInibsMovebg*)thisx) 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 5abeab5f0..5630bdd8f 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 @@ -6,7 +6,7 @@ #include "z_bg_kin2_bombwall.h" -#define FLAGS 0x10000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_10000000) #define THIS ((BgKin2Bombwall*)thisx) 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 d5d28d5a5..6e27d1dc9 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 @@ -7,7 +7,7 @@ #include "z_bg_kin2_fence.h" #include "objects/object_kin2_obj/object_kin2_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgKin2Fence*)thisx) @@ -122,16 +122,16 @@ static InitChainEntry sInitChain[] = { s32 BgKin2Fence_CheckHitMask(BgKin2Fence* this) { ColliderJntSphElement* elements = this->collider.elements; - if (elements[0].info.bumperFlags & 2) { + if (elements[0].info.bumperFlags & BUMP_HIT) { return 0; } - if (elements[1].info.bumperFlags & 2) { + if (elements[1].info.bumperFlags & BUMP_HIT) { return 1; } - if (elements[2].info.bumperFlags & 2) { + if (elements[2].info.bumperFlags & BUMP_HIT) { return 2; } - if (elements[3].info.bumperFlags & 2) { + if (elements[3].info.bumperFlags & BUMP_HIT) { return 3; } return -1; 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 6fec6820a..de9b891ac 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -7,7 +7,7 @@ #include "z_bg_ladder.h" #include "objects/object_ladder/object_ladder.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgLadder*)thisx) @@ -71,7 +71,7 @@ void BgLadder_Init(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, this->switchFlag)) { // If the flag is set, then the ladder draws immediately this->alpha = 255; - this->dyna.actor.flags &= ~0x10; // always update = off + this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off this->action = BgLadder_ActionIdle; } else { // Otherwise, the ladder doesn't draw; wait for the flag to be set @@ -115,7 +115,7 @@ void BgLadder_ActionFadeIn(BgLadder* this, GlobalContext* globalCtx) { this->alpha = 255; ActorCutscene_Stop(this->dyna.actor.cutscene); func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); - this->dyna.actor.flags &= ~0x10; // always update = off + this->dyna.actor.flags &= ~ACTOR_FLAG_10; // always update = off this->action = BgLadder_ActionIdle; } } 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 41d7e12bb..71f1d2b6a 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -99,7 +99,7 @@ void BgLotus_Wait(BgLotus* this, GlobalContext* globalCtx) { } if (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) { this->timer = 40; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; this->actionFunc = BgLotus_Sink; return; } @@ -152,7 +152,7 @@ void BgLotus_WaitToAppear(BgLotus* this, GlobalContext* globalCtx) { func_800C6314(globalCtx, &globalCtx->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 &= ~0x10; + 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; diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c index db363498c..e25aeaf67 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.c @@ -7,7 +7,7 @@ #include "z_bg_market_step.h" #include "objects/object_market_obj/object_market_obj.h" -#define FLAGS 0x10000020 +#define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_10000000) #define THIS ((BgMarketStep*)thisx) 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 62ae7ab8a..186376d9b 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 @@ -5,8 +5,10 @@ */ #include "z_bg_numa_hana.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_syokudai/object_syokudai.h" -#define FLAGS 0x00000410 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((BgNumaHana*)thisx) @@ -15,14 +17,19 @@ void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx); void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A1AA28(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AA4C(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AB00(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1ABF0(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1ACE0(BgNumaHana* this, GlobalContext* globalCtx); -void func_80A1AE1C(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupDoNothing(BgNumaHana* this); +void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupClosedIdle(BgNumaHana* this); +void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this); +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this); +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupRaiseFlower(BgNumaHana* this); +void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx); +void BgNumaHana_SetupOpenedIdle(BgNumaHana* this); +void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx); -#if 0 const ActorInit Bg_Numa_Hana_InitVars = { ACTOR_BG_NUMA_HANA, ACTORCAT_BG, @@ -35,63 +42,379 @@ const ActorInit Bg_Numa_Hana_InitVars = { (ActorFunc)BgNumaHana_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A1B260 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x01CBFBB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFBB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 16, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1B2A8[] = { +static FireObjInitParams sFireObjInit = { + 0.00405000010505f, 0.0500000007451f, 3, 1, 0, 0, 0, +}; + +static s16 sInitialAnglePerPetal[] = { 0x0000, 0x2AAA, 0x5555, 0x8000, 0xAAAA, 0xD555 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 800, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 600, ICHAIN_STOP), }; -#endif +/** + * Spawns another wooden flower instance that handles the opened flower's collision. + * Returns true if this wooden flower instance was succesfully spawned. + */ +s32 BgNumaHana_SpawnOpenFlowerCollisionChild(BgNumaHana* this, GlobalContext* globalCtx) { + Actor* child; -extern ColliderCylinderInit D_80A1B260; -extern InitChainEntry D_80A1B2A8[]; + child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_NUMA_HANA, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, + BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION); -extern UNK_TYPE D_06009FE0; -extern UNK_TYPE D_0600B928; + return child != NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A500.s") +void BgNumaHana_UpdatePetalPosRots(BgNumaHana* this) { + f32 outerPetalPosScale; + f32 innerPetalYPos; + f32 outerPetalYPos; + s16 angle; + WoodenFlowerPetalPosRot* innerPetalPosRot; + WoodenFlowerPetalPosRot* outerPetalPosRot; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A56C.s") + innerPetalYPos = this->dyna.actor.world.pos.y + -10.0f; + angle = this->petalZRotation - 0x2000; + outerPetalPosScale = (Math_CosS(angle) * 77.42784f) + 74.95192f; + outerPetalYPos = (Math_SinS(this->petalZRotation) * 77.42784f) + this->dyna.actor.world.pos.y + -64.74976f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1A750.s") + for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) { + innerPetalPosRot = &this->innerPetalPosRot[i]; + outerPetalPosRot = &this->outerPetalPosRot[i]; + angle = sInitialAnglePerPetal[i] + this->dyna.actor.shape.rot.y + 0x1555; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Init.s") + innerPetalPosRot->pos.x = (Math_SinS(angle) * 74.95192f) + this->dyna.actor.world.pos.x; + innerPetalPosRot->pos.y = innerPetalYPos; + innerPetalPosRot->pos.z = (Math_CosS(angle) * 74.95192f) + this->dyna.actor.world.pos.z; + innerPetalPosRot->rot.x = this->dyna.actor.shape.rot.x; + innerPetalPosRot->rot.y = angle - 0x4000; + innerPetalPosRot->rot.z = this->dyna.actor.shape.rot.z + this->petalZRotation; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Destroy.s") + outerPetalPosRot->pos.x = (Math_SinS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.x; + outerPetalPosRot->pos.y = outerPetalYPos; + outerPetalPosRot->pos.z = (Math_CosS(angle) * outerPetalPosScale) + this->dyna.actor.world.pos.z; + outerPetalPosRot->rot.x = innerPetalPosRot->rot.x; + outerPetalPosRot->rot.y = innerPetalPosRot->rot.y; + outerPetalPosRot->rot.z = innerPetalPosRot->rot.z + this->outerPetalZRotation; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA14.s") +/** + * As the pieces of the petals finish unfolding, they shake to appear + * as if they are "settling" into place. This function is responsible + * for computing the extra rotation for this "settling". + */ +void BgNumaHana_UpdateSettleRotation(s16* settleZRotation, s16* settleAngle, f32* settleScale, f32 scaleStep) { + *settleAngle += 0x32C8; + Math_StepToF(settleScale, 0.0f, scaleStep); + *settleZRotation += (s16)(Math_SinS(*settleAngle) * *settleScale); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA28.s") +void BgNumaHana_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DynaPolyActor* child; + s32 type; + BgNumaHana* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA38.s") + type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 3); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AA4C.s") + if (type == BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerOpenedFlowerCol); + BgNumaHana_SetupDoNothing(this); + this->dyna.actor.draw = NULL; + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWoodenFlowerClosedFlowerCol); + FireObj_Init(globalCtx, &this->fire, &sFireObjInit, &this->dyna.actor); + Collider_InitCylinder(globalCtx, &this->torchCollider); + Collider_SetCylinder(globalCtx, &this->torchCollider, &this->dyna.actor, &sCylinderInit); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + if (!BgNumaHana_SpawnOpenFlowerCollisionChild(this, globalCtx)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AAE8.s") + if (gSaveContext.save.weekEventReg[12] & 1) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AB00.s") + this->petalZRotation = 0x2000; + this->innerPetalZRotation = 0x2000; + this->innerPetalZRotationalVelocity = 0; + this->settleZRotation = 0; + this->settleAngle = 0; + this->settleScale = 0.0f; + this->outerPetalZRotation = -0x4000; + this->outerPetalZRotationalVelocity = 0; + this->flowerRotationalVelocity = 0x147; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABD8.s") + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 210.0f; + FireObj_SetState2(&this->fire, 0.05f, 2); + Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupOpenedIdle(this); + } else { + child = (DynaPolyActor*)this->dyna.actor.child; + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, child->bgId); + Flags_UnsetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupClosedIdle(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ABF0.s") + BgNumaHana_UpdatePetalPosRots(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACCC.s") +void BgNumaHana_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgNumaHana* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1ACE0.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (BG_NUMA_HANA_GET_TYPE(&this->dyna.actor) == BG_NUMA_HANA_TYPE_NORMAL) { + FireObj_Destroy(globalCtx, &this->fire); + Collider_DestroyCylinder(globalCtx, &this->torchCollider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE08.s") +void BgNumaHana_SetupDoNothing(BgNumaHana* this) { + this->actionFunc = BgNumaHana_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/func_80A1AE1C.s") +void BgNumaHana_DoNothing(BgNumaHana* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Update.s") +void BgNumaHana_SetupClosedIdle(BgNumaHana* this) { + this->actionFunc = BgNumaHana_ClosedIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Numa_Hana/BgNumaHana_Draw.s") +/** + * This function waits for the torch to be lit. Once it is, it starts + * the cutscene where the petals unfold. + */ +void BgNumaHana_ClosedIdle(BgNumaHana* this, GlobalContext* globalCtx) { + 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); + gSaveContext.save.weekEventReg[12] |= 1; + Flags_SetSwitch(globalCtx, BG_NUMA_HANA_SWITCH_FLAG(&this->dyna.actor)); + BgNumaHana_SetupUnfoldInnerPetals(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } +} + +void BgNumaHana_SetupUnfoldInnerPetals(BgNumaHana* this) { + this->actionFunc = BgNumaHana_UnfoldInnerPetals; + this->transitionTimer = 0; +} + +/** + * Partially moves the flower to the "open" position by raising the "inner" + * parts of the petals that are closest to the stalk. + */ +void BgNumaHana_UnfoldInnerPetals(BgNumaHana* this, GlobalContext* globalCtx) { + Math_StepToS(&this->innerPetalZRotationalVelocity, 240, 14); + if (Math_ScaledStepToS(&this->innerPetalZRotation, 0x2000, this->innerPetalZRotationalVelocity)) { + if (this->transitionTimer >= 11) { + BgNumaHana_SetupUnfoldOuterPetals(this); + } else { + if (this->transitionTimer <= 0) { + this->settleZRotation = 0; + this->settleAngle = 0; + this->settleScale = 420.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + } + this->transitionTimer++; + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG); + } + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 20.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); +} + +void BgNumaHana_SetupUnfoldOuterPetals(BgNumaHana* this) { + this->actionFunc = BgNumaHana_UnfoldOuterPetals; + this->transitionTimer = 0; +} + +/** + * Partially moves the flower to the "open" position by lowering the "outer" + * parts of the petals that are furthest to the stalk. + */ +void BgNumaHana_UnfoldOuterPetals(BgNumaHana* this, GlobalContext* globalCtx) { + Math_StepToS(&this->outerPetalZRotationalVelocity, 240, 14); + if (Math_ScaledStepToS(&this->outerPetalZRotation, -0x4000, this->outerPetalZRotationalVelocity)) { + if (this->transitionTimer >= 11) { + BgNumaHana_SetupRaiseFlower(this); + } else { + if (this->transitionTimer <= 0) { + this->settleZRotation = 0; + this->settleAngle = 0x5120; + this->settleScale = 130.0f; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_STOP); + } + this->transitionTimer++; + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWERPETAL_MOVE - SFX_FLAG); + } + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 7.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); +} + +void BgNumaHana_SetupRaiseFlower(BgNumaHana* this) { + this->actionFunc = BgNumaHana_RaiseFlower; +} + +/** + * This function slowly raises the flower to its final height and makes it start spinning. + */ +void BgNumaHana_RaiseFlower(BgNumaHana* this, GlobalContext* globalCtx) { + s32 pad; + DynaPolyActor* child; + + BgNumaHana_UpdateSettleRotation(&this->settleZRotation, &this->settleAngle, &this->settleScale, 10.0f); + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + Math_StepToS(&this->flowerRotationalVelocity, 0x111, 0xA); + this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity; + Math_StepToF(&this->dyna.actor.velocity.y, 3.0f, 0.3f); + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 210.0f, + this->dyna.actor.velocity.y)) { + child = (DynaPolyActor*)this->dyna.actor.child; + + // Swaps out the "closed" flower collision for the "opened" collision. + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, child->bgId); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + + this->petalZRotation = 0x2000; + this->innerPetalZRotation = 0x2000; + this->innerPetalZRotationalVelocity = 0; + this->settleZRotation = 0; + this->settleAngle = 0; + this->outerPetalZRotation = -0x4000; + this->outerPetalZRotationalVelocity = 0; + this->flowerRotationalVelocity = 0x147; + this->settleScale = 0.0f; + + ActorCutscene_Stop(this->dyna.actor.cutscene); + BgNumaHana_SetupOpenedIdle(this); + } + + BgNumaHana_UpdatePetalPosRots(this); + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG); +} + +void BgNumaHana_SetupOpenedIdle(BgNumaHana* this) { + this->actionFunc = BgNumaHana_OpenedIdle; +} + +/** + * Spins the "opened" flower around the y-axis. + */ +void BgNumaHana_OpenedIdle(BgNumaHana* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.rot.y += this->flowerRotationalVelocity; + this->petalZRotation = this->innerPetalZRotation + this->settleZRotation; + BgNumaHana_UpdatePetalPosRots(this); + func_800B9010(&this->dyna.actor, NA_SE_EV_FLOWER_ROLLING - SFX_FLAG); +} + +void BgNumaHana_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + BgNumaHana* this = THIS; + s32 type = BG_NUMA_HANA_GET_TYPE(&this->dyna.actor); + Vec3f firePos; + + if (type == BG_NUMA_HANA_TYPE_NORMAL) { + firePos.x = this->dyna.actor.world.pos.x; + firePos.y = this->dyna.actor.world.pos.y + 10.5f; + firePos.z = this->dyna.actor.world.pos.z; + FireObj_SetPosition(&this->fire, &firePos); + FireObj_Update(globalCtx, &this->fire, &this->dyna.actor); + } + + this->actionFunc(this, globalCtx); + + if (type == BG_NUMA_HANA_TYPE_NORMAL) { + this->dyna.actor.child->shape.rot = this->dyna.actor.shape.rot; + Collider_UpdateCylinder(&this->dyna.actor, &this->torchCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->torchCollider.base); + } +} + +void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + BgNumaHana* this = THIS; + WoodenFlowerPetalPosRot* innerPetalPosRot; + WoodenFlowerPetalPosRot* outerPetalPosRot; + s32 objectIndex; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerStalkDL); + + for (i = 0; i < ARRAY_COUNT(this->innerPetalPosRot); i++) { + innerPetalPosRot = &this->innerPetalPosRot[i]; + outerPetalPosRot = &this->outerPetalPosRot[i]; + + Matrix_SetStateRotationAndTranslation(innerPetalPosRot->pos.x, innerPetalPosRot->pos.y, innerPetalPosRot->pos.z, + &innerPetalPosRot->rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerInnerPetalDL); + + Matrix_SetStateRotationAndTranslation(outerPetalPosRot->pos.x, outerPetalPosRot->pos.y, outerPetalPosRot->pos.z, + &outerPetalPosRot->rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gWoodenFlowerOuterPetalDL); + } + + objectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_SYOKUDAI); + if ((objectIndex >= 0) && (Object_IsLoaded(&globalCtx->objectCtx, objectIndex))) { + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 64.5f, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(1.5f, 1.5f, 1.5f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPDisplayList(POLY_OPA_DISP++, gObjectSyokudaiTypeNoSwitchDL); + } + + FireObj_Draw(globalCtx, &this->fire); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 f4974860a..19d30a34f 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 @@ -3,15 +3,41 @@ #include "global.h" +#define BG_NUMA_HANA_GET_TYPE(thisx) ((thisx)->params & 1) +#define BG_NUMA_HANA_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef enum { + /* 0 */ BG_NUMA_HANA_TYPE_NORMAL, + /* 1 */ BG_NUMA_HANA_TYPE_OPEN_FLOWER_COLLISION, +} BgNumaHanaType; + struct BgNumaHana; typedef void (*BgNumaHanaActionFunc)(struct BgNumaHana*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3s rot; + /* 0x12 */ UNK_TYPE1 unk_12[0x2]; +} WoodenFlowerPetalPosRot; // size = 0x14 + typedef struct BgNumaHana { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF0]; - /* 0x0234 */ BgNumaHanaActionFunc actionFunc; - /* 0x0238 */ char unk_238[0x108]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ FireObj fire; + /* 0x1E8 */ ColliderCylinder torchCollider; + /* 0x234 */ BgNumaHanaActionFunc actionFunc; + /* 0x238 */ WoodenFlowerPetalPosRot innerPetalPosRot[6]; + /* 0x2B0 */ WoodenFlowerPetalPosRot outerPetalPosRot[6]; + /* 0x328 */ s16 petalZRotation; + /* 0x32A */ s16 innerPetalZRotation; + /* 0x32C */ s16 innerPetalZRotationalVelocity; + /* 0x32E */ s16 settleZRotation; + /* 0x330 */ s16 settleAngle; + /* 0x334 */ f32 settleScale; + /* 0x338 */ s16 outerPetalZRotation; + /* 0x33A */ s16 outerPetalZRotationalVelocity; + /* 0x33C */ s16 flowerRotationalVelocity; + /* 0x33E */ s16 transitionTimer; } BgNumaHana; // size = 0x340 extern const ActorInit Bg_Numa_Hana_InitVars; 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 ecfc8ad02..f1fa69810 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 @@ -6,7 +6,7 @@ #include "z_bg_open_shutter.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgOpenShutter*)thisx) 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 8657a40db..b776253e6 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 @@ -6,7 +6,7 @@ #include "z_bg_open_spot.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgOpenSpot*)thisx) 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 8e443f529..e5af3fe1f 100644 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c +++ b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.c @@ -1,12 +1,12 @@ /* * File: z_bg_sinkai_kabe.c * Overlay: ovl_Bg_Sinkai_Kabe - * Description: Large Rotating Green Rupee + * Description: Manages the Deep Pythons and Seahorse in Pinnacle Rock */ #include "z_bg_sinkai_kabe.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((BgSinkaiKabe*)thisx) 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 6fccf89a0..d1847009c 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -5,6 +5,7 @@ */ #include "z_bg_spdweb.h" +#include "objects/object_spdweb/object_spdweb.h" #define FLAGS 0x00000000 @@ -15,7 +16,14 @@ void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx); void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809CE068(BgSpdweb* this); +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx); +void func_809CEE74(BgSpdweb* this); +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx); + const ActorInit Bg_Spdweb_InitVars = { ACTOR_BG_SPDWEB, ACTORCAT_BG, @@ -28,89 +36,491 @@ const ActorInit Bg_Spdweb_InitVars = { (ActorFunc)BgSpdweb_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_809CF080[2] = { +static ColliderTrisElementInit sTrisElementsInit1[2] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { 75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, -75.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000C00, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000C00, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 75.0f, -8.0f, 75.0f }, { -75.0f, -8.0f, -75.0f }, { -75.0f, -8.0f, 75.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF0F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 2, D_809CF080, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[4] = { -static ColliderTrisElementInit D_809CF108[4] = { +static ColliderTrisElementInit sTrisElementsInit2[4] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 70.0f, 160.0f, 15.0f }, { -70.0f, 20.0f, 15.0f }, { 70.0f, 20.0f, 15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -70.0f, 160.0f, -15.0f }, { 70.0f, 20.0f, -15.0f }, { -70.0f, 20.0f, -15.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_809CF1F8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_TRIS, }, - 4, D_809CF108, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_TRIS, + }, + 4, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809CF210[] = { +Color_RGBA8 D_809CF208 = { 255, 255, 150, 170 }; + +Color_RGBA8 D_809CF20C = { 255, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; +void BgSpdweb_Init(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_161 = 0; + this->switchFlag = BGSPDWEB_GET_SWITCHFLAG(&this->dyna.actor); + thisx->params &= 0xFF; + DynaPolyActor_Init(&this->dyna, 1); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit1, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_002678); + this->unk_2F8 = globalCtx->colCtx.dyna.bgActors[this->dyna.bgId].colHeader->vtxList; + this->unk_164 = 0.0f; + this->actionFunc = func_809CE4C8; + } else { + Collider_InitAndSetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit2, this->colliderElements); + func_809CE068(this); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spdweb_Colheader_0011C0); + this->actionFunc = func_809CEBC0; + Actor_SetFocus(&this->dyna.actor, 30.0f); + } + + this->unk_162 = 0; + + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgSpdweb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_809CE068(BgSpdweb* this) { + Vec3f sp64[3]; + s32 i; + s32 j; + + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + for (i = 0; i < this->collider.count; i++) { + for (j = 0; j < ARRAY_COUNT(sp64); j++) { + Matrix_MultiplyVector3fByState(this->collider.elements[i].dim.vtx + j, &sp64[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp64[0], &sp64[1], &sp64[2]); + } +} + +void func_809CE15C(BgSpdweb* this) { + this->unk_2F8[0].y = this->unk_2F8[3].y = this->unk_2F8[10].y = this->unk_2F8[11].y = this->unk_2F8[12].y = + this->unk_2F8[13].y = this->unk_2F8[14].y = this->unk_2F8[15].y = + (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y) * 10.0f; +} + +void func_809CE1D0(BgSpdweb* this, GlobalContext* globalCtx) { + this->unk_162 = 30; + Flags_SetSwitch(globalCtx, this->switchFlag); + + if (this->dyna.actor.params == BGSPDWEB_FF_0) { + this->actionFunc = func_809CE234; + } else { + this->actionFunc = func_809CE830; + } +} + +void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spB4; + Vec3f spA8; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + s16 phi_s2; + s16 temp_s0; + s32 i; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + phi_s2 = Rand_ZeroOne() * 10922.0f; + spB4.y = 0.0f; + spA8.y = this->dyna.actor.world.pos.y; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(10240.0f) + phi_s2; + temp_f24 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spA8.x = this->dyna.actor.world.pos.x + (120.0f * temp_f24); + spA8.z = this->dyna.actor.world.pos.z + (120.0f * temp_f22); + + temp_f20 = Math_Vec3f_DistXZ(&this->dyna.actor.home.pos, &spA8) * (1.0f / 120.0f); + if (temp_f20 < 0.7f) { + temp_f20 = 1.0f - temp_f20; + temp_f24 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spB4.x = 7.0f * temp_f24 * temp_f20; + spB4.y = 0.0f; + spB4.z = 7.0f * temp_f22 * temp_f20; + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spB4, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x32, 8, 0xE); + phi_s2 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} + +void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + ColliderTrisElement* element; + s16 sp3A; + s32 i; + f32 temp_f12; + + sp40.x = this->dyna.actor.world.pos.x; + sp40.y = this->dyna.actor.world.pos.y - 50.0f; + sp40.z = this->dyna.actor.world.pos.z; + sp3A = player->unk_B6A; + + if (func_80123F48(globalCtx, &sp40, 70.0f, 50.0f)) { + this->dyna.actor.home.pos.x = player->swordInfo[0].tip.x; + this->dyna.actor.home.pos.z = player->swordInfo[0].tip.z; + func_809CEE74(this); + return; + } + + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < 2; i++) { + element = &this->collider.elements[i]; + if (element->info.bumperFlags & BUMP_HIT) { + if (this->collider.elements[i].info.acHitInfo->toucher.dmgFlags & 0x800) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &element->info.bumper.hitPos); + func_809CEE74(this); + return; + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + sp3A = 300; + break; + } + } + } + } + + if (DynaPolyActor_IsInRidingMovingState(&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; + this->unk_162 = 12; + if (sp3A > 50) { + player->stateFlags1 |= 0x20; + this->unk_161 = 1; + } + } else if (player->actor.speedXZ != 0.0f) { + this->unk_164 = CLAMP_MIN(this->unk_164, 2.0f); + } + } + + if (this->unk_162 != 0) { + this->unk_162--; + } + + this->dyna.actor.world.pos.y = (sin_rad(this->unk_162 * (M_PI / 6)) * this->unk_164) + this->dyna.actor.home.pos.y; + 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))) { + player->actor.velocity.y = this->unk_164 * 0.7f; + player->unk_B68 = (SQ(this->unk_164) * 0.15f) + this->dyna.actor.world.pos.y; + this->unk_161 = 0; + player->stateFlags1 &= ~0x20; + } + } else if (this->unk_162 == 11) { + if (this->unk_164 > 3.0f) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); + } else { + func_801A75E8(NA_SE_EV_WEB_VIBRATION); + } + } + + if (this->unk_162 == 0) { + this->unk_162 = 12; + } + + func_809CE15C(this); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +#ifdef NON_MATCHING +void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 spB0; + f32 spA4; + f32 sp9C; + f32 sp94; + f32 sp90; + f32 temp_f20; + f32 temp_f22; + f32 temp_f28; + f32 temp_f30; + s32 i; + s16 temp_s0; + s16 temp_s3; + + if (this->unk_162 != 0) { + this->unk_162--; + } + + if (this->unk_162 == 0) { + if (ActorCutscene_GetLength(this->dyna.actor.cutscene) == -1) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + if ((this->unk_162 % 3) == 0) { + temp_s3 = Rand_ZeroOne() * 0x2AAA; + spB0 = Math_CosS(this->dyna.actor.shape.rot.x); + temp_f20 = Math_SinS(this->dyna.actor.shape.rot.x); + temp_f30 = Math_CosS(this->dyna.actor.shape.rot.y); + spA4 = Math_SinS(this->dyna.actor.shape.rot.y); + if (1) {} + + spC4.x = this->dyna.actor.world.pos.x + ((90.0f * temp_f20) * spA4); + spC4.y = this->dyna.actor.world.pos.y + (90.0f * spB0); + spC4.z = this->dyna.actor.world.pos.z + ((90.0f * temp_f20) * temp_f30); + + sp94 = temp_f20 * spA4; + sp90 = temp_f20 * temp_f30; + + for (i = 0; i < 6; i++) { + temp_s0 = (s32)randPlusMinusPoint5Scaled(0x2800) + temp_s3; + temp_f20 = Math_SinS(temp_s0); + temp_f22 = Math_CosS(temp_s0); + + spD0.x = spC4.x + (90.0f * ((sp94 * temp_f22) + (temp_f30 * temp_f20))); + spD0.y = spC4.y + ((90.0f * spB0) * temp_f22); + spD0.z = spC4.z + (90.0f * ((sp90 * temp_f22) - (spA4 * temp_f20))); + + temp_f28 = Math_Vec3f_DistXYZ(&this->dyna.actor.home.pos, &spD0) * (1.0f / 90.0f); + if (temp_f28 < 0.65f) { + temp_f28 = 1.0f - temp_f28; + temp_f20 = Math_SinS(BINANG_ROT180(temp_s0)); + temp_f22 = Math_CosS(BINANG_ROT180(temp_s0)); + } + + spDC.x = (6.5f * temp_f28) * ((temp_f30 * temp_f20) + (temp_f22 * sp94)); + spDC.y = temp_f22 * ((6.5f * temp_f28) * spB0); + spDC.z = (6.5f * temp_f28) * ((temp_f22 * sp90) - (spA4 * temp_f20)); + + EffectSsDeadDb_Spawn(globalCtx, &this->dyna.actor.home.pos, &spDC, &gZeroVec3f, &D_809CF208, &D_809CF20C, + 0x3C, 8, 0xE); + temp_s3 += 0x2AAA; + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.home.pos, 11, NA_SE_EN_EXTINCT); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") #endif -extern ColliderTrisElementInit D_809CF080[2]; -extern ColliderTrisInit D_809CF0F8; -extern ColliderTrisElementInit D_809CF108[4]; -extern ColliderTrisInit D_809CF1F8; -extern InitChainEntry D_809CF210[]; +void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 sp58; + f32 temp_f10; + f32 temp_f18; + ColliderTrisElement* ptr; + s32 i; + Vec3f sp3C; + f32 sp38; + f32 sp34; + f32 sp30; + f32 sp2C; -extern UNK_TYPE D_06000060; -extern UNK_TYPE D_06002678; + if (this->collider.base.acFlags & AC_HIT) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + if (ptr->info.bumperFlags & BUMP_HIT) { + Math_Vec3s_ToVec3f(&this->dyna.actor.home.pos, &ptr->info.bumper.hitPos); + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Init.s") + if (i == ARRAY_COUNT(this->colliderElements)) { + this->dyna.actor.home.pos.x = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_SinS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.x; + this->dyna.actor.home.pos.y = + (90.0f * Math_CosS(this->dyna.actor.shape.rot.x)) + this->dyna.actor.world.pos.y; + this->dyna.actor.home.pos.z = + ((90.0f * Math_SinS(this->dyna.actor.shape.rot.x)) * Math_CosS(this->dyna.actor.shape.rot.y)) + + this->dyna.actor.world.pos.z; + } + func_809CEE74(this); + } else if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); + sp38 = Math_SinS(-this->dyna.actor.shape.rot.x); + sp34 = Math_CosS(-this->dyna.actor.shape.rot.x); + sp30 = Math_SinS(-this->dyna.actor.shape.rot.y); + sp2C = Math_CosS(-this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Destroy.s") + temp_f18 = ((sp3C.x * sp38 * sp30) + (sp3C.y * sp34)) - (sp3C.z * sp38 * sp2C); + sp58 = (-sp3C.x * sp34 * sp30) + (sp3C.y * sp38) + (sp3C.z * sp34 * sp2C); + temp_f10 = (sp3C.x * sp2C) + (sp3C.z * sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE068.s") + if ((fabsf(temp_f10) < 70.0f) && (fabsf(sp58) < 10.0f) && (temp_f18 < 160.0f) && (temp_f18 > 20.0f)) { + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &player->swordInfo[0].tip); + func_809CEE74(this); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE15C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE1D0.s") +void func_809CEE74(BgSpdweb* this) { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = func_809CEEAC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE234.s") +void func_809CEEAC(BgSpdweb* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_809CE1D0(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE4C8.s") +void BgSpdweb_Update(Actor* thisx, GlobalContext* globalCtx) { + BgSpdweb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CE830.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEBC0.s") +void BgSpdweb_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEE74.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/func_809CEEAC.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Update.s") + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Spdweb/BgSpdweb_Draw.s") + if (thisx->params == BGSPDWEB_FF_1) { + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_000060); + } else { + Matrix_InsertTranslation(0.0f, (thisx->home.pos.y - thisx->world.pos.y) * 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, ((thisx->home.pos.y - thisx->world.pos.y) + 10.0f) * 0.1f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_spdweb_DL_0012F0); + } + + POLY_XLU_DISP = &gfx[3]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h index 1809d6723..9a71c278f 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.h @@ -7,11 +7,21 @@ struct BgSpdweb; typedef void (*BgSpdwebActionFunc)(struct BgSpdweb*, GlobalContext*); +#define BGSPDWEB_GET_SWITCHFLAG(thisx) (((thisx)->params >> 8) & 0x7F) + +#define BGSPDWEB_FF_0 0 +#define BGSPDWEB_FF_1 1 + typedef struct BgSpdweb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgSpdwebActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x19C]; + /* 0x0160 */ u8 switchFlag; + /* 0x0161 */ u8 unk_161; + /* 0x0162 */ s16 unk_162; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ ColliderTris collider; + /* 0x0188 */ ColliderTrisElement colliderElements[4]; + /* 0x02F8 */ Vec3s* unk_2F8; } BgSpdweb; // size = 0x2FC extern const ActorInit Bg_Spdweb_InitVars; 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 8f8788660..f9b76fd00 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -7,7 +7,7 @@ #include "z_bg_tobira01.h" #include "objects/object_spot11_obj/object_spot11_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BgTobira01*)thisx) diff --git a/src/overlays/actors/ovl_Boss_01/z_boss_01.c b/src/overlays/actors/ovl_Boss_01/z_boss_01.c index 467911ca9..4a6ef6e66 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.c +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.c @@ -6,7 +6,7 @@ #include "z_boss_01.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss01*)thisx) 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 a31a2359f..888a0587a 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -9,8 +9,9 @@ #include "overlays/actors/ovl_Item_B_Heart/z_item_b_heart.h" #include "objects/object_boss02/object_boss02.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "prevent_bss_reordering.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss02*)thisx) @@ -563,7 +564,7 @@ void Boss02_Init(Actor* thisx, GlobalContext* globalCtx) { globalCtx->specialEffects = (void*)D_809E0438; this->actor.update = func_809DC78C; this->actor.draw = func_809DD0A8; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1D70 = 0.00999999977648f; if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x20) || (D_809E0434 != NULL)) { this->unk_1D20 = 0; @@ -732,7 +733,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_INBOSS_ROAR_OLD); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (this->unk_0195 != 0) { this->actor.world.rot.z = Math_SinS(this->unk_014C * 0x1200) * 0xE00; } else { @@ -1152,9 +1153,9 @@ void func_809DC218(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.focus.pos.y < BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp20, &sp24)) || (D_809E0422 != 0)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } } } @@ -1281,22 +1282,22 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { Boss02* this = THIS; this->unk_01AC = D_809DF5B0; - globalCtx->envCtx.unk_EA = 0xD; + globalCtx->envCtx.sandstormState = 0xD; if (D_809E0434 != NULL) { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = 0; - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; globalCtx->skyboxId = 1; } else if (D_809E0422 == 0) { this->unk_1D74 = 0.0f; D_801F4E30 = this->unk_1D7C; - globalCtx->envCtx.unk_C3 = 0; + globalCtx->envCtx.lightSettingOverride = 0; globalCtx->skyboxId = 2; } else { this->unk_1D74 = KREG(23) + -15.0f; D_801F4E30 = ((KREG(24) * 0.1f) + 1.0f) * this->unk_1D7C; - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; globalCtx->skyboxId = 1; } @@ -1320,8 +1321,6 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { func_809DD934(this, globalCtx); } -#ifdef NON_MATCHING -// matrix stuff at the start? void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { static Gfx* D_809DFA9C[] = { object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, @@ -1332,12 +1331,12 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { object_boss02_DL_013210, object_boss02_DL_013590, }; static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; - Boss02* this = THIS; GlobalContext* globalCtx = globalCtx2; + Boss02* this = THIS; s32 i; s32 idx; - RSPMatrix* matrix; - s32 pad; + Mtx* mtx; + Mtx* mtxIter; s32 phi_v0; f32 phi_f12; f32 spAC; @@ -1347,7 +1346,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { f32 sp9C; f32 sp98; - matrix = (RSPMatrix*)GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(RSPMatrix) * 23); + mtxIter = mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 23); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1359,7 +1358,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_boss02_Tex_0041A0)); } - gSPSegment(POLY_OPA_DISP++, 0x0D, matrix); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); if (D_809E0422 == 0) { sp98 = -500.0f; @@ -1396,11 +1395,11 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { spA4 = 0.0f; spA0 = 0.0f; - for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++) { + for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtxIter++) { if (this->unk_0195 != 0) { - phi_v0 = (D_809DF5E4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5E4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } else { - phi_v0 = (D_809DF5B4[i] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); + phi_v0 = (D_809DF5B4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } if ((i == 21) && (this->unk_0144 < 20)) { @@ -1416,9 +1415,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_InsertYRotation_f(M_PI / 2, MTXMODE_APPLY); Matrix_RotateStateAroundXAxis(-(M_PI / 2)); - Matrix_GetStateAsRSPMatrix(&matrix[i]); + Matrix_ToMtx(mtxIter); - gSPMatrix(POLY_OPA_DISP++, &matrix[i], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if ((this->unk_0156 & 1) && (i >= this->unk_0158) && (this->unk_015A >= i)) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); @@ -1443,7 +1442,7 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { Actor* child = this->actor.child; if (child != NULL) { - Matrix_GetStateTranslationAndScaledX(500.0f, &child->world.pos); + Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.child->world.pos); } func_809DA50C(1, &this->colliderSphere2, &this->unk_147C[i + 1]); @@ -1464,18 +1463,6 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_809DA50C(21, &this->colliderSphere1, &D_809DFAF4); } } -#else -static Gfx* D_809DFA9C[] = { - object_boss02_DL_00ECF0, object_boss02_DL_00EF90, object_boss02_DL_00F310, object_boss02_DL_00F690, - object_boss02_DL_00FA10, object_boss02_DL_00FD90, object_boss02_DL_010110, object_boss02_DL_010490, - object_boss02_DL_010810, object_boss02_DL_010B90, object_boss02_DL_010F10, object_boss02_DL_011290, - object_boss02_DL_011610, object_boss02_DL_011990, object_boss02_DL_011D10, object_boss02_DL_012090, - object_boss02_DL_012410, object_boss02_DL_012790, object_boss02_DL_012B10, object_boss02_DL_012E90, - object_boss02_DL_013210, object_boss02_DL_013590, -}; -static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/Boss02_Draw.s") -#endif void func_809DD0A8(Actor* thisx, GlobalContext* globalCtx) { func_809DD2F8(globalCtx); @@ -1591,7 +1578,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { for (i = 0, flag = false; i < ARRAY_COUNT(D_809E0438); i++, effect++) { if (effect->unk_24 == 4) { if (!flag) { //! @bug - dev forgot to set flag to 1, should only apply to first entry? - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } @@ -1603,7 +1590,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } @@ -1621,7 +1608,7 @@ void func_809DD2F8(GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, effect->unk_26 + (i * 3), (effect->unk_26 + (i * 3)) * 5, 32, 64, 1, 0, 0, 32, 32)); - Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, 0); + Matrix_InsertTranslation(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); @@ -1634,8 +1621,6 @@ void func_809DD2F8(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -#ifdef NON_MATCHING -// Small ordering in the last loop void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 i; @@ -1650,10 +1635,10 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { switch (this->unk_1D18) { case 0: if (player->stateFlags1 & 0x100) { - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); func_8016566C(150); this->unk_1D14 = 0; this->unk_1D5C = 0.0f; @@ -1770,8 +1755,8 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D18 = 0; func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); - this->actor.flags |= 1; + Cutscene_End(globalCtx, &globalCtx->csCtx); + this->actor.flags |= ACTOR_FLAG_1; player->stateFlags1 &= ~0x100; this->unk_1D70 = 0.01f; func_80165690(); @@ -1784,7 +1769,7 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { Actor_SetScale(&player->actor, this->unk_1D70); } - globalCtx->envCtx.unk_8C.fogNear = this->unk_1D74; + globalCtx->envCtx.lightSettings.fogNear = this->unk_1D74; if (sp57) { D_809E0422 = 1 - D_809E0422; @@ -1946,9 +1931,11 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { } temp_a0_5 = temp_a0_5->next; } + { + f32 tmp = D_809E0422 ? 3150.0f : 0.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, D_809E0422 ? 3150.0f : 0.0f, 0, 0, 0, 0, - D_809E0422); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_INIBS_MOVEBG, 0, tmp, 0, 0, 0, 0, D_809E0422); + } temp_a0_5 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; while (temp_a0_5 != NULL) { @@ -2048,13 +2035,10 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; Matrix_InsertZRotation_f(this->unk_1D54, MTXMODE_APPLY); Matrix_GetStateTranslationAndScaledY(1.0f, &this->unk_1D3C); - func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); - ShrinkWindow_SetLetterboxTarget(0x1B); + Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); + ShrinkWindow_SetLetterboxTarget(27); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_02/func_809DD934.s") -#endif void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); @@ -2077,10 +2061,10 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { break; } - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); this->unk_1D20 = 2; this->unk_1D1C = 0; @@ -2163,9 +2147,9 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == (u32)(BREG(27) + 335)) { func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1D20 = 0; D_809E0424->unk_0144 = D_809E0428->unk_0144 = 3; D_809E0424->unk_0146[0] = D_809E0428->unk_0146[0] = 60; @@ -2175,10 +2159,10 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { case 100: if (ActorCutscene_GetCurrentIndex() == -1) { - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_1D22 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_1D22, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_1D22 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_1D22, 7); this->unk_1D20 = 101; this->unk_1D1C = 0; this->unk_1D5C = 1.0f; @@ -2224,10 +2208,10 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D1C == 30) { func_80169AFC(globalCtx, this->unk_1D22, 0); this->unk_1D22 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->unk_1D20 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; sp68->unk_0144 = 10; if ((D_809E0424->unk_0144 >= 10) && (D_809E0428->unk_0144 >= 10)) { f32 phi_f0; @@ -2260,9 +2244,9 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { if ((this->unk_1D20 != 0) && (this->unk_1D22 != 0)) { sp5C = this->unk_1D24; sp5C.y += sp58 * D_809DF5B0; - func_8016981C(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); + Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &sp5C, &this->unk_1D3C); this->unk_1D3C.z = this->unk_1D3C.x = 0.0f; this->unk_1D3C.y = 1.0f; - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); } } 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 ce8551aa7..31e8fb0ae 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -4,12 +4,79 @@ * Description: Gyorg */ -#include "z_boss_03.h" +/** + * Some notes: + * + * Global flags: + * - gSaveContext.eventInf[5] & 0x40: Enabled when Gyorg's intro cutscene has been watched + * - gSaveContext.save.weekEventReg[55] & 0x80: Checked to know if Gyorg has been defeated + * + * Seaweed: + * - Refers to the seaweed at the bottom of the stage where Player fights Gyorg + * - The default Gyorg actor will spawn 5 other Gyorg instances using the parameter GYORG_PARAM_SEAWEED to spawn them + * - Seaweed can bend when the main Gyorg instance (the actual boss) or Player are near + * + * This actor makes some heavy assumptions about the positions of the room where it is spawned + * + * Cutscenes: + * - There are 3 cutscenes: + * - IntroCutscene: The cs which is played when Player falls into the main room. It also shows Gyorg's titlecard + * - SpawnSmallFishesCutscene: The short cs which is played when Gyorg is spawning the small fishes (EnTanron3). This + * is triggered when Gyorg reaches half of its life + * - DeathCutscene: Played when Gyorg dies. Showing it splashing and becoming smaller each time until it disappears + * - This actor mainly handles the 3 cutscenes it has manually (instead of relying on existing systems for it) + * + * Main behaviour: + * - Gyorg has two types of behaviour depending on Player's state: + * - If Player is standing on the main platform, then Gyorg follows the PrepareCharge -> Charge -> JumpOverPlatform + * branch + * - Otherwise, Gyorg follows the ChasePlayer -> CatchPlayer -> ChewPlayer branch + * - The main actionFunc which decides which branch should be taken is func_809E34B8 + * - Most of the actions of those two branches are constantly checking for the WORK_TIMER_CURRENT_ACTION timer. If it + * runs out, then the behaviour resets back to func_809E34B8 + * - Either branch behaviour can be interrupted at any time by a hit from Player + * - Being hit once makes Gyorg Stunned + * - When Gyorg is Stunned, it is vulnerable to be Damaged by Player + * - When Gyorg's health drops below half, it spawns the small fishes + * + * The collision logic is handled manually + * + * This file is more or less sectioned like this: + * - SpawnEffect + * - RNG + * - Gyorg + * - Init and actionFuncs + * - Cutscenes + * - More actionFuncs and Update + * - Draw + * - Effect Update/Draw + * - Seaweed + */ -#define FLAGS 0x00000035 +#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" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_water_effect/object_water_effect.h" + +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss03*)thisx) +#define WORK_TIMER_UNK0_A 0 // used in func_809E34B8 +#define WORK_TIMER_CURRENT_ACTION 0 +#define WORK_TIMER_UNK0_C 0 // used in DeathCutscene + +#define WORK_TIMER_UNK1_A 1 // used in func_809E34B8 +#define WORK_TIMER_UNK1_B 1 // used in PrepareCharge + +#define WORK_TIMER_UNK2_A 2 // used in func_809E34B8 +#define WORK_TIMER_STUNNED 2 + +// The Y position of the top of the platform +#define PLATFORM_HEIGHT 440.0f +#define WATER_HEIGHT 430.0f + void Boss03_Init(Actor* thisx, GlobalContext* globalCtx); void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx); void Boss03_Update(Actor* thisx, GlobalContext* globalCtx); @@ -17,18 +84,200 @@ void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx); void func_809E344C(Boss03* this, GlobalContext* globalCtx); void func_809E34B8(Boss03* this, GlobalContext* globalCtx); -void func_809E3968(Boss03* this, GlobalContext* globalCtx); -void func_809E3D98(Boss03* this, GlobalContext* globalCtx); -void func_809E421C(Boss03* this, GlobalContext* globalCtx); -void func_809E475C(Boss03* this, GlobalContext* globalCtx); -void func_809E497C(Boss03* this, GlobalContext* globalCtx); -void func_809E4C90(Boss03* this, GlobalContext* globalCtx); -void func_809E4E80(Boss03* this, GlobalContext* globalCtx); -void func_809E5B64(Boss03* this, GlobalContext* globalCtx); -void func_809E6640(Boss03* this, GlobalContext* globalCtx); -void func_809E6BC0(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2); +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx); +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx); +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx); +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx); +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx); + +void Boss03_UpdateEffects(GlobalContext* globalCtx); +void Boss03_DrawEffects(GlobalContext* globalCtx); + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx); +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx); + +u8 D_809E9840; +// Timer used to start playing the boss background music if the intro cutscene was skipped (because it was already +// watched) +u8 D_809E9841; +// Used to set the timer D_809E9841 in case the intro cutscene was skipped +u8 D_809E9842; + +// Set to Gyorg's projectedPos. sGyorgProjectedPos? +Vec3f D_809E9848; + +GyorgEffect sGyorgEffects[GYORG_EFFECT_COUNT]; + +// Used by the Seaweed variant to interact with the "real" Gyorg boss +Boss03* sGyorgBossInstance; + +void Boss03_PlayUnderwaterSfx(Vec3f* projectedPos, u16 sfxId) { + func_8019F420(projectedPos, sfxId); +} + +/* Start of SpawnEffect section */ + +void Boss03_SpawnEffectWetSpot(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos = *pos; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.4f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectDroplet(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_DROPLET; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = -2.0f; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.0f; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + eff->velocity.x = randPlusMinusPoint5Scaled(25.0f); + eff->velocity.z = randPlusMinusPoint5Scaled(25.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectSplash(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity) { + Vec3f accel = { 0.0f, -1.0f, 0.0f }; + f32 temp_f2; + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if ((eff->type == GYORG_EFFECT_NONE) || (eff->type == GYORG_EFFECT_BUBBLE)) { + eff->type = GYORG_EFFECT_SPLASH; + eff->pos = *pos; + eff->velocity = *velocity; + eff->accel = accel; + temp_f2 = Rand_ZeroFloat(0.02f) + 0.02f; + eff->unk_34.y = temp_f2; + eff->unk_34.x = temp_f2; + eff->unk_34.z = Rand_ZeroFloat(2 * M_PI); + eff->unk_02 = Rand_ZeroFloat(100.0f); + return; + } + + eff++; + } +} + +void Boss03_SpawnEffectBubble(GlobalContext* globalCtx, Vec3f* pos) { + s16 i; + GyorgEffect* eff = globalCtx->specialEffects; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++) { + if (eff->type == GYORG_EFFECT_NONE) { + eff->type = GYORG_EFFECT_BUBBLE; + eff->pos = *pos; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->accel.y = 0.2f; + eff->unk_34.x = Rand_ZeroFloat(0.3f) + 0.2f; + eff->unk_02 = 0; + return; + } + + eff++; + } +} + +/* End of SpawnEffect section */ + +void Boss03_UpdateSphereElement(s32 index, ColliderJntSph* collider, Vec3f* sphereCenter) { + ColliderJntSphElement* sphElement; + + collider->elements[index].dim.worldSphere.center.x = sphereCenter->x; + collider->elements[index].dim.worldSphere.center.y = sphereCenter->y; + collider->elements[index].dim.worldSphere.center.z = sphereCenter->z; + + sphElement = &collider->elements[index]; + sphElement->dim.worldSphere.radius = sphElement->dim.scale * sphElement->dim.modelSphere.radius; +} + +/* Start of RNG section */ + +static s32 sRandSeed0; +static s32 sRandSeed1; +static s32 sRandSeed2; + +void Boss03_SeedRand(s32 seed0, s32 seed1, s32 seed2) { + sRandSeed0 = seed0; + sRandSeed1 = seed1; + sRandSeed2 = seed2; +} + +f32 Boss03_RandZeroOne(void) { + f32 rand; + + // Wichmann-Hill algorithm + sRandSeed0 = (sRandSeed0 * 171) % 30269; + sRandSeed1 = (sRandSeed1 * 172) % 30307; + sRandSeed2 = (sRandSeed2 * 170) % 30323; + + rand = (sRandSeed0 / 30269.0f) + (sRandSeed1 / 30307.0f) + (sRandSeed2 / 30323.0f); + while (rand >= 1.0f) { + rand -= 1.0f; + } + + return fabsf(rand); +} + +/* End of RNG section */ + +// ACTOR_BG_DBLUE_MOVEBG is never spawned naturally on Gyorg's fight +Actor* Boss03_FindActorDblueMovebg(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; + + while (actor != NULL) { + if (actor->id == ACTOR_BG_DBLUE_MOVEBG) { + return actor; + } + actor = actor->next; + } + + return NULL; +} + +/* Start of Gyorg's Init and actionFuncs section */ -#if 0 const ActorInit Boss_03_InitVars = { ACTOR_BOSS_03, ACTORCAT_BOSS, @@ -41,157 +290,2350 @@ const ActorInit Boss_03_InitVars = { (ActorFunc)Boss03_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_809E8ECC[2] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sHeadJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 0, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_NONE, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 1, { { 0, 0, 0 }, 50 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_ROOT, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8F14 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_809E8ECC, // sJntSphElementsInit, +static ColliderJntSphInit sHeadJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sHeadJntSphElementsInit), + sHeadJntSphElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[5] = { -static ColliderJntSphElementInit D_809E8F24[5] = { +// The limbs referenced here are not used. The spheres are positioned manually by Boss03_PostLimbDraw +static ColliderJntSphElementInit sBodyJntSphElementsInit[] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 2, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_HEAD, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 5, { { 0, 0, 0 }, 20 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_LOWER_TRUNK, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 6, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_TAIL, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 7, { { 0, 0, 0 }, 70 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_RIGHT_FIN_ROOT, { { 0, 0, 0 }, 70 }, 100 }, }, { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 8, { { 0, 0, 0 }, 30 }, 100 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { GYORG_LIMB_UPPER_RIGHT_FIN, { { 0, 0, 0 }, 30 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809E8FD8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 5, D_809E8F24, // sJntSphElementsInit, +static ColliderJntSphInit sBodyJntSphInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sBodyJntSphElementsInit), + sBodyJntSphElementsInit, }; -#endif +Vec3f sGyorgInitialPos = { 1216.0f, 140.0f, -1161.0f }; -extern ColliderJntSphElementInit D_809E8ECC[2]; -extern ColliderJntSphInit D_809E8F14; -extern ColliderJntSphElementInit D_809E8F24[5]; -extern ColliderJntSphInit D_809E8FD8; +// unused +Vec3f D_809E8FF4[] = { + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -1276.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 1216.0f, 140.0f, -1161.0f }, + { 261.0f, 140.0f, -1000.0f }, { -504.0f, 120.0f, -890.0f }, { -1157.0f, 80.0f, -836.0f }, + { -1020.0f, 120.0f, 381.0f }, { -34.0f, 120.0f, 1213.0f }, { 803.0f, 80.0f, 1250.0f }, + { 1143.0f, 120.0f, 605.0f }, { 1228.0f, 140.0f, -244.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, +}; -extern UNK_TYPE D_06007EB0; -extern UNK_TYPE D_06007EC8; -extern UNK_TYPE D_06009554; -extern UNK_TYPE D_060099D0; -extern UNK_TYPE D_06009C14; -extern UNK_TYPE D_06009CF8; -extern UNK_TYPE D_0600A6C8; +Color_RGBA8 sGyorgDustPrimColor = { 60, 50, 20, 255 }; +Color_RGBA8 sGyorgDustEnvColor = { 40, 30, 30, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2760.s") +/** + * Used when chasing Player and Gyorg is near the bottom + */ +void Boss03_SpawnDust(Boss03* this, GlobalContext* globalCtx) { + if (this->insideJawPos.y < 80.0f) { + u8 i; + Vec3f pos; + Vec3f velocity; + Vec3f accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2788.s") + for (i = 0; i < 5; i++) { + velocity.x = randPlusMinusPoint5Scaled(10.0f); + velocity.y = Rand_ZeroFloat(2.0f) + 2.0f; + velocity.z = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2880.s") + accel.y = -0.075f; + accel.z = 0.0f; + accel.x = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E299C.s") + pos.y = Rand_ZeroFloat(20.0f) + 5.0f; + pos.z = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.z; + pos.x = randPlusMinusPoint5Scaled(150.0f) + this->insideJawPos.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2AB4.s") + func_800B0EB0(globalCtx, &pos, &velocity, &accel, &sGyorgDustPrimColor, &sGyorgDustEnvColor, + Rand_ZeroFloat(200.0f) + 400.0f, 10, Rand_ZeroFloat(10.0f) + 25.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2B8C.s") +void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { + Boss03* this = THIS; + s32 i; + GlobalContext* globalCtx = globalCtx2; + Vec3f sp70; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C1C.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, PLATFORM_HEIGHT, + 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, 0.0f, PLATFORM_HEIGHT, 0.0f, 0, 0, 0, 0); + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2C3C.s") + if (this->actor.params == GYORG_PARAM_SEAWEED) { + this->actor.update = Boss03_SeaweedUpdate; + this->actor.draw = Boss03_SeaweedDraw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2D64.s") + this->unk_240 = Rand_ZeroFloat(1000.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E2DA0.s") + this->actor.scale.x = Rand_ZeroFloat(0.0075f) + 0.027f; + this->actor.scale.y = 0.02f; + this->actor.scale.z = 0.015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Init.s") + // Manually set the joint table of seaweed + for (i = 0; i < 6; i++) { + this->jointTable[i].x = Math_SinS(this->unk_240 * 0x100 + i * 15000) * 3000.0f; + this->jointTable[i].y = Math_SinS(this->unk_240 * 0x180 + i * 20000) * 2000.0f; + this->jointTable[i].z = Math_SinS(this->unk_240 * 0x10 + i * 19000) * 4000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E344C.s") + this->actor.world.pos = sGyorgInitialPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E34B8.s") + // Since Boss03_RandZeroOne is only used on this Init function, the resulting values end up being deterministic + Boss03_SeedRand(1, 29093, 9786); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E38EC.s") + for (i = 0; i < 5; i++) { + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3968.s") + rand = Boss03_RandZeroOne(); + Matrix_InsertYRotation_f((rand * M_PI * 0.2f) + ((2.0f * M_PI / 5.0f) * i), MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D34.s") + rand = Boss03_RandZeroOne(); + Matrix_GetStateTranslationAndScaledZ((rand * 800.0f) + 400.0f, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E3D98.s") + rand = Boss03_RandZeroOne(); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BOSS_03, sp70.x, sp70.y, sp70.z, 0, rand * 0x10000, 0, + GYORG_PARAM_SEAWEED); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4180.s") + sGyorgBossInstance = this; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E421C.s") + globalCtx->specialEffects = sGyorgEffects; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4674.s") + for (i = 0; i < ARRAY_COUNT(sGyorgEffects); i++) { + sGyorgEffects[i].type = GYORG_EFFECT_NONE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E475C.s") + this->actor.targetMode = 5; + this->actor.colChkInfo.mass = MASS_HEAVY; + this->actor.colChkInfo.health = 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4910.s") + Collider_InitAndSetJntSph(globalCtx, &this->headCollider, &this->actor, &sHeadJntSphInit, + this->headColliderElements); + Collider_InitAndSetJntSph(globalCtx, &this->bodyCollider, &this->actor, &sBodyJntSphInit, + this->bodyColliderElements); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGyorgSkel, &gGyorgCrawlingAnim, this->jointTable, + this->morphTable, GYORG_LIMB_MAX); + Actor_SetScale(&this->actor, 0.2f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E497C.s") + // gSaveContext.eventInf[5] & 0x40: intro cutscene already watched + if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x40)) { + this->actionFunc = func_809E344C; + D_809E9842 = false; + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + } else { + Boss03_SetupIntroCutscene(this, globalCtx); + D_809E9842 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C34.s") + this->numSpawnedSmallFish = -1; + this->waterHeight = WATER_HEIGHT; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4C90.s") +void Boss03_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E2C.s") +/* Start of ActionFuncs section */ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E4E80.s") +void func_809E344C(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5ADC.s") + // Mid-air + if (player->actor.world.pos.y < 540.0f) { + this->actionFunc = func_809E34B8; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_274 = 0; + this->actor.flags |= ACTOR_FLAG_1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E5B64.s") +/** + * Swims randomly until WORK_TIMER_UNK1_A runs out + */ +void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + s32 pad; + s16 i; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E65F4.s") + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6640.s") + this->unk_276 = 0x800; + this->skelAnime.playSpeed = 1.0f; + this->unk_27C = 1.0f; + this->unk_278 = 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E69A4.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6A38.s") + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6B70.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6BC0.s") + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E6CB4.s") + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Update.s") + 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->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7920.s") + if ((this->workTimer[WORK_TIMER_UNK2_A] == 0) && (this->actor.bgCheckFlags & 8)) { + Matrix_GetStateTranslationAndScaledZ(-500.0f, &this->unk_268); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->workTimer[WORK_TIMER_UNK2_A] = 60; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + this->unk_274 = 0x100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E79C4.s") + if (this->workTimer[WORK_TIMER_UNK2_A] == 0) { + if ((sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) || (this->workTimer[WORK_TIMER_UNK0_A] == 0)) { + for (i = 0; i < 200; i++) { + this->unk_268.x = randPlusMinusPoint5Scaled(2500.0f); + this->unk_268.y = Rand_ZeroFloat(100.0f) + 150.0f; + this->unk_268.z = randPlusMinusPoint5Scaled(2500.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7AA8.s") + xDiff = this->unk_268.x - this->actor.world.pos.x; + zDiff = this->unk_268.z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/Boss03_Draw.s") + if (sqrtf(SQ(xDiff) + SQ(zDiff)) > 300.0f) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E7D00.s") + this->unk_274 = 0x100; + this->workTimer[WORK_TIMER_UNK0_A] = Rand_ZeroFloat(60.0f) + 60.0f; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E81E4.s") + Actor_MoveWithoutGravityReverse(&this->actor); + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8810.s") + 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)) { + Boss03_SetupPrepareCharge(this, globalCtx); + } else if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU)) { + if (KREG(70) == 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } else if (this->numSpawnedSmallFish <= 0) { + Boss03_SetupChasePlayer(this, globalCtx); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_03/func_809E8BEC.s") +void Boss03_SetupChasePlayer(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_ChasePlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_276 = 0x1000; + this->skelAnime.playSpeed = 1.5f; + this->unk_278 = 10.0f; + this->unk_27C = 1.0f; +} + +/** + * Approach Player until near enough, then try to catch Player, unless it has since got back on the platform + */ +void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 bodyYRotTarget; + Vec3f sp50; + s32 pad; + f32 phi_f2; + f32 sp44; + u8 sp43; + + this->unk_2BD = true; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = (player->actor.world.pos.y - this->actor.world.pos.y) + 50.0f; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + bodyYRotTarget = + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + 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->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); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // 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)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } else { + if ((this->waterHeight - 80.0f) < player->actor.world.pos.y) { + sp43 = 1; + phi_f2 = 100.0f; + sp44 = 50.0f; + } else { + sp43 = 0; + phi_f2 = 200.0f; + sp44 = 100.0f; + } + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(sp44, &sp50); + + xDiff = sp50.x - player->actor.world.pos.x; + zDiff = sp50.z - player->actor.world.pos.z; + + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < (2.0f * phi_f2)) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + this->unk_278 = 25.0f; + this->unk_27C = 5.0f; + this->skelAnime.playSpeed = 2.5f; + } + + // Near enough to Player? + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < phi_f2) { + Boss03_SetupCatchPlayer(this, globalCtx, sp43); + + if (sp43 != 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, player->actor.world.pos.x, + this->waterHeight, player->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_UTSUBO_EAT); + } + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupCatchPlayer(Boss03* this, GlobalContext* globalCtx, u8 arg2) { + this->actionFunc = Boss03_CatchPlayer; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->unk_2C4 = 0.0f; + this->unk_2B8 = 0.0f; + this->unk_242 = arg2; +} + +void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + + this->skelAnime.playSpeed = 2.0f; + this->unk_27C = 2.0f; + this->unk_276 = 0x1000; + this->unk_2BD = true; + this->unk_278 = 15.0f; + this->actor.flags &= ~ACTOR_FLAG_1; + + SkelAnime_Update(&this->skelAnime); + + xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + yDiff = player->actor.world.pos.y - this->actor.world.pos.y; + zDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -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->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); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // 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)) || + (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0)) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } else { + f32 phi_f0; + + Math_ApproachF(&player->actor.world.pos.x, this->insideJawPos.x, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.y, this->insideJawPos.y, 1.0f, this->unk_2B8); + Math_ApproachF(&player->actor.world.pos.z, this->insideJawPos.z, 1.0f, this->unk_2B8); + + if (this->unk_242 != 0) { + phi_f0 = 10.0f; + } else { + phi_f0 = 2.0f; + } + + Math_ApproachF(&this->unk_2B8, 100.0f, 1.0f, phi_f0); + + if (this->unk_2B8 > 30.0f) { + if ((&this->actor != player->actor.parent) && (globalCtx->grabPlayer(globalCtx, player) != 0)) { + player->actor.parent = &this->actor; + Audio_PlaySfxGeneral(NA_SE_VO_LI_DAMAGE_S, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, + &D_801DB4B8); + Boss03_SetupChewPlayer(this, globalCtx); + } + } else { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0xC00 * phi_f0); + } + + Math_ApproachS(&player->actor.world.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.x, 0x4000, 1, 0x400); + Math_ApproachS(&player->actor.world.rot.y, this->unk_2A2.y, 1, 0x400); + Math_ApproachS(&player->actor.shape.rot.y, this->unk_2A2.y, 1, 0x400); + } + + Boss03_SpawnDust(this, globalCtx); +} + +void Boss03_SetupChewPlayer(Boss03* this, GlobalContext* globalCtx) { + s16 pitchAngle; + Vec3f out; + + this->actionFunc = Boss03_ChewPlayer; + + pitchAngle = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + Matrix_RotateY(pitchAngle, MTXMODE_NEW); + + out.x = 0.0f; + out.y = 200.0f; + out.z = 700.0f; + Matrix_MultiplyVector3fByState(&out, &this->unk_268); + + this->unk_276 = 0x800; + this->unk_242 = 0; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 100; + this->skelAnime.playSpeed = 1.0f; +} + +void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Input* input = CONTROLLER1(globalCtx); + f32 jawZRotTarget; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + this->unk_2BD = true; + this->unk_25C = 15; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 90) { + func_8016566C(0x96); + } + + SkelAnime_Update(&this->skelAnime); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = this->unk_268.y - this->actor.world.pos.y; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + -0.5f, + 5, 0x100); + Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); + Math_ApproachF(&this->unk_260, __sinf(this->skelAnime.curFrame * (M_PI / 5.0f)) * 10.0f * 0.01f, 0.5f, 1.0f); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.speedXZ, 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); + } + break; + + case 1: + Math_ApproachF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 5.0f); + break; + } + + Actor_MoveWithoutGravityReverse(&this->actor); + + Math_ApproachS(&this->actor.shape.rot.x, this->actor.world.rot.x, 2, this->unk_274 * 2); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, this->unk_274 * 2); + + // Mashing A or B reduces the time Gyorg is chewing Player + if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B)) { + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] != 0) { + this->workTimer[WORK_TIMER_CURRENT_ACTION]--; + } + } + + // Stop chewing when the timer runs out + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + func_800B8D50(globalCtx, NULL, 10.0f, this->actor.shape.rot.y, 0.0f, 0x20); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = Rand_ZeroFloat(100.0f) + 200.0f; + + return; + } + + player->actor.world.pos = this->insideJawPos; + + jawZRotTarget = Math_SinS(this->unk_240 * 0x2000); + Math_ApproachS(&this->jawZRot, jawZRotTarget * 2000.0f, 2, 0x3000); + + player->actor.shape.rot.x = 0x4000; + player->actor.world.rot.x = player->actor.shape.rot.x; + + player->actor.world.rot.y = player->actor.shape.rot.y = this->unk_2A2.y; + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] < 5) { + Math_ApproachS(&this->jawZRot, 0x3200, 2, 0x1800); + Math_ApproachF(&this->unk_2C4, 100.0f, 1.0f, 100.0f); + } else { + Math_ApproachF(&this->unk_2C4, -300.0f, 1.0f, 5.0f); + if ((this->unk_240 % 8) == 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BITE_OLD); + } + } +} + +void Boss03_SetupPrepareCharge(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_PrepareCharge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->workTimer[WORK_TIMER_CURRENT_ACTION] = Rand_ZeroFloat(30.0f) + 80.0f; + this->workTimer[WORK_TIMER_UNK1_B] = 50; + this->unk_274 = 0; + + if (sqrtf(SQXZ(this->actor.world.pos)) > 600.0f) { + if (Rand_ZeroOne() < 0.5f) { + this->unk_242 = 1; + } else { + this->unk_242 = 0; + } + } else { + this->unk_242 = 0; + } +} + +/** + * Slowly turns back while looking at Player during WORK_TIMER_CURRENT_ACTION frames, then prepares to charge + */ +void Boss03_PrepareCharge(Boss03* this, GlobalContext* globalCtx) { + f32 posYTarget; + Player* player = GET_PLAYER(globalCtx); + + if (this->workTimer[WORK_TIMER_UNK1_B] != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_WAIT_OLD - SFX_FLAG); + } + + // Rotate towards Player + Math_ApproachS(&this->bodyYRot, + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, this->unk_274, 0) * + -0.7f, + 5, 0x200); + Math_ApproachS(&this->unk_274, 0x800, 1, 0x100); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x1000); + Math_ApproachS(&this->actor.world.rot.x, 0, 0xA, 0x200); + Math_ApproachS(&this->actor.shape.rot.x, 0, 0xA, 0x200); + + posYTarget = this->waterHeight - 70.0f; + if (posYTarget < this->actor.world.pos.y) { + Math_ApproachF(&this->actor.world.pos.y, posYTarget, 0.05f, 5.0f); + } + + 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->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + Boss03_SetupCharge(this, globalCtx); + } + } else if (player->actor.world.pos.y <= this->waterHeight) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 20; + } + + // Turns back slowly + Math_ApproachF(&this->actor.speedXZ, -3.0f, 1.0f, 0.5f); + Actor_MoveWithoutGravityReverse(&this->actor); +} + +void Boss03_SetupCharge(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actionFunc = Boss03_Charge; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -15.0f); + this->unk_268 = player->actor.world.pos; +} + +/** + * Charge against the platform, either by clashing against the platform or by preparing to jump over it + */ +void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + Player* player = GET_PLAYER(globalCtx); + s16 rotXTarget; + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_PREATTACK_OLD - SFX_FLAG); + + xDiff = this->unk_268.x - this->actor.world.pos.x; + yDiff = (this->unk_268.y - this->actor.world.pos.y) - 50.0f; + zDiff = this->unk_268.z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, 0x1000); + + rotXTarget = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff); + Math_ApproachS(&this->actor.world.rot.x, rotXTarget, 0xA, 0x1000); + + this->actor.shape.rot = this->actor.world.rot; + + Math_ApproachF(&this->actor.speedXZ, 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) { + // Jump over platform + if (this->unk_242 == 1) { + if (sqrtf(SQXZ(this->actor.world.pos)) < 700.0f) { + Boss03_SetupJumpOverPlatform(this, globalCtx); + return; + } + } + + // Attack platform + if (this->actor.bgCheckFlags & 8) { + play_sound(NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 20, 15); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, 0.0f, this->waterHeight, 0.0f, 0, 0, + 0x96, ENWATEREFFECT_780); + + // Player is above water && Player is standing on ground + if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { + func_800B8D50(globalCtx, NULL, 7.0f, Math_FAtan2F(player->actor.world.pos.z, player->actor.world.pos.x), + 7.0f, 0); + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } +} + +void Boss03_SetupJumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_JumpOverPlatform; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 30.0f; + this->actor.speedXZ = 25.0f; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); +} + +void Boss03_JumpOverPlatform(Boss03* this, GlobalContext* globalCtx) { + this->bubbleEffectSpawnCount = 0; + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_LEV_OLD - SFX_FLAG); + + this->skelAnime.playSpeed = 2.0f; + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 2, 0x2000); + this->actor.shape.rot.x = this->actor.world.rot.x; + + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y < 0.0f) && (this->actor.world.pos.y < this->waterHeight + 50.0f)) { + this->bubbleEffectSpawnCount = 2; + this->actor.gravity = 0.0f; + Math_ApproachZeroF(&this->actor.velocity.y, 1.0f, 1.0f); + if (this->actor.velocity.y == 0.0f) { + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } else { + s16 i; + Vec3f sp30; + + for (i = 0; i < 3; i++) { + sp30.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(150.0f); + sp30.y = this->actor.world.pos.y; + sp30.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(150.0f); + Boss03_SpawnEffectDroplet(globalCtx, &sp30); + } + } +} + +/* End of Gyorg's Init and actionFuncs section */ + +/* Start of Gyorg's Cutscenes section */ + +void Boss03_SetupIntroCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_IntroCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFastSwimmingAnim, -10.0f); + this->skelAnime.playSpeed = 2.0f; +} + +Vec3f D_809E9104[] = { + { 770.0f, 200.0f, 720.0f }, + { 831.0f, 200.0f, -570.0f }, + { 0.0f, 450.0f, 0.0f }, +}; + +void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f effectPos; + f32 xDiff; + f32 yDiff; + f32 zDiff; + s32 pad; + f32 sp5C; + s16 sp5A; + s16 pad2; + s16 bubblesToSpawnNum = 0; + f32 phi_f2; + Player* player = GET_PLAYER(globalCtx); + + this->bubbleEffectSpawnCount = 0; + this->csTimer++; + this->unk_290 = 0; + + sp5A = 0x4BC; + + switch (this->csState) { + case 0: + if (player->actor.world.pos.y < 1350.0f) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 7); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + + this->actor.world.rot.y = -0x7B30; + this->prevPlayerPos.y = 1850.0f; + + this->actor.world.pos.x = 1400.0f; + this->actor.world.pos.y = 130.0f; + this->actor.world.pos.z = 1400.0f; + + player->actor.shape.rot.y = 0; + player->actor.world.pos.y = 1850.0f; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamAt.y = player->actor.world.pos.y + 30.0f; + this->csState = 1; + this->csTimer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_2D5 = true; + + this->cameraFov = KREG(14) + 60.0f; + + case 1: + player->actor.world.pos.z = 0.0f; + player->actor.world.pos.x = 0.0f; + player->actor.speedXZ = 0.0f; + + this->csCamEye.x = 100.0f; + this->csCamEye.y = 540.0f; + + this->csCamEye.z = player->actor.world.pos.z + 100.0f; + this->csCamAt.x = player->actor.world.pos.x; + + Math_ApproachF(&this->csCamAt.y, player->actor.world.pos.y + 30.0f, 0.5f, 100.0f); + this->csCamAt.z = player->actor.world.pos.z; + + if (this->csTimer > 105) { + this->csState = 2; + this->csTimer = 0; + this->unk_240 = 0; + func_8016566C(0x96); + this->cameraFov = 80.0f; + + case 2: + Actor_PlaySfxAtPos(&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; + zDiff = D_809E9104[this->unk_242].z - this->actor.world.pos.z; + + Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), + 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274); + Math_ApproachS(&this->unk_274, 0x200, 1, 0x10); + + if ((this->csTimer > 30) && (this->csTimer < 50)) { + bubblesToSpawnNum = 2; + } + + if ((this->csTimer == 40) || (this->csTimer == (u32)(KREG(91) + 270))) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + + if (this->csTimer > 50) { + Math_ApproachF(&this->actor.speedXZ, this->unk_278, 1.0f, 0.1f); + } + + if (this->unk_242 < 2) { + if (sqrtf(SQ(xDiff) + SQ(zDiff)) < 100.0f) { + this->unk_242++; + this->unk_274 = 0; + if (this->unk_242 >= 2) { + this->csTimer = 100; + } + } + this->unk_278 = 5.0f; + } else { + this->unk_278 = 0.0f; + bubblesToSpawnNum = 1; + if ((this->actor.speedXZ == 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); + } + if (this->csTimer == 180) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_WATER_DEEP); + } + } + } + } + break; + + 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); + if (this->csTimer > 20) { + this->csState = 4; + this->csTimer = 0; + } + break; + + case 4: + player->actor.world.rot.y = player->actor.shape.rot.y = 0; + + if (this->csTimer == 5) { + // Rotates Player towards Gyorg + func_800B7298(globalCtx, &this->actor, 8); + } + + this->csCamEye.x = player->actor.world.pos.x + 30.0f; + this->csCamEye.y = player->actor.world.pos.y + Player_GetHeight(player) - 4.0f + BREG(17); + this->csCamEye.z = player->actor.world.pos.z - 30.0f; + + this->csCamAt.x = player->actor.world.pos.x; + this->csCamAt.y = player->actor.world.pos.y + Player_GetHeight(player) - 18.0f + 6.0f + BREG(18); + this->csCamAt.z = player->actor.world.pos.z; + + if (player->transformation == PLAYER_FORM_FIERCE_DEITY) { + this->csCamEye.y -= 60.0f; + this->csCamAt.y -= 35.0f; + } + + this->cameraFov = 60.0f; + if (this->csTimer == 16) { + this->csState = 5; + this->csTimer = 0; + this->unk_2D5 = false; + this->actor.speedXZ = -200.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + this->actor.world.pos.y = this->waterHeight - 150.0f; + func_80165690(); + + case 5: + SkelAnime_Update(&this->skelAnime); + this->actor.speedXZ = 20.0f; + Actor_MoveWithoutGravityReverse(&this->actor); + player->actor.shape.rot.y = -0x1470; + player->actor.world.rot.y = player->actor.shape.rot.y; + + this->csCamEye.x = player->actor.world.pos.x + 30.0f - 90.0f + 300.0f; + this->csCamEye.y = player->actor.world.pos.y + 40.0f + 10.0f; + this->csCamEye.z = player->actor.world.pos.z - 30.0f + 160.0f + 300.0f; + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y - 100.0f; + this->csCamAt.z = this->actor.world.pos.z; + + if (this->csTimer == 10) { + this->actor.velocity.y = 30.0f; + this->csState = 6; + this->csTimer = 0; + this->actor.gravity = -1.5f; + this->actor.speedXZ = 20.0f; + + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + Actor_PlaySfxAtPos(&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); + + if (this->csTimer == 30) { + TitleCard_InitBossName(&globalCtx->state, &globalCtx->actorCtx.titleCtxt, + Lib_SegmentedToVirtual(gGyorgTitleCardTex), 160, 180, 128, 40); + } + + if ((this->csTimer < 24) || (this->csTimer >= 90)) { + SkelAnime_Update(&this->skelAnime); + Math_ApproachS(&this->actor.world.rot.x, this->actor.velocity.y * -300.0f, 3, 0x1000); + Actor_MoveWithGravity(&this->actor); + if ((this->actor.velocity.y <= 0.0f) && (this->actor.world.pos.y < (this->waterHeight + 50.0f))) { + 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); + } else { + if (1) {} + if (1) {} + if (1) {} + + for (i = 0; i < 3; i++) { + effectPos.x = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.x; + effectPos.y = this->actor.world.pos.y; + effectPos.z = randPlusMinusPoint5Scaled(150.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectDroplet(globalCtx, &effectPos); + } + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y - 100.0f; + this->csCamTargetAt.z = this->actor.world.pos.z; + } + } else { + Math_ApproachF(&this->csCamEye.x, player->actor.world.pos.x + 30.0f - 90.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->csCamEye.y, player->actor.world.pos.y + 40.0f + 10.0f + 90.0f, 0.05f, 3.0f); + Math_ApproachF(&this->csCamEye.z, player->actor.world.pos.z - 30.0f + 160.0f + 300.0f - 90.0f, 0.05f, + 3.0f); + Math_ApproachF(&this->unk_568, 90.0f, 0.05f, 3.0f); + } + + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y + this->unk_568, 0.5f, 100.0f); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.5f, 100.0f); + + if (this->csTimer == 145) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csCamId = 0; + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + + gSaveContext.eventInf[5] |= 0x40; + } + break; + } + + this->actor.shape.rot = this->actor.world.rot; + + if ((this->csState == 2) || (this->csState == 3)) { + Actor_MoveWithoutGravityReverse(&this->actor); + + phi_f2 = this->actor.speedXZ * 0.02f; + phi_f2 = CLAMP_MAX(phi_f2, 0.12f); + + sp5C = Math_SinS(this->unk_240 * sp5A) * phi_f2; + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + Matrix_InsertYRotation_f(sp5C, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.world.rot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(100.0f, &this->csCamAt); + + this->csCamEye = this->actor.world.pos; + + for (i = 0; i < bubblesToSpawnNum; i++) { + effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.x; + effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.y) - 150.0f; + effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.z; + + Boss03_SpawnEffectBubble(globalCtx, &effectPos); + } + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + Play_CameraSetFov(globalCtx, this->csCamId, this->cameraFov); + } +} + +void Boss03_SetupDeathCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_DeathCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->floppingAnimLastFrame = Animation_GetLastFrame(&gGyorgFloppingAnim); + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + this->workTimer[WORK_TIMER_UNK0_C] = 0; + this->unk_242 = 0; + this->csState = 0; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { + s16 i; + Vec3f sp90; + Vec3f sp84; + Vec3f sp78; + f32 aux; + f32 aux2; + s32 pad; + f32 pad2; + f32 sp64; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + Player* player; + f32 sp4C; + + aux2 = 0.0f; + player = GET_PLAYER(globalCtx); + sp64 = this->actor.scale.x * 5.0f; + + this->csTimer++; + + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->unk_2BE = Math_FAtan2F(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)) { + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.z = -200.0f; + } + + case 1: + this->csTimer = 0; + this->csState = 2; + this->csCamEye.x = camera->eye.x; + this->csCamEye.y = camera->eye.y; + this->csCamEye.z = camera->eye.z; + this->csCamAt.x = camera->at.x; + this->csCamAt.y = camera->at.y; + this->csCamAt.z = camera->at.z; + + aux = this->csCamEye.x - this->actor.world.pos.x; + this->unk_568 = Math_Acot2F(this->csCamEye.z - this->actor.world.pos.z, aux); + + this->unk_570 = 0.0f; + this->unk_56C = 0.0f; + + case 2: + sp90.x = 0.0f; + sp90.y = (50.0f * sp64) + 150.0f; + sp90.z = (400.0f * sp64) + 300.0f; + + this->csCamTargetAt.x = this->actor.world.pos.x; + this->csCamTargetAt.y = this->actor.world.pos.y; + this->csCamTargetAt.z = this->actor.world.pos.z; + + this->unk_568 += this->unk_56C; + Matrix_InsertYRotation_f(this->unk_568, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp90, &this->csCamTargetEye); + + this->csCamTargetEye.x += this->actor.world.pos.x; + this->csCamTargetEye.y += this->waterHeight; + this->csCamTargetEye.z += this->actor.world.pos.z; + + sp4C = 40.0f + aux2; + Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, 0.1f, sp4C); + sp4C = 70.0f + aux2; + Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, 0.1f, sp4C); + Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.1f, sp4C); + } + break; + } + + SkelAnime_Update(&this->skelAnime); + + switch (this->unk_242) { + case 0: + Math_ApproachF(&this->actor.world.pos.y, Math_SinS(this->unk_240 * 0x1000) * 80.0f + this->waterHeight, + 1.0f, 10.0f); + this->actor.shape.rot.z += 0x100; + Matrix_RotateY(this->unk_2BE, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(500.0f, &sp84); + Math_ApproachF(&this->actor.world.pos.x, sp84.x, 0.1f, 5.0f); + 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); + } + if (Animation_OnFrame(&this->skelAnime, this->floppingAnimLastFrame * 0.5f)) { + Actor_PlaySfxAtPos(&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)) { + this->workTimer[WORK_TIMER_UNK0_C] = Rand_ZeroFloat(15.0f) + 15.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + if (this->actionFunc == Boss03_DeathCutscene) { + if ((D_809E9840 % 2) != 0) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_JUMP_OLD); + } else { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); + } + D_809E9840++; + } + + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + + this->unk_280 = 27; + if ((fabsf(this->actor.world.pos.x - sp84.x) < 5.0f) && + (fabsf(this->actor.world.pos.z - sp84.z) < 5.0f)) { + this->unk_242 = 1; + this->actor.gravity = -2.0f; + this->actor.velocity.y = 25.0f; + this->actor.speedXZ = 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); + } + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + break; + + case 1: + if (this->unk_240 == 0x96) { + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); + } + Math_ApproachF(&this->unk_56C, 0.01f, 1.0f, 0.0005f); + Math_ApproachF(&this->actor.scale.x, 0.01f, 0.05f, 0.001f); + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->actor.velocity.y < 0.0f) { + 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; + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetX = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetX) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetZ = + ((s16)randPlusMinusPoint5Scaled(500.0f) + this->shapeRotTargetZ) + 0x8000; + } + + if (Rand_ZeroOne() < 0.5f) { + this->shapeRotTargetY = Rand_ZeroFloat(65536.0f); + } + + this->actor.world.rot.y = Math_FAtan2F(-this->actor.world.pos.z, -this->actor.world.pos.x); + + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND_OLD); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND2_OLD); + } + } + + Math_ApproachS(&this->actor.shape.rot.y, this->shapeRotTargetY, 3, 0x500); + Math_ApproachS(&this->actor.shape.rot.x, this->shapeRotTargetX, 3, 0xA00); + Math_ApproachS(&this->actor.shape.rot.z, this->shapeRotTargetZ, 3, 0xA00); + + sp4C = 150.0f * sp64; + + for (i = 0; i < 1; i++) { + sp78.x = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y; + sp78.z = randPlusMinusPoint5Scaled(sp4C) + this->actor.world.pos.z; + Boss03_SpawnEffectDroplet(globalCtx, &sp78); + } + + Actor_MoveWithGravity(&this->actor); + if (this->actor.scale.x <= 0.0111f) { + this->unk_242 = 2; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_DOOR_WARP1, 0.0f, + PLATFORM_HEIGHT, 200.0f, 0, 0, 0, ENDOORWARP1_FF_1); + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ITEM_B_HEART, this->actor.focus.pos.x, + PLATFORM_HEIGHT, this->actor.focus.pos.z, 0, 0, 0, 0); + this->csTimer = 0; + Actor_SetScale(&this->actor, 0.0f); + Audio_StopSfxByPos(&this->actor.projectedPos); + } + break; + + case 2: + Math_ApproachZeroF(&this->unk_56C, 1.0f, 0.0005f); + if (this->csTimer == 60) { + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + this->csState = 3; + func_80165690(); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_INIT_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_INIT_OLD); + } + break; + + case 3: + this->actor.world.pos.y = 5000.0f; + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +void Boss03_SetupSpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + this->actionFunc = Boss03_SpawnSmallFishesCutscene; + Animation_MorphToLoop(&this->skelAnime, &gGyorgBackingUpAnim, -15.0f); + this->csState = 0; + this->csTimer = 0; +} + +void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + this->csTimer++; + switch (this->csState) { + case 0: + if (ActorCutscene_GetCurrentIndex() == -1) { + Cutscene_Start(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 1); + this->csCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->csCamId, 7); + this->csState = 1; + this->unk_2BE = 0xBB8; + + case 1: + if (player->actor.world.pos.y < 437.0f) { + player->actor.world.pos.z = 500.0f; + player->actor.world.pos.x = 500.0f; + } + + this->actor.shape.rot.z = 0; + this->actor.world.pos.z = 1000.0f; + this->actor.world.pos.x = 1000.0f; + this->actor.world.pos.y = 200.0f; + this->actor.shape.rot.x = this->actor.shape.rot.z; + + this->actor.shape.rot.y = this->actor.world.rot.y = + Math_FAtan2F(-this->actor.world.pos.x, -this->actor.world.pos.x); + this->unk_260 = 0.0f; + + player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(340.0f, &this->csCamEye); + + this->csCamAt.x = this->actor.world.pos.x; + this->csCamAt.y = this->actor.world.pos.y; + this->csCamAt.z = this->actor.world.pos.z; + + Math_ApproachS(&this->unk_2BE, -4000, 10, 70); + + if (this->csTimer >= 61) { + Math_ApproachS(&this->jawZRot, 0x3200, 5, 0x500); + if ((this->csTimer >= 90) && (this->csTimer < 130)) { + if ((this->csTimer % 2) != 0) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON3, + this->actor.world.pos.x - 110.0f, this->actor.world.pos.y - 20.0f, + this->actor.world.pos.z - 110.0f, 0, this->actor.shape.rot.y, 0, 0); + this->numSpawnedSmallFish++; + } + if ((this->csTimer % 8) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KONB_MINI_APPEAR); + } + } + } + + if (this->csTimer >= 150) { + Camera* camera; + + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); + camera->eye = this->csCamEye; + camera->eyeNext = this->csCamEye; + camera->at = this->csCamAt; + + func_80169AFC(globalCtx, this->csCamId, 0); + this->csCamId = 0; + Cutscene_End(globalCtx, &globalCtx->csCtx); + func_800B7298(globalCtx, &this->actor, 6); + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 50; + } + } + break; + } + + if (this->csCamId != 0) { + Play_CameraSetAtEye(globalCtx, this->csCamId, &this->csCamAt, &this->csCamEye); + } +} + +/* End of Gyorg's Cutscenes section */ + +/* Start of Gyorg's More actionFuncs and Update section */ + +void Boss03_SetupStunned(Boss03* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actionFunc != Boss03_Stunned) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgStunnedAnim, -15.0f); + this->workTimer[WORK_TIMER_STUNNED] = 200; + this->actionFunc = Boss03_Stunned; + } + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + this->unk_240 = 0; +} + +void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { + this->actor.hintId = 0x29; + + if (this->unk_240 >= 16) { + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_COMMON_WEAKENED - SFX_FLAG); + } + + SkelAnime_Update(&this->skelAnime); + + if ((this->waterHeight + 30.0f) < this->actor.world.pos.y) { + this->actor.gravity = -2.0f; + Actor_MoveWithGravity(&this->actor); + if (this->actor.bgCheckFlags & 2) { + play_sound(NA_SE_IT_WALL_HIT_HARD); + func_800BC848(&this->actor, globalCtx, 10, 10); + } + } else { + Math_ApproachS(&this->actor.shape.rot.z, -0x6000, 0xA, 0x900); + Math_ApproachS(&this->actor.world.rot.x, 0x800, 0xA, 0x1000); + 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); + Actor_MoveWithoutGravityReverse(&this->actor); + } + + if (this->workTimer[WORK_TIMER_STUNNED] == 0) { + func_809E344C(this, globalCtx); + // WORK_TIMER_UNK1_A wasn't set + } +} + +void Boss03_SetupDamaged(Boss03* this, GlobalContext* globalCtx) { + Animation_MorphToLoop(&this->skelAnime, &gGyorgFloppingAnim, -10.0f); + this->actionFunc = Boss03_Damaged; + this->workTimer[WORK_TIMER_CURRENT_ACTION] = 30; +} + +/** + * Invulnerability period by being damaged by Player + */ +void Boss03_Damaged(Boss03* this, GlobalContext* globalCtx) { + this->unk_25C = 15; + + SkelAnime_Update(&this->skelAnime); + + Math_ApproachS(&this->jawZRot, ((Math_SinS(this->unk_240 * 0x2000) * 3000.0f) + 0x3000), 2, 0x3000); + Math_ApproachF(&this->actor.world.pos.y, 200.0f, 0.05f, 10.0f); + + if (this->workTimer[WORK_TIMER_CURRENT_ACTION] == 0) { + if ((s8)this->actor.colChkInfo.health <= 5) { + if (!this->hasSpwanedSmallFishes) { + this->hasSpwanedSmallFishes++; + Boss03_SetupSpawnSmallFishesCutscene(this, globalCtx); + return; + } + } + + func_809E344C(this, globalCtx); + this->workTimer[WORK_TIMER_UNK1_A] = 100; + } +} + +/* End of ActionFuncs section */ + +void Boss03_UpdateCollision(Boss03* this, GlobalContext* globalCtx) { + ColliderInfo* hitbox; + u8 sp4B = true; + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_v1; + u32 phi_v0; + Boss03ActionFunc stunnedActionFunc = Boss03_Stunned; + + if (((KREG(20) + (this->waterHeight - 50.0f)) < player->actor.world.pos.y) && + (player->transformation != PLAYER_FORM_FIERCE_DEITY)) { + sp4B = false; + } + + if (this->waterHeight < player->actor.world.pos.y) { + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->headCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.toucherFlags & TOUCH_HIT) { + this->bodyCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; + player->unk_B84 = this->actor.shape.rot.y; + player->unk_B80 = 20.0f; + } + } + } + + if (this->unk_25C == 0) { + if ((this->actionFunc == stunnedActionFunc) && sp4B) { + for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { + if (this->bodyCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->bodyCollider.elements[i].info.acHitInfo; + this->bodyCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? this->bodyCollider.elements[i].info.acHitInfo->toucher.damage + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Boss03_SetupDeathCutscene(this, globalCtx); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + return; + } + } + } + + for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { + if (this->headCollider.elements[i].info.bumperFlags & BUMP_HIT) { + hitbox = this->headCollider.elements[i].info.acHitInfo; + this->headCollider.elements[i].info.bumperFlags &= ~BUMP_HIT; + this->unk_25C = 15; + + if (this->actionFunc != stunnedActionFunc) { + Boss03_SetupStunned(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + + if (&this->actor == player->actor.parent) { + player->unk_AE8 = 101; + player->actor.parent = NULL; + player->csMode = 0; + func_80165690(); + } + + continue; + } + + if (sp4B) { + this->unk_25E = 15; + + // (DMG_SWORD_BEAM | DMG_SPIN_ATTACK | DMG_ZORA_PUNCH | DMG_ZORA_BARRIER | DMG_DEKU_LAUNCH | + // DMG_DEKU_SPIN | DMG_GORON_SPIKES | DMG_SWORD | DMG_GORON_PUNCH | DMG_DEKU_STICK) + phi_v0 = (hitbox->toucher.dmgFlags & 0x038AC302) + ? (this->headCollider.elements[i].info.acHitInfo->toucher.damage) + : 0; + + phi_v1 = phi_v0; + if (phi_v0 < 1) { + phi_v1 = 1; + } + this->actor.colChkInfo.health -= phi_v1; + if ((s8)this->actor.colChkInfo.health <= 0) { + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD_OLD); + Boss03_PlayUnderwaterSfx(&D_809E9848, NA_SE_EN_KONB_DEAD2_OLD); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Boss03_SetupDeathCutscene(this, globalCtx); + } else { + Boss03_SetupDamaged(this, globalCtx); + Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_DAMAGE_OLD); + } + } + return; + } + } + } +} + +void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Boss03* this = THIS; + Actor* dblueActor; + Player* player = GET_PLAYER(globalCtx); + s32 i; + Vec3f wetSpotPos; + Vec3f bubblePos; + Vec3f dropletPos; + s16 j; + f32 yRot; + + this->actor.hintId = 0x28; + + if (!D_809E9842 && (player->actor.world.pos.y < (PLATFORM_HEIGHT + 5.0f))) { + D_809E9842 = true; + D_809E9841 = 5; + } + + if (KREG(63) == 0) { + this->unk_290 = 1; + this->unk_240++; + this->unk_2BC = 1; + + this->unk_2BD = false; + + Math_Vec3f_Copy(&D_809E9848, &this->actor.projectedPos); + + for (i = 0; i < ARRAY_COUNT(this->workTimer); i++) { + if (this->workTimer[i] != 0) { + this->workTimer[i]--; + } + } + + if (this->unk_324 != 0) { + this->unk_324--; + } + + if (this->unk_25C != 0) { + this->unk_25C--; + } + + if (this->unk_25E != 0) { + this->unk_25E--; + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != Boss03_DeathCutscene) { + 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(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 5); + this->actor.world.pos.y += 100.0f; + this->actor.prevPos.y += 100.0f; + } + } + + if ((this->actionFunc != Boss03_DeathCutscene) && (!this->unk_2D5)) { + // Going into or out of the water + if (((this->actor.world.pos.y < this->waterHeight + 50.0f) && + (this->waterHeight + 50.0f <= this->actor.prevPos.y)) || + ((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_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WATER_EFFECT, this->actor.world.pos.x, + this->waterHeight, this->actor.world.pos.z, 0, 0, 0x78, ENWATEREFFECT_777); + + this->unk_280 = 27; + this->unk_284 = this->actor.world.pos.x; + this->unk_288 = this->waterHeight; + this->unk_28C = this->actor.world.pos.z; + } + } + + if (this->actionFunc != Boss03_DeathCutscene) { + if ((this->actionFunc == Boss03_Stunned) || (this->actionFunc == Boss03_Damaged)) { + this->bodyCollider.base.colType = COLTYPE_HIT3; + } else { + this->bodyCollider.base.colType = COLTYPE_METAL; + } + + Boss03_UpdateCollision(this, globalCtx); + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + + if (player->transformation == PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + + if (!this->unk_2BD) { + if (player->transformation != PLAYER_FORM_HUMAN) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + + if ((this->actionFunc != Boss03_Stunned) && (!this->unk_2BD)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->headCollider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->bodyCollider.base); + } + } + + dblueActor = Boss03_FindActorDblueMovebg(globalCtx); + if (dblueActor != NULL) { + dblueActor->world.pos.y = this->waterHeight; + } + + Math_ApproachZeroF(&this->unk_260, 0.1f, 0.05f); + + if (this->unk_290 != 0) { + this->unk_294 += 0.1f; + this->unk_298 += 0.12f; + this->leftFinYRot = __sinf(this->unk_294) * 1280.0f; + this->rightFinYRot = __sinf(this->unk_298) * 1280.0f; + } else { + Math_ApproachS(&this->rightFinYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->leftFinYRot, 0, 0xA, 0x100); + } + + Math_ApproachS(&this->bodyYRot, 0, 0xA, 0x100); + Math_ApproachS(&this->jawZRot, 0, 0xA, 0x200); + + if ((this->unk_240 % 2) == 0) { + for (i = 0; i < this->bubbleEffectSpawnCount; i++) { + bubblePos.x = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.x; + bubblePos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.y; + bubblePos.z = randPlusMinusPoint5Scaled(100.0f) + this->actor.world.pos.z; + + Boss03_SpawnEffectBubble(globalCtx, &bubblePos); + } + } + + this->bubbleEffectSpawnCount = 1; + Boss03_UpdateEffects(globalCtx); + + if (D_809E9841 != 0) { + D_809E9841--; + if (D_809E9841 == 0) { + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); + } + } + + if (this->actionFunc != Boss03_CatchPlayer) { + Math_ApproachS(&player->actor.world.rot.x, 0, 1, 0x80); + Math_ApproachS(&player->actor.shape.rot.x, 0, 1, 0x80); + } + + if ((this->waterHeight < player->actor.world.pos.y) && (this->prevPlayerPos.y <= this->waterHeight)) { + this->wetSpotEffectSpawnCount = 20; + } + + // 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 (this->wetSpotEffectSpawnCount != 0) { + this->wetSpotEffectSpawnCount--; + + wetSpotPos.x = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.x; + wetSpotPos.y = PLATFORM_HEIGHT; + wetSpotPos.z = randPlusMinusPoint5Scaled(50.0f) + player->actor.world.pos.z; + Boss03_SpawnEffectWetSpot(globalCtx, &wetSpotPos); + } + } + + this->prevPlayerPos = player->actor.world.pos; + + if (this->waterHeight < this->actor.world.pos.y) { + func_8019F540(0); + } else { + func_8019F540(1); + } + + if (this->unk_280 != 0) { + this->unk_280--; + } + + if ((this->unk_280 == 1) || (this->unk_280 == 5) || (this->unk_280 == 9)) { + yRot = 0.0f; + + for (j = 0, i = 0; i < 20; j++) { + Matrix_InsertYRotation_f(yRot, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(60.000004f) + 312.0f, &dropletPos); + dropletPos.x += this->unk_284 + randPlusMinusPoint5Scaled(40.0f); + dropletPos.y = PLATFORM_HEIGHT; + dropletPos.z += this->unk_28C + randPlusMinusPoint5Scaled(40.0f); + + if (sqrtf(SQ(dropletPos.x) + SQ(dropletPos.z)) < 355.0f) { + Boss03_SpawnEffectDroplet(globalCtx, &dropletPos); + i++; + } + + yRot += ((2.0f * M_PI) / 50.0f); + if (j >= 50) { + break; + } + } + } +} + +/* End of Gyorg's More actionFuncs and Update section */ + +/* Start of Gyorg's Draw section */ + +void Boss03_SetObject(GlobalContext* globalCtx, s16 objectId) { + s32 objectIndex = Object_GetIndex(&globalCtx->objectCtx, objectId); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[objectIndex].segment); + + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[objectIndex].segment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 Boss03_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + Boss03* this = THIS; + + if ((limbIndex == GYORG_LIMB_UPPER_TRUNK) || (limbIndex == GYORG_LIMB_LOWER_TRUNK) || + (limbIndex == GYORG_LIMB_TAIL)) { + rot->y += this->bodyYRot; + } + if (limbIndex == GYORG_LIMB_UPPER_RIGHT_FIN) { + rot->y += this->rightFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_RIGHT_FIN) { + rot->y += (s16)(2 * this->rightFinYRot); + } + if (limbIndex == GYORG_LIMB_UPPER_LEFT_FIN) { + rot->y -= this->leftFinYRot; + } + if (limbIndex == GYORG_LIMB_LOWER_LEFT_FIN) { + rot->y -= (s16)(2 * this->leftFinYRot); + } + if (limbIndex == GYORG_LIMB_JAW) { + rot->z += this->jawZRot; + } + + return false; +} + +/** + * Used to manually index the spheres elements of the two colliders + * Since there are two sets of ColliderJntSph, indices < 2 (ARRAY_COUNT(sHeadJntSphElementsInit)) refers to the first + * collider and indices >= 2 refers to the second one + */ +s8 sGyorgSphElementIndices[] = { + -1, // GYORG_LIMB_NONE, + -1, // GYORG_LIMB_ROOT, + 0, // GYORG_LIMB_HEAD, + -1, // GYORG_LIMB_BODY_ROOT, + 4, // GYORG_LIMB_UPPER_TRUNK, + 5, // GYORG_LIMB_LOWER_TRUNK, + 6, // GYORG_LIMB_TAIL, + -1, // GYORG_LIMB_RIGHT_FIN_ROOT, + 2, // GYORG_LIMB_UPPER_RIGHT_FIN, + -1, // GYORG_LIMB_LOWER_RIGHT_FIN, + -1, // GYORG_LIMB_LEFT_FIN_ROOT, + 3, // GYORG_LIMB_UPPER_LEFT_FIN, + -1, // GYORG_LIMB_LOWER_LEFT_FIN, + -1, // GYORG_LIMB_JAW_ROOT, + 1, // GYORG_LIMB_JAW, + -1, // GYORG_LIMB_MAX + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; + +Vec3f D_809E9148 = { 600.0f, -100.0f, 0.0f }; +Vec3f D_809E9154[] = { + { 450.0f, 0.0f, 0.0f }, { 140.0f, -60.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, { 350.0f, 0.0f, 0.0f }, + { 100.0f, 0.0f, 0.0f }, { 150.0f, 0.0f, 0.0f }, { 500.0f, 0.0f, 0.0f }, +}; +Vec3f D_809E91A8 = { 100000.0f, 100000.0f, 100000.0f }; +Vec3f D_809E91B4 = { 300.0f, -100.0f, -200.0f }; + +void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Boss03* this = THIS; + s32 pad; + s8 sphereElementIndex; + Vec3f spherePos; + Player* player = GET_PLAYER(globalCtx); + + if (limbIndex == GYORG_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_809E9148, &this->actor.focus.pos); + } + + sphereElementIndex = sGyorgSphElementIndices[limbIndex]; + if (sphereElementIndex >= 0) { + Matrix_MultiplyVector3fByState(&D_809E9154[sphereElementIndex], &spherePos); + + if (sphereElementIndex < 2) { + if ((this->actionFunc == Boss03_Stunned) && (this->waterHeight < player->actor.world.pos.y)) { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &D_809E91A8); + } else { + Boss03_UpdateSphereElement(sphereElementIndex, &this->headCollider, &spherePos); + } + } else { + Boss03_UpdateSphereElement(sphereElementIndex - 2, &this->bodyCollider, &spherePos); + } + } + + if (limbIndex == GYORG_LIMB_JAW) { + MtxF mf; + + D_809E91B4.x = this->unk_2C4 + 300.0f; + Matrix_MultiplyVector3fByState(&D_809E91B4, &this->insideJawPos); + Matrix_CopyCurrentState(&mf); + func_8018219C(&mf, &this->unk_2A2, 0); + } +} + +void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (!this->unk_2D5) { + if ((this->unk_25E % 2) != 0) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 900, 1099); + } + + Matrix_InsertYRotation_f(this->unk_260, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + this->unk_2BC = 0; + + Boss03_DrawEffects(globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Gyorg's Draw section */ + +/* Start of Effect Update/Draw section */ + +void Boss03_UpdateEffects(GlobalContext* globalCtx) { + GyorgEffect* eff = globalCtx->specialEffects; + s16 i; + Vec3f sp94; + Vec3f velocity; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + f32 phi_f0; + + if (eff->type == GYORG_EFFECT_NONE) { + continue; + } + + eff->unk_02++; + + eff->pos.x += eff->velocity.x; + eff->pos.y += eff->velocity.y; + eff->pos.z += eff->velocity.z; + + eff->velocity.y += eff->accel.y; + + if ((eff->unk_02 & 6) != 0) { + phi_f0 = 80.0f; + } else { + phi_f0 = 200.0f; + } + + Math_ApproachF(&eff->unk_40, phi_f0, 1.0f, 80.0f); + + if (eff->type == GYORG_EFFECT_DROPLET) { + eff->unk_34.z += 0.15f; + + Math_ApproachF(&eff->unk_34.x, 0.03f, 0.5f, 0.005f); + Math_ApproachF(&eff->unk_34.y, 0.5f, 0.5f, 0.02f); + + if (eff->pos.y <= WATER_HEIGHT) { + eff->type = GYORG_EFFECT_NONE; + eff->pos.y = WATER_HEIGHT; + EffectSsGRipple_Spawn(globalCtx, &eff->pos, 0, 80, 0); + } else if (eff->pos.y <= PLATFORM_HEIGHT) { + s16 j; + + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.1f; + eff->unk_34.y = 0.6f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + + for (j = 0; j < 4; j++) { + Matrix_InsertYRotation_f((2.0f * (j * M_PI)) / 6.0f, 0); + sp94.x = 0.0f; + sp94.y = Rand_ZeroFloat(4.0f) + 2.0f; + sp94.z = Rand_ZeroFloat(1.5f) + 1.5f; + Matrix_MultiplyVector3fByState(&sp94, &velocity); + Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); + } + } + } else if (eff->type == GYORG_EFFECT_SPLASH) { + eff->unk_34.z += 0.15f; + + if (eff->velocity.y < -8.0f) { + eff->velocity.y = -8.0f; + } + + if ((eff->velocity.y < 0.0f) && (eff->pos.y <= PLATFORM_HEIGHT)) { + eff->type = GYORG_EFFECT_WET_SPOT; + eff->pos.y = PLATFORM_HEIGHT; + eff->unk_34.x = 0.05f; + eff->unk_34.y = 0.2f; + eff->velocity = gZeroVec3f; + eff->accel = gZeroVec3f; + eff->alpha = 150; + eff->alphaDelta = Rand_ZeroFloat(4.0f) + 5.0f; + } + } else if (eff->type == GYORG_EFFECT_WET_SPOT) { + Math_ApproachF(&eff->unk_34.x, eff->unk_34.y, 0.1f, 0.6f); + + eff->alpha -= eff->alphaDelta; + if (eff->alpha <= 0) { + eff->alpha = 0; + eff->type = GYORG_EFFECT_NONE; + } + } else if (eff->type == GYORG_EFFECT_BUBBLE) { + if (eff->velocity.y > 5.0f) { + eff->velocity.y = 5.0f; + } + if (sGyorgBossInstance->waterHeight < eff->pos.y) { + eff->type = GYORG_EFFECT_NONE; + } + } + } +} + +void Boss03_DrawEffects(GlobalContext* globalCtx) { + u8 flag = false; + s16 i; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 pad; + GyorgEffect* eff = globalCtx->specialEffects; + GyorgEffect* effFirst = eff; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(gfxCtx); + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_BUBBLE) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleMaterialDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + + flag = true; + } + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + Matrix_Scale(eff->unk_34.x, eff->unk_34.x, 1.0f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGyorgBubbleModelDL); + } + } + + eff = effFirst; + + Boss03_SetObject(globalCtx, OBJECT_WATER_EFFECT); + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if ((eff->type == GYORG_EFFECT_DROPLET) || (eff->type == GYORG_EFFECT_SPLASH)) { + + if (!flag) { + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)eff->unk_40, (u8)((((void)0, eff->unk_40) + 55.0f)), 225, 150); + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + if (eff->type == GYORG_EFFECT_DROPLET) { + Matrix_InsertYRotation_f(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * + (M_PI / 0x8000), + MTXMODE_APPLY); + } else { // GYORG_EFFECT_SPLASH + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + } + + Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_f(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042B0); + } + } + + eff = effFirst; + + flag = false; + + for (i = 0; i < GYORG_EFFECT_COUNT; i++, eff++) { + if (eff->type == GYORG_EFFECT_WET_SPOT) { + if (!flag) { + func_8012C448(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); + + flag++; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (s16)eff->unk_40, ((void)0, ((s16)eff->unk_40) + 55), 225, + eff->alpha); + + Matrix_InsertTranslation(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); + + Matrix_Scale(eff->unk_34.x, 1.0f, eff->unk_34.x, MTXMODE_APPLY); + Matrix_InsertYRotation_f(eff->unk_34.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_0042F8); + } + } + + Boss03_SetObject(globalCtx, OBJECT_BOSS03); + + CLOSE_DISPS(gfxCtx); +} + +/* End of Effect Update/Draw section */ + +/* Start of Seaweed section */ + +#define SEAWEED_FLAG_INTERACT_NONE 0 +#define SEAWEED_FLAG_INTERACT_PLAYER 1 +#define SEAWEED_FLAG_INTERACT_GYORG 2 + +void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + s16 pad; + s16 maxBendSpeed; + u8 flag; + Player* player = GET_PLAYER(globalCtx); + f32 distanceBetweenSeaweedAndDisturbance; + f32 disturbanceFactor; + f32 xDiff; + f32 yDiff; + f32 zDiff; + + flag = SEAWEED_FLAG_INTERACT_NONE; + this->unk_240++; + + for (i = 0; i < ARRAY_COUNT(this->seaweedSegmentPositions); i++) { + xDiff = player->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + 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; + + // Player is standing on ground + if (player->actor.bgCheckFlags & 1) { + maxBendSpeed = 0; + } else { + maxBendSpeed = player->actor.speedXZ * 16.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x100; + } + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, + 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_PLAYER; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_PLAYER) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + + if (sGyorgBossInstance->actor.world.pos.y - 40.0f < sGyorgBossInstance->waterHeight) { + for (i = 0; i < 6; i++) { + xDiff = sGyorgBossInstance->actor.world.pos.x - this->seaweedSegmentPositions[i].x; + yDiff = sGyorgBossInstance->actor.world.pos.y - this->seaweedSegmentPositions[i].y; + zDiff = sGyorgBossInstance->actor.world.pos.z - this->seaweedSegmentPositions[i].z; + + distanceBetweenSeaweedAndDisturbance = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + + if ((i == 0) && (distanceBetweenSeaweedAndDisturbance > 400.0f)) { + break; + } + + maxBendSpeed = sGyorgBossInstance->actor.speedXZ * 16.0f; + disturbanceFactor = sGyorgBossInstance->actor.speedXZ * 5.0f + 150.0f; + if (maxBendSpeed > 0x1000) { + maxBendSpeed = 0x1000; + } else if (maxBendSpeed < 0x100) { + maxBendSpeed = 0x0100; + } + + if (distanceBetweenSeaweedAndDisturbance < disturbanceFactor) { + Math_ApproachS(&this->morphTable[i].x, + (disturbanceFactor - distanceBetweenSeaweedAndDisturbance) * 200.0f, 0xA, maxBendSpeed); + if (maxBendSpeed != 0) { + flag |= SEAWEED_FLAG_INTERACT_GYORG; + } + } + } + + if (flag & SEAWEED_FLAG_INTERACT_GYORG) { + Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + } + } + + if (flag == SEAWEED_FLAG_INTERACT_NONE) { + for (i = 0; i < 6; i++) { + Math_ApproachS(&this->morphTable[i].x, 0, 0x14, 0x80); + } + } +} + +Gfx* sGyorgSeaweedDLs[] = { + gGyorgSeaweedTopDL, gGyorgSeaweedPiece5DL, gGyorgSeaweedPiece4DL, + gGyorgSeaweedPiece3DL, gGyorgSeaweedPiece2DL, gGyorgSeaweedPiece1DL, +}; + +void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { + Boss03* this = THIS; + s16 i; + // Why 10 Mtxs? This seems to only use the first 6 elements + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 10); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(0x4000, MTXMODE_APPLY); + // The indices looks a bit random... + Matrix_RotateY(this->jointTable[5].x * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->jointTable[3].y * -5.0f * 0.1f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->jointTable[2].z * 6.0f * 0.1f, MTXMODE_APPLY); + + for (i = 0; i < ARRAY_COUNT(sGyorgSeaweedDLs); i++, mtx++) { + Matrix_RotateY(this->jointTable[i].x + this->morphTable[i].x, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->jointTable[i].y + this->morphTable[i].y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->jointTable[i].z + this->morphTable[i].z, MTXMODE_APPLY); + + Matrix_ToMtx(mtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, sGyorgSeaweedDLs[i]); + + Matrix_GetStateTranslation(&this->seaweedSegmentPositions[i]); + Matrix_InsertTranslation(4000.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +/* End of Seaweed section */ diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.h b/src/overlays/actors/ovl_Boss_03/z_boss_03.h index ca8a92328..f5af516c0 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.h +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.h @@ -2,22 +2,109 @@ #define Z_BOSS_03_H #include "global.h" +#include "objects/object_boss03/object_boss03.h" struct Boss03; typedef void (*Boss03ActionFunc)(struct Boss03*, GlobalContext*); +#define GYORG_WORK_TIMER_MAX 3 + +typedef struct { + /* 0x00 */ u8 type; + /* 0x02 */ s16 unk_02; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ UNK_TYPE1 unk_28[0x4]; + /* 0x2C */ s16 alpha; + /* 0x2E */ s16 alphaDelta; + /* 0x30 */ UNK_TYPE1 unk_30[0x4]; + /* 0x34 */ Vec3f unk_34; // it may not be a Vec3f + /* 0x40 */ f32 unk_40; // colorIntensity? +} GyorgEffect; // size = 0x44 + +#define GYORG_EFFECT_COUNT 150 + +typedef enum { + /* 0 */ GYORG_EFFECT_NONE, + /* 1 */ GYORG_EFFECT_BUBBLE, + /* 2 */ GYORG_EFFECT_DROPLET, + /* 3 */ GYORG_EFFECT_SPLASH, + /* 4 */ GYORG_EFFECT_WET_SPOT, +} GyorgEffectType; + typedef struct Boss03 { /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk_144[0x10E]; - /* 0x0252 */ s8 unk_252; // number of Tanron3 fish that are currently alive, maybe "numSmallFishAlive"? - /* 0x0253 */ UNK_TYPE1 unk_253[0xD1]; - /* 0x0324 */ s16 unk_324; - /* 0x0326 */ UNK_TYPE1 unk_326[0x2]; + /* 0x0144 */ UNK_TYPE1 unk_144[0x04]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ Vec3s jointTable[GYORG_LIMB_MAX]; + /* 0x01E6 */ Vec3s morphTable[GYORG_LIMB_MAX]; + /* 0x0240 */ s16 unk_240; // generic timer? used by Gyorg and seaweed + /* 0x0242 */ u8 unk_242; + /* 0x0243 */ UNK_TYPE1 unk_243[0x09]; + /* 0x024C */ s16 workTimer[GYORG_WORK_TIMER_MAX]; + /* 0x0252 */ s8 numSpawnedSmallFish; // number of Tanron3 fish that are currently alive, -1 indexed + /* 0x0253 */ u8 hasSpwanedSmallFishes; // Tanron + /* 0x0254 */ s16 bubbleEffectSpawnCount; // Amount of bubble effect which will be spawned by Update + /* 0x0258 */ f32 waterHeight; // always 430.0f + /* 0x025C */ s16 unk_25C; // Timer related to collision? + /* 0x025E */ s16 unk_25E; + /* 0x0260 */ f32 unk_260; // rotY + /* 0x0264 */ UNK_TYPE1 unk_264[0x04]; + /* 0x0268 */ Vec3f unk_268; // set to player.world.pos or random values + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ f32 unk_278; + /* 0x027C */ f32 unk_27C; + /* 0x0280 */ s16 unk_280; + /* 0x0284 */ f32 unk_284; // Maybe a Vec3f + /* 0x0288 */ f32 unk_288; // Set but not used + /* 0x028C */ f32 unk_28C; + /* 0x0290 */ u8 unk_290; + /* 0x0294 */ f32 unk_294; + /* 0x0298 */ f32 unk_298; + /* 0x029C */ s16 leftFinYRot; + /* 0x029E */ s16 rightFinYRot; + /* 0x02A0 */ s16 bodyYRot; + /* 0x02A2 */ Vec3s unk_2A2; + /* 0x02A8 */ s16 jawZRot; + /* 0x02AC */ Vec3f insideJawPos; // used to grab player + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ u8 unk_2BC; // set but not used + /* 0x02BD */ u8 unk_2BD; // playerUnderwater? + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ UNK_TYPE1 unk_2C0[0x04]; + /* 0x02C0 */ f32 unk_2C4; + /* 0x02C8 */ Vec3f prevPlayerPos; + /* 0x02D4 */ u8 wetSpotEffectSpawnCount; + /* 0x02D5 */ u8 unk_2D5; // flag + /* 0x02D6 */ s16 shapeRotTargetX; + /* 0x02D8 */ s16 shapeRotTargetY; + /* 0x02DA */ s16 shapeRotTargetZ; + /* 0x02DC */ Vec3f seaweedSegmentPositions[6]; + /* 0x0324 */ s16 unk_324; // timer? set by Tanron3 /* 0x0328 */ Boss03ActionFunc actionFunc; - /* 0x032C */ UNK_TYPE1 unk_32C[0x250]; + /* 0x032C */ ColliderJntSph headCollider; + /* 0x034C */ ColliderJntSphElement headColliderElements[2]; + /* 0x03CC */ ColliderJntSph bodyCollider; + /* 0x03EC */ ColliderJntSphElement bodyColliderElements[5]; + /* 0x052C */ f32 floppingAnimLastFrame; + /* 0x0530 */ u32 csTimer; + /* 0x0534 */ s16 csState; + /* 0x0536 */ s16 csCamId; + /* 0x0538 */ Vec3f csCamEye; + /* 0x0544 */ Vec3f csCamAt; + /* 0x0550 */ Vec3f csCamTargetEye; + /* 0x055C */ Vec3f csCamTargetAt; + /* 0x0568 */ f32 unk_568; + /* 0x056C */ f32 unk_56C; + /* 0x0570 */ f32 unk_570; // set but not used + /* 0x0574 */ UNK_TYPE1 unk_574[0x04]; + /* 0x0578 */ f32 cameraFov; } Boss03; // size = 0x57C - -extern const ActorInit Boss_03_InitVars; + +#define GYORG_PARAM_DEFAULT (0) +#define GYORG_PARAM_SEAWEED (0x23) #endif // Z_BOSS_03_H 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 67ea1702e..b74d9c66b 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -7,7 +7,7 @@ #include "z_boss_04.h" #include "objects/object_boss04/object_boss04.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss04*)thisx) @@ -179,8 +179,8 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(D_809EE1F8); i++) { spA8.x = D_809EE1F8[i].x + this->actor.world.pos.x; spA8.z = D_809EE1F8[i].z + this->actor.world.pos.z; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, 1, 0, 0, 1, - &spA4)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &spA8, &spB4, &spC0, true, false, false, + true, &spA4)) { if (i == 0) { this->unk_6D8 = spB4.x; } else if (i == 1) { @@ -231,7 +231,7 @@ void Boss04_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_809EC544(Boss04* this) { this->actionFunc = func_809EC568; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void func_809EC568(Boss04* this, GlobalContext* globalCtx) { @@ -259,10 +259,10 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { this->unk_708 = 10; this->unk_704 = 0; - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->unk_70A = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_70A, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->unk_70A = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_70A, 7); func_800B7298(globalCtx, &this->actor, 7); player->actor.world.pos.x = this->unk_6E8; player->actor.world.pos.z = this->unk_6F0 + 410.0f; @@ -380,7 +380,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_704 > 140) { - Camera* sp5C = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* sp5C = Play_GetCamera(globalCtx, CAM_ID_MAIN); this->unk_708 = 0; func_809ECD00(this, globalCtx); @@ -389,7 +389,7 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { sp5C->at = this->unk_718; func_80169AFC(globalCtx, this->unk_70A, 0); this->unk_70A = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); func_80165690(); gSaveContext.eventInf[6] |= 1; @@ -400,14 +400,14 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { if (this->unk_70A != 0) { Vec3f sp50; - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); if (this->unk_748 != 0) { this->unk_748--; } Math_Vec3f_Copy(&sp50, &this->unk_718); sp50.y += Math_SinS(this->unk_748 * 0x4000) * this->unk_748 * 1.5f; Play_CameraSetAtEye(globalCtx, this->unk_70A, &sp50, &this->unk_70C); - func_80169940(globalCtx, this->unk_70A, this->unk_744); + Play_CameraSetFov(globalCtx, this->unk_70A, this->unk_744); Math_ApproachF(&this->unk_744, 60.0f, 0.1f, 1.0f); } this->actor.shape.rot.y = this->actor.yawTowardsPlayer; @@ -521,7 +521,7 @@ void func_809ED224(Boss04* this) { this->unk_2D0 = 10000.0f; this->unk_2C8 = 200; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_801A2ED8(); this->unk_1F6 = 10; } @@ -542,7 +542,7 @@ void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_1F8 == 3) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_700 = 0.0f; this->unk_6FC = 0.0f; this->unk_6F8 = 0.0f; @@ -747,9 +747,9 @@ void Boss04_Update(Actor* thisx, GlobalContext* globalCtx2) { func_809ED45C(this, globalCtx); if (this->unk_2CC > 3000.0f) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.h b/src/overlays/actors/ovl_Boss_04/z_boss_04.h index f4542cf3a..267688ab0 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -13,7 +13,7 @@ typedef struct Boss04 { /* 0x0188 */ Vec3s jointTable[9]; /* 0x01BE */ Vec3s morphtable[9]; /* 0x01F4 */ s16 unk_1F4; - /* 0x01F6 */ s8 unk_1F6; + /* 0x01F6 */ u8 unk_1F6; /* 0x01F7 */ u8 unk_1F7; /* 0x01F8 */ s16 unk_1F8; /* 0x01FA */ s16 unk_1FA; diff --git a/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/src/overlays/actors/ovl_Boss_05/z_boss_05.c index a8122fdaa..a88ad8008 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -6,7 +6,7 @@ #include "z_boss_05.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((Boss05*)thisx) 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 694112c4d..5a88f67c6 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -197,11 +197,11 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { break; } - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 7); - this->unk_A00 = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->unk_A00, 7); + this->unk_A00 = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->unk_A00, 7); D_809F4970->unk_151 = 1; this->unk_1C9 = 1; this->unk_1C8 = 1; @@ -219,11 +219,11 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { case 1: if (this->unk_1CA >= 10) { Math_ApproachF(&this->unk_1E4, 30.0f, 0.2f, 1.0f); - globalCtx->envCtx.unk_E5 = 1; - globalCtx->envCtx.unk_E6[2] = 0; - globalCtx->envCtx.unk_E6[1] = 0; - globalCtx->envCtx.unk_E6[0] = 0; - globalCtx->envCtx.unk_E6[3] = this->unk_A2C; + globalCtx->envCtx.fillScreen = 1; + globalCtx->envCtx.screenFillColor[2] = 0; + globalCtx->envCtx.screenFillColor[1] = 0; + globalCtx->envCtx.screenFillColor[0] = 0; + globalCtx->envCtx.screenFillColor[3] = this->unk_A2C; Math_ApproachF(&this->unk_A2C, 75.0f, 1.0f, 3.0f); } @@ -232,7 +232,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { } if (this->unk_1CA >= 60) { - globalCtx->envCtx.unk_E5 = 0; + globalCtx->envCtx.fillScreen = 0; this->unk_1C8 = 0; this->unk_1DC = 0.0f; this->unk_1D8 = 0.0f; @@ -331,7 +331,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { func_809F2ED0(this, globalCtx); func_80169AFC(globalCtx, this->unk_A00, 0); this->unk_A00 = 0; - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); D_809F4970->unk_151 = 0; } @@ -339,7 +339,7 @@ void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { } if (this->unk_A00 != 0) { - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); Play_CameraSetAtEye(globalCtx, this->unk_A00, &this->unk_A10, &this->unk_A04); } } @@ -499,8 +499,6 @@ void Boss06_Update(Actor* thisx, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// v/a flips void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; Boss06* this = THIS; @@ -509,10 +507,11 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { s16 temp_s0; s16 temp_f10; Vtx* temp_v0_2; - u32 temp_v0; + u16 temp_v0; + u16 pad; u8 spD3; u8 spD2; - s32 pad; + s32 maxColor = 255; // Possible FAKE MATCH f32 sp68; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -521,8 +520,8 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_8012C28C(globalCtx->state.gfxCtx); temp_v0 = gSaveContext.save.time; - if (gSaveContext.save.time > 0x8000) { - temp_v0 = (0xFFFF - gSaveContext.save.time) & 0xFFFF; + if (temp_v0 > CLOCK_TIME(12, 0)) { + temp_v0 = 0xFFFF - temp_v0; } sp68 = (f32)temp_v0 / 0x8000; spD3 = ((10.0f * sp68) + 105.0f) * this->unk_19C; @@ -579,10 +578,12 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertTranslation(0.0f, 0.0f, -1112.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, (u8)((140.0f * sp68) + 115.0f), spD3); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 155, 255, maxColor, (u8)((140.0f * sp68) + 115.0f), spD3); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018CF0); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, (u8)((100.0f * sp68) + 65.0f), spD2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 255, 255, maxColor, (u8)((100.0f * sp68) + 65.0f), spD2); gSPDisplayList(POLY_XLU_DISP++, object_knight_DL_018DE0); + + if (1) {} } if (this->unk_144 & 1) { @@ -603,7 +604,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { func_809F2120(1, 0x71A5, 0x263A); gDPSetEnvColor(POLY_XLU_DISP++, 255, 10, 0, 0); - gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 230); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 128, 255, 255, 0, 230); for (i = 0; i < ARRAY_COUNT(D_809F4370); i++) { if ((fabsf(D_809F4370[i].x - 32.0f) < 30.0f) && (fabsf(D_809F4370[i].y - 32.0f) < 30.0f)) { @@ -621,7 +622,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); } - Matrix_Scale(-0.002f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); + Matrix_Scale(-0.02f / 10.0f, -this->unk_1D8, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -642,7 +643,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { this->actor.world.pos.y + 84.0f + this->unk_1B4, (this->actor.world.pos.z - 2.0f) + spE0, MTXMODE_NEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, (u8)((140.0f * sp68) + 115.0f), temp_s2); gDPSetEnvColor(POLY_XLU_DISP++, 255, 205, (u8)((100.0f * sp68) + 65.0f), 128); @@ -650,11 +651,8 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 64, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Boss_06/Boss06_Draw.s") -#endif diff --git a/src/overlays/actors/ovl_Boss_07/z_boss_07.c b/src/overlays/actors/ovl_Boss_07/z_boss_07.c index d5e0e22ed..9e8841034 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -6,7 +6,7 @@ #include "z_boss_07.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((Boss07*)thisx) diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c index 333d2a89f..d8ebaf7eb 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -6,7 +6,7 @@ #include "z_boss_hakugin.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((BossHakugin*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c index 94bbef096..18be6991c 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -6,7 +6,7 @@ #include "z_demo_effect.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoEffect*)thisx) 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 71f0d9204..9e6661fd0 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.c @@ -6,7 +6,7 @@ #include "z_demo_getitem.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoGetitem*)thisx) 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 c85a48eb8..b51fc64ec 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_bubble/object_bubble.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoKankyo*)thisx) @@ -518,12 +518,12 @@ void DemoKakyo_DrawLostWoodsSparkle(Actor* thisx, GlobalContext* globalCtx2) { Vec3f screenPos; // if not underwater - if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100)) { + if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100)) { OPEN_DISPS(globalCtx->state.gfxCtx); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_079B10)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); for (i = 0; i < globalCtx->envCtx.unk_F2[3]; i++) { @@ -633,7 +633,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, this->particles[i].scale * alphaScale, MTXMODE_APPLY); alphaScale = Math_Vec3f_DistXYZ(&worldPos, &globalCtx->view.eye) / 300.0f; - alphaScale = (alphaScale > 1.0f) ? 0.0f : (1.0f - alphaScale) > 1.0f ? 1.0f : 1.0f - alphaScale; + alphaScale = CLAMP(1.0f - alphaScale, 0.0f, 1.0f); if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { this->particles[i].alpha = 255.0f * alphaScale; @@ -655,7 +655,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { break; } - gSPDisplayList(POLY_XLU_DISP++, &gameplay_keep_DL_023348); + gSPDisplayList(POLY_XLU_DISP++, &gLightOrb1DL); Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); @@ -667,7 +667,7 @@ void DemoKankyo_DrawMoonAndGiant(Actor* thisx, GlobalContext* globalCtx2) { if (this->actor.params == DEMO_KANKYO_TYPE_GIANTS) { gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); } else { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023428); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); } } } diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c index ab3cf474f..9ed7a0c27 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -6,7 +6,7 @@ #include "z_demo_moonend.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoMoonend*)thisx) diff --git a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c index f7001b489..faedc1b74 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c @@ -6,7 +6,7 @@ #include "z_demo_shd.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoShd*)thisx) 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 a22d0f8c6..aa25fddfd 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -5,8 +5,9 @@ */ #include "z_demo_syoten.h" +#include "objects/object_syoten/object_syoten.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DemoSyoten*)thisx) @@ -15,7 +16,15 @@ void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx); void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx); +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx); +void func_80C17690(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Demo_Syoten_InitVars = { ACTOR_DEMO_SYOTEN, ACTORCAT_ITEMACTION, @@ -28,45 +37,539 @@ const ActorInit Demo_Syoten_InitVars = { (ActorFunc)DemoSyoten_Draw, }; -#endif +u8 D_80C177D0[] = { + 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 0, 1, 0, + 2, 2, 0, 1, 0, 1, 2, 2, 1, 2, 2, 0, 0, 0, 1, 1, 0, 2, 2, 2, 2, 0, 0, 1, 0, 2, 2, + 0, 1, 0, 2, 2, 0, 1, 0, 2, 2, 2, 0, 0, 2, 0, 1, 1, 0, 2, 2, 2, 0, 1, 0, 2, 2, 0, +}; -extern UNK_TYPE D_0600023C; -extern UNK_TYPE D_06001298; -extern UNK_TYPE D_060018C0; -extern UNK_TYPE D_06002880; +Color_RGBA8 D_80C17824[] = { + { 160, 100, 130, 255 }, + { 150, 120, 160, 255 }, + { 130, 90, 150, 255 }, + { 90, 70, 120, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Init.s") +Color_RGBA8 D_80C17834[] = { + { 110, 50, 80, 255 }, + { 120, 100, 130, 255 }, + { 90, 40, 100, 255 }, + { 60, 50, 100, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Destroy.s") +void DemoSyoten_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16760.s") + Actor_SetScale(&this->actor, 0.3f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16818.s") + this->actionFunc = func_80C16A64; + this->unk_3E4 = 0; + this->unk_3E6 = 0; + this->unk_3DC = NULL; + this->unk_3E0 = NULL; + this->unk_3F2 = 0; + this->unk_3D8 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C168D0.s") + switch (DEMOSYOTEN_GET_F(&this->actor)) { + case DEMOSYOTEN_F_0: + func_80183430(&this->unk_144, &object_syoten_Blob_001328, &object_syoten_Blob_00023C, this->unk_174, + this->unk_2A6, 0); + func_801835EC(&this->unk_144, &object_syoten_Blob_00023C); + this->actor.draw = NULL; + this->actionFunc = func_80C16A74; + this->actor.child = Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, 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; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16974.s") + case DEMOSYOTEN_F_1: + Actor_SetScale(&this->actor, 0.1f); + this->unk_3DC = object_syoten_DL_001370; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001448); + this->unk_3E4 |= 1; + this->actionFunc = func_80C16BD4; + this->unk_3F0 = 0x215; + Actor_SetScale(&this->actor, 0.05f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A64.s") + 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->actionFunc = func_80C16DD4; + this->unk_3E4 |= 2; + Actor_SetScale(&this->actor, 4.0f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16A74.s") + 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->unk_3E4 |= 8; + this->actionFunc = func_80C16EAC; + Actor_SetScale(&this->actor, 0.5f); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16BD4.s") + case DEMOSYOTEN_F_4: + this->unk_3DC = object_syoten_DL_002880; + this->unk_3E0 = Lib_SegmentedToVirtual(&object_syoten_Matanimheader_002B88); + this->unk_3E4 |= 2; + this->actionFunc = func_80C17008; + this->unk_3F0 = 0x217; + this->unk_3E4 |= 1; + this->unk_3E4 |= 8; + this->actor.draw = func_80C17690; + Actor_SetScale(&this->actor, 5.0f); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16DD4.s") +void DemoSyoten_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C16EAC.s") + if (DEMOSYOTEN_GET_F(&this->actor) == DEMOSYOTEN_F_0) { + func_8018349C(&this->unk_144); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17008.s") +void func_80C16760(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Vec3s* points; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Update.s") + this->unk_3EC = 0; + if (DEMOSYOTEN_GET_7E00(&this->actor) != DEMOSYOTEN_7E00_3F) { + this->unk_3E8 = &globalCtx->setupPathList[DEMOSYOTEN_GET_7E00(&this->actor)]; + if (this->unk_3E8 != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + Math_Vec3s_ToVec3f(&this->actor.world.pos, &points[0]); + this->unk_3EC++; + points++; + Math_Vec3s_ToVec3f(&sp2C, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp2C); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp2C); + } + } else { + this->unk_3E8 = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C170F8.s") +s32 func_80C16818(DemoSyoten* this) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C173B4.s") + if (path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17468.s") + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp28, points); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp28); + this->actor.world.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &sp28); + Actor_MoveWithoutGravityReverse(&this->actor); + if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp28) < 2.0f) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/DemoSyoten_Draw.s") +void func_80C168D0(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + Path* path = this->unk_3E8; + Vec3s* points; + Vec3f sp30; + Vec3f sp24; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Syoten/func_80C17690.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(this->unk_3E8->points); + points += this->unk_3EC; + Math_Vec3s_ToVec3f(&sp30, points); + Actor_GetProjectedPos(globalCtx, &sp30, &sp24, &sp20); + Math_Vec3f_Copy(&sp30, &this->actor.projectedPos); + sp30.z = sp30.y; + sp24.z = sp24.y; + this->actor.shape.rot.z = -Math_Vec3f_Yaw(&sp24, &sp30); + } +} + +void func_80C16974(f32 arg0) { + Vtx* vtx = Lib_SegmentedToVirtual(&object_syotenVtx_0018C0); + u8 sp20[3]; + s32 i; + + arg0 = CLAMP_MAX(arg0, 1.0f); + + sp20[0] = (s8)0.0f; + sp20[1] = (s8)(152.0f * arg0); + sp20[2] = (s8)(255.0f * arg0); + + for (i = 0; i < ARRAY_COUNT(D_80C177D0); i++, vtx++) { + vtx->v.cn[3] = sp20[D_80C177D0[i]]; + } +} + +void func_80C16A64(DemoSyoten* this, GlobalContext* globalCtx) { +} + +void func_80C16A74(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + func_80183DE0(&this->unk_144); + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + if ((globalCtx->csCtx.frames >= 160) && (globalCtx->csCtx.frames < 322)) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_SOUL_LV - SFX_FLAG); + } else if (globalCtx->csCtx.frames == 322) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_IKANA_SOUL_TRANSFORM); + } + + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C173B4; + this->unk_3D8 = 1.0f; + break; + + case 3: + break; + + case 4: + this->actor.draw = NULL; + break; + } + } + + if (temp_a0 == 3) { + if (this->unk_3D8 > 0.0125f) { + this->unk_3D8 -= 0.0125f; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0x14; + } + } else { + this->actor.draw = NULL; + if (this->actor.child != NULL) { + this->actor.child->home.rot.z = 0; + } + } + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16BD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + default: + this->actor.draw = NULL; + break; + + case 1: + case 2: + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E4 &= ~4; + this->unk_3E4 |= 1; + this->actor.shape.rot.z = 0; + break; + + case 4: + this->actor.draw = DemoSyoten_Draw; + func_80C16760(this, globalCtx); + this->unk_3E4 |= 4; + this->unk_3E4 &= ~1; + break; + } + } + + switch (temp_a0) { + case 3: + if (this->actor.scale.x < 0.05f) { + this->actor.scale.x += 0.000625f; + } + Actor_SetScale(&this->actor, this->actor.scale.x); + break; + + case 4: + this->actor.speedXZ = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->urot.z * + 0.005493164f; + if (this->unk_3EC < this->unk_3E8->count) { + if (func_80C16818(this)) { + this->unk_3EC++; + } + func_80C168D0(this, globalCtx); + } + break; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16DD4(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + this->unk_3E6 = -6; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_FLYING_GOD_DASH); + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 40)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void func_80C16EAC(DemoSyoten* this, GlobalContext* globalCtx) { + s32 pad; + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + this->unk_3D8 = 0.0f; + Actor_SetScale(&this->actor, 0.5f); + break; + + case 2: + this->actor.draw = DemoSyoten_Draw; + break; + } + } + + if (temp_a0 == 2) { + if (this->actor.scale.x < 8.0f) { + this->actor.scale.x += 0.1875f; + } + + Actor_SetScale(&this->actor, this->actor.scale.x); + + if (this->unk_3D8 < 1.0f) { + this->unk_3D8 += 0.025f; + } + + if (this->unk_3D8 > 1.0f) { + this->unk_3D8 = 1.0f; + } + func_800B9010(&this->actor, NA_SE_EV_IKANA_PURIFICATION - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } + func_80C16974(this->unk_3D8); +} + +void func_80C17008(DemoSyoten* this, GlobalContext* globalCtx) { + u16 temp_a0; + + if (Cutscene_CheckActorAction(globalCtx, this->unk_3F0)) { + temp_a0 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_3F0)]->action; + if (this->unk_3F2 != temp_a0) { + this->unk_3F2 = temp_a0; + switch (temp_a0) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + this->actor.draw = func_80C17690; + this->unk_3E6 = -10; + break; + } + } + + if ((temp_a0 == 2) && (this->unk_3E6 < 15)) { + this->unk_3E6++; + } + } else { + this->actor.draw = NULL; + } +} + +void DemoSyoten_Update(Actor* thisx, GlobalContext* globalCtx) { + DemoSyoten* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 func_80C170F8(GlobalContext* globalCtx, UNK_TYPE arg1, s32 arg2, UNK_TYPE arg3, UNK_TYPE arg4, Actor* thisx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + DemoSyoten* this = THIS; + + OPEN_DISPS(gfxCtx); + + switch (arg2) { + case 2: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 140, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 4: + case 12: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 190, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 6: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 150, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 8: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 180, (s32)(this->unk_3D8 * 200.0f)); + break; + + case 10: + case 14: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 170, (s32)(this->unk_3D8 * 150.0f)); + break; + + case 16: + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 240, 160, (s32)(this->unk_3D8 * 200.0f)); + break; + } + + CLOSE_DISPS(gfxCtx); + return true; +} + +void func_80C173B4(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + Mtx* matrix; + + AnimatedMat_DrawXlu(globalCtx, Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001298)); + + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_144.unk_18->unk_1)); + + if (matrix != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); + } +} + +void func_80C17468(GlobalContext* globalCtx) { + Color_RGBA8 sp2C; + Color_RGBA8 sp28; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800FE7A8(D_80C17824, &sp2C); + func_800FE7A8(D_80C17834, &sp28); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sp2C.r, sp2C.g, sp2C.b, 255); + gDPSetEnvColor(POLY_XLU_DISP++, sp28.r, sp28.g, sp28.b, 255); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void DemoSyoten_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->unk_3E4 & 4) { + Matrix_InsertZRotation_s(-this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Scale(1.0f, 5.0f, 1.0f, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 1) { + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + } + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + if (this->unk_3E0 != NULL) { + if (this->unk_3E4 & 2) { + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + } else { + AnimatedMat_DrawXlu(globalCtx, this->unk_3E0); + } + } + + if (this->unk_3DC != NULL) { + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, this->unk_3DC); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80C17690(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DemoSyoten* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + + if (this->unk_3E4 & 8) { + func_80C17468(globalCtx); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002880); + + AnimatedMat_DrawStepXlu(globalCtx, this->unk_3E0, this->unk_3E6 + 5); + + gSPDisplayList(POLY_XLU_DISP++, object_syoten_DL_002A20); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 26f9902eb..204243f47 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.h @@ -7,9 +7,33 @@ struct DemoSyoten; typedef void (*DemoSyotenActionFunc)(struct DemoSyoten*, GlobalContext*); +#define DEMOSYOTEN_GET_F(thisx) ((thisx)->params & 0xF) +#define DEMOSYOTEN_GET_7E00(thisx) (((thisx)->params & 0x7E00) >> 9) + +#define DEMOSYOTEN_7E00_3F 0x3F + +enum { + /* 0 */ DEMOSYOTEN_F_0, + /* 1 */ DEMOSYOTEN_F_1, + /* 2 */ DEMOSYOTEN_F_2, + /* 3 */ DEMOSYOTEN_F_3, + /* 4 */ DEMOSYOTEN_F_4 +}; + typedef struct DemoSyoten { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2B0]; + /* 0x0144 */ SkeletonInfo unk_144; + /* 0x0174 */ Vec3s unk_174[51]; + /* 0x02A6 */ s16 unk_2A6[153]; + /* 0x03D8 */ f32 unk_3D8; + /* 0x03DC */ Gfx* unk_3DC; + /* 0x03E0 */ AnimatedMaterial* unk_3E0; + /* 0x03E4 */ u16 unk_3E4; + /* 0x03E6 */ s16 unk_3E6; + /* 0x03E8 */ Path* unk_3E8; + /* 0x03EC */ s32 unk_3EC; + /* 0x03F0 */ u16 unk_3F0; + /* 0x03F2 */ u16 unk_3F2; /* 0x03F4 */ DemoSyotenActionFunc actionFunc; } DemoSyoten; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index d4ce73419..060a201d7 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -6,7 +6,7 @@ #include "z_demo_tre_lgt.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DemoTreLgt*)thisx) 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 3a84e6b39..ede7baa1d 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -6,7 +6,7 @@ #include "z_dm_ah.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAh*)thisx) 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 f61a8f74e..d289b99ec 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -6,7 +6,7 @@ #include "z_dm_al.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAl*)thisx) 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 865cbeef0..2c23601f7 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -5,8 +5,10 @@ */ #include "z_dm_an.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmAn*)thisx) @@ -17,8 +19,8 @@ void DmAn_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C1C958(DmAn* this, GlobalContext* globalCtx); void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx); void func_80C1CC80(DmAn* this, GlobalContext* globalCtx); +void func_80C1D0B0(Actor* this, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_An_InitVars = { ACTOR_DM_AN, ACTORCAT_NPC, @@ -31,37 +33,336 @@ const ActorInit Dm_An_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C1C410(DmAn* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C410.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C4D8.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C5B4.s") +s32 func_80C1C4D8(DmAn* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C62C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C83C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C8E8.s") +void func_80C1C5B4(DmAn* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1C958.s") +s32 func_80C1C62C(DmAn* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CAB0.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CC80.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/DmAn_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CD80.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1CEFC.s") +s32 func_80C1C83C(DmAn* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C1C62C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_An/func_80C1D0B0.s") +Actor* func_80C1C8E8(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C1C958(DmAn* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C1C4D8(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C1D0B0; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C1C8E8(globalCtx); + func_80C1C4D8(this, globalCtx, 1); + this->actionFunc = func_80C1CC80; + } else { + this->actionFunc = func_80C1CAB0; + } + } +} + +void func_80C1CAB0(DmAn* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C1C4D8(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C1C4D8(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C1C4D8(this, globalCtx, this->unk_2CC); + } +} + +void func_80C1CC80(DmAn* this, GlobalContext* globalCtx) { +} + +void DmAn_Init(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C1C958; +} + +void DmAn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmAn_Update(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C1C83C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C1C410(this, globalCtx); + func_80C1C5B4(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C1D2C8 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C1D2D4 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C1D2DC = { 1000.0f, 0.0f, 0.0f }; + +void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmAn* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80C1D2C8, &D_80C1D2D4); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80C1D2DC, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmAn* this = THIS; + s16 phi_v1; + s16 phi_v0; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, + phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +TexturePtr D_80C1D2E8[] = { + object_an1_Tex_00E6E0, + &object_an1_Tex_00F7A0, + &object_an1_Tex_0101A0, +}; + +TexturePtr D_80C1D2F4[] = { + &object_an1_Tex_00E1E0, &object_an1_Tex_00EFA0, &object_an1_Tex_00F3A0, &object_an1_Tex_00EFA0, + &object_an1_Tex_00FDA0, &object_an1_Tex_00F9A0, &object_an1_Tex_0103A0, +}; + +void func_80C1D0B0(Actor* thisx, GlobalContext* globalCtx) { + DmAn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C1D2F4[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C1D2E8[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80C1CD80, func_80C1CEFC, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 70fcaa852..1b2b6f354 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -2,6 +2,7 @@ #define Z_DM_AN_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmAn; @@ -9,9 +10,30 @@ typedef void (*DmAnActionFunc)(struct DmAn*, GlobalContext*); typedef struct DmAn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmAnActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmAn; // size = 0x2D8 extern const ActorInit Dm_An_InitVars; 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 4394c6109..aa4abb91d 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -6,7 +6,7 @@ #include "z_dm_bal.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((DmBal*)thisx) 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 596945272..c72634216 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -5,8 +5,10 @@ */ #include "z_dm_char00.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_delf/object_delf.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar00*)thisx) @@ -15,7 +17,9 @@ void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx); void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx); +void func_80AA695C(DmChar00* this, GlobalContext* globalCtx); + const ActorInit Dm_Char00_InitVars = { ACTOR_DM_CHAR00, ACTORCAT_ITEMACTION, @@ -28,56 +32,921 @@ const ActorInit Dm_Char00_InitVars = { (ActorFunc)DmChar00_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gameplay_keep_Anim_02B2E8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &gameplay_keep_Anim_029140, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_004FF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0053A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_005B68, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_006328, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00FB30, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_010590, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_005B68, 1.0f, 37.0f, 56.0f, 4, 0.0f }, + { &object_delf_Anim_006328, 1.0f, 37.0f, 56.0f, 4, 0.0f }, + { &object_delf_Anim_00E024, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00F0D0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011C70, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011FE0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_011088, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0118FC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_012388, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_012738, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_013BE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_013E80, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_007B04, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0080A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00859C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_008A44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00EB18, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00EBB0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00EE30, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_012BBC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_012EF8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C248, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C588, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00BDFC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C0BC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_013040, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_013378, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0091BC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0094B0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_009C4C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_009F40, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_009010, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0097C4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00A7B4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00C588, 1.0f, 0.0f, -1.0f, 0, -10.0f }, + { &object_delf_Anim_004FF4, 1.0f, 0.0f, -1.0f, 2, -10.0f }, + { &object_delf_Anim_011C70, 1.0f, 0.0f, -1.0f, 0, -10.0f }, + { &object_delf_Anim_006B28, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_014190, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_01447C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_003FAC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_004798, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0042E8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_004C44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_01088C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_01498C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_014E9C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00CEE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00D260, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C690, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00C790, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00AF78, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00B2B8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00BCD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_006D74, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00706C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0072B0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_007570, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00A2A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00A4B4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_006614, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_015114, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00CCD4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00046C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_00065C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00377C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_003148, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001410, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_0010F8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_00199C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_003BB4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001754, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_0008E0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_000A94, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001ED4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, + { &object_delf_Anim_001B28, 1.0f, 0.0f, -1.0f, 2, 0.0f }, + { &object_delf_Anim_000E44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5580.s") +DmChar00Struct D_80AA77A8[] = { + { 250.0f, 255.0f, 230.0f, 255.0f }, + { 63.0f, 18.0f, 93.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA561C.s") +DmChar00Struct D_80AA77D8[] = { + { 220.0f, 160.0f, 80.0f, 255.0f }, + { 250.0f, 40.0f, 10.0f, 255.0f }, + { 255.0f, 235.0f, 220.0f, 255.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5720.s") +Vec3f D_80AA7808 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA575C.s") +void func_80AA5580(SkelAnime* skelAnime, AnimationInfo* animation, u16 idx) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5890.s") + animation += idx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA58CC.s") + if (animation->frameCount < 0.0f) { + phi_f2 = Animation_GetLastFrame(animation->animation); + } else { + phi_f2 = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f2, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5950.s") +void func_80AA561C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames + 20) { + case 503: + case 926: + case 979: + case 1222: + case 1682: + case 2194: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5960.s") + case 1858: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA59E4.s") + case 2043: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + } + } else { + switch (globalCtx->csCtx.frames + 20) { + case 503: + case 926: + case 979: + case 1234: + case 1687: + case 2194: + case 2210: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5A6C.s") + case 2043: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5AF4.s") +void func_80AA5720(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 505)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SPOT_LIGHT_OPEN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5BF8.s") +void func_80AA575C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 474: + case 489: + case 495: + case 505: + case 854: + case 860: + case 866: + case 872: + case 877: + case 882: + case 887: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5CD4.s") + case 520: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SPIT); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5D10.s") + case 774: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5D6C.s") + case 904: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_SIGH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5DC8.s") + case 813: + case 972: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + } + } else if (globalCtx->csCtx.frames == 660) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONDO_SURPRISE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5E2C.s") +void func_80AA5890(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) == DMCHAR00_0) && (globalCtx->csCtx.frames == 20)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA5EBC.s") +void func_80AA58CC(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + if (globalCtx->csCtx.frames == 568) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + } + } else { + switch (globalCtx->csCtx.frames) { + case 375: + case 479: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Init.s") + case 534: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Destroy.s") +void func_80AA5950(DmChar00* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA62FC.s") +void func_80AA5960(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + if (globalCtx->csCtx.frames == 280) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + } + } else { + switch (globalCtx->csCtx.frames) { + case 87: + case 190: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA67F8.s") + case 244: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_ATTACK); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA695C.s") +void func_80AA59E4(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 125: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Update.s") + case 1832: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + break; + } + } else if (globalCtx->csCtx.frames == 125) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/func_80AA6A6C.s") +void func_80AA5A6C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 44: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char00/DmChar00_Draw.s") + case 891: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_WHITE_OUT_INTO_MOON); + break; + } + } else if (globalCtx->csCtx.frames == 44) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5AF4(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 352: + case 401: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 440: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 550: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + } + } else { + switch (globalCtx->csCtx.frames) { + case 362: + case 401: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + + case 454: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + } + + if ((globalCtx->csCtx.frames >= 500) && (globalCtx->csCtx.frames < 602)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SHIVER - SFX_FLAG); + } + } +} + +void func_80AA5BF8(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 762: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_SHOT_DASH); + break; + case 797: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + } + } else { + switch (globalCtx->csCtx.frames) { + case 762: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_SHOT_DASH); + break; + + case 797: + Actor_PlaySfxAtPos(&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); + } +} + +void func_80AA5CD4(DmChar00* this, GlobalContext* globalCtx) { + if ((DMCHAR00_GET(&this->actor) != DMCHAR00_0) && (globalCtx->csCtx.frames == 467)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + } +} + +void func_80AA5D10(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 8: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + break; + } + } +} + +void func_80AA5D6C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 2: + case 166: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 31: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_SURPRISE); + break; + } + } +} + +void func_80AA5DC8(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_0) { + switch (globalCtx->csCtx.frames) { + case 233: + case 415: + case 593: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 130: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); + break; + } + } +} + +void func_80AA5E2C(DmChar00* this, GlobalContext* globalCtx) { + if (DMCHAR00_GET(&this->actor) == DMCHAR00_1) { + switch (globalCtx->csCtx.frames) { + case 32: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); + break; + + case 42: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BLACK_FAIRY_DASH); + break; + + case 192: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_BRAKE); + break; + + case 215: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WEED); + break; + } + } +} + +void func_80AA5EBC(DmChar00* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.state != 0) { + switch (globalCtx->sceneNum) { + case SCENE_LOST_WOODS: + if (gSaveContext.sceneSetupIndex == 1) { + func_80AA561C(this, globalCtx); + } + break; + + case SCENE_OPENINGDAN: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA5720(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA575C(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + func_80AA5890(this, globalCtx); + } + } + break; + + case SCENE_OKUJOU: + if (gSaveContext.sceneSetupIndex == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA58CC(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA5950(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + func_80AA5960(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 2) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA59E4(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA5A6C(this, globalCtx); + } + } + break; + + case SCENE_00KEIKOKU: + if (gSaveContext.sceneSetupIndex == 3) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA5AF4(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 2) { + func_80AA5E2C(this, globalCtx); + } + } else if (gSaveContext.sceneSetupIndex == 7) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AA5BF8(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AA5CD4(this, globalCtx); + } + } + break; + + case SCENE_MITURIN: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 1)) { + func_80AA5DC8(this, globalCtx); + } + break; + + case SCENE_INSIDETOWER: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { + func_80AA5D10(this, globalCtx); + } + break; + + case SCENE_PIRATE: + if ((gSaveContext.sceneSetupIndex == 0) && (globalCtx->csCtx.currentCsIndex == 0)) { + func_80AA5D6C(this, globalCtx); + } + break; + } + } +} + +void DmChar00_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmChar00* this = THIS; + + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + Actor_MarkForDeath(thisx); + } + + this->unk_240 = D_80AA77A8[DMCHAR00_GET(thisx)]; + this->unk_250 = D_80AA77D8[DMCHAR00_GET(thisx)]; + + thisx->targetArrowOffset = 3000.0f; + this->unk_260 = 99; + this->unk_262 = DMCHAR00_GET_F800(thisx); + + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_keep_Skel_02AF58.sh, &gameplay_keep_Anim_029140, + this->jointTable, this->morphTable, 7); + ActorShape_Init(&thisx->shape, 0.0f, NULL, 15.0f); + func_80AA5580(&this->skelAnime, sAnimations, 0); + Actor_SetScale(thisx, 0.01f); + this->actionFunc = func_80AA67F8; +} + +void DmChar00_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { + u16 sp26 = DMCHAR00_GET(&this->actor) + 113; + s32 temp_v0; + s32 pad; + + if (Cutscene_CheckActorAction(globalCtx, sp26)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, sp26); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { + if (this->unk_260 != globalCtx->csCtx.actorActions[temp_v0]->action) { + this->unk_260 = globalCtx->csCtx.actorActions[temp_v0]->action; + + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { + case 0x1: + this->unk_261 = 0; + break; + + case 0x2: + this->unk_261 = 2; + break; + + case 0x3: + this->unk_261 = 3; + break; + + case 0x4: + this->unk_261 = 4; + break; + + case 0x5: + this->unk_261 = 5; + break; + + case 0x6: + this->unk_261 = 6; + break; + + case 0x7: + this->unk_261 = 7; + break; + + case 0x8: + this->unk_261 = 20; + break; + + case 0x9: + this->unk_261 = 21; + break; + + case 0xA: + this->unk_261 = 14; + break; + + case 0xB: + this->unk_261 = 15; + break; + + case 0xC: + this->unk_261 = 18; + break; + + case 0xD: + this->unk_261 = 25; + break; + + case 0xE: + this->unk_261 = 27; + break; + + case 0xF: + this->unk_261 = 24; + break; + + case 0x10: + this->unk_261 = 10; + break; + + case 0x11: + this->unk_261 = 12; + break; + + case 0x12: + this->unk_261 = 13; + break; + + case 0x13: + this->unk_261 = 29; + break; + + case 0x14: + this->unk_261 = 31; + break; + + case 0x15: + this->unk_261 = 33; + break; + + case 0x16: + Actor_MarkForDeath(&this->actor); + break; + + case 0x17: + this->unk_261 = 35; + break; + + case 0x18: + this->unk_261 = 37; + break; + + case 0x19: + this->unk_261 = 39; + break; + + case 0x1A: + this->unk_261 = 41; + break; + + case 0x1B: + this->unk_261 = 45; + break; + + case 0x1C: + this->unk_261 = 46; + break; + + case 0x1E: + this->unk_261 = 48; + break; + + case 0x1F: + this->unk_261 = 50; + break; + + case 0x20: + this->unk_261 = 52; + break; + + case 0x21: + this->unk_261 = 53; + break; + + case 0x23: + this->unk_261 = 55; + break; + + case 0x24: + this->unk_261 = 57; + break; + + case 0x25: + this->unk_261 = 58; + break; + + case 0x26: + this->unk_261 = 59; + break; + + case 0x27: + this->unk_261 = 61; + break; + + case 0x28: + this->unk_261 = 62; + break; + + case 0x29: + this->unk_261 = 64; + break; + + case 0x2A: + this->unk_261 = 66; + break; + + case 0x2B: + this->unk_261 = 68; + break; + + case 0x2C: + this->unk_261 = 69; + break; + + case 0x2D: + this->unk_261 = 70; + break; + + case 0x2E: + this->unk_261 = 67; + break; + + case 0x2F: + this->unk_261 = 71; + break; + + case 0x30: + this->unk_261 = 73; + break; + + case 0x31: + this->unk_261 = 74; + break; + + case 0x32: + this->unk_261 = 75; + break; + + case 0x33: + this->unk_261 = 77; + break; + + case 0x34: + this->unk_261 = 78; + break; + + case 0x35: + this->unk_261 = 79; + break; + + case 0x36: + this->unk_261 = 80; + break; + + case 0x37: + this->unk_261 = 82; + break; + + case 0x38: + this->unk_261 = 83; + break; + + default: + this->unk_261 = 0; + break; + } + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); + } else { + this->unk_260 = 99; + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->unk_261) { + case 0x4: + case 0x5: + this->unk_261 += 4; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + this->skelAnime.curFrame = 37.0f; + break; + + case 0xE: + case 0xF: + case 0x14: + case 0x15: + this->unk_261 += 2; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0xA: + case 0x12: + case 0x19: + case 0x1B: + case 0x1D: + case 0x1F: + case 0x21: + case 0x23: + case 0x25: + case 0x27: + case 0x2B: + case 0x2E: + case 0x30: + case 0x32: + case 0x35: + case 0x37: + case 0x3B: + case 0x3E: + case 0x40: + case 0x42: + case 0x47: + case 0x4B: + case 0x50: + case 0x53: + this->unk_261 += 1; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0x2D: + this->unk_261 = 19; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + + case 0x46: + case 0x4D: + this->unk_261 = 0; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + break; + } + } +} + +void func_80AA67F8(DmChar00* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((globalCtx->csCtx.state == 0) && (gSaveContext.sceneSetupIndex == 0) && + (globalCtx->csCtx.currentCsIndex == 1)) { + if (this->unk_261 != 42) { + this->unk_261 = 42; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + } + + Math_SmoothStepToF(&this->actor.world.pos.x, 0.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.y, 30.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.z, -560.0f, 0.5f, 20.0f, 0.001f); + + if (player->actor.world.pos.z < -625.0f) { + this->unk_261 = 43; + func_80AA5580(&this->skelAnime, &sAnimations[this->unk_261], 0); + this->actionFunc = func_80AA695C; + this->skelAnime.playSpeed = 1.5f; + } + } +} + +void func_80AA695C(DmChar00* this, GlobalContext* globalCtx) { + if (this->unk_261 == 44) { + Math_SmoothStepToF(&this->actor.world.pos.x, 0.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.y, 30.0f, 0.5f, 0.5f, 0.001f); + Math_SmoothStepToF(&this->actor.world.pos.z, -680.0f, 0.5f, 10.0f, 0.001f); + } +} + +void DmChar00_Update(Actor* thisx, GlobalContext* globalCtx) { + DmChar00* this = THIS; + + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + this->unk_262++; + func_80AA5EBC(this, globalCtx); + func_80AA62FC(this, globalCtx); +} + +s32 DmChar00_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx, Gfx** gfx) { + DmChar00* this = THIS; + f32 sp28; + Vec3f sp1C; + + if (limbIndex == 6) { + sp28 = ((Math_SinS(this->unk_262 * 0x1000) * 0.1f) + 1.0f) * 0.012f * (this->actor.scale.x * 124.99999f); + Matrix_MultiplyVector3fByState(&D_80AA7808, &sp1C); + Matrix_InsertTranslation(sp1C.x, sp1C.y, sp1C.z, MTXMODE_NEW); + Matrix_Scale(sp28, sp28, sp28, MTXMODE_APPLY); + } + return false; +} + +void DmChar00_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DmChar00* this = THIS; + s32 phi_a0; + s32 pad; + Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + + if ((globalCtx->csCtx.state == 0) && + ((globalCtx->sceneNum != SCENE_OPENINGDAN) || (gSaveContext.sceneSetupIndex != 0) || + (globalCtx->roomCtx.currRoom.num != 0) || (globalCtx->csCtx.currentCsIndex != 1) || + (DMCHAR00_GET(&this->actor) != DMCHAR00_0))) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C94C(globalCtx->state.gfxCtx); + + do { + phi_a0 = (this->unk_262 * 50) & 511; + if (phi_a0 >= 256) { + phi_a0 = 511 - phi_a0; + } + } while (0); + + gSPSegment(POLY_XLU_DISP++, 0x08, &gfx[0]); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)this->unk_240.unk_00, (u8)this->unk_240.unk_04, (u8)this->unk_240.unk_08, + (u8)(this->unk_240.unk_0C * 1)); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPEndDisplayList(gfx); + + gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->unk_250.unk_00, (u8)(s8)this->unk_250.unk_04, + (u8)(s8)this->unk_250.unk_08, (u8)(s8)((f32)phi_a0 * 1)); + gDPSetDither(POLY_XLU_DISP++, G_CD_BAYER); + + POLY_XLU_DISP = SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar00_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 0bc9b9d0a..52adfe794 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.h @@ -7,11 +7,32 @@ struct DmChar00; typedef void (*DmChar00ActionFunc)(struct DmChar00*, GlobalContext*); +#define DMCHAR00_GET(thisx) ((thisx)->params) +#define DMCHAR00_GET_F800(thisx) ((thisx)->params << 0xB) + +#define DMCHAR00_0 0 +#define DMCHAR00_1 1 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; +} DmChar00Struct; // size = 0x10 + typedef struct DmChar00 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xF8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[7]; + /* 0x01B2 */ UNK_TYPE1 unk_1B2[0x30]; + /* 0x01E2 */ Vec3s morphTable[7]; + /* 0x020C */ UNK_TYPE1 unk_20C[0x30]; /* 0x023C */ DmChar00ActionFunc actionFunc; - /* 0x0240 */ char unk_240[0x24]; + /* 0x0240 */ DmChar00Struct unk_240; + /* 0x0250 */ DmChar00Struct unk_250; + /* 0x0260 */ u8 unk_260; + /* 0x0261 */ u8 unk_261; + /* 0x0262 */ u16 unk_262; } DmChar00; // size = 0x264 extern const ActorInit Dm_Char00_InitVars; 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 cf2d8b03b..b4537b1af 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -5,8 +5,9 @@ */ #include "z_dm_char01.h" +#include "objects/object_mtoride/object_mtoride.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((DmChar01*)thisx) @@ -15,7 +16,24 @@ void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx); void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AA8698(DmChar01* this, GlobalContext* globalCtx); +void func_80AA884C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx); +void func_80AA892C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8F1C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx); +void func_80AA9020(DmChar01* this, GlobalContext* globalCtx); +void func_80AA90AC(DmChar01* this, GlobalContext* globalCtx); +void func_80AA90F4(DmChar01* this, GlobalContext* globalCtx); + +s16 D_80AAAE20; +s16 D_80AAAE22; +s16 D_80AAAE24; +s16 D_80AAAE26; + +#include "overlays/ovl_Dm_Char01/ovl_Dm_Char01.c" + const ActorInit Dm_Char01_InitVars = { ACTOR_DM_CHAR01, ACTORCAT_ITEMACTION, @@ -28,44 +46,501 @@ const ActorInit Dm_Char01_InitVars = { (ActorFunc)DmChar01_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AAAAB0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 300, ICHAIN_STOP), }; -#endif +s16 D_80AAAAB4 = false; -extern InitChainEntry D_80AAAAB0[]; +void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { + DmChar01* this = THIS; + s32 i; -extern UNK_TYPE D_06009E4C; -extern UNK_TYPE D_0600AA50; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Init.s") + this->unk_346 = 0; + this->unk_34D = false; + D_80AAAE24 = 0; + D_80AAAE26 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Destroy.s") + switch (DMCHAR01_GET(&this->dyna.actor)) { + case DMCHAR01_0: + if (gSaveContext.save.weekEventReg[20] & 2) { + this->unk_34C = 2; + this->actionFunc = func_80AA8F1C; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8698.s") + if (gSaveContext.sceneSetupIndex == 0) { + globalCtx->envCtx.unk_1F = 5; + globalCtx->envCtx.unk_20 = 5; + } + this->unk_348 = 255.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA884C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1AC); i++) { + this->unk_1AC[i] = ovl_dm_char01_Vtx_1BE0[i].v.ob[1] * 409.6f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA88A8.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_009E4C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA892C.s") + this->unk_34D = true; + if (gSaveContext.sceneSetupIndex == 1) { + this->unk_34C = 1; + this->actionFunc = func_80AA8C28; + } else { + this->unk_34C = 0; + this->actionFunc = func_80AA892C; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8C28.s") + case DMCHAR01_1: + if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + this->unk_34C = 1; + this->actionFunc = func_80AA8F1C; + } else { + this->actionFunc = func_80AA8698; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F0C.s") + case DMCHAR01_2: + this->unk_34C = 0; + if (!(gSaveContext.save.weekEventReg[20] & 1)) { + this->unk_34C = 1; + this->dyna.actor.world.pos.y -= 400.0f; + } + this->dyna.actor.world.rot.y += 0x8000; + this->dyna.actor.shape.rot.y += 0x8000; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_010C3C); + this->unk_34D = true; + this->unk_348 = 200.0f; + this->actionFunc = func_80AA8F2C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F1C.s") + case DMCHAR01_3: + this->dyna.actor.world.rot.y += 0x8000; + this->dyna.actor.shape.rot.y += 0x8000; + if (!(gSaveContext.save.weekEventReg[20] & 1)) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA8F2C.s") + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_00FE5C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA9020.s") + this->unk_34D = true; + if (!(gSaveContext.save.weekEventReg[20] & 2)) { + this->actionFunc = func_80AA9020; + this->dyna.actor.world.pos.y -= 120.0f; + } else { + this->actionFunc = func_80AA8F1C; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA90AC.s") + default: + this->actionFunc = func_80AA88A8; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/func_80AA90F4.s") +void DmChar01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DmChar01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Update.s") + if (this->unk_34D) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char01/DmChar01_Draw.s") +void func_80AA8698(DmChar01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + if (gSaveContext.save.weekEventReg[20] & 1) { + return; + } + + if ((player->stateFlags2 & 0x8000000) && (player2->actor.world.pos.x > -40.0f) && + (player2->actor.world.pos.x < 40.0f) && (player2->actor.world.pos.z > 1000.0f) && + (player2->actor.world.pos.z < 1078.0f)) { + if (!D_80AAAAB4) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + D_80AAAAB4 = true; + } + } else { + D_80AAAAB4 = false; + } + + if ((player->transformation == PLAYER_FORM_DEKU) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 0)) { + + if ((player2->actor.world.pos.x > -40.0f) && (player2->actor.world.pos.x < 40.0f) && + (player2->actor.world.pos.z > 1000.0f) && (player2->actor.world.pos.z < 1078.0f)) { + gSaveContext.save.weekEventReg[20] |= 1; + this->actionFunc = func_80AA884C; + } + } +} + +void func_80AA884C(DmChar01* this, GlobalContext* globalCtx) { + s16 sp1E = this->dyna.actor.cutscene; + + if (ActorCutscene_GetCanPlayNext(sp1E)) { + ActorCutscene_Start(sp1E, &this->dyna.actor); + this->actionFunc = func_80AA88A8; + } else { + ActorCutscene_SetIntentToPlay(sp1E); + } +} + +void func_80AA88A8(DmChar01* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 135)) { + if (globalCtx->csCtx.frames == + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]->startFrame) { + D_80AAAE24 = 1; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FORT_RISING); + } + } else { + D_80AAAE24 = 0; + } +} + +void func_80AA892C(DmChar01* this, GlobalContext* globalCtx) { + f32 temp_f18; + s32 temp_v0_4; + s32 i; + + switch (this->unk_346) { + case 0: + D_80AAAE22 = -2200; + D_80AAAE20 = 380; + this->unk_346++; + break; + + case 1: + if (D_80AAAE24 != 0) { + this->unk_34C = 1; + if (D_80AAAE22 > -2000) { + D_80AAAE26 = 1; + } + + D_80AAAE22 += 40; + if (D_80AAAE22 > 3400) { + if (D_80AAAE20 > 100) { + D_80AAAE20 -= 230; + } + this->unk_346++; + } + } + break; + + case 2: + D_80AAAE22 -= 40; + if (D_80AAAE22 <= -2200) { + if (D_80AAAE20 > 100) { + D_80AAAE20 -= 70; + } + this->unk_346--; + } + break; + } + + if (D_80AAAE24 == 0) { + this->unk_34C = 0; + } + + for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { + s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); + f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; + + if (temp_f20 < 0.0f) { + temp_f20 = 0.0f; + } + + temp_f18 = Math_SinS(this->unk_1AC[i]) * 15.0f; + temp_f20 += temp_f18; + + this->unk_1AC[i] += 1600; + ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + } +} + +void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { + f32 temp_f18; + s32 temp_v0_4; + s32 i; + + switch (this->unk_346) { + case 0: + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WATER_PURIFICATION); + D_80AAAE22 = -2200; + D_80AAAE20 = 100; + this->unk_346++; + break; + + case 1: + D_80AAAE22 += 40; + if (D_80AAAE22 > 3400) { + this->unk_346++; + } + break; + + case 2: + D_80AAAE22 -= 40; + if (D_80AAAE22 <= -2200) { + this->unk_346--; + } + break; + } + + for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { + s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); + f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; + + if (temp_f20 < 0.0f) { + temp_f20 = 0.0f; + } + + temp_f18 = Math_SinS(this->unk_1AC[i]) * 15.0f; + temp_f20 += temp_f18; + + this->unk_1AC[i] += 1600; + ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + } + + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.6f, 0.4f); + + if (this->unk_348 < 0.01f) { + this->unk_34C = 2; + this->actionFunc = func_80AA8F1C; + } +} + +void func_80AA8F0C(DmChar01* this, GlobalContext* globalCtx) { +} + +void func_80AA8F1C(DmChar01* this, GlobalContext* globalCtx) { +} + +void func_80AA8F2C(DmChar01* this, GlobalContext* globalCtx) { + if (D_80AAAE26 != 0) { + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 0.0f, 0.05f, 6.0f, 0.001f); + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.01f, 0.5f, 0.4f); + if ((s32)this->dyna.actor.world.pos.y >= 0) { + D_80AAAE26 = 2; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ETCETERA, 5.0f, 202.0f, 294.0f, 0, 0, 0, 0x80); + this->actionFunc = func_80AA90F4; + } + } + func_80AA8F0C(this, globalCtx); +} + +void func_80AA9020(DmChar01* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 135)) { + CsCmdActorAction* temp_v1 = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 135)]; + + if ((temp_v1->startFrame == globalCtx->csCtx.frames) && (temp_v1->action == 2)) { + gSaveContext.save.weekEventReg[20] |= 2; + this->actionFunc = func_80AA90AC; + } + } +} + +void func_80AA90AC(DmChar01* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 0.0f, 0.05f, 2.0f, 0.001f); +} + +void func_80AA90F4(DmChar01* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.8f, 0.4f); +} + +void DmChar01_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DmChar01* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_34D) { + if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_0) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.world.pos.y > 5.0f) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + } + + if (DMCHAR01_GET(&this->dyna.actor) == DMCHAR01_2) { + if (this->dyna.actor.xzDistToPlayer > 600.0f) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } else { + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + } + } +} + +void DmChar01_Draw(Actor* thisx, GlobalContext* globalCtx) { + static f32 D_80AAAAB8 = 0.0f; + static f32 D_80AAAABC = 0.0f; + static s16 D_80AAAAC0 = 0; + static s16 D_80AAAAC4 = 0; + static s16 D_80AAAAC8 = 0; + static s16 D_80AAAACC = 0; + DmChar01* this = THIS; + f32 temp_f12; + f32 spBC; + s32 i; + u8 spB7 = false; + + switch (DMCHAR01_GET(thisx)) { + case DMCHAR01_0: + switch (this->unk_34C) { + case 0: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00AA50)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00A8F8); + break; + + case 1: + if (gSaveContext.sceneSetupIndex == 1) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); + Matrix_InsertTranslation(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); + } + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((u8)this->unk_348 == 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x96, 255, 255, 255, 255); + gSPSegment(POLY_OPA_DISP++, 0x0B, Lib_SegmentedToVirtual(ovl_dm_char01_Vtx_1BE0)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_mtoride_DL_009928); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)this->unk_348); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x96, 255, 255, 255, (u8)this->unk_348); + gSPSegment(POLY_XLU_DISP++, 0x0B, Lib_SegmentedToVirtual(ovl_dm_char01_Vtx_1BE0)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_009928); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 2: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_0110B8)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_010FD8); + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_010EF0); + break; + } + break; + + case DMCHAR01_1: + switch (this->unk_34C) { + case 0: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00A5C0)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00A398); + break; + + case 1: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00B1A0)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00AF98); + break; + } + break; + + case DMCHAR01_2: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00FE90)); + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00DF18); + + if ((this->unk_34C != 0) && ((u8)this->unk_348 != 0)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00F768)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, (u8)this->unk_348); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, (u8)this->unk_348); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_mtoride_DL_00F3C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (D_80AAAE24 != 0) { + if ((D_80AAAE22 > -1800) && (D_80AAAE22 < 3000)) { + temp_f12 = D_80AAAE22 - 640.0f; + if ((D_80AAAE20 == 380) && (D_80AAAE22 > 640)) { + D_80AAAAC0 = 2; + D_80AAAAC4 = 0; + D_80AAAAC8 = 900; + D_80AAAACC = 700; + spB7 = true; + if (D_80AAAE22 < 1350) { + f32 temp_f0 = temp_f12 / 2000.0f; + + D_80AAAAB8 = 420.0f - (420.0f * temp_f0); + D_80AAAABC = (200.0f * temp_f0) + 200.0f; + } else { + f32 temp_f0 = temp_f12 / 2000.0f; + + D_80AAAAB8 = 420.0f - (420.0f * temp_f0); + D_80AAAABC = 400.0f; + } + } + } + + if (spB7) { + for (i = 0; i < D_80AAAAC0 * 2; i++) { + Vec3f sp44; + f32 phi_f2 = D_80AAAABC; + s16 temp; + + spBC = Rand_ZeroOne() * D_80AAAAC8; + if ((globalCtx->state.frames % 2) != 0) { + sp44.x = (Rand_ZeroOne() - 0.5f) * (2.0f * phi_f2); + sp44.y = D_80AAAAB8; + sp44.z = (Rand_ZeroOne() * D_80AAAAC4) + phi_f2; + temp = (s16)spBC + D_80AAAACC; + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, temp); + } else { + sp44.x = -phi_f2 - (Rand_ZeroOne() * D_80AAAAC4); + sp44.y = D_80AAAAB8; + sp44.z = (Rand_ZeroOne() - 0.5f) * (2.0f * phi_f2); + temp = (s16)spBC + D_80AAAACC; + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, temp); + } + } + } + } + + Gfx_DrawDListXlu(globalCtx, object_mtoride_DL_00DE50); + break; + + case DMCHAR01_3: + if (thisx->world.pos.y > -120.0f) { + Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00FAE8); + } + break; + } +} diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h index a0d4fb336..b2c235f56 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.h @@ -7,11 +7,25 @@ struct DmChar01; typedef void (*DmChar01ActionFunc)(struct DmChar01*, GlobalContext*); +#define DMCHAR01_GET(thisx) ((thisx)->params) + +enum { + /* 0 */ DMCHAR01_0, + /* 1 */ DMCHAR01_1, + /* 2 */ DMCHAR01_2, + /* 3 */ DMCHAR01_3, +}; + typedef struct DmChar01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ UNK_TYPE1 unk15C[0x44]; /* 0x01A0 */ DmChar01ActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0x1AC]; + /* 0x01A4 */ UNK_TYPE1 unk1A4[0x8]; + /* 0x01AC */ s16 unk_1AC[205]; + /* 0x0346 */ s16 unk_346; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ u8 unk_34C; + /* 0x034D */ u8 unk_34D; } DmChar01; // size = 0x350 extern const ActorInit Dm_Char01_InitVars; 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 116b2732d..72258b70b 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -6,7 +6,7 @@ #include "z_dm_char02.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar02*)thisx) 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 b5e6c8742..1508f95a2 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -6,7 +6,7 @@ #include "z_dm_char03.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar03*)thisx) 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 e2c72238e..eff96b7e5 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -6,7 +6,7 @@ #include "z_dm_char04.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar04*)thisx) 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 1f61d302f..956f7317c 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -5,8 +5,9 @@ */ #include "z_dm_char05.h" +#include "objects/object_dmask/object_dmask.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar05*)thisx) @@ -28,8 +29,12 @@ void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx); void func_80AACD68(DmChar05* this, GlobalContext* globalCtx); void func_80AACE10(DmChar05* this, GlobalContext* globalCtx); void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx); +void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this); +void func_80AADE78(GlobalContext* globalCtx, DmChar05* this); +void func_80AADF54(GlobalContext* globalCtx, DmChar05* this); +void func_80AAE030(GlobalContext* globalCtx, DmChar05* this); +void func_80AAE114(GlobalContext* globalCtx, DmChar05* this); -#if 0 const ActorInit Dm_Char05_InitVars = { ACTOR_DM_CHAR05, ACTORCAT_ITEMACTION, @@ -42,86 +47,743 @@ const ActorInit Dm_Char05_InitVars = { (ActorFunc)DmChar05_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &object_dmask_Anim_001090, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_004288, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0001A8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_00017C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0011A0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dmask_Anim_0013A4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, +}; -extern UNK_TYPE D_060001D0; -extern UNK_TYPE D_060010B0; -extern UNK_TYPE D_060013D0; -extern UNK_TYPE D_06001E70; -extern UNK_TYPE D_060042B0; +void func_80AAC5A0(SkelAnime* skelAnime, AnimationInfo* animation, u16 arg2) { + f32 phi_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC5A0.s") + animation += arg2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC63C.s") + if (animation->frameCount < 0.0f) { + phi_f2 = Animation_GetLastFrame(animation->animation); + } else { + phi_f2 = animation->frameCount; + } + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f2, + animation->mode, animation->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC6E4.s") +void func_80AAC63C(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC770.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_010B0, NULL, NULL, NULL, 0); + if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { + func_80AAC5A0(&this->skelAnime, &sAnimations[0], 0); + } else { + func_80AAC5A0(&this->skelAnime, &sAnimations[1], 0); + } + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC7FC.s") +void func_80AAC6E4(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC888.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_042B0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[1], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Init.s") +void func_80AAC770(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dmask_Skel_001D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[3], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC990.s") +void func_80AAC7FC(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAC9DC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dmask_Skel_013D0, NULL, NULL, NULL, 0); + func_80AAC5A0(&this->skelAnime, &sAnimations[4], 0); + this->actionFunc = func_80AACC48; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACA98.s") +void func_80AAC888(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACAE4.s") + this->actionFunc = func_80AACA98; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACBE4.s") +void DmChar05_Init(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACC48.s") + this->unk_18C = 0; + this->unk_18E = 0; + this->unk_19C = 0; + this->unk_1A0 = 0; + this->unk_1A4 = 0; + this->unk_1A8 = 0; + this->unk_1AC = 100; + this->unk_1B0 = 1000; + this->unk_1B4 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACC6C.s") + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + func_80AAC63C(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACCD4.s") + case DMCHAR05_1: + func_80AAC6E4(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD0C.s") + case DMCHAR05_2: + func_80AAC770(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD1C.s") + case DMCHAR05_3: + func_80AAC7FC(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACD68.s") + case DMCHAR05_4: + func_80AAC888(thisx, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACE10.s") + case DMCHAR05_5: + case DMCHAR05_6: + case DMCHAR05_7: + case DMCHAR05_8: + case DMCHAR05_9: + case DMCHAR05_10: + case DMCHAR05_11: + case DMCHAR05_12: + this->actionFunc = func_80AACBE4; + break; + } + Actor_SetScale(&this->actor, 0.01f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACE5C.s") +void DmChar05_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AACF04.s") +void func_80AAC990(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_GOLONMASK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD3F8.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AAC9DC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD450.s") +void func_80AAC9DC(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 109) != 0) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD4A8.s") + if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Update.s") +void func_80AACA98(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK13); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD964.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACAE4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD980.s") +void func_80AACAE4(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 564)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 564); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAD998.s") + if (globalCtx->csCtx.actorActions[actionIndex]->action == 2) { + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + Item_Give(globalCtx, ITEM_MASK_COUPLE); + } + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } else { + this->unk_18E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADA90.s") +void func_80AACBE4(DmChar05* this, GlobalContext* globalCtx) { + static s16 D_80AAE2F0[] = { + OBJECT_GI_MASK17, OBJECT_GI_MASK14, OBJECT_GI_MASK10, OBJECT_GI_MASK21, + OBJECT_GI_MASK11, OBJECT_GI_MASK20, OBJECT_GI_RABIT_MASK, OBJECT_GI_MASK12, + }; + s32 params = DMCHAR05_GET(&this->actor) - DMCHAR05_5; + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, D_80AAE2F0[params]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADB4C.s") + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACD0C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADC00.s") +void func_80AACC48(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_1B4 != 0) { + this->actionFunc = func_80AACC6C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/DmChar05_Draw.s") +void func_80AACC6C(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_19C < 247) { + this->unk_19C += 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADD9C.s") + if (this->unk_1A0 < 247) { + this->unk_1A0 += 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADE78.s") + if (this->unk_1A4 < 247) { + this->unk_1A4 += 8; + } else { + this->unk_19C = 255; + this->unk_1A0 = 255; + this->unk_1A4 = 255; + this->actionFunc = func_80AACCD4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AADF54.s") +void func_80AACCD4(DmChar05* this, GlobalContext* globalCtx) { + if (this->unk_1AC < 975) { + this->unk_1AC += 25; + } else { + this->unk_1AC = 996; + this->actionFunc = func_80AACD0C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAE030.s") +void func_80AACD0C(DmChar05* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char05/func_80AAE114.s") +void func_80AACD1C(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_ZORAMASK); + + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACD68; + } +} + +void func_80AACD68(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 473)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); + + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } +} + +void func_80AACE10(DmChar05* this, GlobalContext* globalCtx) { + s32 objectIdx = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MASK15); + + if (objectIdx >= 0) { + this->unk_18F = objectIdx; + this->actionFunc = func_80AACE5C; + } +} + +void func_80AACE5C(DmChar05* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 518)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); + + this->unk_18E = 1; + this->unk_190.x = globalCtx->csCtx.actorActions[actionIndex]->startPos.x; + this->unk_190.y = globalCtx->csCtx.actorActions[actionIndex]->startPos.y; + this->unk_190.z = globalCtx->csCtx.actorActions[actionIndex]->startPos.z; + } +} + +void func_80AACF04(DmChar05* this, GlobalContext* globalCtx) { + u8 sp2F = true; + s32 actionIndex; + + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + if (Cutscene_CheckActorAction(globalCtx, 109)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 109); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_1B4 = 1; + break; + + case 3: + this->unk_18C = 0; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_GORON); + sp2F = false; + this->actionFunc = func_80AAC990; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + break; + + case DMCHAR05_1: + if (Cutscene_CheckActorAction(globalCtx, 473)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 473); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 1; + this->unk_1B4 = 1; + break; + + case 3: + this->unk_18C = 1; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_ZORA); + sp2F = false; + this->actionFunc = func_80AACD1C; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + break; + + case DMCHAR05_2: + if (Cutscene_CheckActorAction(globalCtx, 518)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 518); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 3; + break; + + case 3: + this->unk_18C = 2; + break; + + case 4: + Item_Give(globalCtx, ITEM_MASK_GIBDO); + sp2F = false; + this->actionFunc = func_80AACE10; + break; + + case 5: + sp2F = false; + Actor_MarkForDeath(&this->actor); + break; + + default: + sp2F = false; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } + break; + + case DMCHAR05_3: + if (Cutscene_CheckActorAction(globalCtx, 559)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); + + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + default: + sp2F = false; + break; + + case 1: + sp2F = false; + break; + + case 2: + this->unk_18C = 4; + break; + + case 3: + this->unk_18C = 5; + break; + + case 4: + this->unk_18C = 5; + break; + } + + if (sp2F) { + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + + if (globalCtx->csCtx.actorActions[actionIndex]->action != 4) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } else { + Cutscene_ActorTranslate(&this->actor, globalCtx, actionIndex); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_18C == 4) { + this->unk_18C++; + func_80AAC5A0(&this->skelAnime, &sAnimations[this->unk_18C], 0); + } + } + break; + } +} + +void func_80AAD3F8(DmChar05* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 490) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + + if (globalCtx->csCtx.frames > 550) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + } +} + +void func_80AAD450(DmChar05* this, GlobalContext* globalCtx) { + if (globalCtx->csCtx.frames == 262) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + + if (globalCtx->csCtx.frames > 318) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MASK_FLOAT - SFX_FLAG); + } +} + +void func_80AAD4A8(DmChar05* this, GlobalContext* globalCtx) { + if (DMCHAR05_GET(&this->actor) == DMCHAR05_0) { + if (Cutscene_CheckActorAction(globalCtx, 109) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3)) { + if (Animation_OnFrame(&this->skelAnime, 14.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&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); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_1) { + if (Cutscene_CheckActorAction(globalCtx, 473)) { + if ((globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) && + Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_SAND); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_2) { + if (Cutscene_CheckActorAction(globalCtx, 518) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action == 2)) { + if (Animation_OnFrame(&this->skelAnime, 7.0f)) { + Actor_PlaySfxAtPos(&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); + } + + if (Animation_OnFrame(&this->skelAnime, 18.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_MASK_BOUND_1); + } + } + } else if (DMCHAR05_GET(&this->actor) == DMCHAR05_3) { + if (globalCtx->sceneNum == SCENE_OKUJOU) { + if (gSaveContext.sceneSetupIndex == 2) { + if (globalCtx->csCtx.currentCsIndex == 0) { + func_80AAD3F8(this, globalCtx); + } else if (globalCtx->csCtx.currentCsIndex == 1) { + func_80AAD450(this, globalCtx); + } + } + } else if (globalCtx->sceneNum == SCENE_SPOT00) { + if (gSaveContext.sceneSetupIndex == 9) { + if ((globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 255)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER); + } + } else if ((gSaveContext.sceneSetupIndex == 0xB) && (globalCtx->csCtx.frames == 115)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EVIL_POWER_PREDEMO); + } + } + } +} + +void DmChar05_Update(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + func_80AACF04(this, globalCtx); + if (Cutscene_CheckActorAction(globalCtx, 109)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action == 3) { + SkelAnime_Update(&this->skelAnime); + } + } else if (Cutscene_CheckActorAction(globalCtx, 473)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action == 3) { + SkelAnime_Update(&this->skelAnime); + } + } else if (Cutscene_CheckActorAction(globalCtx, 518)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action == 2) { + SkelAnime_Update(&this->skelAnime); + } + } else if (Cutscene_CheckActorAction(globalCtx, 559)) { + if ((globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 2) || + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 3)) { + SkelAnime_Update(&this->skelAnime); + } + + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 559)]->action == 4) { + this->actor.world.rot.y += 0x258; + this->actor.shape.rot.y += 0x258; + } + } + this->actionFunc(this, globalCtx); + func_80AAD4A8(this, globalCtx); +} + +s32 DmChar05_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void DmChar05_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void func_80AAD998(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + s32 pad[2]; + + if (this->unk_18E == 0) { + if (Cutscene_CheckActorAction(globalCtx, 109) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 109)]->action != 1)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, this->unk_19C, this->unk_1A0, this->unk_1A4, this->unk_1A8, + this->unk_1AC, this->unk_1B0); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } else if (this->unk_18E == 1) { + func_80AADD9C(globalCtx, this); + } +} + +void func_80AADA90(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + if (this->unk_18E == 0) { + if (Cutscene_CheckActorAction(globalCtx, 473) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 473)]->action != 1)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + } + } else if (this->unk_18E == 1) { + func_80AADE78(globalCtx, this); + } +} + +void func_80AADB4C(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + if (this->unk_18E == 0) { + if (Cutscene_CheckActorAction(globalCtx, 518) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 518)]->action != 1)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor); + } + } else if (this->unk_18E == 1) { + func_80AADF54(globalCtx, this); + } +} + +void func_80AADC00(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DmChar05* this = THIS; + s32 actionIndex; + + if (Cutscene_CheckActorAction(globalCtx, 559)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 559); + + if ((globalCtx->csCtx.actorActions[actionIndex]->action != 1) && + (globalCtx->csCtx.actorActions[actionIndex]->action != 4)) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + DmChar05_OverrideLimbDraw, DmChar05_PostLimbDraw, &this->actor); + } + + if (globalCtx->csCtx.actorActions[actionIndex]->action == 4) { + Matrix_InsertTranslation(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); + } + } +} + +void DmChar05_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmChar05* this = THIS; + + switch (DMCHAR05_GET(&this->actor)) { + case DMCHAR05_0: + func_80AAD998(thisx, globalCtx); + break; + + case DMCHAR05_1: + func_80AADA90(thisx, globalCtx); + break; + + case DMCHAR05_2: + func_80AADB4C(thisx, globalCtx); + break; + + case DMCHAR05_3: + func_80AADC00(thisx, globalCtx); + break; + + case DMCHAR05_4: + func_80AAE030(globalCtx, this); + break; + + case DMCHAR05_5: + case DMCHAR05_6: + case DMCHAR05_7: + case DMCHAR05_8: + case DMCHAR05_9: + case DMCHAR05_10: + case DMCHAR05_11: + case DMCHAR05_12: + func_80AAE114(globalCtx, this); + break; + } +} + +void func_80AADD9C(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_44); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AADE78(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_45); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AADF54(GlobalContext* globalCtx, DmChar05* this) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_6B); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} + +void func_80AAE030(GlobalContext* globalCtx, DmChar05* this) { + if (this->unk_18E != 0) { + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, GID_03); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } + } +} + +void func_80AAE114(GlobalContext* globalCtx, DmChar05* this) { + s32 sp34; + s16 sp24[] = { + GID_02, GID_6A, GID_70, GID_3A, GID_0E, GID_0F, GID_3E, GID_71, + }; + + sp34 = DMCHAR05_GET(&this->actor) - DMCHAR05_5; + if (this->actor.objBankIndex == this->unk_18F) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + Matrix_InsertRotation(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); + GetItem_Draw(globalCtx, sp24[sp34]); + } + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_18F)) { + this->actor.objBankIndex = this->unk_18F; + } +} diff --git a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h index a2e1a6208..83bb67948 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.h @@ -7,11 +7,39 @@ struct DmChar05; typedef void (*DmChar05ActionFunc)(struct DmChar05*, GlobalContext*); +#define DMCHAR05_GET(thisx) ((thisx)->params) + +enum { + /* 0 */ DMCHAR05_0, + /* 1 */ DMCHAR05_1, + /* 2 */ DMCHAR05_2, + /* 3 */ DMCHAR05_3, + /* 4 */ DMCHAR05_4, + /* 5 */ DMCHAR05_5, + /* 6 */ DMCHAR05_6, + /* 7 */ DMCHAR05_7, + /* 8 */ DMCHAR05_8, + /* 9 */ DMCHAR05_9, + /* 10 */ DMCHAR05_10, + /* 11 */ DMCHAR05_11, + /* 12 */ DMCHAR05_12, +}; + typedef struct DmChar05 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmChar05ActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x2C]; + /* 0x018C */ s16 unk_18C; + /* 0x018E */ u8 unk_18E; + /* 0x018F */ u8 unk_18F; + /* 0x0190 */ Vec3f unk_190; + /* 0x019C */ u32 unk_19C; + /* 0x01A0 */ u32 unk_1A0; + /* 0x01A4 */ u32 unk_1A4; + /* 0x01A8 */ s32 unk_1A8; + /* 0x01AC */ s32 unk_1AC; + /* 0x01B0 */ s32 unk_1B0; + /* 0x01B4 */ u8 unk_1B4; } DmChar05; // size = 0x1B8 extern const ActorInit Dm_Char05_InitVars; 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 1518cd4b4..e35328af0 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -6,7 +6,7 @@ #include "z_dm_char06.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar06*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c index 290f5a797..d2aac5a7c 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c @@ -7,7 +7,7 @@ #include "z_dm_char07.h" #include "objects/object_milkbar/object_milkbar.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar07*)thisx) 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 aa0357ef2..f944c9c63 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c @@ -6,7 +6,7 @@ #include "z_dm_char08.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((DmChar08*)thisx) 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 490800ea9..7fb20d1a0 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -6,7 +6,7 @@ #include "z_dm_char09.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmChar09*)thisx) 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 c6499f0ee..88a99ad53 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -5,8 +5,10 @@ */ #include "z_dm_gm.h" +#include "objects/object_an4/object_an4.h" +#include "objects/object_msmo/object_msmo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmGm*)thisx) @@ -17,8 +19,8 @@ void DmGm_Update(Actor* thisx, GlobalContext* globalCtx); void func_80C248A8(DmGm* this, GlobalContext* globalCtx); void func_80C24A00(DmGm* this, GlobalContext* globalCtx); void func_80C24BD0(DmGm* this, GlobalContext* globalCtx); +void func_80C25000(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Dm_Gm_InitVars = { ACTOR_DM_GM, ACTORCAT_NPC, @@ -31,37 +33,337 @@ const ActorInit Dm_Gm_InitVars = { (ActorFunc)NULL, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_an1_Anim_007E08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an1_Anim_0071E8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_006CC0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an1_Anim_013E1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_an4_Anim_007E3C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_0088C0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0013C8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_002550, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_00353C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004498, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_an4_Anim_0060B4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00041C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_004A78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_an4_Anim_00506C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06012618; +s32 func_80C24360(DmGm* this, GlobalContext* globalCtx) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24360.s") + if (this->unk_2C8 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24428.s") + if (objectIndex2 >= 0) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + ret = SkelAnime_Update(&this->skelAnime); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24504.s") +s32 func_80C24428(DmGm* this, GlobalContext* globalCtx, s32 arg2) { + s8 objectIndex = this->actor.objBankIndex; + s8 objectIndex2; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2457C.s") + if (arg2 < 2) { + objectIndex2 = this->actor.objBankIndex; + } else { + objectIndex2 = this->unk_2AC; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C2478C.s") + if ((objectIndex2 >= 0) && (arg2 != this->unk_2C8)) { + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex2].segment); + this->unk_2C8 = arg2; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); + gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objectIndex].segment); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24838.s") +void func_80C24504(DmGm* this) { + if (DECR(this->unk_2BA) == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 4) { + this->unk_2BA = Rand_S16Offset(30, 30); + this->unk_2B8 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C248A8.s") +s32 func_80C2457C(DmGm* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24A00.s") + Math_Vec3f_Copy(&sp40, &this->unk_2B4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24BD0.s") + Math_ApproachS(&this->unk_2C0, (sp32 - this->unk_2C4) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C0 = CLAMP(this->unk_2C0, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Init.s") + Math_ApproachS(&this->unk_2C4, (sp32 - this->unk_2C0) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2C4 = CLAMP(this->unk_2C4, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Destroy.s") + if (this->unk_2B4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_2B4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_2B4->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/DmGm_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_2BE, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2C2, 4, 0x2AA8); + this->unk_2BE = CLAMP(this->unk_2BE, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24CD0.s") + Math_ApproachS(&this->unk_2C2, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2BE, 4, 0x2AA8); + this->unk_2C2 = CLAMP(this->unk_2C2, -0x1C70, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C24E4C.s") +s32 func_80C2478C(DmGm* this, GlobalContext* globalCtx) { + if (this->unk_2B4 != NULL) { + func_80C2457C(this, globalCtx); + this->unk_2AE &= ~1; + this->unk_2AE |= 2; + } else if (this->unk_2AE & 2) { + this->unk_2AE &= ~2; + this->unk_2BE = 0; + this->unk_2C0 = 0; + this->unk_2C2 = 0; + this->unk_2C4 = 0; + this->unk_2BC = 20; + } else if (DECR(this->unk_2BC) == 0) { + this->unk_2AE |= 1; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Gm/func_80C25000.s") +Actor* func_80C24838(GlobalContext* globalCtx) { + Actor* tempActor; + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, ACTORCAT_NPC, ACTOR_DM_AH); + + if ((foundActor == NULL) || (foundActor->update != NULL)) { + break; + } + + tempActor = foundActor->next; + if (tempActor == NULL || false) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } + return foundActor; +} + +void func_80C248A8(DmGm* this, GlobalContext* globalCtx) { + if ((this->unk_2AC >= 0) && SubS_IsObjectLoaded(this->unk_2AC, globalCtx) && (this->unk_2AD >= 0) && + SubS_IsObjectLoaded(this->unk_2AD, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_an1_Skel_012618, NULL, this->jointTable, + this->morphTable, OBJECT_AN1_LIMB_MAX); + + this->unk_2C8 = -1; + func_80C24428(this, globalCtx, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2AE |= 1; + this->actor.draw = func_80C25000; + + if ((globalCtx->sceneNum == SCENE_YADOYA) && (globalCtx->curSpawn == 4)) { + this->unk_2B4 = func_80C24838(globalCtx); + func_80C24428(this, globalCtx, 1); + this->actionFunc = func_80C24BD0; + } else { + this->actionFunc = func_80C24A00; + } + } +} + +void func_80C24A00(DmGm* this, GlobalContext* globalCtx) { + s32 sp28[] = { 0, 0, 12, 2, 4, 6, 8, 10, 11, 3 }; + u16 action; + s32 sp20; + + if (globalCtx->csCtx.state != 0) { + if (this->unk_2D0 == 0) { + this->unk_2B0 = 255; + this->unk_2D0 = 1; + this->unk_2D4 = 0; + this->unk_2CC = this->unk_2C8; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x22D)) { + sp20 = Cutscene_GetActorActionIndex(globalCtx, 0x22D); + action = globalCtx->csCtx.actorActions[sp20]->action; + + if (this->unk_2B0 != (action & 0xFF)) { + this->unk_2B0 = action; + this->unk_2D4 = 1; + func_80C24428(this, globalCtx, sp28[action]); + } + + switch (this->unk_2B0) { + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + if ((this->unk_2C8 == 12) || (this->unk_2C8 == 4) || (this->unk_2C8 == 6) || (this->unk_2C8 == 8)) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80C24428(this, globalCtx, this->unk_2C8 + 1); + } + } + break; + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp20); + } + } else if (this->unk_2D0 != 0) { + this->unk_2D0 = 0; + this->unk_2D4 = 0; + func_80C24428(this, globalCtx, this->unk_2CC); + } +} + +void func_80C24BD0(DmGm* this, GlobalContext* globalCtx) { +} + +void DmGm_Init(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->unk_2AC = SubS_GetObjectIndex(OBJECT_AN4, globalCtx); + this->unk_2AD = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = func_80C248A8; +} + +void DmGm_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void DmGm_Update(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80C2478C(this, globalCtx); + + if (this->actor.draw != NULL) { + func_80C24360(this, globalCtx); + func_80C24504(this); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); +} + +Vec3f D_80C25218 = { 450.0f, 700.0f, -760.0f }; +Vec3s D_80C25224 = { 0x238C, 0, -0x3FFC }; +Vec3f D_80C2522C = { 1000.0f, 0.0f, 0.0f }; + +void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad[2]; + DmGm* this = THIS; + s8 sp2B = this->actor.objBankIndex; + s8 sp2A = this->unk_2AD; + + if ((limbIndex == OBJECT_AN1_LIMB_05) && (this->unk_2D4 != 0)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80C25218, &D_80C25224); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2A].segment); + gSPDisplayList(POLY_OPA_DISP++, gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[sp2B].segment); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80C2522C, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + DmGm* this = THIS; + s16 phi_v1; + s16 phi_v0; + + if (!(this->unk_2AE & 1)) { + if (this->unk_2AE & 2) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_AN1_LIMB_09) { + func_8013AD9C(this->unk_2BE + this->unk_2C2 + 0x4000, + this->unk_2C0 + this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_18C, &this->unk_1A4, + phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_18C.x, this->unk_18C.y, this->unk_18C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1A4.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1A4.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1A4.z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == OBJECT_AN1_LIMB_02) { + func_8013AD9C(this->unk_2C2 + 0x4000, this->unk_2C4 + this->actor.shape.rot.y + 0x4000, &this->unk_194, + &this->unk_1AA, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_194.x, this->unk_194.y, this->unk_194.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_1AA.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_1AA.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_1AA.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +TexturePtr D_80C25238[] = { + object_an1_Tex_00E6E0, + object_an1_Tex_00F7A0, + object_an1_Tex_0101A0, +}; + +TexturePtr D_80C25244[] = { + object_an1_Tex_00E1E0, object_an1_Tex_00EFA0, object_an1_Tex_00F3A0, object_an1_Tex_00EFA0, + object_an1_Tex_00FDA0, object_an1_Tex_00F9A0, object_an1_Tex_0103A0, +}; + +void func_80C25000(Actor* thisx, GlobalContext* globalCtx) { + DmGm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C25244[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C25238[0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, DmGm_PostLimbDraw, DmGm_TransformLimbDraw, + &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 8b416d7b7..6f2307378 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -2,6 +2,7 @@ #define Z_DM_GM_H #include "global.h" +#include "objects/object_an1/object_an1.h" struct DmGm; @@ -9,9 +10,30 @@ typedef void (*DmGmActionFunc)(struct DmGm*, GlobalContext*); typedef struct DmGm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ DmGmActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x14C]; + /* 0x018C */ Vec3f unk_18C; + /* 0x018C */ Vec3f unk_194; + /* 0x01A4 */ Vec3s unk_1A4; + /* 0x01A4 */ Vec3s unk_1AA; + /* 0x01B0 */ Vec3s jointTable[OBJECT_AN1_LIMB_MAX]; + /* 0x022E */ Vec3s morphTable[OBJECT_AN1_LIMB_MAX]; + /* 0x02AC */ s8 unk_2AC; + /* 0x02AD */ s8 unk_2AD; + /* 0x02AE */ u16 unk_2AE; + /* 0x02B0 */ u8 unk_2B0; + /* 0x02B4 */ Actor* unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 unk_2C2; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C8 */ s32 unk_2C8; + /* 0x02CC */ s32 unk_2CC; + /* 0x02D0 */ s32 unk_2D0; + /* 0x02D4 */ s32 unk_2D4; } DmGm; // size = 0x2D8 extern const ActorInit Dm_Gm_InitVars; diff --git a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c index 187e93514..a30e83620 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c @@ -6,7 +6,7 @@ #include "z_dm_hina.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmHina*)thisx) 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 871cc0cf2..102ecd95e 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -7,7 +7,7 @@ #include "z_dm_nb.h" #include "objects/object_nb/object_nb.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((DmNb*)thisx) @@ -28,14 +28,14 @@ const ActorInit Dm_Nb_InitVars = { (ActorFunc)DmNb_Draw, }; -static ActorAnimationEntryS D_80C1E200[] = { &object_nb_Anim_000990, 1.0f, 0, -1, 0, 0 }; +static AnimationInfoS D_80C1E200[] = { { &object_nb_Anim_000990, 1.0f, 0, -1, ANIMMODE_LOOP, 0 } }; s32 func_80C1DED0(DmNb* this, s32 arg1) { - s32 ret = 0; + s32 ret = false; if (arg1 != this->unk1F0) { this->unk1F0 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80C1E200, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80C1E200, arg1); } return ret; } @@ -43,7 +43,7 @@ s32 func_80C1DED0(DmNb* this, s32 arg1) { void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { s32 sp2C[] = { 0, 0, 0, 0, 0 }; u16 actionUnk0; - u32 actionIndex; + s32 actionIndex; if (globalCtx->csCtx.state != 0) { if (this->unk1F8 == 0) { @@ -51,14 +51,14 @@ void func_80C1DF18(DmNb* this, GlobalContext* globalCtx) { this->unk1F8 = 1; this->unk1F4 = this->unk1F0; } - if (func_800EE29C(globalCtx, 0x232)) { - actionIndex = func_800EE200(globalCtx, 0x232); - actionUnk0 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 562)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 562); + actionUnk0 = globalCtx->csCtx.actorActions[actionIndex]->action; if (this->unk1EC != (actionUnk0 & 0xFF)) { this->unk1EC = actionUnk0; func_80C1DED0(this, sp2C[actionUnk0]); } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } } else if (this->unk1F8 != 0) { this->unk1F8 = 0; @@ -74,7 +74,7 @@ void DmNb_Init(Actor* thisx, GlobalContext* globalCtx) { 8); this->unk1F0 = -1; func_80C1DED0(this, 0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80C1DF18; } 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 6f22be2ff..ef81bc467 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -6,7 +6,7 @@ #include "z_dm_opstage.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmOpstage*)thisx) 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 cddc2f1a2..bb8b735a4 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -6,7 +6,7 @@ #include "z_dm_ravine.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmRavine*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 53e0fec63..4d5a20114 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -7,7 +7,7 @@ #include "z_dm_sa.h" #include "objects/object_stk/object_stk.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmSa*)thisx) @@ -30,12 +30,12 @@ const ActorInit Dm_Sa_InitVars = { (ActorFunc)DmSa_Draw, }; -static ActorAnimationEntry D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, 0, 0 } }; +static AnimationInfo D_80A2ED00[] = { { &object_stk_Anim_00CC94, 1.0f, 0, -1.0f, ANIMMODE_LOOP, 0 } }; -void func_80A2E960(SkelAnime* arg0, ActorAnimationEntry* animations, u16 index) { +void func_80A2E960(SkelAnime* arg0, AnimationInfo* animations, u16 index) { f32 frameCount; - animations += index; + animations += index; if (animations->frameCount < 0.0f) { frameCount = Animation_GetLastFrame(animations->animation); } else { 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 d4ca48e11..6c9d11170 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 0x04000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) #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 4b94b31e2..08e515d26 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.c @@ -9,7 +9,7 @@ #include "objects/object_stk2/object_stk2.h" #include "objects/object_stk3/object_stk3.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((DmStk*)thisx) @@ -102,43 +102,79 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static ActorAnimationEntry sAnimations[] = { - { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, 0, 0.0f }, { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, - { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, 0, 0.0f }, - { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, 2, 0.0f }, { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_stk_Anim_01C21C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_01D3D0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_001030, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_01D008, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_015C14, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0070DC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00D830, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00055C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00130C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00C270, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00CBB8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_01AA80, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01D07C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_016910, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_018ED0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_01DDE0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01EF50, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02DC64, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02E9A0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0035C8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_0049C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0259F4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_0266C8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_026CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01C114, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_004580, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_020CAC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02200C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02336C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_002774, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_003068, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0101A4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_010B60, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02A2D8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_01F9E4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_029A04, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_02AD54, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_00BB2C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_00C964, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0110B4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_011FB0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_012A58, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_0141E4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00E6EC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00EEC0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_027CF4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_028F28, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_03323C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_031210, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_0322FC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_032AE0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_03021C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_036964, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_016508, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk_Anim_015028, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk_Anim_014920, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_02FA70, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_037B94, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_03967C, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_03A8F8, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_034FD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_005F44, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk3_Anim_002CD8, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_0039F0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk3_Anim_004554, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_0051C0, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk3_Anim_001374, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk3_Anim_001EDC, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, }; void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { @@ -158,8 +194,7 @@ void func_80A9FDB0(DmStk* this, GlobalContext* globalCtx) { } } -void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, ActorAnimationEntry* animation, - u16 index) { +void func_80A9FE3C(DmStk* this, GlobalContext* globalCtx, SkelAnime* skelAnime, AnimationInfo* animation, u16 index) { func_80A9FDB0(this, globalCtx); animation += index; @@ -314,7 +349,7 @@ void func_80AA01C0(DmStk* this, GlobalContext* globalCtx) { case 785: func_8019F128(NA_SE_SY_STALKIDS_PSYCHO); - func_8019FE74(&D_801D6654, 0.0f, 150); + func_8019FE74(&gSfxVolume, 0.0f, 150); break; case 560: @@ -344,7 +379,7 @@ void func_80AA0264(DmStk* this, GlobalContext* globalCtx) { break; case 650: - func_8019FE74(&D_801D6654, 0.0f, 80); + func_8019FE74(&gSfxVolume, 0.0f, 80); break; case 265: @@ -686,7 +721,7 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { func_80A9FED8(this, globalCtx); } else if (gSaveContext.sceneSetupIndex == 0) { func_80AA0100(this, globalCtx); - } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.unk_12 == 0)) { + } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) { func_80AA0158(this, globalCtx); } break; @@ -699,9 +734,9 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_OPENINGDAN: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA01C0(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA0264(this, globalCtx); } } @@ -709,19 +744,19 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_OKUJOU: if (gSaveContext.sceneSetupIndex == 0) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA0420(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA05F0(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { + } else if (globalCtx->csCtx.currentCsIndex == 2) { func_80AA09DC(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 3) { + } else if (globalCtx->csCtx.currentCsIndex == 3) { func_80AA0B08(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA0DA8(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA0E1C(this, globalCtx); } } @@ -729,15 +764,15 @@ void func_80AA0E90(DmStk* this, GlobalContext* globalCtx) { case SCENE_00KEIKOKU: if (gSaveContext.sceneSetupIndex == 3) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA0634(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 2) { + } else if (globalCtx->csCtx.currentCsIndex == 2) { func_80AA066C(this, globalCtx); } } else if (gSaveContext.sceneSetupIndex == 7) { - if (globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->csCtx.currentCsIndex == 0) { func_80AA071C(this, globalCtx); - } else if (globalCtx->csCtx.unk_12 == 1) { + } else if (globalCtx->csCtx.currentCsIndex == 1) { func_80AA076C(this, globalCtx); } } @@ -859,7 +894,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E0 = 5; this->actionFunc = func_80AA1714; } else { - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !func_800EE2F4(globalCtx)) { + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { Actor_MarkForDeath(&this->actor); } this->unk_32C = 2; @@ -885,7 +920,7 @@ void DmStk_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.unk_12 > 0)) { + (globalCtx->csCtx.currentCsIndex > 0)) { globalCtx->envCtx.unk_17 = 15; globalCtx->envCtx.unk_18 = 15; } @@ -1016,7 +1051,7 @@ void func_80AA1B9C(DmStk* this, GlobalContext* globalCtx) { if (this->unk_339 >= 3) { this->unk_339 = 0; if (!(player->stateFlags2 & 0x8000000)) { - func_801518B0(globalCtx, 0x2013, &this->actor); + Message_StartTextbox(globalCtx, 0x2013, &this->actor); } } @@ -1041,21 +1076,21 @@ void func_80AA1C64(DmStk* this, GlobalContext* globalCtx) { void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { s32 pad; - u32 temp_v0; + s32 temp_v0; - if (func_800EE29C(globalCtx, 0x6B)) { - temp_v0 = func_800EE200(globalCtx, 0x6B); + if (Cutscene_CheckActorAction(globalCtx, 107)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 107); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[temp_v0]->startFrame) { - if (this->unk_334 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - this->unk_334 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[temp_v0]->startFrame) { + if (this->unk_334 != globalCtx->csCtx.actorActions[temp_v0]->action) { + this->unk_334 = globalCtx->csCtx.actorActions[temp_v0]->action; if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { this->unk_32D = 6; } else { this->unk_32D = 9; } - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { case 0: case 1: this->unk_2E0 = 3; @@ -1315,7 +1350,7 @@ void func_80AA1D1C(DmStk* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } else { this->unk_334 = 99; } @@ -1442,12 +1477,12 @@ void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { func_80AA1AF8(this, globalCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_328++; if (this->unk_328 > 800) { this->unk_328 = 0; if (!(player->stateFlags2 & 0x8000000)) { - func_801518B0(globalCtx, 0x2014, &this->actor); + Message_StartTextbox(globalCtx, 0x2014, &this->actor); } } if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { @@ -1460,7 +1495,7 @@ void func_80AA2720(DmStk* this, GlobalContext* globalCtx) { void func_80AA27EC(DmStk* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state == 0) { func_80AA1AF8(this, globalCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (this->unk_2E0 == 33) { this->actor.targetArrowOffset = 3100.0f; @@ -1531,7 +1566,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && - (globalCtx->msgCtx.unk11F04 == 0x5E6) && !FrameAdvance_IsEnabled(globalCtx) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && !FrameAdvance_IsEnabled(&globalCtx->state) && (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { time = gSaveContext.save.time; @@ -1544,7 +1579,7 @@ void DmStk_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.unk_12 > 0)) { + (globalCtx->csCtx.currentCsIndex > 0)) { globalCtx->envCtx.unk_17 = 15; globalCtx->envCtx.unk_18 = 15; } @@ -1623,8 +1658,9 @@ void DmStk_PostLimbDraw2(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_006BB0); gSPDisplayList(POLY_OPA_DISP++, object_stk_DL_005870); - if (func_800EE29C(globalCtx, 0x201) && - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x201)]->unk0 == 2) && (this->unk_337 >= 0)) { + if (Cutscene_CheckActorAction(globalCtx, 513) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 513)]->action == 2) && + (this->unk_337 >= 0)) { Matrix_StatePush(); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_337].segment); 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 80eb930fd..6290b41e0 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -6,7 +6,7 @@ #include "z_dm_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DmTag*)thisx) diff --git a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c index b3c11b83e..9ed86ba2c 100644 --- a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c +++ b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c @@ -6,7 +6,7 @@ #include "z_dm_tsg.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((DmTsg*)thisx) 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 993dbc320..fc9d21b3d 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.c @@ -6,7 +6,7 @@ #include "z_dm_zl.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DmZl*)thisx) 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 05b79fb63..0d1daa6b5 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -7,7 +7,7 @@ #include "z_door_ana.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((DoorAna*)thisx) @@ -52,8 +52,7 @@ static ColliderCylinderInit sCylinderInit = { { 50, 10, 0, { 0, 0, 0 } }, }; -// entrances grottos can link to statically, type DOORANA_TYPE_ADJACENT uses scene exit addresses instead -static u16 entrances[] = { +static u16 sEntranceIndexes[] = { 0x1A00, 0x1400, 0x1410, 0x1420, 0x1430, 0x1440, 0x1450, 0x1460, 0x1470, 0x1480, 0x1490, 0x14A0, 0x14B0, 0x14C0, 0x14D0, }; @@ -64,14 +63,15 @@ void DoorAna_SetupAction(DoorAna* this, DoorAnaActionFunc actionFunction) { void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); + this->actor.shape.rot.y = this->actor.shape.rot.z = 0; - if ((grottoType == DOORANA_TYPE_UNK) || (grottoType == DOORANA_TYPE_HIDDEN)) { - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_STORMS || grottoType == DOORANA_TYPE_HIDDEN_BOMB) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_InitAndSetCylinder(globalCtx, &this->bombCollider, &this->actor, &sCylinderInit); } else { - this->actor.flags |= 0x10; // always update + this->actor.flags |= ACTOR_FLAG_10; // always update } Actor_SetScale(&this->actor, 0); @@ -86,27 +86,27 @@ void DoorAna_Init(Actor* thisx, GlobalContext* globalCtx) { void DoorAna_Destroy(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; - s32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_HIDDEN) { + if (grottoType == DOORANA_TYPE_HIDDEN_BOMB) { Collider_DestroyCylinder(globalCtx, &this->bombCollider); } } void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { - s32 grottoIsOpen = 0; - u32 grottoType = GET_DOORANA_TYPE(this); + s32 grottoIsOpen = false; + u32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (grottoType == DOORANA_TYPE_UNK) { - // in OOT decomp its marked as open with storms, but does not seem to open with storms in MM - if ((this->actor.xyzDistToPlayerSq < 40000.0f) && (EnvFlags_Get(globalCtx, 5))) { - grottoIsOpen = 1; - this->actor.flags &= ~0x10; // always update OFF + 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(globalCtx, 5)) { + grottoIsOpen = true; + this->actor.flags &= ~ACTOR_FLAG_10; // always update OFF } } else { if (this->bombCollider.base.acFlags & AC_HIT) { // bomb collision - grottoIsOpen = 1; + grottoIsOpen = true; Collider_DestroyCylinder(globalCtx, &this->bombCollider); } else { @@ -116,7 +116,7 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { } if (grottoIsOpen) { - this->actor.params &= ~DOORANA_TYPE_BITRANGE; + DOORANA_SET_TYPE(&this->actor, DOORANA_TYPE_VISIBLE); DoorAna_SetupAction(this, DoorAna_WaitOpen); play_sound(NA_SE_SY_CORRECT_CHIME); } @@ -126,56 +126,44 @@ void DoorAna_WaitClosed(DoorAna* this, GlobalContext* globalCtx) { void DoorAna_WaitOpen(DoorAna* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s32 dooranaType = GET_DOORANA_TYPE(this); - s8 pad[4]; - s32 entranceIndex; - f32 playerHeightRel; + s32 grottoType = DOORANA_GET_TYPE(&this->actor); - if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f) != 0) { - if ((this->actor.targetMode != 0) && (globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0) && - (player->stateFlags1 & 0x80000000) && (player->unk_AE7 == 0)) { + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { + if (this->actor.targetMode != 0 && globalCtx->sceneLoadFlag == 0 && globalCtx->unk_18B4A == 0 && + (player->stateFlags1 & 0x80000000) && player->unk_AE7 == 0) { - if (dooranaType == DOORANA_TYPE_ADJACENT) { - s32 requiredScopeTemp; + if (grottoType == DOORANA_TYPE_VISIBLE_SCENE_EXIT) { + s32 exitIndex = DOORANA_GET_EXIT_INDEX(&this->actor); - // 300 uses scene exit addresses, not static DoorAna entrance addresses, - // eg. deku playground gets address in the NCT scene exit table - - entranceIndex = GET_DOORANA_ADJACENT_ENTRANCE(this); - globalCtx->nextEntranceIndex = globalCtx->setupExitList[entranceIndex]; + globalCtx->nextEntranceIndex = globalCtx->setupExitList[exitIndex]; } else { - // unused in vanilla, the highest params bits can directly index an address - entranceIndex = GET_DOORANA_DIRECT_ENTRANCE(this); + s32 destinationIdx = DOORANA_GET_ENTRANCE(&this->actor); - func_80169E6C(globalCtx, 3, 0x4FF); + Play_SetupRespawnPoint(&globalCtx->state, RESPAWN_MODE_UNK_3, 0x4FF); - gSaveContext.respawn[3].pos.y = this->actor.world.pos.y; - gSaveContext.respawn[3].yaw = this->actor.home.rot.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].pos.y = this->actor.world.pos.y; + gSaveContext.respawn[RESPAWN_MODE_UNK_3].yaw = this->actor.home.rot.y; - // save the params lower byte for En_Torch to decide what item to use in the grotto chest - gSaveContext.respawn[3].data = GET_DOORANA_ITEMFLAGS(this); + // Stores item and chest flag that ACTOR_EN_TORCH uses for spawning the grotto chest + gSaveContext.respawn[RESPAWN_MODE_UNK_3].data = DOORANA_GET_ITEMFLAGS(&this->actor); - // most grottos in the game use their zrotation as their entrance index, not params - if (DOORANA_TYPE_ROTATION_ENTRANCE(entranceIndex)) { - entranceIndex = GET_DOORANA_ROTATION_ENTRANCE(this); + if (destinationIdx < 0) { + destinationIdx = DOORANA_GET_EX_ENTRANCE(&this->actor); } - globalCtx->nextEntranceIndex = entrances[entranceIndex]; + globalCtx->nextEntranceIndex = sEntranceIndexes[destinationIdx]; } DoorAna_SetupAction(this, DoorAna_GrabLink); - } else { - if ((func_801690CC(globalCtx) == 0) && ((player->stateFlags1 & 0x08800000) == 0) && - (this->actor.xzDistToPlayer <= 20.0f) && - (playerHeightRel = this->actor.playerHeightRel, (playerHeightRel >= -50.0f)) && - (playerHeightRel <= 15.0f)) { - player->stateFlags1 |= 0x80000000; - this->actor.targetMode = 1; + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags1 & 0x08800000) && + (this->actor.xzDistToPlayer <= 20.0f) && (this->actor.playerHeightRel >= -50.0f) && + (this->actor.playerHeightRel <= 15.0f)) { + player->stateFlags1 |= 0x80000000; + this->actor.targetMode = 1; - } else { - this->actor.targetMode = 0; - } + } else { + this->actor.targetMode = 0; } } @@ -194,10 +182,10 @@ void DoorAna_GrabLink(DoorAna* this, GlobalContext* globalCtx) { } } - if ((this->actor.playerHeightRel <= 0.0f) && (this->actor.xzDistToPlayer > 20.0f)) { + if (this->actor.playerHeightRel <= 0.0f && this->actor.xzDistToPlayer > 20.0f) { player = GET_PLAYER(globalCtx); - player->actor.world.pos.x = (Math_SinS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.x; - player->actor.world.pos.z = (Math_CosS(this->actor.yawTowardsPlayer) * 20.0f) + this->actor.world.pos.z; + player->actor.world.pos.x = Math_SinS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.x; + player->actor.world.pos.z = Math_CosS(this->actor.yawTowardsPlayer) * 20.0f + this->actor.world.pos.z; } } @@ -205,7 +193,7 @@ void DoorAna_Update(Actor* thisx, GlobalContext* globalCtx) { DoorAna* this = THIS; this->actionFunc(this, globalCtx); - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); } void DoorAna_Draw(Actor* thisx, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h index aec6e70be..0cff726e9 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.h +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.h @@ -15,18 +15,17 @@ typedef struct DoorAna { extern const ActorInit Door_Ana_InitVars; -#define DOORANA_TYPE_REGULAR 0x000 -#define DOORANA_TYPE_UNK 0x100 -#define DOORANA_TYPE_HIDDEN 0x200 -#define DOORANA_TYPE_ADJACENT 0x300 -#define DOORANA_TYPE_BITRANGE 0x300 +#define DOORANA_TYPE_BITMASK 0x300 +#define DOORANA_TYPE_VISIBLE 0x000 +#define DOORANA_TYPE_HIDDEN_STORMS 0x100 // Incomplete, leftover from OoT +#define DOORANA_TYPE_HIDDEN_BOMB 0x200 +#define DOORANA_TYPE_VISIBLE_SCENE_EXIT 0x300 // Destination dependent on scene exit list -#define GET_DOORANA_TYPE(this)(this->actor.params & 0x300) - -#define DOORANA_TYPE_ROTATION_ENTRANCE(directEntrance)(directEntrance < 0) -#define GET_DOORANA_DIRECT_ENTRANCE(this) ((((this)->actor.params >> 0xC) & 0x7) - 1) -#define GET_DOORANA_ADJACENT_ENTRANCE(this) ((this)->actor.params & 0x1F) -#define GET_DOORANA_ROTATION_ENTRANCE(this) (this->actor.home.rot.z + 1) -#define GET_DOORANA_ITEMFLAGS(this) ((this)->actor.params & 0xFF) +#define DOORANA_GET_TYPE(thisx) ((thisx)->params & DOORANA_TYPE_BITMASK) +#define DOORANA_GET_ENTRANCE(thisx) ((((thisx)->params >> 12) & 0x7) - 1) +#define DOORANA_GET_EX_ENTRANCE(thisx) ((thisx)->home.rot.z + 1) +#define DOORANA_GET_EXIT_INDEX(thisx) ((thisx)->params & 0x1F) +#define DOORANA_GET_ITEMFLAGS(thisx) ((thisx)->params & 0xFF) +#define DOORANA_SET_TYPE(thisx, t) ((thisx)->params = ((thisx)->params & ~DOORANA_TYPE_BITMASK) + (t)) #endif // Z_DOOR_ANA_H 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 44f699298..01430acc3 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -5,8 +5,20 @@ */ #include "z_door_shutter.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_bdoor/object_bdoor.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_hakugin_obj/object_hakugin_obj.h" +#include "objects/object_dblue_object/object_dblue_object.h" +#include "objects/object_ikana_obj/object_ikana_obj.h" +#include "objects/object_redead_obj/object_redead_obj.h" +#include "objects/object_ikninside_obj/object_ikninside_obj.h" +#include "objects/object_random_obj/object_random_obj.h" +#include "objects/object_kinsta1_obj/object_kinsta1_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/object_last_obj/object_last_obj.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DoorShutter*)thisx) @@ -14,7 +26,18 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx); void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx); void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx); +void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1080(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1090(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1548(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1618(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1684(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1784(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx); +void func_808A1C50(DoorShutter* this, GlobalContext* globalCtx); +void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Door_Shutter_InitVars = { ACTOR_DOOR_SHUTTER, ACTORCAT_DOOR, @@ -27,64 +50,670 @@ const ActorInit Door_Shutter_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808A2248[] = { +typedef struct { + /* 0x0 */ s16 objectId; + /* 0x2 */ u8 index1; + /* 0x3 */ u8 index2; +} ShutterObjectInfo; // size = 0x4 + +ShutterObjectInfo D_808A2180[] = { + { OBJECT_BDOOR, 0, 0 }, { GAMEPLAY_KEEP, 1, 1 }, { OBJECT_NUMA_OBJ, 2, 2 }, + { OBJECT_HAKUGIN_OBJ, 3, 3 }, { OBJECT_DBLUE_OBJECT, 4, 4 }, { OBJECT_IKANA_OBJ, 5, 5 }, + { OBJECT_REDEAD_OBJ, 6, 6 }, { OBJECT_IKNINSIDE_OBJ, 7, 7 }, { OBJECT_LAST_OBJ, 11, 11 }, + { OBJECT_RANDOM_OBJ, 8, 8 }, { OBJECT_KINSTA1_OBJ, 9, 9 }, { OBJECT_KAIZOKU_OBJ, 10, 10 }, +}; + +typedef struct { + /* 0x0 */ Gfx* unk_00; + /* 0x4 */ Gfx* unk_04; + /* 0x8 */ u8 unk_08; + /* 0x9 */ u8 translateZ; + /* 0xA */ u8 unk_0A; + /* 0xB */ u8 unk_0B; +} ShutterInfo; // size = 0xC + +ShutterInfo D_808A21B0[] = { + { object_bdoor_DL_0000C0, NULL, 130, 12, 50, 15 }, + { gameplay_keep_DL_077990, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_numa_obj_DL_007150, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_hakugin_obj_DL_000128, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_dblue_object_DL_017D00, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_ikana_obj_DL_014A40, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_redead_obj_DL_0001A0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_ikninside_obj_DL_004440, object_ikninside_obj_DL_005260, 130, 0, 20, 15 }, + { object_random_obj_DL_000190, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_kinsta1_obj_DL_000198, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_kaizoku_obj_DL_0001A0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { object_last_obj_DL_0039C0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, +}; + +s8 D_808A2240[] = { + -1, -1, -1, -1, -1, 0, -1, -1, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +typedef struct { + /* 0x00 */ s16 sceneNum; + /* 0x02 */ u8 index; +} ShutterSceneInfo; // size = 0x4 -extern InitChainEntry D_808A2248[]; +ShutterSceneInfo D_808A2258[] = { + { SCENE_MITURIN, 2 }, { SCENE_HAKUGIN, 3 }, { SCENE_SEA, 4 }, + { SCENE_INISIE_N, 5 }, { SCENE_INISIE_R, 5 }, { SCENE_REDEAD, 6 }, + { SCENE_IKNINSIDE, 7 }, { SCENE_CASTLE, 7 }, { SCENE_RANDOM, 9 }, + { SCENE_KINSTA1, 10 }, { SCENE_KAIZOKU, 11 }, { SCENE_PIRATE, 11 }, + { SCENE_TORIDE, 11 }, { SCENE_LAST_DEKU, 8 }, { SCENE_LAST_GORON, 8 }, + { SCENE_LAST_ZORA, 8 }, { SCENE_LAST_LINK, 8 }, { -1, 1 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A08F0.s") +typedef struct { + /* 0x00 */ s16 dungeonScene; + /* 0x02 */ s16 bossScene; + /* 0x04 */ u8 index; +} BossDoorInfo; // size = 0x6 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0900.s") +BossDoorInfo D_808A22A0[] = { + { SCENE_MITURIN, SCENE_MITURIN_BS, 1 }, { SCENE_HAKUGIN, SCENE_HAKUGIN_BS, 2 }, { SCENE_SEA, SCENE_SEA_BS, 3 }, + { SCENE_INISIE_N, SCENE_INISIE_BS, 4 }, { SCENE_INISIE_R, SCENE_INISIE_BS, 4 }, { -1, -1, 0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0974.s") +Vec3f D_808A22C4 = { 120.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Init.s") +Vec3f D_808A22D0 = { -90.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Destroy.s") +TexturePtr D_808A22DC[] = { + object_bdoor_Tex_006BA0, object_bdoor_Tex_005BA0, object_bdoor_Tex_0005C0, + object_bdoor_Tex_004BA0, object_bdoor_Tex_003BA0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0D0C.s") +void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc) { + this->actionFunc = actionFunc; + this->unk_167 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0D90.s") +s32 func_808A0900(DoorShutter* this, GlobalContext* globalCtx) { + TransitionActorEntry* transitionEntry = &globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + s8 frontRoom = transitionEntry->sides[0].room; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0E28.s") + if (frontRoom == transitionEntry->sides[1].room) { + if (ABS_ALT(BINANG_SUB(this->actor.shape.rot.y, this->actor.yawTowardsPlayer)) < 0x4000) { + frontRoom = -1; + } + } + return frontRoom == this->actor.room; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A0F88.s") +s32 DoorShutter_SetupDoor(DoorShutter* this, GlobalContext* globalCtx) { + ShutterObjectInfo* sp24 = &D_808A2180[this->unk_163]; + s32 doorType = this->doorType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1080.s") + if (doorType != 4) { + if (func_808A0900(this, globalCtx)) { + if ((doorType == 7) || (doorType == 6)) { + doorType = 1; + } else if (doorType == 5) { + doorType = 3; + } else { + doorType = 0; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1090.s") + if (doorType == 0) { + this->unk_164 = sp24->index1; + } else { + this->unk_164 = sp24->index2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1288.s") + if (doorType == 1) { + if (!Flags_GetClear(globalCtx, this->actor.room)) { + DoorShutter_SetupAction(this, func_808A0F88); + this->unk_168 = 1.0f; + return true; + } + } else if ((doorType == 2) || (doorType == 7)) { + if (!Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + DoorShutter_SetupAction(this, func_808A1548); + this->unk_168 = 1.0f; + return true; + } + DoorShutter_SetupAction(this, func_808A1618); + return false; + } else if (doorType == 3) { + DoorShutter_SetupAction(this, func_808A1080); + this->unk_168 = 1.0f; + return false; + } + DoorShutter_SetupAction(this, func_808A1090); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1340.s") +void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + DoorShutter* this = THIS; + s32 sp24; + s32 i; + s8 objId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1478.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->doorType = DOORSHUTTER_GET_380(&this->actor); + sp24 = D_808A2240[this->doorType]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1548.s") + if (sp24 < 0) { + ShutterSceneInfo* shutterSceneInfo = &D_808A2258[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1618.s") + for (i = 0; i < ARRAY_COUNT(D_808A2258) - 1; i++, shutterSceneInfo++) { + if (globalCtx->sceneNum == shutterSceneInfo->sceneNum) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1684.s") + sp24 = shutterSceneInfo->index; + if (sp24 == 6) { + this->actor.flags |= ACTOR_FLAG_10000000; + } + } else if (sp24 == 0) { + BossDoorInfo* bossDoorInfo = &D_808A22A0[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1784.s") + for (i = 0; i < ARRAY_COUNT(D_808A22A0) - 1; i++, bossDoorInfo++) { + if ((globalCtx->sceneNum == bossDoorInfo->dungeonScene) || + (globalCtx->sceneNum == bossDoorInfo->bossScene)) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1884.s") + this->unk_15E = bossDoorInfo->index; + } else { + this->actor.room = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1A70.s") + // clang-format off + objId = Object_GetIndex(&globalCtx->objectCtx, D_808A2180[sp24].objectId); this->requiredObjBankIndex = objId; if (objId < 0) { Actor_MarkForDeath(&this->actor); return; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1B48.s") + DoorShutter_SetupAction(this, DoorShutter_SetupType); + this->unk_163 = sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1C50.s") + if ((this->doorType == 4) || (this->doorType == 5)) { + if (!Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + this->unk_166 = 10; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/DoorShutter_Update.s") + Actor_SetFocus(&this->actor, 60.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1D68.s") +void DoorShutter_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DoorShutter* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Door_Shutter/func_808A1E14.s") + if (this->actor.room >= 0) { + s32 transitionActorId = DOORSHUTTER_GET_FC00(&this->actor); + + globalCtx->doorCtx.transitionActorList[transitionActorId].id = + -globalCtx->doorCtx.transitionActorList[transitionActorId].id; + } +} + +void DoorShutter_SetupType(DoorShutter* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex) && ((MREG(64) == 0) || (MREG(68) == 0))) { + this->actor.objBankIndex = this->requiredObjBankIndex; + this->actor.draw = DoorShutter_Draw; + DoorShutter_SetupDoor(this, globalCtx); + } +} + +f32 func_808A0D90(GlobalContext* globalCtx, DoorShutter* this, f32 arg2, f32 arg3, f32 arg4) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp28; + Vec3f sp1C; + + sp28.x = player->actor.world.pos.x; + sp28.y = player->actor.world.pos.y + arg2; + sp28.z = player->actor.world.pos.z; + + Actor_OffsetOfPointInActorCoords(&this->actor, &sp1C, &sp28); + + if ((arg3 < fabsf(sp1C.x)) || (arg4 < fabsf(sp1C.y))) { + return FLT_MAX; + } + return sp1C.z; +} + +s32 func_808A0E28(DoorShutter* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!Player_InCsMode(&globalCtx->state)) { + ShutterInfo* shutterInfo = &D_808A21B0[this->unk_164]; + f32 temp_f0 = func_808A0D90(globalCtx, this, 0.0f, shutterInfo->unk_0A, shutterInfo->unk_0B); + + if (fabsf(temp_f0) < 50.0f) { + s16 temp_v0_2 = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); + + if (temp_f0 > 0.0f) { + temp_v0_2 = 0x8000 - temp_v0_2; + } + + if (ABS_ALT(temp_v0_2) < 0x3000) { + return (temp_f0 >= 0.0f) ? 1.0f : -1.0f; + } + } + } + return false; +} + +void func_808A0F88(DoorShutter* this, GlobalContext* globalCtx) { + if (Flags_GetClear(globalCtx, this->actor.room) || Flags_GetClearTemp(globalCtx, this->actor.room)) { + this->unk_160 = this->actor.cutscene; + if (this->doorType == 7) { + if (this->unk_160 != -1) { + this->unk_160 = ActorCutscene_GetAdditionalCutscene(this->unk_160); + } + } + + if (ActorCutscene_GetCanPlayNext(this->unk_160)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + Flags_SetClear(globalCtx, this->actor.room); + DoorShutter_SetupAction(this, func_808A1784); + this->unk_167 = -1; + } else { + ActorCutscene_SetIntentToPlay(this->unk_160); + } + } else if (func_808A0E28(this, globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = -1; + player->doorActor = &this->actor; + this->actor.textId = 0x1801; + func_80122F28(player); + } +} + +void func_808A1080(DoorShutter* this, GlobalContext* globalCtx) { +} + +void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_15C != 0) { + DoorShutter_SetupAction(this, func_808A1684); + this->actor.velocity.y = 0.0f; + if (this->unk_166 != 0) { + Flags_SetSwitch(globalCtx, 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); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); + } + } + } else { + s32 doorDirection = func_808A0E28(this, globalCtx); + + if (doorDirection != 0) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = 2; + player->doorDirection = doorDirection; + player->doorActor = &this->actor; + + if (this->unk_163 == 7) { + player->doorTimer = 12; + } else { + player->doorTimer = 0; + } + + if (this->doorType == 6) { + if (gSaveContext.save.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { + player->doorType = -1; + this->actor.textId = 0x14FC; + } + } else if (this->unk_166 != 0) { + if (this->doorType == 5) { + if (!CHECK_DUNGEON_ITEM(0, gSaveContext.mapIndex)) { + player->doorType = -1; + this->actor.textId = 0x1803; + } + player->doorTimer += 10; + } else if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) <= 0) { + player->doorType = -1; + this->actor.textId = 0x1802; + } else { + player->doorTimer += 10; + } + } + func_80122F28(player); + } + } +} + +void func_808A1288(DoorShutter* this, GlobalContext* globalCtx) { + if (this->actor.category == ACTORCAT_DOOR) { + Player* player = GET_PLAYER(globalCtx); + s32 sp38 = this->unk_164; + s32 sp34 = 0xF; + + if (DoorShutter_SetupDoor(this, globalCtx)) { + sp34 = 0x20; + } + + DoorShutter_SetupAction(this, func_808A1684); + + this->unk_164 = sp38; + this->unk_168 = 0.0f; + + func_800DFFAC(globalCtx->cameraPtrs[CAM_ID_MAIN], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); + } +} + +s32 func_808A1340(DoorShutter* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this->actor.velocity.y == 0.0f) { + func_808A1288(this, globalCtx); + if (this->unk_163 != 7) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); + } + } + + if (this->unk_163 == 7) { + s32 pad; + + if (this->unk_163 == 7) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_OPEN - SFX_FLAG); + } + + Lib_Vec3f_TranslateAndRotateY(&this->actor.home.pos, this->actor.shape.rot.y, + (this->unk_163 == 7) ? &D_808A22C4 : &D_808A22D0, &sp2C); + Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &sp2C, this->actor.velocity.y) == 0.0f) { + return true; + } + } else { + Math_StepToF(&this->actor.velocity.y, 15.0f, 3.0f); + + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 200.0f, this->actor.velocity.y)) { + return true; + } + } + return false; +} + +s32 func_808A1478(DoorShutter* this, GlobalContext* globalCtx, f32 arg2) { + f32 temp = 1.0f - arg2; + + if (temp == this->unk_168) { + if (arg2 == 1.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_CLOSE); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_METALDOOR_OPEN); + } + + if ((this->unk_160 != -1) && (ActorCutscene_GetCurrentIndex() == this->unk_160)) { + func_800B724C(globalCtx, &this->actor, 1); + } + } + + if (Math_StepToF(&this->unk_168, arg2, 0.2f)) { + return true; + } + return false; +} + +void func_808A1548(DoorShutter* this, GlobalContext* globalCtx) { + if (func_808A1478(this, globalCtx, 1.0f)) { + if (Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + this->unk_160 = this->actor.cutscene; + if (ActorCutscene_GetCanPlayNext(this->unk_160)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_160, &this->actor); + DoorShutter_SetupAction(this, func_808A1784); + this->unk_167 = -1; + } else { + ActorCutscene_SetIntentToPlay(this->unk_160); + } + } else if (func_808A0E28(this, globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + + player->doorType = -1; + player->doorActor = &this->actor; + this->actor.textId = 0x1800; + func_80122F28(player); + } + } +} + +void func_808A1618(DoorShutter* this, GlobalContext* globalCtx) { + if ((this->unk_15C == 0) && !Flags_GetSwitch(globalCtx, DOORSHUTTER_GET_7F(&this->actor))) { + DoorShutter_SetupAction(this, func_808A1548); + } else { + func_808A1090(this, globalCtx); + } +} + +void func_808A1684(DoorShutter* this, GlobalContext* globalCtx) { + f32 phi_f0; + + if ((DECR(this->unk_166) == 0) && (globalCtx->roomCtx.unk31 == 0) && func_808A1340(this, globalCtx)) { + if (this->doorType == 5) { + phi_f0 = 20.0f; + } else { + phi_f0 = 50.0f; + } + + if (phi_f0 < this->actor.xzDistToPlayer) { + if (this->unk_163 == 7) { + this->actor.velocity.y = 0.0f; + } else { + if (DoorShutter_SetupDoor(this, globalCtx)) { + this->actor.velocity.y = 30.0f; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + } + DoorShutter_SetupAction(this, func_808A1B48); + } + } +} + +void func_808A1784(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_167 != 0) { + if (func_800F22C4(this->unk_160, &this->actor)) { + if (this->unk_167 < 0) { + if ((globalCtx->state.frames % 2) != 0) { + this->unk_167++; + } + } else { + this->unk_167--; + } + } + } else if (func_808A1478(this, globalCtx, 0.0f)) { + u8 doorType = this->doorType; + + if ((doorType != 0) && (doorType != 1) && + (((doorType != 7) && (doorType != 6)) || !func_808A0900(this, globalCtx))) { + DoorShutter_SetupAction(this, func_808A1618); + } else { + DoorShutter_SetupAction(this, func_808A1090); + } + func_801A2ED8(); + } +} + +void func_808A1884(DoorShutter* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s8 room = this->actor.room; + Vec3f sp44; + + if (this->actor.room >= 0) { + Actor_OffsetOfPointInActorCoords(&this->actor, &sp44, &player->actor.world.pos); + + this->actor.room = globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)] + .sides[(sp44.z < 0.0f) ? 0 : 1] + .room; + + if (room != this->actor.room) { + Room temp = globalCtx->roomCtx.currRoom; + + globalCtx->roomCtx.currRoom = globalCtx->roomCtx.prevRoom; + globalCtx->roomCtx.prevRoom = temp; + globalCtx->roomCtx.activeMemPage ^= 1; + } + func_8012EBF8(globalCtx, &globalCtx->roomCtx); + } + + this->unk_15C = 0; + this->actor.velocity.y = 0.0f; + + if (DoorShutter_SetupDoor(this, globalCtx) && !(player->stateFlags1 & 0x800)) { + DoorShutter_SetupAction(this, func_808A1C50); + if (ActorCutscene_GetCurrentIndex() == 0x7D) { + s8 data = gSaveContext.respawn[RESTART_MODE_DOWN].data; + + func_801226E0(globalCtx, data); + player->unk_A86 = -1; + func_800B7298(globalCtx, NULL, 0x73); + } + } +} + +s32 func_808A1A70(DoorShutter* this) { + if (this->unk_163 == 7) { + if (this->unk_163 == 7) { + func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_CLOSE - SFX_FLAG); + } + + Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.velocity.y) == 0.0f) { + return true; + } + } else { + if (this->actor.velocity.y < 20.0f) { + Math_StepToF(&this->actor.velocity.y, 20.0f, 8.0f); + } + + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, this->actor.velocity.y)) { + return true; + } + } + return false; +} + +void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx) { + s16 quake; + + if (func_808A1A70(this)) { + if (this->actor.velocity.y > 20.0f) { + this->actor.floorHeight = this->actor.home.pos.y; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BIGWALL_BOUND); + quake = Quake_Add(Play_GetCamera(globalCtx, 0), 3); + Quake_SetSpeed(quake, -32536); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 10); + func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + func_808A1884(this, globalCtx); + } +} + +void func_808A1C50(DoorShutter* this, GlobalContext* globalCtx) { + if (this->unk_167++ > 30) { + if (GET_PLAYER(globalCtx)->csMode == 0x73) { + func_800B7298(globalCtx, NULL, 6); + } + DoorShutter_SetupDoor(this, globalCtx); + } +} + +void DoorShutter_Update(Actor* thisx, GlobalContext* globalCtx) { + DoorShutter* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x100004C0) || (this->actionFunc == DoorShutter_SetupType)) { + this->actionFunc(this, globalCtx); + + if (this->unk_163 == 7) { + this->actor.home.rot.z = Math_Vec3f_DistXZ(&this->actor.home.pos, &this->actor.world.pos) * -100.0f; + } + } +} + +s32 func_808A1D68(DoorShutter* this, GlobalContext* globalCtx) { + s32 temp_a0; + s32 temp_a1; + + if (Player_InCsMode(&globalCtx->state)) { + return true; + } + + temp_a0 = BINANG_SUB(Actor_YawToPoint(&this->actor, &globalCtx->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); + temp_a1 = ABS_ALT(temp_a1); + + if (((temp_a1 < 0x4000) && (temp_a0 > 0x4000)) || ((temp_a1 > 0x4000) && (temp_a0 < 0x4000))) { + return false; + } + return true; +} + +void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + DoorShutter* this = THIS; + ShutterInfo* sp44; + + if (func_808A1D68(this, globalCtx)) { + sp44 = &D_808A21B0[this->unk_164]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_164 == 7) { + Matrix_InsertTranslation(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); + } + + if (sp44->unk_04 != 0) { + TransitionActorEntry* transitionEntry = + &globalCtx->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + + if ((globalCtx->roomCtx.prevRoom.num >= 0) || + (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { + s16 yaw = this->actor.shape.rot.y - Math_Vec3f_Yaw(&globalCtx->view.eye, &this->actor.world.pos); + + if (ABS_ALT(yaw) < 0x4000) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + } else if (this->actor.room == transitionEntry->sides[0].room) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + } else if (this->doorType == 5) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808A22DC[this->unk_15E])); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp44->unk_00); + + if ((this->unk_168 != 0.0f) && (sp44->unk_04 != 0)) { + Matrix_InsertTranslation(0.0f, sp44->unk_08 * (1.0f - this->unk_168), sp44->translateZ, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sp44->unk_04); + } + + if (this->unk_166 != 0) { + Matrix_Scale(0.01f, 0.01f, 0.025f, MTXMODE_APPLY); + Actor_DrawDoorLock(globalCtx, this->unk_166, (this->doorType == 5) ? DOORLOCK_BOSS : DOORLOCK_NORMAL); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} 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 e9da6684b..0b796d442 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h @@ -7,9 +7,24 @@ struct DoorShutter; typedef void (*DoorShutterActionFunc)(struct DoorShutter*, GlobalContext*); +#define DOORSHUTTER_GET_1F(thisx) ((thisx)->params & 0x1F) +#define DOORSHUTTER_GET_7F(thisx) ((thisx)->params & 0x7F) +#define DOORSHUTTER_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define DOORSHUTTER_GET_FC00(thisx) (((u16)(thisx)->params >> 0xA)) + typedef struct DoorShutter { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x28]; + /* 0x0144 */ UNK_TYPE1 unk144[0x18]; + /* 0x015C */ s16 unk_15C; + /* 0x015E */ s16 unk_15E; + /* 0x0160 */ s16 unk_160; + /* 0x0162 */ u8 doorType; + /* 0x0163 */ u8 unk_163; + /* 0x0164 */ u8 unk_164; + /* 0x0165 */ s8 requiredObjBankIndex; + /* 0x0166 */ s8 unk_166; + /* 0x0167 */ s8 unk_167; + /* 0x0168 */ f32 unk_168; /* 0x016C */ DoorShutterActionFunc actionFunc; } DoorShutter; // size = 0x170 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 27d8bd211..a2bc8a0be 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.c @@ -12,7 +12,7 @@ #include "objects/object_ikninside_obj/object_ikninside_obj.h" #include "objects/object_danpei_object/object_danpei_object.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((DoorSpiral*)thisx) @@ -125,7 +125,7 @@ s32 DoorSpiral_SetSpiralType(DoorSpiral* this, GlobalContext* globalCtx) { this->spiralType = SPIRAL_WOODFALL_TEMPLE_ALT; } - this->actor.flags |= 0x10000000; + this->actor.flags |= ACTOR_FLAG_10000000; } DoorSpiral_SetupAction(this, DoorSpiral_Wait); @@ -286,7 +286,7 @@ void DoorSpiral_Wait(DoorSpiral* this, GlobalContext* globalCtx) { transition = GET_TRANSITION_ID_PARAM(this); player->doorNext = ((u16)globalCtx->doorCtx.transitionActorList[transition].params) >> 10; - func_80122F28(player, globalCtx, &this->actor); + func_80122F28(player); } } 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 0698b8a64..b2b05230f 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -177,10 +177,10 @@ void DoorWarp1_Destroy(Actor* thisx, GlobalContext* globalCtx) { LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1DC); LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_1F0); - for (i = 0; i < ARRAY_COUNT(globalCtx->envCtx.unk_8C.diffuseColor1); i++) { - globalCtx->envCtx.unk_8C.diffuseColor1[i] = 0; - globalCtx->envCtx.unk_8C.fogColor[i] = globalCtx->envCtx.unk_8C.diffuseColor1[i]; - globalCtx->envCtx.unk_8C.ambientColor[i] = globalCtx->envCtx.unk_8C.diffuseColor1[i]; + for (i = 0; i < ARRAY_COUNT(globalCtx->envCtx.lightSettings.diffuseColor1); i++) { + globalCtx->envCtx.lightSettings.diffuseColor1[i] = 0; + globalCtx->envCtx.lightSettings.fogColor[i] = globalCtx->envCtx.lightSettings.diffuseColor1[i]; + globalCtx->envCtx.lightSettings.ambientColor[i] = globalCtx->envCtx.lightSettings.diffuseColor1[i]; } if (this->unk_1D3 != 0) { @@ -279,14 +279,15 @@ void func_808B8E78(DoorWarp1* this, GlobalContext* globalCtx) { } s32 func_808B900C(DoorWarp1* this, GlobalContext* globalCtx) { - u32 index; + s32 index; u8 ret = false; - if (func_800EE29C(globalCtx, 0x239)) { - index = func_800EE200(globalCtx, 0x239); - if (this->unk_208 != globalCtx->csCtx.npcActions[index]->unk0) { - this->unk_208 = globalCtx->csCtx.npcActions[index]->unk0; - if (globalCtx->csCtx.npcActions[index]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 569)) { + index = Cutscene_GetActorActionIndex(globalCtx, 569); + + if (this->unk_208 != globalCtx->csCtx.actorActions[index]->action) { + this->unk_208 = globalCtx->csCtx.actorActions[index]->action; + if (globalCtx->csCtx.actorActions[index]->action == 2) { ret = true; } } @@ -342,9 +343,9 @@ void func_808B921C(DoorWarp1* this, GlobalContext* globalCtx) { func_808BB8D4(this, globalCtx, 1); } - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { func_800B7298(globalCtx, &this->dyna.actor, 7); - func_801518B0(globalCtx, 0xF2, &this->dyna.actor); + Message_StartTextbox(globalCtx, 0xF2, &this->dyna.actor); DoorWarp1_SetupAction(this, func_808B93A0); } @@ -355,7 +356,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); @@ -375,7 +376,7 @@ void func_808B93A0(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { - if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->unk_1879C[8])) { + if (!func_808B866C(this, globalCtx) && (ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[8])) { DoorWarp1_SetupAction(this, func_808B921C); } func_808BB8D4(this, globalCtx, 1); @@ -383,10 +384,10 @@ void func_808B94A4(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9524(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B958C); } } @@ -442,7 +443,7 @@ void func_808B96B0(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if (func_808B866C(this, globalCtx) && !func_801690CC(globalCtx)) { + if (func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); @@ -455,10 +456,10 @@ void func_808B977C(DoorWarp1* this, GlobalContext* globalCtx) { } void func_808B9840(DoorWarp1* this, GlobalContext* globalCtx) { - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); DoorWarp1_SetupAction(this, func_808B98A8); } } @@ -487,7 +488,7 @@ void func_808B98A8(DoorWarp1* this, GlobalContext* globalCtx) { Scene_SetExitFade(globalCtx); globalCtx->sceneLoadFlag = 0x14; } else { - func_80169FDC(globalCtx); + func_80169FDC(&globalCtx->state); } } } @@ -557,22 +558,23 @@ void func_808B9CE8(DoorWarp1* this, GlobalContext* globalCtx) { 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.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFFFF00FF) | + ((((u8)gSaveContext.save.unk_ECC[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.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0xFF00FFFF) | + ((((u8)gSaveContext.save.unk_ECC[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.unk_ECC[0] = (((void)0, gSaveContext.save.unk_ECC[0]) & 0x00FFFFFF) | + ((((u8)gSaveContext.save.unk_ECC[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.unk_ECC[1] = + (gSaveContext.save.unk_ECC[1] & 0xFFFFFF00) | ((((u8)gSaveContext.save.unk_ECC[1]) + 1) & 0xFF); Item_Give(globalCtx, func_808B849C(this, globalCtx) + (ITEM_REMAINS_ODOLWA - 1)); DoorWarp1_SetupAction(this, func_808B9E94); } @@ -593,7 +595,7 @@ void func_808B9ED8(DoorWarp1* this, GlobalContext* globalCtx) { void func_808B9F10(DoorWarp1* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WARP_HOLE - SFX_FLAG); - if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !func_801690CC(globalCtx) && (this->unk_203 == 0)) { + if ((this->unk_203 == 0) && func_808B866C(this, globalCtx) && !Play_InCsMode(globalCtx) && (this->unk_203 == 0)) { Player* player = GET_PLAYER(globalCtx); Interface_ChangeAlpha(1); @@ -614,10 +616,10 @@ void func_808B9FD0(DoorWarp1* this, GlobalContext* globalCtx) { return; } - if (!ActorCutscene_GetCanPlayNext(globalCtx->unk_1879C[9])) { - ActorCutscene_SetIntentToPlay(globalCtx->unk_1879C[9]); + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[9])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[9]); } else { - ActorCutscene_Start(globalCtx->unk_1879C[9], NULL); + ActorCutscene_Start(globalCtx->playerActorCsIds[9], NULL); Audio_PlaySfxGeneral(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &D_801DB4B0, &D_801DB4B0, &D_801DB4B8); Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, Animation_GetLastFrame(&object_warp1_Anim_001374.common), @@ -766,7 +768,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { Scene_SetExitFade(globalCtx); globalCtx->sceneLoadFlag = 0x14; } else { - func_80169FDC(globalCtx); + func_80169FDC(&globalCtx->state); } } @@ -831,15 +833,15 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { } if (this->unk_1D0 > 140) { - globalCtx->envCtx.unk_E5 = 1; + globalCtx->envCtx.fillScreen = 1; temp_f0 = (this->unk_1D0 - 140) / 20.0f; if (temp_f0 > 1.0f) { temp_f0 = 1.0f; } - globalCtx->envCtx.unk_E6[0] = 160; - globalCtx->envCtx.unk_E6[1] = 160; - globalCtx->envCtx.unk_E6[2] = 160; - globalCtx->envCtx.unk_E6[3] = 255.0f * temp_f0; + globalCtx->envCtx.screenFillColor[0] = 160; + globalCtx->envCtx.screenFillColor[1] = 160; + globalCtx->envCtx.screenFillColor[2] = 160; + globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0; } Lights_PointNoGlowSetInfo(&this->unk_1E0, player->actor.world.pos.x + 10.0f, player->actor.world.pos.y + 10.0f, @@ -862,13 +864,13 @@ void func_808BA550(DoorWarp1* this, GlobalContext* globalCtx) { temp_f16 = -255.0f * temp_f0; for (i = 0; i < 3; i++) { - globalCtx->envCtx.unk_8C.diffuseColor1[i] = temp_f16; - globalCtx->envCtx.unk_8C.fogColor[i] = temp_f16; - globalCtx->envCtx.unk_8C.ambientColor[i] = temp_f16; + globalCtx->envCtx.lightSettings.diffuseColor1[i] = temp_f16; + globalCtx->envCtx.lightSettings.fogColor[i] = temp_f16; + globalCtx->envCtx.lightSettings.ambientColor[i] = temp_f16; } - globalCtx->envCtx.unk_8C.fogNear = -500.0f * temp_f0; - if (globalCtx->envCtx.unk_8C.fogNear < -300) { + globalCtx->envCtx.lightSettings.fogNear = -500.0f * temp_f0; + if (globalCtx->envCtx.lightSettings.fogNear < -300) { globalCtx->roomCtx.currRoom.segment = NULL; } } 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 45a62ed72..d7bd601f0 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -6,7 +6,7 @@ #include "z_eff_change.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EffChange*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 7582a378a..e53635603 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "system_malloc.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffDust*)thisx) 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 faea4c4e4..687ae1b96 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 @@ -6,7 +6,7 @@ #include "z_eff_kamejima_wave.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EffKamejimaWave*)thisx) 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 4f9138aa7..3901c0179 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -6,7 +6,7 @@ #include "z_eff_lastday.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffLastday*)thisx) diff --git a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c index b02e52e57..b54bba577 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c @@ -6,7 +6,7 @@ #include "z_eff_stk.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffStk*)thisx) 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 6da3885be..8ed8c6db4 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -6,7 +6,7 @@ #include "z_eff_zoraband.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EffZoraband*)thisx) 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 d3d0317ae..372a21d11 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -6,7 +6,7 @@ #include "z_elf_msg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg*)thisx) 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 ece5b9a5c..5397ca5d6 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -6,7 +6,7 @@ #include "z_elf_msg2.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg2*)thisx) 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 95942b815..dc0e5eb72 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -6,7 +6,7 @@ #include "z_elf_msg3.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg3*)thisx) 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 c55591fba..ca7981362 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -6,7 +6,7 @@ #include "z_elf_msg4.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg4*)thisx) diff --git a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c index 3fc56c89b..aceb36807 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -6,7 +6,7 @@ #include "z_elf_msg5.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg5*)thisx) 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 ecd927765..68c22f2d1 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -5,8 +5,9 @@ */ #include "z_elf_msg6.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ElfMsg6*)thisx) @@ -22,7 +23,6 @@ void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx); void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx); -#if 0 const ActorInit Elf_Msg6_InitVars = { ACTOR_ELF_MSG6, ACTORCAT_ITEMACTION, @@ -35,34 +35,380 @@ const ActorInit Elf_Msg6_InitVars = { (ActorFunc)NULL, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA15A0.s") +s32 func_80BA15A0(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && !(gSaveContext.save.weekEventReg[87] & 0x10)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA165C.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && !(gSaveContext.save.weekEventReg[87] & 0x20)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA16F4.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && !(gSaveContext.save.weekEventReg[87] & 0x40)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Init.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD) && !(gSaveContext.save.weekEventReg[87] & 0x80)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Destroy.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C00.s") +void func_80BA165C(void) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + gSaveContext.save.weekEventReg[87] |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1C88.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + gSaveContext.save.weekEventReg[87] |= 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1CF8.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + gSaveContext.save.weekEventReg[87] |= 0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1E30.s") + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + gSaveContext.save.weekEventReg[87] |= 0x80; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA1F80.s") +s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[31] & 4) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->actor.textId = 0x216; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2038.s") + if (!func_80BA15A0()) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA2048.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + this->actor.textId = 0x256; + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA215C.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + if (gSaveContext.save.weekEventReg[31] & 1) { + this->actor.textId = 0x257; + } else { + this->actor.textId = 0x231; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/func_80BA21C4.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { + if (gSaveContext.save.weekEventReg[31] & 2) { + this->actor.textId = 0x258; + } else { + this->actor.textId = 0x232; + } + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg6/ElfMsg6_Update.s") + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + if (gSaveContext.save.weekEventReg[80] & 4) { + this->actor.textId = 0x259; + } else { + this->actor.textId = 0x233; + } + return false; + } + + return true; +} + +void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (ABS_ALT(this->actor.home.rot.x) == 0) { + this->actor.scale.z = 0.4f; + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.scale.z = ABS_ALT(this->actor.home.rot.x) * 0.04f; + } + + if (this->actor.home.rot.z == 0) { + this->actor.scale.y = 0.4f; + } else { + this->actor.scale.y = this->actor.home.rot.z * 0.04f; + } + + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + + switch (ELFMSG6_GET_F(&this->actor)) { + case 0: + this->actionFunc = func_80BA1E30; + if (func_80BA16F4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + this->actionFunc = func_80BA1F80; + if ((this->actor.cutscene == -1) || ((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)))) { + Actor_MarkForDeath(&this->actor); + return; + } + + switch (ELFMSG6_GET_F0(&this->actor)) { + case 0: + if (gSaveContext.save.inventory.items[ITEM_HOOKSHOT] != ITEM_HOOKSHOT) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + + case 1: + if (gSaveContext.save.weekEventReg[83] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } + break; + + case 2: + if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (gSaveContext.save.weekEventReg[8] & 0x40) { + if (gSaveContext.save.weekEventReg[88] & 0x20) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x25B; + } else { + if (!(gSaveContext.save.weekEventReg[74] & 0x20) || (gSaveContext.save.weekEventReg[79] & 0x10)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x224; + } + this->actionFunc = func_80BA1CF8; + break; + + case 3: + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && + Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80BA2048; + this->actor.textId = 0x24D; + break; + + case 4: + this->actionFunc = func_80BA215C; + this->actor.textId = 0x255; + break; + + case 5: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25E; + break; + + case 6: + this->actionFunc = func_80BA21C4; + this->actor.textId = 0x25F; + break; + + default: + this->actionFunc = func_80BA2038; + break; + } +} + +void ElfMsg6_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +s32 func_80BA1C00(ElfMsg6* this) { + return (this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && + ((this->actor.playerHeightRel >= 0.0f) && (this->actor.playerHeightRel < (100.0f * this->actor.scale.y))); +} + +void func_80BA1C88(ElfMsg6* this, GlobalContext* globalCtx, s16 arg2) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor != NULL) { + player->tatlTextId = arg2; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1CF8(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x224: + gSaveContext.save.weekEventReg[79] |= 0x10; + break; + + case 0x25B: + gSaveContext.save.weekEventReg[88] |= 0x20; + break; + } + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->actor.textId == 0x224) && (gSaveContext.save.weekEventReg[8] & 0x40)) { + this->actor.textId = 0x25B; + } else if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnElf* sp20 = (EnElf*)player->tatlActor; + + if (player->tatlActor == NULL) { + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + switch (this->actor.textId) { + case 0x216: + gSaveContext.save.weekEventReg[31] |= 4; + break; + + case 0x231: + gSaveContext.save.weekEventReg[31] |= 1; + break; + + case 0x232: + gSaveContext.save.weekEventReg[31] |= 2; + break; + + case 0x233: + gSaveContext.save.weekEventReg[80] |= 4; + break; + } + func_80BA165C(); + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { + player->tatlTextId = -this->actor.textId; + ActorCutscene_SetIntentToPlay(0x7C); + sp20->elfMsg = &this->actor; + if (this->actor.cutscene == -1) { + this->actor.cutscene = 0x7C; + } + } +} + +void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { + if (((ELFMSG6_GET_F0(&this->actor)) == 1) && (gSaveContext.save.weekEventReg[83] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, NULL); + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80BA2038(ElfMsg6* this, GlobalContext* globalCtx) { +} + +void func_80BA2048(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, 0x24D); + } +} + +void func_80BA215C(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, -this->actor.textId); + } +} + +void func_80BA21C4(ElfMsg6* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnElf* sp20 = (EnElf*)GET_PLAYER(globalCtx)->tatlActor; + + sp20->unk_264 |= 0x20; + if (ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); + } + Actor_MarkForDeath(&this->actor); + return; + } + + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || + CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80BA1C00(this)) { + func_80BA1C88(this, globalCtx, this->actor.textId); + } +} + +void ElfMsg6_Update(Actor* thisx, GlobalContext* globalCtx) { + ElfMsg6* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h index 05713b146..78f970de0 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h @@ -7,6 +7,10 @@ struct ElfMsg6; typedef void (*ElfMsg6ActionFunc)(struct ElfMsg6*, GlobalContext*); +#define ELFMSG6_GET_F(thisx) ((thisx)->params & 0xF) +#define ELFMSG6_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define ELFMSG6_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9) + typedef struct ElfMsg6 { /* 0x0000 */ Actor actor; /* 0x0144 */ ElfMsg6ActionFunc actionFunc; 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 19a2aaf2d..be25dec24 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -5,8 +5,9 @@ */ #include "z_en_ah.h" +#include "objects/object_ah/object_ah.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAh*)thisx) @@ -18,7 +19,19 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BD36B8(EnAh* this, GlobalContext* globalCtx); void func_80BD3768(EnAh* this, GlobalContext* globalCtx); -#if 0 +s32 D_80BD3DB0[] = { + 0x0A00611D, 0x0C000303, 0x0400010C, 0x00021102, 0x15001700, 0x08003220, 0x03040001, + 0x05040003, 0x050A0010, 0x120C0003, 0x0D021200, 0x06000105, 0x0E120006, 0x00020505, +}; + +s32 D_80BD3DE8[] = { 0x0E28FF0C, 0x10000000 }; + +s32 D_80BD3DF0[] = { 0x0E29000C, 0x10000000 }; + +s32 D_80BD3DF8[] = { 0x00330100, 0x050E28FE, 0x0C100E28, -0x03F3F000 }; + +s32 D_80BD3E08[] = { 0x0E28FD0C, 0x0F29540C, 0x10000000 }; + const ActorInit En_Ah_InitVars = { ACTOR_EN_AH, ACTORCAT_NPC, @@ -31,75 +44,576 @@ const ActorInit En_Ah_InitVars = { (ActorFunc)EnAh_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD3E34 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 68, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BD3E60 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_ah_Anim_001860, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_002280, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_ah_Anim_000968, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_ah_Anim_000DDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_80BD3E34; -extern CollisionCheckInfoInit2 D_80BD3E60; +s16 D_80BD3EBC[] = { 0, 0, 1, 0 }; -extern UNK_TYPE D_06009E70; +PosRot D_80BD3EC4 = { { 100.0f, 0.0f, 67.0f }, { 0, 0x349C, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2A30.s") +PosRot D_80BD3ED8 = { { 855.0f, 260.0f, 31.0f }, { 0, 0x7FF8, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2AE0.s") +PosRot D_80BD3EEC = { { -395.0f, 210.0f, -162.0f }, { 0, 0xBE98, 0 } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2B0C.s") +Vec3f D_80BD3F00 = { 1000.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BA4.s") +TexturePtr D_80BD3F0C[] = { object_ah_Tex_008D70, object_ah_Tex_009570 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2BE8.s") +TexturePtr D_80BD3F14[] = { + object_ah_Tex_006D70, object_ah_Tex_007570, object_ah_Tex_007D70, object_ah_Tex_007570, object_ah_Tex_008570, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2C6C.s") +s32 func_80BD2A30(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* tempActor; + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DA0.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2DC8.s") + if ((foundActor == NULL) || (((EnAh*)foundActor != this) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD2FD0.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD30C0.s") + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3118.s") +void func_80BD2AE0(EnAh* this) { + this->skelAnime.playSpeed = this->unk_2DC; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3198.s") +s32 func_80BD2B0C(EnAh* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3294.s") + if ((arg1 == 0) || (arg1 == 1)) { + if ((this->unk_300 != 0) && (this->unk_300 != 1)) { + phi_v1 = true; + } + } else if (arg1 != this->unk_300) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3320.s") + if (phi_v1) { + this->unk_300 = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_2DC = this->skelAnime.playSpeed; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3374.s") +void func_80BD2BA4(EnAh* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD33FC.s") +s32 func_80BD2BE8(EnAh* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3484.s") + if (this->unk_2D8 & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + ret = true; + this->unk_2D8 |= 8; + this->actionFunc = func_80BD3768; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3548.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD35BC.s") +void func_80BD2C6C(EnAh* this) { + s32 phi_a3 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3658.s") + if (this->unk_2D8 & 0x40) { + if (DECR(this->unk_2F8) == 0) { + switch (this->unk_2F6) { + case 1: + case 2: + if ((this->unk_2FA == 4) || (this->unk_2FA == 2)) { + phi_a3 = true; + this->unk_2FA = 4; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD36B8.s") + if (!phi_a3 && (this->unk_2FA == 4)) { + this->unk_2FA = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3768.s") + if (!phi_a3) { + this->unk_2FA++; + if (this->unk_2FA >= 4) { + if (this->unk_2F6 == 0) { + this->unk_2F8 = Rand_S16Offset(30, 30); + } else { + this->unk_2F8 = 8; + } + this->unk_2FA = 0; + phi_a3 = true; + } + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Init.s") + if (phi_a3 == true) { + this->unk_2FC = D_80BD3EBC[this->unk_2F6]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Destroy.s") +Actor* func_80BD2DA0(EnAh* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Update.s") + if (this->unk_1DC == 3) { + actor = this->actor.child; + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AA8.s") +void func_80BD2DC8(EnAh* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/func_80BD3AF8.s") + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ah/EnAh_Draw.s") + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + + Math_ApproachS(&this->unk_2EE, (sp32 - this->unk_2F2) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2EE = CLAMP(this->unk_2EE, -0x1FFE, 0x1FFE); + + Math_ApproachS(&this->unk_2F2, (sp32 - this->unk_2EE) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_2F2 = CLAMP(this->unk_2F2, -0x1C70, 0x1C70); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_1E4->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_1E4)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->focus.pos); + } + + Math_ApproachS(&this->unk_2EC, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2F0, 4, 0x2AA8); + this->unk_2EC = CLAMP(this->unk_2EC, -0x1554, 0x1554); + + Math_ApproachS(&this->unk_2F0, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_2EC, 4, 0x2AA8); + this->unk_2F0 = CLAMP(this->unk_2F0, -0xE38, 0xE38); +} + +void func_80BD2FD0(EnAh* this, GlobalContext* globalCtx) { + this->unk_1E4 = func_80BD2DA0(this, globalCtx); + + if ((this->unk_2D8 & 8) && (this->unk_1E4 != NULL)) { + if (DECR(this->unk_2F4) == 0) { + func_80BD2DC8(this); + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2D8 &= ~0x80; + this->unk_2D8 |= 0x20; + return; + } + } + + if (this->unk_2D8 & 0x20) { + this->unk_2D8 &= ~0x20; + this->unk_2EC = 0; + this->unk_2EE = 0; + this->unk_2F0 = 0; + this->unk_2F2 = 0; + this->unk_2F4 = 20; + } else if (DECR(this->unk_2F4) == 0) { + this->unk_2D8 |= 0x80; + } +} + +s32 func_80BD30C0(EnAh* this, GlobalContext* globalCtx) { + switch (this->unk_1DC) { + case 1: + func_80BD2B0C(this, 0); + break; + + case 2: + func_80BD2B0C(this, 4); + break; + } + return false; +} + +void func_80BD3118(EnAh* this, GlobalContext* globalCtx) { + if (this->unk_2FE == 0) { + func_80BD2B0C(this, 2); + this->unk_2FE++; + } else if ((this->unk_2FE == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BD2B0C(this, 3); + this->unk_2FE++; + } +} + +s32 func_80BD3198(EnAh* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.currentTextId; + + if (player->stateFlags1 & 0x40) { + if (this->unk_2DA != temp) { + if (temp == 0x2954) { + this->unk_18C = func_80BD3118; + this->unk_2FE = 0; + } + + switch (temp) { + case 0x28FD: + this->unk_2F6 = 1; + this->unk_2F8 = 8; + break; + + case 0x2954: + this->unk_2F6 = 2; + this->unk_2F8 = 8; + break; + } + } + this->unk_2DA = temp; + this->unk_2D8 |= 0x100; + } else if (this->unk_2D8 & 0x100) { + this->unk_18C = NULL; + this->unk_2DA = 0; + this->unk_2D8 &= ~0x100; + this->unk_2F6 = 0; + this->unk_2F8 = 4; + func_80BD30C0(this, globalCtx); + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return false; +} + +s32* func_80BD3294(EnAh* this, GlobalContext* globalCtx) { + s32 mask = Player_GetMask(globalCtx); + + if (PLAYER_MASK_KAFEIS_MASK == mask) { + return D_80BD3E08; + } + + switch (this->unk_1DC) { + case 1: + if (gSaveContext.save.day == 2) { + return D_80BD3DF0; + } + return D_80BD3DE8; + + case 2: + return D_80BD3DF8; + } + return NULL; +} + +s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + s32 pad; + s32 ret = false; + Actor* temp_v0 = func_80BD2A30(this, globalCtx, actorCat, actorId); + + if (temp_v0 != NULL) { + this->actor.child = temp_v0; + ret = true; + } + return ret; +} + +s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EC4.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 0); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= 0x40; + return true; +} + +s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3ED8.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + func_80BD2B0C(this, 4); + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 |= (0x40 | 0x10); + return true; +} + +s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + + if (func_80BD3320(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN)) { + if (sREG(81) == 0) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EEC.pos); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BD3EEC.rot); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + } + func_80BD2B0C(this, 4); + this->unk_2D8 |= (0x40 | 0x8); + this->unk_2D8 |= 0x10; + this->unk_2D8 |= 0x80; + this->actor.gravity = 0.0f; + ret = true; + } + return ret; +} + +s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + this->unk_2D8 = 0; + + switch (arg2->unk0) { + default: + ret = false; + break; + + case 1: + ret = func_80BD3374(this, globalCtx, arg2); + break; + + case 2: + ret = func_80BD33FC(this, globalCtx, arg2); + break; + + case 3: + ret = func_80BD3484(this, globalCtx, arg2); + break; + } + return ret; +} + +s32 func_80BD35BC(EnAh* this, GlobalContext* globalCtx) { + s16 temp; + s16 temp2; + + switch (this->unk_1DC) { + default: + return false; + + case 2: + temp = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + temp2 = ABS_ALT(temp); + if (temp2 < 0x3800) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + } else { + SubS_UpdateFlags(&this->unk_2D8, 0, 7); + } + return false; + } +} + +void func_80BD3658(EnAh* this, GlobalContext* globalCtx) { + if ((this->unk_1DC == 1) || (this->unk_1DC == 2) || (this->unk_1DC == 3)) { + func_80BD35BC(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { + s32 pad; + struct_80133038_arg2 sp18; + + if (!func_80133038(globalCtx, D_80BD3DB0, &sp18) || + ((this->unk_1DC != sp18.unk0) && !func_80BD3548(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1DC = sp18.unk0; + func_80BD3658(this, globalCtx); +} + +void func_80BD3768(EnAh* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (func_8010BF58(&this->actor, globalCtx, func_80BD3294(this, globalCtx), NULL, &this->unk_1E0)) { + SubS_UpdateFlags(&this->unk_2D8, 3, 7); + this->unk_2D8 &= ~8; + this->unk_2D8 |= 0x80; + this->unk_2F4 = 20; + this->unk_1E0 = 0; + this->actionFunc = func_80BD36B8; + } else if (this->unk_1DC != 2) { + if (this->unk_1E4 != NULL) { + Math_Vec3f_Copy(&sp40, &this->unk_1E4->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } + } +} + +void EnAh_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (func_80BD2A30(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AH)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ah_Skel_009E70, NULL, this->jointTable, this->morphTable, + 17); + this->unk_300 = -1; + func_80BD2B0C(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); + this->unk_1DC = 0; + this->unk_2D8 = 0; + + this->actionFunc = func_80BD36B8; + this->actionFunc(this, globalCtx); +} + +void EnAh_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnAh_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + f32 radius; + f32 height; + + func_80BD2BE8(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1DC != 0) { + func_80BD3198(this, globalCtx); + func_80BD2AE0(this); + func_80BD2C6C(this); + func_80BD2FD0(this, globalCtx); + radius = this->collider.dim.radius + 60; + height = this->collider.dim.height + 10; + + func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2D8 & 7); + if (!(this->unk_2D8 & 0x10)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_80BD2BA4(this, globalCtx); + } +} + +void func_80BD3AA8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnAh* this = THIS; + + if (limbIndex == 7) { + Matrix_MultiplyVector3fByState(&D_80BD3F00, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void func_80BD3AF8(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAh* this = THIS; + s32 phi_v1; + s32 phi_v0; + + if (!(this->unk_2D8 & 0x80)) { + if (this->unk_2D8 & 0x20) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + phi_v1 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == 7) { + func_8013AD9C(BINANG_ADD(this->unk_2EC + this->unk_2F0, 0x4000), + BINANG_ADD(this->unk_2EE + this->unk_2F2 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_StatePush(); + } else if (limbIndex == 2) { + func_8013AD9C(BINANG_ADD(this->unk_2F0, 0x4000), BINANG_ADD(this->unk_2F2 + this->actor.shape.rot.y, 0x4000), + &this->unk_1E8[1], &this->unk_200[1], phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[1].x, this->unk_1E8[1].y, this->unk_1E8[1].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[1].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[1].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[1].z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAh* this = THIS; + + if (this->unk_1DC != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BD3F14[this->unk_2FA])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80BD3F0C[this->unk_2FC])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80BD3AA8, func_80BD3AF8, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.h b/src/overlays/actors/ovl_En_Ah/z_en_ah.h index 13dd73027..85263e04b 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.h +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.h @@ -6,12 +6,36 @@ struct EnAh; typedef void (*EnAhActionFunc)(struct EnAh*, GlobalContext*); +typedef void (*EnAhUnkFunc)(struct EnAh*, GlobalContext*); typedef struct EnAh { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnAhActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x178]; + /* 0x018C */ EnAhUnkFunc unk_18C; + /* 0x0190 */ ColliderCylinder collider; + /* 0x01DC */ u8 unk_1DC; + /* 0x01E0 */ s32 unk_1E0; + /* 0x01E4 */ Actor* unk_1E4; + /* 0x01E8 */ Vec3f unk_1E8[2]; + /* 0x0200 */ Vec3s unk_200[2]; + /* 0x020C */ Vec3s jointTable[17]; + /* 0x0272 */ Vec3s morphTable[17]; + /* 0x02D8 */ u16 unk_2D8; + /* 0x02DA */ u16 unk_2DA; + /* 0x02DC */ f32 unk_2DC; + /* 0x02E0 */ UNK_TYPE1 unk2E0[0xC]; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ s16 unk_2F0; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ s32 unk_300; } EnAh; // size = 0x304 extern const ActorInit En_Ah_InitVars; 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 07353d3bd..1c48235ae 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -7,7 +7,7 @@ #include "z_en_akindonuts.h" #include "objects/object_dnt/object_dnt.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAkindonuts*)thisx) @@ -62,19 +62,30 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static u16 D_80BF048C[] = { @@ -246,16 +257,16 @@ void func_80BED090(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.save.weekEventReg[63] |= 0x8; + gSaveContext.save.weekEventReg[63] |= 8; gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } else if (player->transformation == PLAYER_FORM_ZORA) { - gSaveContext.save.weekEventReg[63] &= (u8)~0x8; + gSaveContext.save.weekEventReg[63] &= (u8)~8; gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_GORON) { - gSaveContext.save.weekEventReg[63] |= 0x8; + gSaveContext.save.weekEventReg[63] |= 8; gSaveContext.save.weekEventReg[63] |= 0x10; } else if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.save.weekEventReg[63] &= (u8)~0x8; + gSaveContext.save.weekEventReg[63] &= (u8)~8; gSaveContext.save.weekEventReg[63] &= (u8)~0x10; } } @@ -264,19 +275,19 @@ s32 func_80BED140(GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (player->transformation == PLAYER_FORM_DEKU) { - if ((gSaveContext.save.weekEventReg[63] & 0x8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_ZORA) { - if (!(gSaveContext.save.weekEventReg[63] & 0x8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.save.weekEventReg[63] & 0x8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { + if ((gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (!(gSaveContext.save.weekEventReg[63] & 0x8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { return true; } } @@ -303,11 +314,11 @@ s32 func_80BED208(EnAkindonuts* this) { } s32 func_80BED27C(EnAkindonuts* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return 2; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) < 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) < 2) { return 0; } @@ -444,7 +455,7 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -515,7 +526,7 @@ void func_80BED680(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -621,7 +632,7 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -630,7 +641,7 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { switch (this->unk_33C) { case 0: if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[62] & 2)) { - gSaveContext.save.weekEventReg[62] |= 0x2; + gSaveContext.save.weekEventReg[62] |= 2; this->unk_33C = 0x15F0; break; } @@ -693,7 +704,7 @@ void func_80BEDB88(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -785,7 +796,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x160D; - gSaveContext.save.weekEventReg[62] |= 0x4; + gSaveContext.save.weekEventReg[62] |= 4; this->unk_32C |= 0x20; break; @@ -794,7 +805,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -861,7 +872,7 @@ void func_80BEE070(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -955,7 +966,7 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -1022,7 +1033,7 @@ void func_80BEE530(EnAkindonuts* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { @@ -1143,7 +1154,7 @@ void func_80BEE938(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); s16 phi_v0; Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -1166,7 +1177,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BEEDC0; this->unk_338 = 3; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); return; } } @@ -1176,19 +1187,19 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_338 = 17; this->collider.dim.height = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); - func_8013BC6C(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 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); - func_8013BC6C(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); } else if (this->unk_338 == 17) { phi_v0 = DECR(this->unk_33A); if (phi_v0 == 0) { this->unk_33A = Rand_ZeroOne() * 10.0f; this->unk_338 = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); } } else if (this->unk_338 == 16) { phi_v0 = DECR(this->unk_33A); @@ -1196,7 +1207,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_33A = Rand_S16Offset(40, 40); this->unk_338 = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); } } } @@ -1205,7 +1216,7 @@ void func_80BEEB20(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEEDC0(EnAkindonuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BEEE10; - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); } } @@ -1223,7 +1234,7 @@ void func_80BEEE10(EnAkindonuts* this, GlobalContext* globalCtx) { } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_338 = 4; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BEEB20; } } @@ -1232,7 +1243,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1241,20 +1252,20 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80BEEE10; } else if (this->unk_32C & 0x20) { this->unk_32C &= ~0x20; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_32C &= ~0x4; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_338 = 8; this->unk_33C = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); this->actionFunc = func_80BEF518; } else { this->unk_2DC(this, globalCtx); } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: this->unk_32C |= 0x8; @@ -1274,7 +1285,7 @@ void func_80BEEFA8(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_33C = 0; @@ -1285,21 +1296,21 @@ void func_80BEF18C(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF20C(EnAkindonuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 sp24 = this->skelAnime.curFrame; - s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp22 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); if (this->unk_356 == 40) { this->unk_338 = 5; - func_8013BC6C(&this->skelAnime, sAnimations, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 5); } this->unk_356++; if ((sp24 == sp22) && (this->unk_338 == 5)) { this->unk_338 = 6; - func_8013BC6C(&this->skelAnime, sAnimations, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_32C & 1) { this->unk_32C &= ~0x1; globalCtx->msgCtx.msgMode = 0x43; @@ -1330,7 +1341,7 @@ void func_80BEF360(EnAkindonuts* this, GlobalContext* globalCtx) { } void func_80BEF450(EnAkindonuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->actionFunc = func_80BEF4B8; } @@ -1347,7 +1358,7 @@ void func_80BEF4B8(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp24 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); switch (sp26) { case 10: @@ -1421,7 +1432,7 @@ void func_80BEF518(EnAkindonuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_33E = 3; this->unk_338 = 19; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_32C &= ~2; this->unk_32C |= 0x80; @@ -1454,7 +1465,7 @@ void func_80BEF770(EnAkindonuts* this, GlobalContext* globalCtx) { void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { Vec3f sp34; s16 sp32 = this->skelAnime.curFrame; - s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animationSeg->common); + s16 sp30 = Animation_GetLastFrame(&sAnimations[this->unk_338].animation->common); if (sp32 == sp30) { Math_SmoothStepToS(&this->unk_362, 0x1C71, 3, 0x100, 0); @@ -1480,7 +1491,7 @@ void func_80BEF83C(EnAkindonuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 0.3f; this->unk_338 = 9; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80BEF9F0; } @@ -1499,7 +1510,7 @@ void func_80BEF9F0(EnAkindonuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 200.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_338 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_338); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_338); if (ENAKINDONUTS_GET_3(&this->actor) == ENAKINDONUTS_3_2) { this->unk_32C |= 0x2; } @@ -1595,14 +1606,14 @@ void EnAkindonuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; if (!ENAKINDONUTS_GET_4(&this->actor)) { - this->path = func_8013D648(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENAKINDONUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); return; } } - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->unk_32C |= 0x2; this->unk_32C |= 0x4; this->unk_338 = 4; diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 26961e4c7..e86f3971d 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -5,8 +5,9 @@ */ #include "z_en_al.h" +#include "objects/object_al/object_al.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAl*)thisx) @@ -18,7 +19,60 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx); void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx); -#if 0 +s32 D_80BDFC70[] = { + 0x0C00030D, 0x02120006, 0x0001050E, 0x12000600, 0x02020800, 0x0A002F02, 0x0A000A37, + 0x23020A37, 0x0B2D0D02, 0x0B2D1400, 0x01050E0B, 0x2D140001, 0x0C000206, 0x0E0A370B, + 0x2D010E0A, 0x370B2D03, 0x0E0A000A, 0x37010400, 0x01000000, +}; + +s32 D_80BDFCBC[] = { + 0x09000017, 0x0E27A50C, 0x09000018, 0x0E27A60C, 0x09000017, 0x0E27A70C, 0x09000018, 0x0E27A80C, + 0x09000017, 0x0E27A90C, 0x09000018, 0x0E27AA0C, 0x09000017, 0x0E27AB0C, 0x09000018, 0x0E27AC0C, + 0x09000017, 0x0E27AD2D, 0x000B2D00, 0x080C1159, 0x08090000, 0x10000000, +}; + +s32 D_80BDFD14[] = { + 0x00562000, 0xA2090000, 0x170E2AA6, 0x0C090000, 0x180E2AA7, 0x0C090000, 0x170E2AA8, 0x0C090000, + 0x180E2AA9, 0x0C090000, 0x170E2AAA, 0x0C090000, 0x180E2AAB, 0x0C090000, 0x170E2AAC, 0x0C090000, + 0x170E2AAD, 0x0C0F2AAE, 0x0C090000, 0x180E2AAF, 0x0C090000, 0x170E2AB0, 0x0C090000, 0x170E2AB1, + 0x0C090000, 0x180E2AB2, 0x0C090000, 0x170E2AB3, 0x0C090000, 0x180E2AB4, 0x0C090000, 0x170E2AB5, + 0x0C090000, 0x180E2AB6, 0x0C090000, 0x170E2AB7, 0x0C090000, 0x180E2AB8, 0x2D00082D, 0x00092D00, + 0x0A0C1156, 0x20121009, 0x0000170E, 0x2AEA0C09, 0x0000180E, 0x2AEB0C09, 0x00001210, +}; + +s32 D_80BDFDD0[] = { 0x005C0800, 0x0B0E2AE5, 0x2D000811, 0x5C080C10, 0x0E2AE62D, 0x00080C10 }; + +s32 D_80BDFDE8[] = { 0x0900000E, 0x2B192D00, 0x080C1509, 0x00001210 }; + +s32 D_80BDFDF8[] = { + 0x09000000, 0x39040071, 0x0E2B1A0C, 0x0F00FF1E, 0x00330018, 0x000D0000, 0x0E2B1B2D, 0x00080C15, 0x09000012, + 0x102C2B1C, 0x0C2F0000, 0x0C19FFDC, 0x2C2B1D0C, 0x2F00000C, 0x0F2B1E0C, 0x0F2B1F0C, 0x122A002E, 0x00390800, + 0x1306006F, 0x00001300, 0x6F2F0000, 0x2E2D0023, 0x0C07000C, 0x06000500, 0x00130005, 0x0C070000, 0x0E2B202D, + 0x00080C16, 0x11390411, 0x390819FF, 0xA60E2B3C, 0x2D00080C, 0x19FF9C00, +}; + +s32 D_80BDFE7C[] = { 0x0E2A9C2D, 0x00080C10 }; + +s32 D_80BDFE84[] = { 0x0E2A9D2D, 0x00080C10 }; + +s32 D_80BDFE8C[] = { + 0x00390200, 0x0F0E2A9E, 0x0C0F2A9F, 0x0C0F2AA0, 0x0C190004, 0x0E2AA00C, 0x05000000, 0x1A001A30, 0x0E2AA20C, + 0x1206008F, 0x00001300, 0x8F2F0000, 0x2E2D002C, 0x2D00080C, 0x10310E2A, 0xA12D0008, 0x0C113902, 0x10000000, +}; + +s32 D_80BDFED4[] = { + 0x0900002C, 0x2B1D0C2F, 0x00000C0F, 0x2B1E0C0F, 0x2B1F0C12, 0x2A002E00, 0x39080013, + 0x06006F00, 0x0013006F, 0x2F00002E, 0x2D00230C, 0x07000C06, 0x00050000, 0x1300050C, + 0x0700000E, 0x2B202D00, 0x080C1611, 0x39041139, 0x08150900, 0x00121000, +}; + +s32 D_80BDFF24[] = { + 0x0900002C, 0x2B1C0C0F, 0x00FF1E00, 0x33000DFF, 0xF000000E, 0x2B1B2D00, 0x080C1509, 0x00001210, + 0x2C2B1D0C, 0x2F00000C, 0x0F2B1E0C, 0x0F2B1F0C, 0x122A002E, 0x00390800, 0x1306006F, 0x00001300, + 0x6F2F0000, 0x2E2D0023, 0x0C07000C, 0x06000500, 0x00130005, 0x0C070000, 0x0E2B202D, 0x00080C16, + 0x11390411, 0x390819FF, 0xB10E2B3C, 0x2D00080C, 0x19FFA700, +}; + const ActorInit En_Al_InitVars = { ACTOR_EN_AL, ACTORCAT_NPC, @@ -31,87 +85,830 @@ const ActorInit En_Al_InitVars = { (ActorFunc)EnAl_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDFFB8 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BDFFE4 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_al_Anim_000C54, 1.0f, 0, -1, 0, -4 }, { &object_al_Anim_00DBE0, 1.0f, 0, -1, 0, 0 }, + { &object_al_Anim_00DBE0, 1.0f, 0, -1, 0, -4 }, { &object_al_Anim_00ACA0, 1.0f, 0, -1, 2, 0 }, + { &object_al_Anim_00ACA0, -1.0f, 0, -1, 2, 0 }, { &object_al_Anim_00CA28, 1.0f, 0, -1, 0, -4 }, + { &object_al_Anim_00BCA4, 1.0f, 0, -1, 2, 0 }, { &object_al_Anim_00A764, 1.0f, 0, -1, 0, -4 }, +}; -extern ColliderCylinderInit D_80BDFFB8; -extern CollisionCheckInfoInit2 D_80BDFFE4; +Vec3f D_80BE0070 = { 1000.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0600A0D8; +Gfx* D_80BE007C[] = { + object_al_DL_006598, object_al_DL_005920, object_al_DL_005878, + object_al_DL_0057D0, object_al_DL_005728, object_al_DL_005680, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE1A0.s") +Actor* func_80BDE1A0(EnAl* this, GlobalContext* globalCtx, u8 arg0, s16 arg1) { + Actor* foundActor = NULL; + Actor* temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE250.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, arg0, arg1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE27C.s") + if (foundActor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE318.s") + if ((this != (EnAl*)foundActor) && (foundActor->update != NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE384.s") + temp = foundActor->next; + if (temp == NULL) { + foundActor = NULL; + break; + } + foundActor = temp; + } + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE408.s") +void func_80BDE250(EnAl* this) { + this->skelAnime.playSpeed = this->unk_4C8; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE484.s") +s32 func_80BDE27C(EnAl* this, s32 arg1) { + s32 phi_v1 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE4E0.s") + if ((arg1 == 1) || (arg1 == 2)) { + if ((this->unk_4F8 != 1) && (this->unk_4F8 != 2)) { + phi_v1 = true; + } + } else if (arg1 != this->unk_4F8) { + phi_v1 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE678.s") + if (phi_v1) { + this->unk_4F8 = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_4C8 = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE7FC.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDE92C.s") +void func_80BDE318(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEA14.s") + Collider_UpdateCylinder(&this->actor, &this->unk_310); + temp = this->actor.focus.pos.y - this->actor.world.pos.y; + this->unk_310.dim.height = temp; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->unk_310.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEABC.s") +Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEC2C.s") + switch (this->unk_35C) { + case 2: + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { + actor = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_PM); + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDED20.s") + case 3: + actor = this->unk_368; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEE5C.s") + default: + actor = &GET_PLAYER(globalCtx)->actor; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEF3C.s") + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDEFE4.s") +s32 func_80BDE408(EnAl* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF064.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(arg1); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(arg1); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF244.s") +s16 func_80BDE484(EnAl* this, s32 arg1) { + s16 cs = this->actor.cutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF308.s") + for (i = 0; i < arg1; i++) { + cs = ActorCutscene_GetAdditionalCutscene(cs); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF390.s") + return cs; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF414.s") +s32 func_80BDE4E0(EnAl* this, s16* arg1, s16 arg2) { + s32 ret = false; + s16 sp42; + Vec3f sp34; + Vec3f sp28; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF568.s") + if ((this->unk_368 == NULL) || (this->unk_368->update == NULL)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF578.s") + if (arg2 == *arg1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_80BDE27C(this, 3); + this->unk_4E8 = 0; + (*arg1)++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF5E8.s") + if ((arg2 + 1) == *arg1) { + Math_Vec3f_Copy(&sp28, &this->unk_368->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp42 = Math_Vec3f_Yaw(&sp34, &sp28); + temp = sp42 / 364; + this->unk_4E8++; + if ((temp != (this->actor.world.rot.y / 364)) && (this->unk_4E8 < 20)) { + Math_ApproachS(&this->actor.world.rot.y, sp42, 3, 0x2AA8); + } else { + func_80BDE27C(this, 5); + this->actor.world.rot.y = sp42; + this->unk_4E8 = 0; + (*arg1)++; + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF6C4.s") +s32 func_80BDE678(EnAl* this, s16* arg1, s16 arg2) { + s32 ret = false; + s16 sp22; + s32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Init.s") + if ((this->unk_368 == NULL) || (this->unk_368->update == NULL)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Destroy.s") + if (arg2 == *arg1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); + func_80BDE27C(this, 4); + this->unk_4E8 = 0; + (*arg1)++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Update.s") + if ((arg2 + 1) == *arg1) { + sp22 = this->actor.home.rot.y; + temp = sp22 / 364; + this->unk_4E8++; + if ((temp != (this->actor.world.rot.y / 364)) && (this->unk_4E8 < 20)) { + Math_ApproachS(&this->actor.world.rot.y, sp22, 3, 0x2AA8); + } else { + func_80BDE27C(this, 2); + this->actor.world.rot.y = sp22; + this->unk_4E8 = 0; + (*arg1)++; + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF914.s") +s32 func_80BDE7FC(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp2A = func_80BDE484(this, 0); + s32 pad2; + s32 sp20 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDF950.s") + switch (this->unk_4E6) { + case 0: + if (!func_80BDE408(this, sp2A)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/func_80BDFA34.s") + case 2: + case 4: + case 6: + case 8: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); + } + this->unk_4E6++; + sp20 = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Al/EnAl_Draw.s") + case 1: + case 3: + case 5: + case 7: + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + this->unk_4E6++; + sp20 = true; + break; + + case 9: + ActorCutscene_Stop(sp2A); + this->unk_4E6++; + sp20 = true; + break; + } + return sp20; +} + +s32 func_80BDE92C(EnAl* this, GlobalContext* globalCtx) { + s32 pad[2]; + Actor* sp1C = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + + if ((sp1C == NULL) || (sp1C->update == NULL) || (temp_v0 == NULL) || (temp_v0->update == NULL)) { + this->unk_4E6++; + return true; + } + + switch (this->unk_4E6) { + case 0: + case 1: + case 3: + case 5: + case 8: + case 10: + case 11: + case 13: + case 15: + case 17: + this->actor.child = sp1C; + this->unk_4E6++; + break; + + case 7: + case 9: + case 12: + this->actor.child = temp_v0; + this->unk_4E6++; + break; + + case 2: + case 4: + case 6: + case 14: + case 16: + this->unk_4E6++; + break; + + default: + this->unk_4E6++; + break; + } + return true; +} + +s32 func_80BDEA14(EnAl* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp18 = false; + + switch (this->unk_4E6) { + case 0: + case 1: + if ((gSaveContext.save.weekEventReg[75] & 2)) { + sp18 = true; + } else if (func_80BDE4E0(this, &this->unk_4E6, 0)) { + sp18 = true; + } + break; + + case 2: + case 3: + if (func_80BDE678(this, &this->unk_4E6, 2)) { + sp18 = true; + } + break; + } + return sp18; +} + +s32* func_80BDEABC(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_35C == 3) { + this->unk_4EC = func_80BDE92C; + return D_80BDFD14; + } + + switch (this->unk_35C) { + case 1: + if (player->transformation == PLAYER_FORM_DEKU) { + return D_80BDFDD0; + } + + if (INV_CONTENT(ITEM_MASK_KAFEIS_MASK) != ITEM_MASK_KAFEIS_MASK) { + return D_80BDFE8C; + } + + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + return D_80BDFE7C; + } + return D_80BDFE84; + + case 2: + if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { + this->unk_4EC = func_80BDE7FC; + return D_80BDFCBC; + } + + this->unk_4EC = func_80BDEA14; + if (Player_GetMask(globalCtx) != PLAYER_MASK_KAFEIS_MASK) { + return D_80BDFDE8; + } + + if (this->unk_4C2 & 0x800) { + return D_80BDFED4; + } + + if (this->unk_4C2 & 0x1000) { + return D_80BDFF24; + } + return D_80BDFDF8; + } + return NULL; +} + +s32 func_80BDEC2C(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = false; + + if ((this->unk_4C2 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_4C2 &= ~0x1800; + if (player->exchangeItemId == 0x33) { + this->unk_4C2 |= 0x800; + this->unk_4F4 = player->exchangeItemId; + } else if (player->exchangeItemId != 0) { + this->unk_4C2 |= 0x1000; + this->unk_4F4 = player->exchangeItemId; + } + SubS_UpdateFlags(&this->unk_4C2, 0, 7); + this->unk_4E6 = 0; + this->unk_4EC = 0; + this->actor.child = this->unk_368; + this->unk_360 = func_80BDEABC(this, globalCtx); + this->unk_4C2 |= 0x20; + this->actionFunc = func_80BDF6C4; + ret = true; + } + + return ret; +} + +void func_80BDED20(EnAl* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s32 pad2; + + Math_Vec3f_Copy(&sp40, &this->unk_368->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + + Math_ApproachS(&this->unk_4DE, Math_Vec3f_Yaw(&sp34, &sp40) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_4DE = CLAMP(this->unk_4DE, -0x1FFE, 0x1FFE); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_368->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_368)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_368->focus.pos); + } + + Math_ApproachS(&this->unk_4DC, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x2AA8); + this->unk_4DC = CLAMP(this->unk_4DC, -0x1554, 0x1554); +} + +void func_80BDEE5C(EnAl* this) { + if (this->unk_4C2 & 0x20) { + if ((this->unk_368 != NULL) && (this->unk_368->update != NULL)) { + if (DECR(this->unk_4E2) == 0) { + func_80BDED20(this); + this->unk_4C2 &= ~0x200; + this->unk_4C2 |= 0x80; + return; + } + } + } + + if (this->unk_4C2 & 0x80) { + this->unk_4C2 &= ~0x80; + this->unk_4DC = 0; + this->unk_4DE = 0; + this->unk_4E2 = 0x14; + } else if (DECR(this->unk_4E2) == 0) { + this->unk_4C2 |= 0x200; + } +} + +void func_80BDEF3C(EnAl* this, GlobalContext* globalCtx) { + if (this->unk_4E4 == 0) { + func_80BDE27C(this, 7); + this->unk_4C2 &= ~0x20; + this->unk_4C2 |= 0x200; + this->unk_4E4++; + } else if ((this->unk_4E4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BDE27C(this, 0); + this->unk_4C2 &= ~0x200; + this->unk_4C2 |= 0x20; + this->unk_4E4++; + } +} + +void func_80BDEFE4(EnAl* this, GlobalContext* globalCtx) { + if (this->unk_4E4 == 0) { + func_80BDE27C(this, 6); + this->unk_4E4 += 1; + } else if ((this->unk_4E4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80BDE27C(this, 5); + this->unk_4E4 += 1; + } +} + +s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 sp22 = globalCtx->msgCtx.currentTextId; + Actor* sp1C = func_80BDE1A0(this, globalCtx, 4, 0xA4); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, 4, 0x234); + + if (player->stateFlags1 & 0x40) { + this->unk_4C2 |= 0x400; + if (this->unk_4C4 != sp22) { + switch (sp22) { + case 0x2AA6: + case 0x2AAF: + case 0x2AB4: + if ((sp1C != NULL) && (sp1C->update != NULL)) { + this->unk_368 = sp1C; + } + break; + + case 0x2AAD: + case 0x2AB0: + if ((temp_v0 != NULL) && (temp_v0->update != NULL)) { + this->unk_368 = temp_v0; + } + break; + } + + switch (sp22) { + case 0x2AA1: + case 0x2AA2: + case 0x2AA7: + case 0x2AE6: + case 0x2AE8: + case 0x2AE9: + case 0x2AB4: + this->unk_18C = func_80BDEF3C; + this->unk_4E4 = 0; + break; + + case 0x27A6: + case 0x27A8: + case 0x27AA: + case 0x2B1E: + this->unk_18C = func_80BDEFE4; + this->unk_4E4 = 0; + break; + + case 0x2B19: + case 0x2B20: + case 0x2B3C: + func_80BDE27C(this, 5); + break; + } + } + this->unk_4C4 = sp22; + } else if (this->unk_4C2 & 0x400) { + this->unk_4C4 = 0; + this->unk_4C2 &= ~0x400; + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, globalCtx); + } + + return false; +} + +s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + Actor* sp20 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); + + if ((sp20 != NULL) && (sp20->update != NULL) && (temp_v0 != NULL) && (temp_v0->update != NULL)) { + func_80BDE27C(this, 0); + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + this->unk_368 = sp20; + this->unk_4C2 |= 0x20; + ret = true; + } + return ret; +} + +s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + + switch (arg2->unk0) { + case 1: + func_80BDE27C(this, 0); + break; + + case 2: + this->unk_4F0 = 0; + this->unk_4EA = 0; + func_80BDE27C(this, 2); + break; + } + return true; +} + +s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + this->actor.flags |= ACTOR_FLAG_1; + this->actor.targetMode = 0; + this->unk_4F0 = 0; + this->unk_4C2 = 0; + this->unk_4D4 = 40.0f; + + switch (arg2->unk0) { + case 3: + ret = func_80BDF244(this, globalCtx, arg2); + break; + + case 1: + case 2: + ret = func_80BDF308(this, globalCtx, arg2); + break; + + default: + ret = false; + break; + } + return ret; +} + +void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { + s16 temp_v0; + + switch (this->unk_4EA) { + case 0: + case 1: + if (!(gSaveContext.save.weekEventReg[89] & 8)) { + if (gSaveContext.save.weekEventReg[85] & 0x80) { + func_80BDE4E0(this, &this->unk_4EA, 0); + } + } + break; + + case 2: + if (gSaveContext.save.weekEventReg[89] & 8) { + this->unk_4EA++; + } + break; + + case 3: + case 4: + func_80BDE678(this, &this->unk_4EA, 3); + break; + } + + temp_v0 = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + if (((this->unk_4EA == 0) && (ABS_ALT(temp_v0) >= 0x5800)) || + ((this->unk_4EA == 5) && (ABS_ALT(temp_v0) >= 0x5800)) || (this->unk_4EA == 2)) { + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + } else { + SubS_UpdateFlags(&this->unk_4C2, 0, 7); + } +} + +void func_80BDF568(EnAl* this, GlobalContext* globalCtx) { +} + +void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { + switch (this->unk_35C) { + case 1: + case 3: + func_80BDF568(this, globalCtx); + break; + + case 2: + func_80BDF414(this, globalCtx); + break; + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { + u32* unk14 = &gSaveContext.save.daySpeed; + struct_80133038_arg2 sp20; + + this->unk_4E0 = REG(15) + *unk14; + if (!func_80133038(globalCtx, D_80BDFC70, &sp20) || + ((this->unk_35C != sp20.unk0) && !func_80BDF390(this, globalCtx, &sp20))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_35C = sp20.unk0; + this->unk_368 = func_80BDE384(this, globalCtx); + func_80BDF578(this, globalCtx); +} + +void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx) { + if (func_8010BF58(&this->actor, globalCtx, this->unk_360, this->unk_4EC, &this->unk_364)) { + SubS_UpdateFlags(&this->unk_4C2, 3, 7); + this->unk_4C2 &= ~0x20; + this->unk_4C2 |= 0x200; + this->actor.child = NULL; + this->unk_4E2 = 20; + this->unk_364 = 0; + this->actionFunc = func_80BDF5E8; + } else { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + } +} + +void EnAl_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_al_Skel_00A0D8, NULL, this->jointTable, this->morphTable, + 27); + this->unk_4F8 = -1; + func_80BDE27C(this, 1); + Collider_InitAndSetCylinder(globalCtx, &this->unk_310, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->unk_35C = 0; + this->actionFunc = func_80BDF5E8; + + this->actionFunc(this, globalCtx); +} + +void EnAl_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->unk_310); +} + +void EnAl_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + + func_80BDEC2C(this, globalCtx); + + this->actionFunc(this, globalCtx); + + func_80BDF064(this, globalCtx); + + if (this->unk_35C != 0) { + func_80BDE250(this); + func_80BDEE5C(this); + func_8013C964(&this->actor, globalCtx, this->unk_4D4, 30.0f, this->unk_4F0, this->unk_4C2 & 7); + func_80BDE318(this, globalCtx); + } +} + +s32 EnAl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + switch (limbIndex) { + case 3: + case 11: + case 12: + case 13: + case 14: + case 15: + *dList = NULL; + break; + + case 16: + break; + } + return false; +} + +void EnAl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnAl* this = THIS; + + switch (limbIndex) { + case 3: + Matrix_CopyCurrentState(&this->unk_190[0]); + break; + + case 11: + Matrix_CopyCurrentState(&this->unk_190[1]); + break; + + case 12: + Matrix_CopyCurrentState(&this->unk_190[2]); + break; + + case 13: + Matrix_CopyCurrentState(&this->unk_190[3]); + break; + + case 14: + Matrix_CopyCurrentState(&this->unk_190[4]); + break; + + case 15: + Matrix_CopyCurrentState(&this->unk_190[5]); + break; + + case 16: + Matrix_MultiplyVector3fByState(&D_80BE0070, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + break; + } +} + +void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnAl* this = THIS; + s32 phi_v0; + s32 phi_v1; + + if (!(this->unk_4C2 & 0x200)) { + if (this->unk_4C2 & 0x80) { + phi_v1 = 1; + } else { + phi_v1 = 0; + } + phi_v0 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == 16) { + func_8013AD9C(this->unk_4DC + 0x4000, this->unk_4DE + this->actor.shape.rot.y + 0x4000, &this->unk_36C, + &this->unk_378, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_36C.x, this->unk_36C.y, this->unk_36C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_378.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_378.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_378.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAl* this = THIS; + s32 i; + + if (this->unk_35C != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnAl_OverrideLimbDraw, EnAl_PostLimbDraw, + EnAl_TransformLimbDraw, &this->actor); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + Matrix_SetCurrentState(&this->unk_190[i]); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80BE007C[i]); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.h b/src/overlays/actors/ovl_En_Al/z_en_al.h index a4a8cf999..9e5ee8872 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.h +++ b/src/overlays/actors/ovl_En_Al/z_en_al.h @@ -6,12 +6,43 @@ struct EnAl; typedef void (*EnAlActionFunc)(struct EnAl*, GlobalContext*); +typedef s32 (*EnAlUnkFunc)(struct EnAl*, GlobalContext*); +typedef void (*EnAlUnkFunc2)(struct EnAl*, GlobalContext*); typedef struct EnAl { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnAlActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x374]; + /* 0x018C */ EnAlUnkFunc2 unk_18C; + /* 0x0190 */ MtxF unk_190[6]; + /* 0x0310 */ ColliderCylinder unk_310; + /* 0x035C */ u8 unk_35C; + /* 0x0360 */ s32* unk_360; + /* 0x0364 */ s32 unk_364; + /* 0x0368 */ Actor* unk_368; + /* 0x036C */ Vec3f unk_36C; + /* 0x0378 */ Vec3s unk_378; + /* 0x037E */ Vec3s jointTable[27]; + /* 0x0420 */ Vec3s morphTable[27]; + /* 0x04C2 */ u16 unk_4C2; + /* 0x04C4 */ u16 unk_4C4; + /* 0x04C8 */ f32 unk_4C8; + /* 0x04CC */ UNK_TYPE1 unk4CC[8]; + /* 0x04D4 */ f32 unk_4D4; + /* 0x04D8 */ UNK_TYPE1 unk4D8[4]; + /* 0x04DC */ s16 unk_4DC; + /* 0x04DE */ s16 unk_4DE; + /* 0x04E0 */ s16 unk_4E0; + /* 0x04E2 */ s16 unk_4E2; + /* 0x04E4 */ s16 unk_4E4; + /* 0x04E6 */ s16 unk_4E6; + /* 0x04E8 */ s16 unk_4E8; + /* 0x04EA */ s16 unk_4EA; + /* 0x04EC */ EnAlUnkFunc unk_4EC; + /* 0x04F0 */ s32 unk_4F0; + /* 0x04F4 */ s32 unk_4F4; + /* 0x04F8 */ s32 unk_4F8; + /* 0x04FC */ UNK_TYPE1 unk4FC[4]; } EnAl; // size = 0x500 extern const ActorInit En_Al_InitVars; 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 355d37e59..c5b9381f6 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -5,8 +5,10 @@ */ #include "z_en_am.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_400 | ACTOR_FLAG_4 | ACTOR_FLAG_1) #define THIS ((EnAm*)thisx) @@ -15,18 +17,26 @@ void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAm_Update(Actor* thisx, GlobalContext* globalCtx); void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808B0040(EnAm* this, GlobalContext* globalCtx); -void func_808B0124(EnAm* this, GlobalContext* globalCtx); +void func_808AFF9C(EnAm* this); +void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void EnAm_WakeUp(EnAm* this); +void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx); +void func_808B0358(EnAm* this); void func_808B03C0(EnAm* this, GlobalContext* globalCtx); +void func_808B0460(EnAm* this); void func_808B04A8(EnAm* this, GlobalContext* globalCtx); void func_808B0508(EnAm* this, GlobalContext* globalCtx); +void func_808B057C(EnAm* this); void func_808B05C8(EnAm* this, GlobalContext* globalCtx); +void func_808B0640(EnAm* this); void func_808B066C(EnAm* this, GlobalContext* globalCtx); +void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx); void func_808B07A8(EnAm* this, GlobalContext* globalCtx); +void func_808B0820(EnAm* this); void func_808B0894(EnAm* this, GlobalContext* globalCtx); void func_808B0B4C(EnAm* this, GlobalContext* globalCtx); +void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor); -#if 0 const ActorInit En_Am_InitVars = { ACTOR_EN_AM, ACTORCAT_ENEMY, @@ -39,22 +49,47 @@ const ActorInit En_Am_InitVars = { (ActorFunc)EnAm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B1070 = { - { COLTYPE_HIT5, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0x81C2C788, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sEnemyCylinderInit = { + { + COLTYPE_HIT5, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0x81C2C788, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 23, 98, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B109C = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x760D3877, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x760D3877, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 23, 98, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808B10C8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0xF), @@ -89,81 +124,449 @@ static DamageTable D_808B10C8 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808B10E8 = { 1, 23, 98, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 23, 98, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808B10F0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 19, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Vec3f sVelocity = { 0.0f, -1.5f, 0.0f }; -extern ColliderCylinderInit D_808B1070; -extern ColliderCylinderInit D_808B109C; -extern DamageTable D_808B10C8; -extern CollisionCheckInfoInit D_808B10E8; -extern InitChainEntry D_808B10F0[]; +static Vec3f sAccel = { 0.0f, -(1.0f / 5.0f), 0.0f }; -extern UNK_TYPE D_06000238; -extern UNK_TYPE D_0600033C; -extern UNK_TYPE D_06005B3C; +static Color_RGBA8 D_808B1118 = { 100, 100, 100, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Init.s") +static Color_RGBA8 D_808B111C = { 40, 40, 40, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Destroy.s") +static Color_RGBA8 D_808B1120 = { 150, 150, 150, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808AFE38.s") +static Color_RGBA8 D_808B1124 = { 100, 100, 100, 150 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808AFF9C.s") +static Vec3f D_808B1128[] = { + { 4700.0f, -500.0f, 1800.0f }, { 4700.0f, -500.0f, -1800.0f }, { 2000.0f, -1500.0f, 0.0f }, + { 2000.0f, 0.0f, -1500.0f }, { 2000.0f, 0.0f, 1500.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0040.s") +static Vec3f D_808B1164[] = { + { 0.0f, -3000.0f, 0.0f }, + { 700.0f, -800.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B00D8.s") +static Vec3f D_808B117C[] = { + { 800.0f, 1000.0f, -1000.0f }, + { 800.0f, 1000.0f, 1000.0f }, + { 800.0f, -1000.0f, 1000.0f }, + { 800.0f, -1000.0f, -1000.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0124.s") +void EnAm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0208.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 300.0f / 7.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + this->morphTable, OBJECT_AM_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->enemyCollider, &this->actor, &sEnemyCylinderInit); + Collider_InitAndSetCylinder(globalCtx, &this->interactCollider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->actor.home.pos.x -= 9.0f * Math_SinS(this->actor.shape.rot.y); + this->actor.home.pos.z -= 9.0f * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.z = this->actor.home.pos.z; + func_808AFF9C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0358.s") +void EnAm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B03C0.s") + Collider_DestroyCylinder(globalCtx, &this->enemyCollider); + Collider_DestroyCylinder(globalCtx, &this->interactCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0460.s") +void EnAm_SpawnEffects(EnAm* this, GlobalContext* globalCtx) { + s32 i; + Vec3f effectPos; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B04A8.s") + // Dust Clouds that spawn from the hop + for (i = 4; i > 0; i--) { + effectPos.x = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.x; + effectPos.y = randPlusMinusPoint5Scaled(10.0f) + (this->actor.world.pos.y + 40.0f); + effectPos.z = randPlusMinusPoint5Scaled(65.0f) + this->actor.world.pos.z; + EffectSsKiraKira_SpawnSmall(globalCtx, &effectPos, &sVelocity, &sAccel, &D_808B1118, &D_808B111C); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WALK); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 4.0f, 3, 8.0f, 300, 15, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B04E4.s") +void func_808AFF9C(EnAm* this) { + f32 lastFrame = Animation_GetLastFrame(&gArmosPushedBackAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0508.s") + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, lastFrame, lastFrame, 0, 0.0f); + this->enemyCollider.info.bumper.dmgFlags = 0x80000088; + this->interactCollider.info.bumper.dmgFlags = 0x77CFFF77; + if (this->actor.colChkInfo.health != 0) { + this->enemyCollider.base.atFlags &= ~AT_ON; + } + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actionFunc = EnAm_RemoveEnemyTexture; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B057C.s") +void EnAm_RemoveEnemyTexture(EnAm* this, GlobalContext* globalCtx) { + if (((this->enemyCollider.base.ocFlags1 & OC1_HIT) && (this->enemyCollider.base.ocFlags2 & OC2_HIT_PLAYER)) || + (this->interactCollider.base.acFlags & AC_HIT)) { + if (this->textureBlend == 0) { + EnAm_WakeUp(this); + } + } else if (this->textureBlend > 10) { + this->textureBlend -= 10; + } else { + this->textureBlend = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unkFlag = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B05C8.s") +void EnAm_WakeUp(EnAm* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_WAVE); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + this->returnHomeTimer = 300; + this->actionFunc = EnAm_ApplyEnemyTexture; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0640.s") +void EnAm_ApplyEnemyTexture(EnAm* this, GlobalContext* globalCtx) { + s32 tempTextureBlend; + f32 cos; + u8 pad; + f32 rand; + f32 sin; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B066C.s") + if (this->textureBlend + 20 >= 255) { + this->textureBlend = 255; + this->actor.flags |= ACTOR_FLAG_1; + this->enemyCollider.info.bumper.dmgFlags = 0x81C2C788; + this->interactCollider.info.bumper.dmgFlags = 0x760D3877; + this->enemyCollider.base.atFlags |= AT_ON; + this->actor.shape.yOffset = 0.0f; + func_808B0358(this); + } else { + tempTextureBlend = this->textureBlend + 20; + rand = randPlusMinusPoint5Scaled(10.0f); + cos = Math_CosS(this->actor.shape.rot.y) * rand; + sin = Math_SinS(this->actor.shape.rot.y) * rand; + this->actor.world.pos.x = this->actor.home.pos.x + cos; + this->actor.world.pos.z = this->actor.home.pos.z + sin; + this->textureBlend = tempTextureBlend; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B06D0.s") +void func_808B0208(EnAm* this, GlobalContext* globalCtx) { + // If the armos is against a wall, rotate and turn away from it + if ((this->actor.speedXZ > 0.0f) && (this->actor.bgCheckFlags & 8)) { + 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); + } + SkelAnime_Update(&this->skelAnime); + if (Animation_OnFrame(&this->skelAnime, 8.0f) != 0) { + this->actor.speedXZ = this->speed; + this->actor.velocity.y = 12.0f; + } else if (this->skelAnime.curFrame > 11.0f) { + if (!(this->actor.bgCheckFlags & 1)) { + 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) { + EnAm_SpawnEffects(this, globalCtx); + } + } + } + if (this->actionFunc != func_808B0894) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B07A8.s") +void func_808B0358(EnAm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); + this->explodeTimer = 3; + this->actor.speedXZ = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 6.0f; + this->actionFunc = func_808B03C0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0820.s") +void func_808B03C0(EnAm* this, GlobalContext* globalCtx) { + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->actor.bgCheckFlags & 2) { + this->explodeTimer--; + } + if (this->explodeTimer == 0) { + func_808B0640(this); + } else if ((this->returnHomeTimer == 0) || Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 240.0f) { + func_808B0460(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0894.s") +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->actionFunc = func_808B04A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0AD0.s") +void func_808B04A8(EnAm* this, GlobalContext* globalCtx) { + func_808B0208(this, globalCtx); + if (this->armosYaw == this->actor.world.rot.y) { + func_808B057C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0B4C.s") +void func_808B04E4(EnAm* this) { + this->speed = 0.0f; + this->armosYaw = this->actor.home.rot.y; + this->actionFunc = func_808B0508; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0B9C.s") +void func_808B0508(EnAm* this, GlobalContext* globalCtx) { + func_808B0208(this, globalCtx); + if (!(this->actor.bgCheckFlags & 1)) { + 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); + } + if (this->actor.home.rot.y == this->actor.world.rot.y) { + func_808AFF9C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Update.s") +void func_808B057C(EnAm* this) { + this->speed = 6.0f; + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + this->explodeTimer = 1; + this->actionFunc = func_808B05C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/func_808B0EA4.s") +void func_808B05C8(EnAm* this, GlobalContext* globalCtx) { + this->armosYaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + func_808B0208(this, globalCtx); + if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 8.0f) { + func_808B04E4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Am/EnAm_Draw.s") +void func_808B0640(EnAm* this) { + this->explodeTimer = 40; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->speed = 0.0f; + this->actionFunc = func_808B066C; +} + +void func_808B066C(EnAm* this, GlobalContext* globalCtx) { + if (this->explodeTimer != 0) { + this->explodeTimer--; + } else { + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->armosYaw == this->actor.shape.rot.y) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AMOS_VOICE); + func_808B0358(this); + } + } +} + +void EnAm_TakeDamage(EnAm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gArmosTakeDamageAnim, 1.0f, 4.0f, + Animation_GetLastFrame(&gArmosTakeDamageAnim) - 6, 2, 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->enemyCollider.base.acFlags &= ~AC_ON; + this->textureBlend = 255; + this->actionFunc = func_808B07A8; +} + +void func_808B07A8(EnAm* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + func_808B0820(this); + } else { + this->enemyCollider.base.acFlags |= AC_ON; + func_808B0358(this); + } + } +} + +void func_808B0820(EnAm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &gArmosHopAnim, 4.0f); + 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->speed = 6.0f; + this->actionFunc = func_808B0894; +} + +void func_808B0894(EnAm* this, GlobalContext* globalCtx) { + s32 i; + Vec3f dustPos; + s32 pad; + + this->explodeTimer--; + this->armosYaw = this->actor.yawTowardsPlayer; + func_808B0208(this, globalCtx); + if (this->explodeTimer == 1) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 2, 0); + if (bomb != NULL) { + bomb->timer = 0; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + + for (i = 0; i < 8; i++) { + dustPos.x = (Math_SinS(0) * 7.0f) + this->actor.world.pos.x; + dustPos.y = (randPlusMinusPoint5Scaled(10.0f) * 6.0f) + (this->actor.world.pos.y + 40.0f); + dustPos.z = (Math_CosS(0) * 7.0f) + this->actor.world.pos.z; + + func_800B0EB0(globalCtx, &dustPos, &gZeroVec3f, &gZeroVec3f, &D_808B1120, &D_808B1124, 200, 45, 12); + } + } else if (this->explodeTimer == 0) { + Actor_MarkForDeath(&this->actor); + return; + } else if (!(this->explodeTimer & 3)) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 4); + } + if (this->actor.world.rot.z < 0x1F40) { + this->actor.world.rot.z += 0x320; + } + this->actor.shape.rot.y += this->actor.world.rot.z; +} + +void func_808B0AD0(EnAm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 1.0f, 0.0f, 8.0f, 2, 0.0f); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.speedXZ = -6.0f; + this->actionFunc = func_808B0B4C; +} + +void func_808B0B4C(EnAm* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + if (SkelAnime_Update(&this->skelAnime)) { + func_808B0358(this); + } +} + +s32 EnAm_UpdateDamage(EnAm* this, GlobalContext* globalCtx) { + if (this->enemyCollider.base.acFlags & AC_HIT) { + this->enemyCollider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->enemyCollider.info); + if (!Actor_ApplyDamage(&this->actor)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + if (this->actor.colChkInfo.damageEffect == 0xD) { + return true; + } + if (this->actor.colChkInfo.health != 0) { + this->enemyCollider.base.atFlags &= ~AT_ON; + } + this->enemyCollider.base.atFlags &= ~AT_HIT; + if (this->actor.colChkInfo.damageEffect == 0x4) { + this->drawDmgEffScale = 0.7f; + this->drawDmgEffAlpha = 4.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->enemyCollider.info.bumper.hitPos.x, + this->enemyCollider.info.bumper.hitPos.y, this->enemyCollider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + EnAm_TakeDamage(this, globalCtx); + return true; + } + return false; +} + +void EnAm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAm* this = THIS; + s32 pad; + + if (EnAm_UpdateDamage(this, globalCtx) == false) { + if (this->enemyCollider.base.atFlags & AT_BOUNCED) { + this->enemyCollider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + if (this->actor.colChkInfo.health == 0) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + } else { + func_808B0AD0(this, globalCtx); + } + } + } + if (this->returnHomeTimer != 0) { + this->returnHomeTimer--; + } + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 30.0f, 100.0f, 0x1D); + Actor_SetFocus(&this->actor, 64.0f); + Collider_UpdateCylinder(&this->actor, &this->enemyCollider); + Collider_UpdateCylinder(&this->actor, &this->interactCollider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + if (this->enemyCollider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->interactCollider.base); + if (this->enemyCollider.base.atFlags & AC_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->enemyCollider.base); + } + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.35f; + this->drawDmgEffScale = (this->drawDmgEffScale > 0.7f) ? 0.7f : this->drawDmgEffScale; +} + +void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 i; + s32 phi_s3; + Vec3f* phi_s1; + Vec3f* phi_s2; + EnAm* this = THIS; + + phi_s2 = 0; + phi_s1 = 0; + if (limbIndex == 4) { + phi_s2 = &this->limbPos[0]; + phi_s1 = D_808B1128; + phi_s3 = 5; + } else if (limbIndex == 13) { + phi_s2 = &this->limbPos[9]; + phi_s1 = D_808B117C; + phi_s3 = 4; + } else if ((limbIndex == 7) || (limbIndex == 10)) { + phi_s2 = (limbIndex == 7) ? &this->limbPos[5] : &this->limbPos[7]; + phi_s1 = D_808B1164; + phi_s3 = 2; + } else { + phi_s3 = 0; + } + for (i = 0; i < phi_s3; i++, phi_s2++, phi_s1++) { + Matrix_MultiplyVector3fByState(phi_s1, phi_s2); + } +} + +void EnAm_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; + EnAm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + gDPSetEnvColor(&gfx[1], 0, 0, 0, this->textureBlend); + POLY_OPA_DISP = &gfx[2]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnAm_PostLimbDraw, + &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + 0.0f, this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.h b/src/overlays/actors/ovl_En_Am/z_en_am.h index 59d8abbad..2199a832f 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -2,6 +2,7 @@ #define Z_EN_AM_H #include "global.h" +#include "objects/object_am/object_am.h" struct EnAm; @@ -9,9 +10,21 @@ typedef void (*EnAmActionFunc)(struct EnAm*, GlobalContext*); typedef struct EnAm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xEC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x01DC */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x0230 */ EnAmActionFunc actionFunc; - /* 0x0234 */ char unk_234[0x14C]; + /* 0x0234 */ u8 textureBlend; // 0 = statue textures; 255 = enemy textures + /* 0x0236 */ s16 explodeTimer; // timer counting down till armos explodes + /* 0x0238 */ s16 returnHomeTimer; // Timer that counts down till an armos will return to its spawn position + /* 0x023A */ s16 unkFlag; + /* 0x023C */ s16 armosYaw; // Yaw of Armos + /* 0x0240 */ f32 speed; // Hopping speed of Armos + /* 0x0244 */ f32 drawDmgEffAlpha; + /* 0x0248 */ f32 drawDmgEffScale; + /* 0x024C */ Vec3f limbPos[13]; + /* 0x02E8 */ ColliderCylinder enemyCollider; // Collider for when Armos is Hostile + /* 0x0334 */ ColliderCylinder interactCollider; // Collider for when an interactable Armos is docile } EnAm; // size = 0x380 extern const ActorInit En_Am_InitVars; diff --git a/src/overlays/actors/ovl_En_An/z_en_an.c b/src/overlays/actors/ovl_En_An/z_en_an.c index 43ea5744a..9144d34fa 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -6,7 +6,7 @@ #include "z_en_an.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAn*)thisx) 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 ad0291e7d..437bd1750 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -6,7 +6,7 @@ #include "z_en_and.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnAnd*)thisx) 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 c12578420..43e9de4f0 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -1,21 +1,44 @@ /* * File: z_en_ani.c * Overlay: ovl_En_Ani - * Description: Part-time worker + * Description: Man in Tree in South Termina Field + * version in shop at night is EnOssan actor using object_ani */ #include "z_en_ani.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnAni*)thisx) +// clang-format off +#define ANI_STATE_STANDING (0) +#define ANI_STATE_UNK (1 << 0) +#define ANI_STATE_WRITHING (1 << 1) +#define ANI_STATE_CLIMBING (1 << 2) +#define ANI_STATE_FALLING (1 << 3) +// clang-format on + void EnAni_Init(Actor* thisx, GlobalContext* globalCtx); void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnAni_Update(Actor* thisx, GlobalContext* globalCtx); void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnAni_DefaultBlink(EnAni* this); +void EnAni_WaitForEyeClose(EnAni* this); +void EnAni_WaitForEyeOpen(EnAni* this); + +void EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId); + +void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx); +void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx); +void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx); +void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx); +void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx); +void EnAni_IdleInPain(EnAni* this, GlobalContext* globalCtx); +void EnAni_Talk(EnAni* this, GlobalContext* globalCtx); +void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx); + const ActorInit En_Ani_InitVars = { ACTOR_EN_ANI, ACTORCAT_NPC, @@ -28,62 +51,304 @@ const ActorInit En_Ani_InitVars = { (ActorFunc)EnAni_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80968670 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +// two different colliders, but only one init for both +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096869C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 850, ICHAIN_STOP), }; -#endif +void EnAni_DefaultBlink(EnAni* this) { + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } -extern ColliderCylinderInit D_80968670; -extern InitChainEntry D_8096869C[]; + this->eyeState = this->blinkTimer; + if (this->eyeState >= 3) { + this->eyeState = 0; + } +} -extern UNK_TYPE D_06000C14; -extern UNK_TYPE D_060011CC; -extern UNK_TYPE D_060027A0; -extern UNK_TYPE D_06009220; -extern UNK_TYPE D_06009D34; +void EnAni_WaitForEyeClose(EnAni* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else if (this->eyeState < 2) { + this->eyeState++; + } else { + this->blinkFunc = EnAni_WaitForEyeOpen; + this->blinkTimer = Rand_S16Offset(20, 20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_809679D0.s") +void EnAni_WaitForEyeOpen(EnAni* this) { + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else if (this->eyeState > 0) { + this->eyeState--; + } else { + this->blinkFunc = EnAni_WaitForEyeClose; + this->blinkTimer = Rand_S16Offset(10, 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967A48.s") +void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnAni* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967AB4.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, + this->morphTable, ANI_LIMB_MAX); + Animation_PlayOnce(&this->skelAnime, &gAniStandingNormalAnim); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider2); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->stateFlags = ANI_STATE_STANDING; + this->unk2EE = 0; + this->treeReachTimer = 0; + this->blinkFunc = EnAni_DefaultBlink; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Init.s") + if (GET_ANI_TYPE(thisx) == ANI_TYPE_TREE_HANGING) { + Animation_Change(&this->skelAnime, &gAniTreeHangingAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniTreeHangingAnim), ANIMMODE_ONCE, 0.0f); + this->actionFunc = EnAni_HangInTree; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = 0.0f; + this->actor.gravity = 0.0f; + this->actor.flags |= ACTOR_FLAG_10; + this->stateFlags |= ANI_STATE_CLIMBING; + gSaveContext.eventInf[1] &= (u8)~0x10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Destroy.s") + } else { // ANI_TYPE_STANDING + // ( unused code ) + // for some reason standing he has a large collider + // possibly he was meant to be a blocking npc like bomber + this->collider2.dim.radius = 60; + this->actionFunc = EnAni_IdleStanding; + this->actor.velocity.y = -25.0f; + this->actor.terminalVelocity = -25.0f; + this->actor.gravity = -5.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967D20.s") +void EnAni_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAni* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967DA0.s") + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967DCC.s") +void EnAni_SetText(EnAni* this, GlobalContext* globalCtx, u16 textId) { + s16 diffAngle = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967E34.s") + this->actor.textId = textId; + if ((this->stateFlags & ANI_STATE_WRITHING) || ABS_ALT(diffAngle) <= 0x4300) { + if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967E90.s") +void EnAni_IdleStanding(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967F20.s") +void EnAni_Talk(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Message_GetState(&globalCtx->msgCtx) == 2 && globalCtx->msgCtx.currentTextId == 0x6DE) { + this->actionFunc = EnAni_IdleInPain; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80967FA4.s") +void EnAni_IdleInPain(EnAni* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnAni_Talk; + } else { + // telling you not to take his rupees you knocked from the tree + EnAni_SetText(this, globalCtx, 0x6DE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_809680B0.s") +void EnAni_FallOverInPain(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + this->blinkFunc = EnAni_WaitForEyeOpen; + this->actionFunc = EnAni_IdleInPain; + Animation_Change(&this->skelAnime, &gAniHoldingFootWrithingInPainAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniHoldingFootWrithingInPainAnim), ANIMMODE_LOOP, 0.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80968164.s") +void EnAni_LandOnFoot(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + this->actionFunc = EnAni_FallOverInPain; + Animation_Change(&this->skelAnime, &gAniFallOverHoldingFootAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniFallOverHoldingFootAnim), ANIMMODE_ONCE, 0.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Update.s") +void EnAni_FallToGround(EnAni* this, GlobalContext* globalCtx) { + s32 pad; + s16 quakeValue; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_80968504.s") + if (this->actor.bgCheckFlags & 1) { // hit the ground + this->actor.flags &= ~ACTOR_FLAG_10; + this->actionFunc = EnAni_LandOnFoot; + this->actor.velocity.x = 0.0f; + this->actor.velocity.z = 0.0f; + // the animation gets cut short, (first 16 frames only) only the landing part is seen + Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 1.0f, 0.0f, 16.0f, ANIMMODE_ONCE, 0.0f); + this->stateFlags |= ANI_STATE_WRITHING; + quakeValue = Quake_Add(globalCtx->cameraPtrs[0], 3); + Quake_SetSpeed(quakeValue, 0x6978); + Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); + Quake_SetCountdown(quakeValue, 0x14); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HAMMER_HIT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/func_8096854C.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2, 0x7D0, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ani/EnAni_Draw.s") +void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx) { + s32 pad; + + if (SkelAnime_Update(&this->skelAnime)) { + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = -5.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.z = -4.0f; + // frame count : 0.0f, only first frame, rest is handled in next action func + Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 5.0f); + this->actionFunc = EnAni_FallToGround; + gSaveContext.eventInf[1] |= 0x10; + } +} + +void EnAni_HangInTree(EnAni* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->treeReachTimer > 0) { + this->treeReachTimer--; + if (this->treeReachTimer > 0) { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingReachAnim); + } else { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingAnim); + } + } else if (Rand_ZeroFloat(1.0f) < 0.4f) { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingReachAnim); + this->treeReachTimer = 2; + } else { + Animation_PlayOnce(&this->skelAnime, &gAniTreeHangingAnim); + } + } + + // his bonk detection is based on his tilt, neat + if (this->actor.home.rot.x != 0) { + this->stateFlags |= ANI_STATE_FALLING; + this->actionFunc = EnAni_LoseBalance; + Animation_Change(&this->skelAnime, &gAniTreeHangLosingBalanceAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gAniTreeHangLosingBalanceAnim), ANIMMODE_ONCE, -5.0f); + } +} + +void EnAni_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAni* this = THIS; + f32 minVelocity; + + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (!(this->stateFlags & ANI_STATE_UNK)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + this->actor.velocity.y += this->actor.gravity; + minVelocity = this->actor.terminalVelocity; + if (this->actor.velocity.y < minVelocity) { + this->actor.velocity.y = minVelocity; + } + + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actionFunc(this, globalCtx); + if (this->actor.xzDistToPlayer < 100.0f && !(this->stateFlags & ANI_STATE_CLIMBING)) { + func_800E9250(globalCtx, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + this->chestRot.x = this->chestRot.y = this->chestRot.z = 0; + } else { + Math_SmoothStepToS(&this->headRot.x, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->chestRot.x, 0, 0x6, 0x1838, 0x64); + Math_SmoothStepToS(&this->chestRot.y, 0, 0x6, 0x1838, 0x64); + } + + this->blinkFunc(this); + if (this->stateFlags & ANI_STATE_FALLING) { + if (this->actor.cutscene == -1) { + 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(globalCtx, ActorCutscene_GetCurrentCamera(this->actor.cutscene)), + &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +s32 EnAni_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnAni* this = THIS; + + if (limbIndex == ANI_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + } + + return false; +} + +void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_809686A4 = { 800.0f, 500.0f, 0.0f }; + + if (limbIndex == ANI_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_809686A4, &thisx->focus.pos); + } +} + +void EnAni_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; + s32 pad; + EnAni* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAni_OverrideLimbDraw, EnAni_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.h b/src/overlays/actors/ovl_En_Ani/z_en_ani.h index 554c1bc8a..21dced2c1 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.h +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.h @@ -2,18 +2,37 @@ #define Z_EN_ANI_H #include "global.h" +#include "objects/object_ani/object_ani.h" struct EnAni; typedef void (*EnAniActionFunc)(struct EnAni*, GlobalContext*); +typedef void (*EnAniBlinkFunc)(struct EnAni*); + typedef struct EnAni { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1B0]; - /* 0x02F4 */ EnAniActionFunc actionFunc; - /* 0x02F8 */ char unk_2F8[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider1; + /* 0x190 */ ColliderCylinder collider2; + /* 0x1DC */ SkelAnime skelAnime; + /* 0x220 */ Vec3s jointTable[ANI_LIMB_MAX]; + /* 0x280 */ Vec3s morphTable[ANI_LIMB_MAX]; + /* 0x2E0 */ Vec3s headRot; + /* 0x2E6 */ Vec3s chestRot; // unused + /* 0x2EC */ u16 stateFlags; + /* 0x2EE */ s16 unk2EE; // assigned to zero in init, never used after + /* 0x2F0 */ s16 treeReachTimer; + /* 0x2F4 */ EnAniBlinkFunc blinkFunc; + /* 0x2F8 */ s16 eyeState; + /* 0x2FA */ s16 blinkTimer; + /* 0x2FC */ EnAniActionFunc actionFunc; } EnAni; // size = 0x300 -extern const ActorInit En_Ani_InitVars; +enum EnAniType { + /* else */ ANI_TYPE_STANDING, // unfinshed and unused + /* 1 */ ANI_TYPE_TREE_HANGING = 1, +}; + +#define GET_ANI_TYPE(thisx) (thisx->params & 0xFF) #endif // Z_EN_ANI_H 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 f906c073f..9fcb56018 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 @@ -7,9 +7,8 @@ #include "z_en_aob_01.h" #include "overlays/actors/ovl_En_Racedog/z_en_racedog.h" #include "overlays/actors/ovl_En_Dg/z_en_dg.h" -#include "objects/object_aob/object_aob.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnAob01*)thisx) @@ -45,10 +44,13 @@ const ActorInit En_Aob_01_InitVars = { (ActorFunc)EnAob01_Draw, }; -static ActorAnimationEntry D_809C3790[6] = { - { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0068B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_aob_Anim_00700C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_0058EC, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_aob_Anim_006040, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_aob_Anim_007758, 1.0f, 0.0f, 0.0f, 0, -6.0f }, +static AnimationInfo D_809C3790[6] = { + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanLaughStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanLaughLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanSurpriseStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gMamamuYanSurpriseLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gMamamuYanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -88,11 +90,11 @@ static EnAobStruct D_809C384C[] = { }; void func_809C10B0(EnAob01* this, s32 arg1) { - if (DECR(this->unk_3F0) == 0) { - this->unk_3EE++; - if (this->unk_3EE >= arg1) { - this->unk_3EE = 0; - this->unk_3F0 = Rand_S16Offset(30, 30); + if (DECR(this->blinkTimer) == 0) { + this->eyeIndex++; + if (this->eyeIndex >= arg1) { + this->eyeIndex = 0; + this->blinkTimer = Rand_S16Offset(30, 30); } } } @@ -111,7 +113,7 @@ void func_809C1158(EnAob01* this, GlobalContext* globalCtx) { if (temp_s0 != 0x3F) { do { - this->unk_1D8[i] = func_8013D648(globalCtx, temp_s0, 0x3F); + this->unk_1D8[i] = SubS_GetPathByIndex(globalCtx, temp_s0, 0x3F); temp_s0 = this->unk_1D8[i]->unk1; i++; } while (temp_s0 != 0xFF); @@ -150,7 +152,7 @@ s32 func_809C1424(EnAob01* this) { if (this->unk_43C == 1) { if (curFrame == lastFrame) { this->unk_43C = 2; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 2); return true; } } else if (this->unk_43C == 2) { @@ -166,13 +168,13 @@ s32 func_809C14D0(EnAob01* this) { if ((this->unk_43C == 0) || (this->unk_43C == 5)) { if (curFrame == lastFrame) { this->unk_43C = 3; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 3); return true; } } else if (this->unk_43C == 3) { if (curFrame == lastFrame) { this->unk_43C = 4; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 4); return true; } } else if (this->unk_43C == 4) { @@ -188,7 +190,7 @@ s32 func_809C15BC(EnAob01* this) { if ((this->unk_43C != 0) && (this->unk_43C != 5)) { if (curFrame == lastFrame) { this->unk_43C = 5; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 5); return true; } } else { @@ -330,7 +332,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; case 0x3525: @@ -345,7 +347,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x40; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -360,7 +362,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; case 0x3527: @@ -372,7 +374,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3536; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -380,7 +382,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x3537; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } @@ -408,7 +410,7 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { break; } - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); } void func_809C1C9C(EnAob01* this, GlobalContext* globalCtx) { @@ -430,19 +432,19 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); this->unk_210 = 0x3524; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); } else { func_8019F208(); this->unk_2D2 |= 4; this->unk_2D2 |= 0x10; this->unk_210 = 0x3522; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C21E0; } break; @@ -450,11 +452,11 @@ void func_809C1D64(EnAob01* this, GlobalContext* globalCtx) { case 1: func_8019F230(); this->unk_210 = 0x3535; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); break; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_210 = 0; @@ -468,7 +470,7 @@ void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { Vec3f sp30; SkelAnime_Update(&this->skelAnime); - if (func_8013D5E8(this->actor.shape.rot.y, 14000, this->actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; @@ -483,7 +485,7 @@ void func_809C1EC8(EnAob01* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_2E0.y, 0, 4, 1000, 1); } func_809C10B0(this, 3); - func_8013D9C8(globalCtx, this->unk_2F8, this->unk_318, 0x10); + SubS_FillLimbRotTables(globalCtx, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); func_809C165C(this, globalCtx); if (player->stateFlags1 & 0x20) { func_809C1124(); @@ -494,7 +496,7 @@ void func_809C2060(EnAob01* this, GlobalContext* globalCtx) { if (func_809C15BC(this)) { if (func_809C2EC4(this, globalCtx) && !(this->unk_2D2 & 0x100)) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 100.0f); this->unk_2D2 |= 8; this->actionFunc = func_809C21E0; @@ -528,7 +530,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } this->actor.textId = 0; this->unk_2D2 &= ~8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_809C2060; return; } @@ -543,7 +545,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { if (this->unk_2D2 & 8) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(globalCtx, &this->actor); if (this->unk_2D2 & 4) { func_809C16DC(this, globalCtx); @@ -552,13 +554,13 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { this->unk_2D2 |= 0x10; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); - func_801518B0(globalCtx, 0x354B, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); + Message_StartTextbox(globalCtx, 0x354B, &this->actor); } this->unk_2D2 &= ~8; } } else if (sp2F == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -574,7 +576,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { } } } else if (sp2F == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; if (this->unk_2D2 & 0x10) { this->unk_2D2 &= ~0x10; @@ -585,7 +587,7 @@ void func_809C21E0(EnAob01* this, GlobalContext* globalCtx) { func_809C16DC(this, globalCtx); } } - } else if ((sp2F == 14) && func_80147624(globalCtx)) { + } else if ((sp2F == 14) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_434 = globalCtx->msgCtx.bankRupeesSelected; func_809C16DC(this, globalCtx); @@ -700,7 +702,7 @@ void func_809C2824(EnAob01* this, GlobalContext* globalCtx) { void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80123E90(globalCtx, &this->actor); this->unk_434 = gSaveContext.unk_3F5C; switch ((gSaveContext.eventInf[0] & 0xF8) >> 3) { @@ -731,11 +733,11 @@ void func_809C28B8(EnAob01* this, GlobalContext* globalCtx) { this->unk_210 = 0x352D; this->unk_2D2 |= 0x40; this->unk_43C = 1; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 1); break; } - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2D0C; } else if (this->actor.xzDistToPlayer < 100.0f) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -746,7 +748,7 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { u8 sp2F = Message_GetState(&globalCtx->msgCtx); if (func_809C15BC(this)) { - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_434 = 0; globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -775,7 +777,7 @@ void func_809C2A64(EnAob01* this, GlobalContext* globalCtx) { void func_809C2BE4(EnAob01* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); - if (((temp_v0 == 5) || (temp_v0 == 6)) && func_80147624(globalCtx)) { + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { if (gSaveContext.save.weekEventReg[63] & 2) { gSaveContext.save.weekEventReg[63] &= (u8)~2; } @@ -816,12 +818,12 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } } - if ((sp2F == 5) && func_80147624(globalCtx)) { + if ((sp2F == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_2D2 &= ~0x40; this->unk_2D2 &= ~0x80; if (this->unk_434 >= 150) { this->unk_210 = 0x352E; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C2A64; } else { this->unk_2D4 = this->unk_2E6; @@ -839,7 +841,7 @@ void func_809C2D0C(EnAob01* this, GlobalContext* globalCtx) { } this->unk_210 = 0x354C; - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); this->actionFunc = func_809C1D64; gSaveContext.eventInf[0] &= (u8)~7; } @@ -922,19 +924,19 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { EnAob01* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_aob_Skel_000180, NULL, this->jointTable, this->morphTable, - 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMamamuYanSkel, NULL, this->jointTable, this->morphTable, + MAMAMU_YAN_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_43C = 0; - Actor_ChangeAnimation(&this->skelAnime, D_809C3790, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, D_809C3790, 0); Actor_SetScale(&this->actor, 0.01f); switch (gSaveContext.eventInf[0] & 7) { case 0: func_809C2FA0(); func_809C11EC(this, globalCtx); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_809C2060; break; @@ -945,7 +947,7 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_430 = this->actor.cutscene; func_809C2594(this, globalCtx); ActorCutscene_SetIntentToPlay(this->unk_430); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_809C2F34(this, globalCtx); this->actionFunc = func_809C2824; break; @@ -953,8 +955,8 @@ void EnAob01_Init(Actor* thisx, GlobalContext* globalCtx) { case 3: func_809C2FA0(); func_809C11EC(this, globalCtx); - this->actor.flags |= 1; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_809C28B8; break; } @@ -979,35 +981,36 @@ void EnAob01_Update(Actor* thisx, GlobalContext* globalCtx) { s32 EnAob01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnAob01* this = THIS; - TexturePtr sp38[] = { - object_aob_Tex_000658, - object_aob_Tex_000E58, - object_aob_Tex_001658, + TexturePtr eyeTextures[] = { + gMamamuYanEyeOpenTex, + gMamamuYanEyeHalfTex, + gMamamuYanEyeClosedTex, }; - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { OPEN_DISPS(globalCtx->state.gfxCtx); - *dList = object_aob_DL_003D18; + *dList = gMamamuYanHeadDL; - gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sp38[this->unk_3EE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(eyeTextures[this->eyeIndex])); CLOSE_DISPS(globalCtx->state.gfxCtx); } - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk_2DA.y, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_2DA.x * -1, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 8) { + if (limbIndex == MAMAMU_YAN_LIMB_TORSO) { Matrix_InsertXRotation_s(this->unk_2E0.y * -1, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->unk_2E0.x * -1, MTXMODE_APPLY); } - if ((limbIndex == 8) || (limbIndex == 9) || (limbIndex == 12)) { + 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; } @@ -1018,7 +1021,7 @@ void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, static Vec3f D_809C3968 = { 0.0f, 0.0f, 0.0f }; EnAob01* this = THIS; - if (limbIndex == 15) { + if (limbIndex == MAMAMU_YAN_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&D_809C3968, &this->actor.focus.pos); } } 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 be7655fad..69e15f658 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 @@ -2,6 +2,7 @@ #define Z_EN_AOB_01_H #include "global.h" +#include "objects/object_aob/object_aob.h" struct EnAob01; @@ -17,8 +18,8 @@ typedef struct EnAob01 { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ Path* unk_1D8[14]; /* 0x210 */ u16 unk_210; - /* 0x212 */ Vec3s jointTable[16]; - /* 0x272 */ Vec3s morphTable[16]; + /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; + /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; /* 0x2D4 */ Vec3s unk_2D4; /* 0x2DA */ Vec3s unk_2DA; @@ -26,11 +27,11 @@ typedef struct EnAob01 { /* 0x2E6 */ Vec3s unk_2E6; /* 0x2EC */ Vec3s unk_2EC; /* 0x2F2 */ Vec3s unk_2F2; - /* 0x2F8 */ s16 unk_2F8[16]; - /* 0x318 */ s16 unk_318[16]; + /* 0x2F8 */ s16 unk_2F8[MAMAMU_YAN_LIMB_MAX]; + /* 0x318 */ s16 unk_318[MAMAMU_YAN_LIMB_MAX]; /* 0x338 */ UNK_TYPE1 unk338[0xB6]; - /* 0x3EE */ s16 unk_3EE; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3EE */ s16 eyeIndex; + /* 0x3F0 */ s16 blinkTimer; /* 0x3F4 */ Actor* unk_3F4; /* 0x3F8 */ Actor* unk_3F8[14]; /* 0x430 */ s16 unk_430; 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 097c90fe0..d3286f545 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -5,8 +5,10 @@ */ #include "z_en_arrow.h" +#include "overlays/effects/ovl_Effect_Ss_Sbn/z_eff_ss_sbn.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnArrow*)thisx) @@ -20,7 +22,6 @@ void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx); void func_8088B630(EnArrow* this, GlobalContext* globalCtx); void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Arrow_InitVars = { ACTOR_EN_ARROW, ACTORCAT_ITEMACTION, @@ -33,45 +34,718 @@ const ActorInit En_Arrow_InitVars = { (ActorFunc)EnArrow_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_8088C1E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_PLAYER, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK2, { 0x00000020, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000020, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8088C230[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(terminalVelocity, -150, ICHAIN_STOP), }; +void EnArrow_Init(Actor* thisx, GlobalContext* globalCtx) { + static EffectBlureInit2 D_8088C234 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 0, 150, 0, 0 }, + }; + static EffectBlureInit2 D_8088C258 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 200, 0, 255 }, { 255, 0, 0, 0 }, + }; + static EffectBlureInit2 D_8088C27C = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 170, 255, 255, 255 }, { 0, 0x64, 255, 0 }, + }; + static EffectBlureInit2 D_8088C2A0 = { + 0, 4, 0, { 0, 255, 200, 255 }, { 0, 255, 255, 255 }, { 0, 255, 200, 0 }, { 0, 255, 255, 0 }, 16, + 0, 1, 0, { 255, 255, 170, 255 }, { 255, 255, 0, 0 }, + }; + EnArrow* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + if (this->actor.params == ENARROW_MINUS8) { + this->unk_263 = 1; + this->actor.params = 8; + } + + if (this->actor.params < ENARROW_6) { + SkelAnime_Init(globalCtx, &this->arrow.skelAnime, &gameplay_keep_Skel_014560, &gameplay_keep_Anim_0128BC, + this->arrow.jointTable, this->arrow.jointTable, 5); + if (this->actor.params < ENARROW_3) { + if (this->actor.params == ENARROW_1) { + D_8088C234.elemDuration = 4; + } else { + D_8088C234.elemDuration = 16; + } + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C234); + } else if (this->actor.params == ENARROW_3) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C258); + } else if (this->actor.params == ENARROW_4) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C27C); + } else if (this->actor.params == ENARROW_5) { + Effect_Add(globalCtx, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C2A0); + } + } + + Collider_InitQuad(globalCtx, &this->collider); + Collider_SetQuad(globalCtx, &this->collider, &this->actor, &sQuadInit); + + if (this->actor.params < ENARROW_6) { + this->collider.info.toucherFlags &= ~(TOUCH_SFX_WOOD | TOUCH_SFX_HARD); + this->collider.info.toucherFlags |= 0; + } + + 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); + if (this->actor.params == ENARROW_8) { + this->collider.info.toucher.damage = 1; + } + + if (this->actor.params == ENARROW_7) { + Actor_SetScale(&this->actor, 1.0f); + } + } + this->actionFunc = func_8088A594; +} + +void EnArrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnArrow* this = THIS; + + if (this->actor.params < ENARROW_6) { + Effect_Destroy(globalCtx, this->unk_240); + } + + Collider_DestroyQuad(globalCtx, &this->collider); + + if ((this->unk_264 != NULL) && (this->unk_264->update != NULL)) { + this->unk_264->flags &= ~0x8000; + } + + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6) && (this->actor.child == NULL)) { + func_80115D5C(&globalCtx->state); + } +} + +void func_8088A514(EnArrow* this) { + f32 temp_f0 = 16.0f - this->bubble.unk_144; + + Actor_SetSpeeds(&this->actor, CLAMP(temp_f0, 1.0f, 80.0f)); +} + +void func_8088A594(EnArrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.parent != NULL) { + if (this->actor.params == ENARROW_7) { + if (Math_SmoothStepToF(&this->bubble.unk_144, 16.0f, 0.07f, 1.8f, 0.0f) > 0.5f) { + func_800B9010(&this->actor, NA_SE_PL_DEKUNUTS_BUBLE_BREATH - SFX_FLAG); + return; + } + + this->bubble.unk_148++; + if (this->bubble.unk_148 > 20) { + this->actionFunc = func_8088ACE0; + func_80115D5C(&globalCtx->state); + } + } + } else { + if ((this->actor.params != ENARROW_8) && (player->unk_D57 == 0)) { + if (this->actor.params == ENARROW_7) { + func_80115D5C(&globalCtx->state); + } + Actor_MarkForDeath(&this->actor); + return; + } + + switch (this->actor.params) { + case ENARROW_6: + func_800B8E58(player, NA_SE_IT_SLING_SHOT); + break; + + case ENARROW_0: + case ENARROW_1: + case ENARROW_2: + func_800B8E58(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); + + case ENARROW_7: + func_800B8E58(player, NA_SE_PL_DEKUNUTS_FIRE); + break; + } + + this->actionFunc = func_8088ACE0; + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + + if (this->actor.params == ENARROW_7) { + this->bubble.unk_144 = CLAMP_MIN(this->bubble.unk_144, 3.5f); + func_8088A514(this); + this->unk_260 = 99; + func_80115D5C(&globalCtx->state); + } else if (this->actor.params >= ENARROW_6) { + if ((this->actor.params == ENARROW_8) && (this->actor.world.rot.x < 0)) { + Actor_SetScale(&this->actor, 0.009f); + this->unk_260 = 40; + } else { + Actor_SetSpeeds(&this->actor, 80.0f); + this->unk_260 = 15; + } + this->actor.shape.rot.x = 0; + this->actor.shape.rot.y = 0; + this->actor.shape.rot.z = 0; + } else { + Actor_SetSpeeds(&this->actor, 150.0f); + this->unk_260 = 16; + } + } +} + +void func_8088A7D8(GlobalContext* globalCtx, 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.gravity = -1.5f; + this->unk_260 = 50; + this->unk_263 = 1; +} + +void func_8088A894(EnArrow* this, GlobalContext* globalCtx) { + CollisionPoly* sp74; + Vec3f sp68; + Vec3f sp5C; + Vec3f sp50; + f32 sp4C; + f32 temp_f0; + s32 sp44; + + Math_Vec3f_Diff(&this->actor.world.pos, &this->unk_228, &sp68); + sp4C = ((this->actor.world.pos.x - this->unk_264->world.pos.x) * sp68.x) + + ((this->actor.world.pos.y - this->unk_264->world.pos.y) * sp68.y) + + ((this->actor.world.pos.z - this->unk_264->world.pos.z) * sp68.z); + if (sp4C < 0.0f) { + return; + } + + temp_f0 = Math3D_LengthSquared(&sp68); + if (temp_f0 < 1.0f) { + return; + } + + temp_f0 = sp4C / temp_f0; + Math_Vec3f_Scale(&sp68, temp_f0); + Math_Vec3f_Sum(&this->unk_264->world.pos, &sp68, &sp5C); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->unk_264->world.pos, &sp5C, &sp50, &sp74, true, true, true, + true, &sp44)) { + this->unk_264->world.pos.x = ((sp5C.x <= sp50.x) ? 1.0f : -1.0f) + sp50.x; + this->unk_264->world.pos.y = ((sp5C.y <= sp50.y) ? 1.0f : -1.0f) + sp50.y; + this->unk_264->world.pos.z = ((sp5C.z <= sp50.z) ? 1.0f : -1.0f) + sp50.z; + } else { + Math_Vec3f_Copy(&this->unk_264->world.pos, &sp5C); + } +} + +void func_8088AA98(EnArrow* this, GlobalContext* globalCtx) { + WaterBox* sp54; + f32 sp50 = this->actor.world.pos.y; + Vec3f sp44; + f32 temp_f0; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->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; + + Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.home.pos, &sp44); + + if (sp44.y != 0.0f) { + temp_f0 = sqrtf(SQ(sp44.x) + SQ(sp44.z)); + if (temp_f0 != 0.0f) { + temp_f0 = (((sp50 - this->actor.home.pos.y) / sp44.y) * temp_f0) / temp_f0; + } + sp44.x = this->actor.home.pos.x + (sp44.x * temp_f0); + sp44.y = sp50; + sp44.z = this->actor.home.pos.z + (sp44.z * temp_f0); + EffectSsGSplash_Spawn(globalCtx, &sp44, NULL, NULL, 0, 300); + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 0); + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &sp44, 100, 500, 8); + + if ((this->actor.params == ENARROW_4) || (this->actor.params == ENARROW_3)) { + if ((this->actor.params == ENARROW_4) && (func_8088B6B0 != this->actionFunc)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_BG_ICEFLOE, sp44.x, sp44.y, sp44.z, 0, 0, 0, 300); + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.params = ENARROW_2; + this->collider.info.toucher.dmgFlags = 0x20; + + if (this->actor.child != NULL) { + Actor_MarkForDeath(this->actor.child); + return; + } + + func_80115D5C(&globalCtx->state); + } + } +} + +#ifdef NON_MATCHING +// Stack. Scoped variable required to fix code gen at the bottom, likely sp60/54 there, +// but sp50 must be declared below those so maybe not? +void func_8088ACE0(EnArrow* this, GlobalContext* globalCtx) { + CollisionPoly* spAC; + s32 spA8; + Vec3f sp9C; + s32 phi_a2 = 0; + EffectSsSbnInitParams sp84; + u16 sp82; + Actor* sp7C; + f32 sp78; + f32 sp74; + f32 temp_f12_2; + Vec3f sp60; + Vec3f sp54; + s32 sp50; + + if ((DECR(this->unk_260) == 0) || + ((this->actor.params == ENARROW_7) && + ((this->unk_262 != 0) || (phi_a2 = (this->collider.base.atFlags & AT_HIT) != 0)))) { + if (this->actor.params == ENARROW_7) { + if (phi_a2 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4) && + (this->collider.base.atFlags & AT_BOUNCED)) { + if ((this->collider.base.at != NULL) && (this->collider.base.at->id != ACTOR_OBJ_SYOKUDAI)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + this->actor.world.rot.y += BINANG_ROT180((s16)randPlusMinusPoint5Scaled(8000.0f)); + this->actor.velocity.y = -this->actor.velocity.y; + this->bubble.unk_149 = -1; + return; + } + } + + if ((this->unk_262 != 0) || phi_a2) { + EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_DEKUNUTS_BUBLE_VANISH); + + if ((this->unk_262 != 0) && (this->actor.wallBgId == BG_ACTOR_MAX)) { + + Math_Vec3f_Copy(&sp84.unk_00, &this->actor.world.pos); + sp84.unk_0C = this->actor.wallPoly; + sp84.unk_10 = this->bubble.unk_144; + EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84.unk_00); + } + } + Actor_MarkForDeath(&this->actor); + return; + } + + sp50 = + (this->actor.params != ENARROW_0) && (this->actor.params < ENARROW_8) && (this->collider.base.atFlags & AT_HIT); + + if (sp50 || (this->unk_262 != 0)) { + if (this->actor.params >= ENARROW_6) { + if (sp50) { + this->actor.world.pos.x = (this->actor.world.pos.x + this->actor.prevPos.x) * 0.5f; + this->actor.world.pos.y = (this->actor.world.pos.y + this->actor.prevPos.y) * 0.5f; + this->actor.world.pos.z = (this->actor.world.pos.z + this->actor.prevPos.z) * 0.5f; + } + + if (this->actor.params == ENARROW_8) { + iREG(50) = -1; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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); + sp82 = NA_SE_IT_DEKU; + } else { + sp82 = NA_SE_IT_SLING_REFLECT; + } + EffectSsStone1_Spawn(globalCtx, &this->actor.world.pos, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, sp82); + Actor_MarkForDeath(&this->actor); + } else { + EffectSsHitMark_SpawnCustomScale(globalCtx, 0, 150, &this->actor.world.pos); + + if (sp50 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { + sp7C = this->collider.base.at; + + if ((sp7C->update != NULL) && !(this->collider.base.atFlags & AT_BOUNCED) && (sp7C->flags & 0x4000)) { + this->unk_264 = sp7C; + func_8088A894(this, globalCtx); + Math_Vec3f_Diff(&sp7C->world.pos, &this->actor.world.pos, &this->unk_268); + sp7C->flags |= 0x8000; + this->collider.base.atFlags &= ~AT_HIT; + this->actor.speedXZ *= 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(globalCtx, this); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HOOKSHOT_STICK_CRE); + } + } else if (this->unk_262 != 0) { + this->actionFunc = func_8088B630; + Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_0128BC); + if (this->actor.params >= ENARROW_0) { + this->unk_260 = 60; + } else { + this->unk_260 = 20; + } + 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); + this->unk_261 |= 1; + } + } + } else { + func_8088AA98(this, globalCtx); + 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; + + 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)); + this->actor.prevPos.z = this->actor.world.pos.z - (temp_f12_2 * (10.0f / sp78)); + + this->bubble.unk_149 = 1; + } + + if (Math_StepToF(&this->bubble.unk_144, 1.0f, 0.4f)) { + this->unk_260 = 0; + } else { + this->bubble.unk_14A += (s16)(this->bubble.unk_144 * (500.0f + Rand_ZeroFloat(1400.0f))); + this->actor.world.rot.x += (s16)(500.0f * Math_SinS(this->bubble.unk_14A)); + this->actor.shape.rot.x = this->actor.world.rot.x; + + this->bubble.unk_14C += (s16)(this->bubble.unk_144 * (500.0f + Rand_ZeroFloat(1400.0f))); + this->actor.world.rot.y += (s16)(500.0f * Math_SinS(this->bubble.unk_14C)); + + this->actor.shape.rot.y = this->actor.world.rot.y; + + func_8088A514(this); + } + func_800B9010(&this->actor, NA_SE_IT_DEKUNUTS_BUBLE_SHOT_LEVEL - SFX_FLAG); + } else if (this->unk_260 < 7) { + this->actor.gravity = -0.4f; + } + + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + + if (this->actor.speedXZ == 0.0f) { + this->actor.velocity.y -= 1.0f; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } + Actor_UpdatePos(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + this->unk_262 = BgCheck_ProjectileLineTest(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, + &sp9C, &this->actor.wallPoly, true, true, true, true, &spA8); + if (this->unk_262 != 0) { + func_800B90AC(globalCtx, &this->actor, this->actor.wallPoly, spA8, &sp9C); + Math_Vec3f_Copy(&this->actor.world.pos, &sp9C); + this->actor.wallBgId = spA8; + } + + if (this->actor.params < ENARROW_6) { + this->actor.shape.rot.x = Math_FAtan2F(this->actor.speedXZ, -this->actor.velocity.y); + } + } + + if (this->unk_264 != NULL) { + if (this->unk_264->update != NULL) { + s32 pad; + + Math_Vec3f_Sum(&this->unk_228, &this->unk_268, &sp60); + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &sp54); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp60, &sp54, &sp9C, &spAC, true, true, true, true, + &spA8)) { + this->unk_264->world.pos.x = ((sp54.x <= sp9C.x) ? 1.0f : -1.0f) + sp9C.x; + this->unk_264->world.pos.y = ((sp54.y <= sp9C.y) ? 1.0f : -1.0f) + sp9C.y; + this->unk_264->world.pos.z = ((sp54.z <= sp9C.z) ? 1.0f : -1.0f) + sp9C.z; + + Math_Vec3f_Diff(&this->unk_264->world.pos, &this->actor.world.pos, &this->unk_268); + this->unk_264->flags &= ~0x8000; + this->unk_264 = NULL; + } else { + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk_268, &this->unk_264->world.pos); + } + + if ((this->unk_262 != 0) && (this->unk_264 != NULL)) { + this->unk_264->flags &= ~0x8000; + this->unk_264 = NULL; + } + } else { + this->unk_264 = NULL; + } + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088ACE0.s") #endif -extern ColliderQuadInit D_8088C1E0; -extern InitChainEntry D_8088C230[]; +void func_8088B630(EnArrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->arrow.skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Init.s") + if (this->actor.wallBgId != BG_ACTOR_MAX) { + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.wallBgId, &this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Destroy.s") + if (DECR(this->unk_260) == 0) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A514.s") +void func_8088B6B0(EnArrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->arrow.skelAnime); + Actor_MoveWithGravity(&this->actor); + func_8088AA98(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A594.s") + if (DECR(this->unk_260) == 0) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A7D8.s") +void EnArrow_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f D_8088C2CC = { 0.0f, 0.5f, 0.0f }; + static Vec3f D_8088C2D8 = { 0.0f, 0.5f, 0.0f }; + static Color_RGBA8 D_8088C2E4 = { 255, 255, 100, 255 }; + static Color_RGBA8 D_8088C2E8 = { 255, 50, 0, 0 }; + s32 pad; + EnArrow* this = THIS; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088A894.s") + if ((this->unk_263 != 0) || + ((this->actor.params >= ENARROW_0) && ((this->actor.params == ENARROW_7) || (player->unk_D57 != 0))) || + !func_80123358(globalCtx, player)) { + this->actionFunc(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088AA98.s") + if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { + s16 sp44[] = { ACTOR_ARROW_FIRE, ACTOR_ARROW_ICE, ACTOR_ARROW_LIGHT }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088ACE0.s") + if (this->actor.child == NULL) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, sp44[this->actor.params - ENARROW_3], + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + } + } else if (this->actor.params == ENARROW_0) { + func_800B0EB0(globalCtx, &this->unk_234, &D_8088C2CC, &D_8088C2D8, &D_8088C2E4, &D_8088C2E8, 100, 0, 8); + } + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.prevPos); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B630.s") +typedef struct { + /* 0x00 */ Vec3f unk_00[2]; + /* 0x18 */ Vec3f unk_18[2][2]; + /* 0x48 */ Vec3f unk_48; +} EnArrowUnkStruct; // size = 0x54 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B6B0.s") +void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* arg2) { + Vec3f* sp4C; + Vec3f sp40; + Vec3f sp34; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Update.s") + Matrix_MultiplyVector3fByState(&arg2->unk_48, &this->unk_234); + if (func_8088ACE0 == this->actionFunc) { + if (this->unk_244 == 0) { + sp4C = arg2->unk_00; + } else { + sp4C = arg2->unk_18[globalCtx->gameplayFrames % 2]; + } + Matrix_MultiplyVector3fByState(&sp4C[0], &sp40); + Matrix_MultiplyVector3fByState(&sp4C[1], &sp34); + if (this->actor.params < ENARROW_8) { + sp30 = this->actor.params < ENARROW_6; + if (this->unk_264 == 0) { + sp30 &= func_80126440(globalCtx, &this->collider.base, &this->unk_244, &sp40, &sp34); + } else if (sp30 && (sp40.x == this->unk_248) && (sp40.y == this->unk_24C) && (sp40.z == this->unk_250) && + (sp34.x == this->unk_254) && (sp34.y == this->unk_258) && (sp34.z == this->unk_25C)) { + sp30 = false; + } + if (sp30) { + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_240), &sp40, &sp34); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/func_8088B88C.s") +void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + static EnArrowUnkStruct D_8088C2EC[] = { + { + { + { 400.0f, 400.0f, 0.0f }, + { -400.0f, 400.0f, 0.0f }, + }, + { + { + { 400.0f, 400.0f, 1500.0f }, + { -400.0f, 400.0f, 1500.0f }, + }, + { + { 400.0f, 400.0f, 1500.0f }, + { -400.0f, 400.0f, 1500.0f }, + }, + }, + { 0.0f, 0.0f, -300.0f }, + }, + { + { + { 20.0f, -20.0f, 20.0f }, + { 20.0f, -20.0f, 20.0f }, + }, + { + { + { 20.0f, -20.0f, 20.0f }, + { -20.0f, 20.0f, 20.0f }, + }, + { + { -20.0f, -20.0f, 20.0f }, + { 20.0f, 20.0f, 20.0f }, + }, + }, + { 0.0f, 0.0f, 20.0f }, + }, + }; + EnArrow* this = THIS; + s32 phi_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Arrow/EnArrow_Draw.s") + if (this->actor.params < ENARROW_6) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawLod(globalCtx, this->arrow.skelAnime.skeleton, this->arrow.skelAnime.jointTable, NULL, NULL, + &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 sp9C = (1.0f / spA0); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->bubble.unk_149 >= 0) { + func_8088B88C(globalCtx, this, &D_8088C2EC[1]); + } else { + Collider_ResetQuadAT(globalCtx, &this->collider.base); + } + + sp9C *= 0.002f; + spA0 *= 0.002f; + + Matrix_Scale(this->bubble.unk_144 * sp9C, this->bubble.unk_144 * sp9C, this->bubble.unk_144 * spA0, + MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 460.0f, MTXMODE_APPLY); + + if (this->actor.speedXZ == 0.0f) { + func_800B8118(&this->actor, globalCtx, MTXMODE_NEW); + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_06F380); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, 0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, + COMBINED, 0, ENVIRONMENT, 0, COMBINED, 0, ENVIRONMENT, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 225, 150, spA4); + + Matrix_NormalizeXYZ(&gIdentityMtxF); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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, globalCtx, MTXMODE_NEW); + + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06F380); + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, 0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, + COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x7F, 230, 225, 150, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06FAE0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return; + } else if (this->actor.speedXZ != 0.0f) { + u8 sp63 = (Math_CosS(this->unk_260 * 5000) * 127.5f) + 127.5f; + f32 sp5C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C240(globalCtx->state.gfxCtx); + + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + if (this->actor.params == ENARROW_6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, sp63); + sp5C = 50.0f; + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 12, 0, 0, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 0, sp63); + sp5C = 150.0f; + } + + Matrix_StatePush(); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + if (this->actor.speedXZ == 0.0f) { + phi_v0 = 0; + } else { + phi_v0 = (globalCtx->gameplayFrames % 256) * 4000; + } + + Matrix_InsertZRotation_s(phi_v0, MTXMODE_APPLY); + Matrix_Scale(sp5C, sp5C, sp5C, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + + Matrix_StatePop(); + Matrix_RotateY(this->actor.world.rot.y, MTXMODE_APPLY); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (this->actor.velocity.y != 0.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_058BA0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + func_8088B88C(globalCtx, this, &D_8088C2EC[0]); +} 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 119507d4d..f318cf152 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -7,15 +7,56 @@ struct EnArrow; typedef void (*EnArrowActionFunc)(struct EnArrow*, GlobalContext*); +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, +}; + +typedef struct { + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[5]; +} EnArrowArrow; // size = 0x1A8 + +typedef struct { + /* 0x144 */ f32 unk_144; + /* 0x148 */ u8 unk_148; + /* 0x149 */ s8 unk_149; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ s16 unk_14C; +} EnArrowBubble; // size = 0x150 + typedef struct EnArrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x7C]; - /* 0x01C0 */ s32 unk_1C0; - /* 0x01C4 */ char unk_1C4[0x9C]; - /* 0x0260 */ u8 unk_260; // timer in OoT - /* 0x0261 */ u8 unk_261; // hitFlags in OoT - /* 0x0262 */ char unk_262[0x12]; - /* 0x0274 */ EnArrowActionFunc actionFunc; + /* 0x000 */ Actor actor; + union { + EnArrowArrow arrow; + EnArrowBubble bubble; + }; + /* 0x1A8 */ ColliderQuad collider; + /* 0x228 */ Vec3f unk_228; + /* 0x234 */ Vec3f unk_234; + /* 0x240 */ s32 unk_240; + /* 0x244 */ s32 unk_244; + /* 0x248 */ f32 unk_248; + /* 0x24C */ f32 unk_24C; + /* 0x250 */ f32 unk_250; + /* 0x254 */ f32 unk_254; + /* 0x258 */ f32 unk_258; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ u8 unk_260; // timer in OoT + /* 0x261 */ u8 unk_261; // hitFlags in OoT + /* 0x262 */ u8 unk_262; + /* 0x263 */ u8 unk_263; + /* 0x264 */ Actor* unk_264; + /* 0x268 */ Vec3f unk_268; + /* 0x274 */ EnArrowActionFunc actionFunc; } EnArrow; // size = 0x278 extern const ActorInit En_Arrow_InitVars; 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 5eca6c796..b100f692f 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 @@ -5,8 +5,9 @@ */ #include "z_en_attack_niw.h" +#include "overlays/actors/ovl_En_Niw/z_en_niw.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnAttackNiw*)thisx) @@ -19,7 +20,6 @@ void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx); void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx); void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, ACTORCAT_ENEMY, @@ -32,35 +32,421 @@ const ActorInit En_Attack_Niw_InitVars = { (ActorFunc)EnAttackNiw_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80959120[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 1, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 0, ICHAIN_STOP), }; -#endif +void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; -extern InitChainEntry D_80959120[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_niw_Skel_002530, &object_niw_Anim_0000E8, this->jointTable, + this->morphTable, OBJECT_NIW_LIMB_MAX); -extern UNK_TYPE D_060000E8; + if (this->actor.params < 0) { + this->actor.params = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Init.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.gravity = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Destroy.s") + this->unk_290.x = randPlusMinusPoint5Scaled(100.0f); + this->unk_290.y = randPlusMinusPoint5Scaled(10.0f); + this->unk_290.z = randPlusMinusPoint5Scaled(100.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958228.s") + Actor_SetScale(&this->actor, 0.01f); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.shape.rot.y = this->actor.world.rot.y = (Rand_ZeroOne() - 0.5f) * 60000.0f; + this->actionFunc = func_80958634; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_809585B0.s") +void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + EnNiw* parent = (EnNiw*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958634.s") + if ((thisx->parent != NULL) && (thisx->parent->update != NULL)) { + if (parent->unk290 > 0) { + parent->unk290--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958974.s") +void func_80958228(EnAttackNiw* this, GlobalContext* globalCtx, s16 arg2) { + if (this->unk_24C == 0) { + if (arg2 == 0) { + this->unk_25C = 0.0f; + } else { + this->unk_25C = -10000.0f; + } + this->unk_286++; + this->unk_24C = 3; + if ((this->unk_286 % 2) == 0) { + this->unk_25C = 0.0f; + if (arg2 == 0) { + this->unk_24C = Rand_ZeroFloat(30.0f); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958BE4.s") + if (this->unk_250 == 0) { + this->unk_28A++; + this->unk_28A &= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Update.s") + switch (arg2) { + case 0: + this->unk_264 = 0.0f; + this->unk_260 = 0.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/func_80958F6C.s") + case 1: + this->unk_250 = 3; + this->unk_264 = 7000.0f; + this->unk_260 = 7000.0f; + if (this->unk_28A == 0) { + this->unk_264 = 0.0f; + this->unk_260 = 0.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Attack_Niw/EnAttackNiw_Draw.s") + case 2: + this->unk_250 = 2; + this->unk_264 = -10000.0f; + this->unk_260 = -10000.0f; + this->unk_278 = 25000.0f; + this->unk_270 = 25000.0f; + this->unk_27C = 6000.0f; + this->unk_274 = 6000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 8000.0f; + this->unk_278 = 8000.0f; + } + break; + + case 3: + this->unk_250 = 2; + this->unk_270 = 10000.0f; + this->unk_278 = 10000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 3000.0f; + this->unk_278 = 3000.0f; + } + break; + + case 4: + this->unk_24E = 5; + this->unk_24C = this->unk_24E; + break; + + case 5: + this->unk_250 = 5; + this->unk_270 = 14000.0f; + this->unk_278 = 14000.0f; + if (this->unk_28A == 0) { + this->unk_270 = 10000.0f; + this->unk_278 = 10000.0f; + } + break; + } + } + + if (this->unk_280 != this->unk_2B8) { + Math_ApproachF(&this->unk_2B8, this->unk_280, 0.5f, 4000.0f); + } + + if (this->unk_25C != this->unk_2B4) { + Math_ApproachF(&this->unk_2B4, this->unk_25C, 0.5f, 4000.0f); + } + + if (this->unk_264 != this->unk_29C) { + Math_ApproachF(&this->unk_29C, this->unk_264, 0.8f, 7000.0f); + } + + if (this->unk_278 != this->unk_2A0) { + Math_ApproachF(&this->unk_2A0, this->unk_278, 0.8f, 7000.0f); + } + + if (this->unk_27C != this->unk_2A4) { + Math_ApproachF(&this->unk_2A4, this->unk_27C, 0.8f, 7000.0f); + } + + if (this->unk_260 != this->unk_2A8) { + Math_ApproachF(&this->unk_2A8, this->unk_260, 0.8f, 7000.0f); + } + + if (this->unk_270 != this->unk_2AC) { + Math_ApproachF(&this->unk_2AC, this->unk_270, 0.8f, 7000.0f); + } + + if (this->unk_274 != this->unk_2B0) { + Math_ApproachF(&this->unk_2B0, this->unk_274, 0.8f, 7000.0f); + } +} + +s32 func_809585B0(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 sp1E; + s16 sp1C; + + Actor_SetFocus(&this->actor, this->unk_2DC); + Actor_GetScreenPos(globalCtx, &this->actor, &sp1E, &sp1C); + + if ((this->actor.projectedPos.z < -20.0f) || (sp1E < 0) || (sp1E > SCREEN_WIDTH) || (sp1C < 0) || + (sp1C > SCREEN_HEIGHT)) { + return false; + } + return true; +} + +void func_80958634(EnAttackNiw* this, GlobalContext* globalCtx) { + s16 sp4E; + s16 sp4C; + Vec3f temp; + Vec3f sp34; + s32 pad; + + this->actor.speedXZ = 10.0f; + + temp.x = (this->unk_290.x + globalCtx->view.at.x) - globalCtx->view.eye.x; + temp.y = (this->unk_290.y + globalCtx->view.at.y) - globalCtx->view.eye.y; + temp.z = (this->unk_290.z + globalCtx->view.at.z) - globalCtx->view.eye.z; + + sp34.x = globalCtx->view.at.x + temp.x; + sp34.y = globalCtx->view.at.y + temp.y; + sp34.z = globalCtx->view.at.z + temp.z; + + this->unk_2CC = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); + this->unk_2C8 = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34) * -1.0f; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 5, this->unk_2D4, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + + Actor_SetFocus(&this->actor, this->unk_2DC); + Actor_GetScreenPos(globalCtx, &this->actor, &sp4E, &sp4C); + + if (this->actor.bgCheckFlags & 8) { + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_2C8 = this->actor.world.rot.x - 3000.0f; + this->unk_252 = 0; + this->unk_254 = 100; + this->unk_2D4 = 0.0f; + this->unk_27C = 0.0f; + this->unk_274 = 0.0f; + this->unk_250 = this->unk_252; + this->unk_24E = this->unk_252; + this->unk_24C = this->unk_252; + this->actor.gravity = -0.2f; + this->unk_280 = 0.0f; + this->actionFunc = func_80958974; + this->unk_2D8 = 5.0f; + } else if (((this->actor.projectedPos.z > 0.0f) && (fabsf(sp34.x - this->actor.world.pos.x) < 50.0f) && + (fabsf(sp34.y - this->actor.world.pos.y) < 50.0f) && + (fabsf(sp34.z - this->actor.world.pos.z) < 50.0f)) || + (this->actor.bgCheckFlags & 1)) { + this->unk_252 = 0; + this->unk_250 = this->unk_252; + this->unk_24E = this->unk_252; + this->unk_24C = this->unk_252; + this->unk_2D4 = 0.0f; + this->unk_274 = 0.0f; + this->unk_27C = 0.0f; + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_2C8 = this->actor.world.rot.x - 2000.0f; + this->actor.gravity = -0.2f; + this->unk_280 = 0.0f; + this->actionFunc = func_80958974; + this->unk_2D8 = 5.0f; + } else { + this->unk_24C = 10; + this->unk_25C = -10000.0f; + this->unk_280 = -3000.0f; + func_80958228(this, globalCtx, 2); + } +} + +void func_80958974(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!func_809585B0(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 1) { + if (this->unk_252 == 0) { + this->unk_252 = 3; + this->actor.velocity.y = 3.5f; + } + + if (this->actor.gravity != -2.0f) { + this->unk_2CC = this->actor.yawTowardsPlayer; + this->unk_25A = 50; + this->unk_254 = 100; + this->unk_270 = 14000.0f; + this->unk_278 = 14000.0f; + this->unk_274 = 0.0f; + this->unk_27C = 0.0f; + this->unk_260 = 0.0f; + this->unk_264 = 0.0f; + this->unk_2C8 = 0.0f; + this->actor.gravity = -2.0f; + } + } + + if (this->unk_254 == 50) { + this->unk_2CC = randPlusMinusPoint5Scaled(200.0f) + this->actor.yawTowardsPlayer; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2CC, 2, this->unk_2D4, 0); + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 2, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 10000.0f, 1.0f, 1000.0f); + Math_ApproachF(&this->actor.speedXZ, this->unk_2D8, 0.9f, 1.0f); + + if ((this->actor.gravity == -2.0f) && (this->unk_25A == 0) && + ((this->actor.bgCheckFlags & 8) || (this->unk_254 == 0))) { + this->unk_2D8 = 0.0f; + this->actor.gravity = 0.0f; + this->unk_2D4 = 0.0f; + this->unk_2C8 = this->actor.world.rot.x - 5000.0f; + this->actionFunc = func_80958BE4; + } else if (this->actor.bgCheckFlags & 1) { + func_80958228(this, globalCtx, 5); + } else { + func_80958228(this, globalCtx, 2); + } +} + +void func_80958BE4(EnAttackNiw* this, GlobalContext* globalCtx) { + if (!func_809585B0(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Math_SmoothStepToS(&this->actor.world.rot.x, this->unk_2C8, 5, this->unk_2D4, 0); + Math_ApproachF(&this->unk_2D4, 5000.0f, 1.0f, 100.0f); + Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); + func_80958228(this, globalCtx, 2); +} + +void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + s32 pad; + EnNiw* parent; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + Vec3f sp30; + + this->unk_284++; + + if (this->unk_24C != 0) { + this->unk_24C--; + } + + if (this->unk_250 != 0) { + this->unk_250--; + } + + if (this->unk_252 != 0) { + this->unk_252--; + } + + if (this->unk_256 != 0) { + this->unk_256--; + } + + if (this->unk_258 != 0) { + this->unk_258--; + } + + if (this->unk_254 != 0) { + this->unk_254--; + } + + if (this->unk_25A != 0) { + this->unk_25A--; + } + + this->actor.shape.rot = this->actor.world.rot; + this->actor.shape.shadowScale = 15.0f; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + + if (this->actionFunc == func_80958634) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.floorHeight <= -32000.0f) { + Actor_MarkForDeath(&this->actor); + } else if ((this->actor.bgCheckFlags & 0x20) && (this->actionFunc != func_80958BE4)) { + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + sp30.y += this->actor.depthInWater; + + EffectSsGSplash_Spawn(globalCtx, &sp30, NULL, NULL, 0, 400); + this->unk_2D4 = 0.0f; + this->actor.gravity = 0.0f; + this->unk_2D8 = 0.0f; + this->unk_2C8 = this->actor.world.rot.x - 5000.0f; + this->actionFunc = func_80958BE4; + } else { + f32 temp = 20.0f; + + label: + + if (this->actor.xyzDistToPlayerSq < SQ(temp)) { + parent = (EnNiw*)this->actor.parent; + if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && + (parent->unusedTimer25E == 0) && (player->invincibilityTimer == 0)) { + func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + parent->unusedTimer25E = 70; + } + } + + if (this->unk_256 == 0) { + this->unk_256 = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_A); + } + + if (this->unk_258 == 0) { + this->unk_258 = 7; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_CHICKEN_FLUTTER); + } + } +} + +s32 EnAttackNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnAttackNiw* this = THIS; + + if (limbIndex == OBJECT_NIW_LIMB_0D) { + rot->y += (s16)this->unk_2B4; + } + + if (limbIndex == OBJECT_NIW_LIMB_0F) { + rot->z += (s16)this->unk_2B8; + } + + if (limbIndex == OBJECT_NIW_LIMB_0B) { + rot->x += (s16)this->unk_2B0; + rot->y += (s16)this->unk_2AC; + rot->z += (s16)this->unk_2A8; + } + + if (limbIndex == OBJECT_NIW_LIMB_07) { + rot->x += (s16)this->unk_2A4; + rot->y += (s16)this->unk_2A0; + rot->z += (s16)this->unk_29C; + } + return false; +} + +void EnAttackNiw_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnAttackNiw* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnAttackNiw_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h index 27d5546a1..4d3243ef5 100644 --- a/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h +++ b/src/overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h @@ -2,16 +2,56 @@ #define Z_EN_ATTACK_NIW_H #include "global.h" +#include "objects/object_niw/object_niw.h" struct EnAttackNiw; typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); typedef struct EnAttackNiw { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnAttackNiwActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x94]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_NIW_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[OBJECT_NIW_LIMB_MAX]; + /* 0x248 */ EnAttackNiwActionFunc actionFunc; + /* 0x24C */ s16 unk_24C; + /* 0x24E */ s16 unk_24E; + /* 0x250 */ s16 unk_250; + /* 0x252 */ s16 unk_252; + /* 0x254 */ s16 unk_254; + /* 0x256 */ s16 unk_256; + /* 0x258 */ s16 unk_258; + /* 0x25A */ s16 unk_25A; + /* 0x25C */ f32 unk_25C; + /* 0x260 */ f32 unk_260; + /* 0x264 */ f32 unk_264; + /* 0x268 */ UNK_TYPE1 unk268[8]; + /* 0x270 */ f32 unk_270; + /* 0x274 */ f32 unk_274; + /* 0x278 */ f32 unk_278; + /* 0x27C */ f32 unk_27C; + /* 0x280 */ f32 unk_280; + /* 0x284 */ s16 unk_284; + /* 0x286 */ s16 unk_286; + /* 0x288 */ UNK_TYPE1 unk288[2]; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ UNK_TYPE1 unk28C[4]; + /* 0x290 */ Vec3f unk_290; + /* 0x29C */ f32 unk_29C; + /* 0x2A0 */ f32 unk_2A0; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 unk_2AC; + /* 0x2B0 */ f32 unk_2B0; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ f32 unk_2B8; + /* 0x2BC */ UNK_TYPE1 unk2BC[0xC]; + /* 0x2C8 */ f32 unk_2C8; + /* 0x2CC */ f32 unk_2CC; + /* 0x2D0 */ UNK_TYPE1 unk2D0[4]; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ f32 unk_2D8; + /* 0x2DC */ f32 unk_2DC; } EnAttackNiw; // size = 0x2E0 extern const ActorInit En_Attack_Niw_InitVars; 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 c5f687498..f815991c1 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -6,7 +6,7 @@ #include "z_en_az.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnAz*)thisx) 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 4593ec4b0..ff2d7c48e 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -5,8 +5,10 @@ */ #include "z_en_baba.h" +#include "overlays/actors/ovl_En_Ossan/z_en_ossan.h" +#include "objects/object_bba/object_bba.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBaba*)thisx) @@ -27,7 +29,6 @@ void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx); void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx); void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Baba_InitVars = { ACTOR_EN_BABA, ACTORCAT_NPC, @@ -40,18 +41,38 @@ const ActorInit En_Baba_InitVars = { (ActorFunc)EnBaba_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BAA430 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &gBbaIdleHoldingBagAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaWalkingHoldingBagAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaKnockedOverAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gBbaLyingDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gBbaWalkingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BAA45C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80BAA468 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -86,67 +107,661 @@ static DamageTable D_80BAA468 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +s32 D_80BAA488[] = { + 0x0C000119, 0x0A006E14, 0x02000000, 0x1E080F00, 0x1E030400, 0x01050E00, 0x00001E02, 0x05050000, +}; -extern ColliderCylinderInit D_80BAA430; -extern CollisionCheckInfoInit2 D_80BAA45C; -extern DamageTable D_80BAA468; +s32 D_80BAA4A8[] = { -1, -1, 0 }; -extern UNK_TYPE D_06006B10; -extern UNK_TYPE D_060092A0; +u16 D_80BAA4B4[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8820.s") +s32 func_80BA8820(EnBaba* this, GlobalContext* globalCtx) { + this->unk_144 = (EnOssan*)SubS_FindActor(globalCtx, &this->unk_144->actor, ACTORCAT_NPC, ACTOR_EN_OSSAN); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA886C.s") + if (this->unk_144 != NULL) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8C4C.s") +void func_80BA886C(EnBaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8C90.s") + switch (this->unk_1E0) { + case 0: + if (this->unk_40A & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { + this->unk_1E0 = 0x2A34; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8D2C.s") + if (gSaveContext.save.weekEventReg[79] & 0x40) { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A33; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8DF4.s") + this->unk_40A |= 1; + this->unk_1E0 = 0x2A32; + break; + } else if (player->transformation == PLAYER_FORM_DEKU) { + if (!(gSaveContext.save.weekEventReg[79] & 0x20)) { + gSaveContext.save.weekEventReg[79] |= 0x20; + this->unk_40A |= 1; + this->unk_1E0 = 0x2A37; + break; + } else { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A38; + } + break; + } else if (!(gSaveContext.save.weekEventReg[33] & 8)) { + if (!(gSaveContext.save.weekEventReg[73] & 1)) { + this->unk_1E0 = 0x660; + break; + } + this->unk_1E0 = 0x662; + break; + } else { + if (!(gSaveContext.save.weekEventReg[73] & 2)) { + this->unk_1E0 = 0x65A; + break; + } + this->unk_1E0 = 0x65E; + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA8F88.s") + case 0x660: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x661; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9110.s") + case 0x661: + Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); + this->unk_1E0 = 0x662; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9160.s") + case 0x662: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x663; + gSaveContext.save.weekEventReg[73] |= 1; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA93AC.s") + case 0x65A: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65B; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9480.s") + case 0x65B: + Actor_ChangeFocus(&this->unk_144->actor, globalCtx, &this->actor); + this->unk_1E0 = 0x65C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9758.s") + case 0x65C: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65D; + gSaveContext.save.weekEventReg[73] |= 2; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9848.s") + case 0x65E: + Actor_ChangeFocus(&this->actor, globalCtx, &this->unk_144->actor); + this->unk_1E0 = 0x65F; + this->unk_40A |= 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA98EC.s") + case 0x2A34: + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + this->unk_40A |= 1; + this->unk_1E0 = 0x2A36; + break; + } + this->unk_40A |= 0x20; + this->unk_1E0 = 0x2A35; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9AB8.s") + case 0x2A35: + this->unk_40A |= 1; + this->unk_1E0 = 0x2A36; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9B24.s") + case 0x2A30: + case 0x2A31: + this->unk_40A |= 1; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9B80.s") + Message_StartTextbox(globalCtx, this->unk_1E0, &this->actor); + if (this->unk_40A & 1) { + if (this->unk_40A & 0x40) { + this->unk_40A &= ~0x40; + func_80151BB4(globalCtx, 0x33); + } + func_80151BB4(globalCtx, 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9CD4.s") +void func_80BA8C4C(GlobalContext* globalCtx, u16 nextEntrance) { + globalCtx->nextEntranceIndex = nextEntrance; + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 0x40; + globalCtx->sceneLoadFlag = 0x14; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E00.s") +void func_80BA8C90(EnBaba* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x + 5.0f; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z + 22.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E10.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9E48.s") +s32 func_80BA8D2C(EnBaba* this, f32 arg1) { + s16 sp3E; + s32 ret = false; + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Init.s") + Math_SmoothStepToF(&this->actor.speedXZ, arg1, 0.4f, 1000.0f, 0.0f); + sp3E = this->actor.speedXZ * 400.0f; + if (SubS_CopyPointFromPath(this->path, this->unk_1E8, &sp2C) && SubS_MoveActorToPoint(&this->actor, &sp2C, sp3E)) { + this->unk_1E8++; + if (this->unk_1E8 >= this->path->count) { + ret = true; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Destroy.s") +void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Update.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BA9FB0.s") + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && + !(this->unk_40A & 4)) { + sp30.x = player->actor.world.pos.x; + sp30.y = player->bodyPartsPos[7].y + 3.0f; + sp30.z = player->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BAA198.s") + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk_2DE, &this->unk_2E4, + &this->unk_2EA, D_80BAA4B4); + } else { + Math_SmoothStepToS(&this->unk_2DE.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2DE.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E4.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2E4.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2EA.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk_2EA.y, 0, 4, 1000, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/func_80BAA20C.s") + SubS_FillLimbRotTables(globalCtx, this->unk_302, this->unk_326, ARRAY_COUNT(this->unk_302)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Baba/EnBaba_Draw.s") + if (this->unk_40A & 2) { + func_80BA8C90(this, globalCtx); + } +} + +s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); + u16 temp; + u8 sp23 = ENBABA_GET_3F00(&this->actor); + + if (D_80BAA4A8[arg2->unk0] >= 0) { + this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + } + + if (this->unk_410 == NULL) { + return false; + } + + if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { + temp = sp26; + } else { + temp = arg2->unk4; + } + + if (arg2->unk8 < temp) { + this->unk_424 = (temp - arg2->unk8) + 0xFFFF; + } else { + this->unk_424 = arg2->unk8 - temp; + } + + this->unk_430 = sp26 - temp; + temp = this->unk_410->count - 2; + this->unk_428 = this->unk_424 / temp; + this->unk_438 = 0; + this->unk_42C = (this->unk_430 / this->unk_428) + 2; + this->unk_43C = 0; + return true; +} + +s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + switch (arg2->unk0) { + default: + ret = false; + break; + + case 2: + ret = func_80BA8F88(this, globalCtx, arg2); + break; + + case 1: + ret = true; + break; + } + return ret; +} + +s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { + f32 sp7C[265]; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + s32 sp54 = 0; + s32 sp50 = 0; + s32 pad; + + func_8013AF00(sp7C, 3, this->unk_410->count + 3); + + if (this->unk_438 == 0) { + sp58 = gZeroVec3f; + + func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, + &sp58, this->unk_436); + func_8013B878(globalCtx, this->unk_410, this->unk_42C, &sp58); + this->actor.world.pos.y = sp58.y; + this->unk_438 = 1; + } else { + sp58 = this->unk_414; + } + + this->actor.world.pos.x = sp58.x; + this->actor.world.pos.z = sp58.z; + + if (func_8013AD6C(globalCtx)) { + sp54 = this->unk_430; + sp50 = this->unk_42C; + sp58 = this->actor.world.pos; + } + + this->unk_414 = gZeroVec3f; + + if (func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, + &this->unk_414, this->unk_436)) { + this->unk_43C = 1; + } else { + sp70 = this->actor.world.pos; + sp64 = this->unk_414; + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); + } + + if (func_8013AD6C(globalCtx)) { + this->unk_430 = sp54; + this->unk_42C = sp50; + this->unk_414 = sp58; + } + + return false; +} + +void func_80BA93AC(EnBaba* this, GlobalContext* globalCtx) { + if (this->unk_434 != 1) { + if (this->unk_434 == 2) { + gSaveContext.save.weekEventReg[58] |= 0x40; + this->unk_40A |= 2; + func_80BA9160(this, globalCtx); + } + } else { + this->unk_40C = 3; + this->unk_1E0 = 10800; + this->actor.speedXZ = 0.0f; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->unk_40A |= 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); + this->actionFunc = func_80BA9CD4; + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); +} + +void func_80BA9480(EnBaba* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBbaSkel, &gBbaWalkingHoldingBagAnim, this->jointTable, + this->morphTable, 0x12); + + this->actor.draw = EnBaba_Draw; + this->unk_40A |= 0x80; + this->actor.flags |= ACTOR_FLAG_1; + + if (globalCtx->sceneNum == SCENE_BOMYA) { + this->unk_40A |= 2; + this->unk_40C = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80BA9758; + } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { + if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_0) && (gSaveContext.save.entranceIndex != 0xD670) && + ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F)) { + if ((gSaveContext.save.weekEventReg[58] & 0x40) || + (!(gSaveContext.save.time < CLOCK_TIME(0, 20)) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_404 = 50; + this->unk_40C = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80BA9B80; + } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.save.entranceIndex == 0xD670)) { + if (gSaveContext.save.weekEventReg[81] & 2) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_40A |= 2; + if (gSaveContext.save.weekEventReg[33] & 8) { + this->unk_40C = 0; + } else { + this->unk_40C = 1; + } + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_40C); + this->unk_40A |= 8; + this->actionFunc = func_80BA9758; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } else { + this->unk_40A |= 2; + if (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2) { + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_40C = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80BA9E00; + } else if ((ENBABA_GET_3F00(&this->actor)) != ENBABA_3F00_3F) { + this->unk_40C = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80BA9E10; + } else { + this->unk_40C = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80BA9E48; + } + } +} + +void func_80BA9758(EnBaba* this, GlobalContext* globalCtx) { + if ((this->unk_40A & 8) || (this->unk_144 != NULL) || func_80BA8820(this, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BA886C(this, globalCtx); + if (this->unk_40A & 8) { + this->actor.flags &= ~ACTOR_FLAG_10000; + } + this->actionFunc = func_80BA98EC; + } else if (this->actor.xzDistToPlayer < 100.0f) { + if (this->unk_40A & 8) { + this->actor.flags |= ACTOR_FLAG_10000; + } + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } +} + +void func_80BA9848(EnBaba* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (((temp_v0 == 5) || (temp_v0 == 6)) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BA9B80; + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); +} + +void func_80BA98EC(EnBaba* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 5) { + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_40A & 1) { + this->unk_40A &= ~1; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + if (this->unk_40A & 8) { + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + if (globalCtx->msgCtx.unk120B1 == 0) { + gSaveContext.save.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + return; + } + } else { + gSaveContext.save.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + } + } else { + this->unk_1E0 = 0; + this->actionFunc = func_80BA9758; + } + } else if (this->unk_40A & 0x20) { + this->unk_40A &= ~0x20; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80BA9AB8; + } else { + func_80BA886C(this, globalCtx); + } + } + } else if (temp_v0 == 6) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.unk120B1 == 0)) { + gSaveContext.save.weekEventReg[81] |= 2; + func_80BA8C4C(globalCtx, 0xD670); + } + } +} + +void func_80BA9AB8(EnBaba* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->unk_40A |= 0x40; + this->actionFunc = func_80BA9B24; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BLAST, 300.0f, 300.0f); + } +} + +void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BA886C(this, globalCtx); + this->actionFunc = func_80BA98EC; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { + u32* unk14 = &gSaveContext.save.daySpeed; + struct_80133038_arg2 sp20; + + this->unk_436 = REG(15) + *unk14; + + if (!func_80133038(globalCtx, D_80BAA488, &sp20) || + ((this->unk_434 != sp20.unk0) && !func_80BA9110(this, globalCtx, &sp20))) { + this->unk_40A &= ~0x80; + this->actor.flags &= ~ACTOR_FLAG_1; + sp20.unk0 = false; + } else { + this->unk_40A |= 0x80; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_434 = sp20.unk0; + + func_80BA93AC(this, globalCtx); + + if (this->unk_40A & 2) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x2A39, &this->actor); // "I'm sorry" + this->actionFunc = func_80BA9848; + } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } + } + Actor_MoveWithGravity(&this->actor); +} + +void func_80BA9CD4(EnBaba* this, GlobalContext* globalCtx) { + s16 sp2E = this->skelAnime.curFrame; + s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_40C].animation); + + this->collider.dim.height = 37; + this->collider.dim.radius = 23; + + if (this->unk_40C == 3) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_BBVO00); + } + + if (sp2E == sp2C) { + this->unk_40C = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } else { + if ((gSaveContext.save.weekEventReg[79] & 0x40) && (DECR(this->unk_404) == 0)) { + Audio_QueueSeqCmd(0x101400FF); + func_80BA8C4C(globalCtx, 0xD670); + } else { + Actor_MoveWithGravity(&this->actor); + } + } +} + +void func_80BA9E00(EnBaba* this, GlobalContext* globalCtx) { +} + +void func_80BA9E10(EnBaba* this, GlobalContext* globalCtx) { + if (func_80BA8D2C(this, 1.0f)) { + this->unk_1E8 = 0; + } +} + +void func_80BA9E48(EnBaba* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} + +void EnBaba_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBaba* this = THIS; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->path = SubS_GetPathByIndex(globalCtx, ENBABA_GET_3F00(&this->actor), ENBABA_3F00_3F); + + Actor_SetScale(&this->actor, 0.01f); + + this->actor.targetMode = 0; + this->actor.gravity = -4.0f; + this->actionFunc = func_80BA9480; +} + +void EnBaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBaba* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnBaba_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBaba* this = THIS; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + func_80BA8DF4(this, globalCtx); +} + +s32 EnBaba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBaba* this = THIS; + + if (limbIndex == 6) { + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_2E4.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk_2E4.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == 5) { + Matrix_InsertXRotation_s(-this->unk_2EA.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk_2EA.x, MTXMODE_APPLY); + } + + if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == 5) || (limbIndex == 10) || (limbIndex == 14)) { + rot->y += (s16)(Math_SinS(this->unk_302[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->unk_326[limbIndex]) * 200.0f); + } + + if (((this->unk_40C == 1) || (this->unk_40C == 3) || (this->unk_40C == 4) || + (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2)) && + (limbIndex == 8)) { + *dList = NULL; + } + return 0; +} + +void EnBaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBaba* this = THIS; + Vec3f sp18 = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == 7) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y; + this->actor.focus.pos.z = this->actor.world.pos.z; + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} + +void EnBaba_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnBaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBaba* this = THIS; + Vec3f sp4C; + Vec3f sp40; + + if (this->unk_40A & 2) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gBbaEyeTex)); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnBaba_OverrideLimbDraw, EnBaba_PostLimbDraw, + EnBaba_TransformLimbDraw, &this->actor); + + if (this->unk_40A & 0x80) { + if ((this->unk_40C == 3) || (this->unk_40C == 4)) { + func_8012C2DC(globalCtx->state.gfxCtx); + sp4C.x = this->actor.world.pos.x + 20.0f; + sp4C.y = this->actor.world.pos.y; + sp4C.z = this->actor.world.pos.z + 20.0f; + } else { + sp4C = this->actor.world.pos; + } + + sp40.x = sp40.y = sp40.z = 0.3f; + func_800BC620(&sp4C, &sp40, 255, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index fdc0648b9..d26e68625 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -7,11 +7,53 @@ struct EnBaba; typedef void (*EnBabaActionFunc)(struct EnBaba*, GlobalContext*); +#define ENBABA_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) +#define ENBABA_GET_C000(thisx) (((thisx)->params & 0xC000) >> 0xE) + +#define ENBABA_3F00_3F 0x3F + +enum { + /* 0 */ ENBABA_C000_0, + /* 1 */ ENBABA_C000_1, + /* 2 */ ENBABA_C000_2, +}; + typedef struct EnBaba { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; + /* 0x0144 */ struct EnOssan* unk_144; /* 0x0148 */ EnBabaActionFunc actionFunc; - /* 0x014C */ char unk_14C[0x2F4]; + /* 0x014C */ UNK_TYPE1 unk14C[4]; + /* 0x0150 */ SkelAnime skelAnime; + /* 0x0194 */ ColliderCylinder collider; + /* 0x01E0 */ u16 unk_1E0; + /* 0x01E2 */ u8 unk_1E2; + /* 0x01E4 */ Path* path; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ UNK_TYPE1 unk1EA[0x1C]; + /* 0x0206 */ Vec3s jointTable[18]; + /* 0x0272 */ Vec3s morphTable[18]; + /* 0x02DE */ Vec3s unk_2DE; + /* 0x02E4 */ Vec3s unk_2E4; + /* 0x02EA */ Vec3s unk_2EA; + /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; + /* 0x0302 */ s16 unk_302[18]; + /* 0x0326 */ s16 unk_326[18]; + /* 0x034A */ UNK_TYPE1 unk34A[0xBA]; + /* 0x0404 */ s16 unk_404; + /* 0x0406 */ UNK_TYPE1 unk406[4]; + /* 0x040A */ u16 unk_40A; + /* 0x040C */ s32 unk_40C; + /* 0x0410 */ Path* unk_410; + /* 0x0414 */ Vec3f unk_414; + /* 0x0420 */ f32 unk_420; + /* 0x0424 */ s32 unk_424; + /* 0x0428 */ s32 unk_428; + /* 0x042C */ s32 unk_42C; + /* 0x0430 */ s32 unk_430; + /* 0x0434 */ u8 unk_434; + /* 0x0436 */ s16 unk_436; + /* 0x0438 */ s32 unk_438; + /* 0x043C */ s32 unk_43C; } EnBaba; // size = 0x440 extern const ActorInit En_Baba_InitVars; 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 f6a2895aa..8e70d5d6b 100644 --- a/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c +++ b/src/overlays/actors/ovl_En_Baguo/z_en_baguo.c @@ -7,7 +7,7 @@ #include "z_en_baguo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBaguo*)thisx) @@ -146,8 +146,8 @@ void EnBaguo_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = -3000.0f; this->actor.gravity = -3.0f; this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags |= AC_HARD; this->actionFunc = EnBaguo_UndergroundIdle; } @@ -165,8 +165,8 @@ void EnBaguo_UndergroundIdle(EnBaguo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_APPEAR); this->actor.world.rot.z = 0; this->actor.world.rot.x = this->actor.world.rot.z; - this->actor.flags &= ~0x8000000; - this->actor.flags |= 1; + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = EnBaguo_EmergeFromUnderground; } this->actor.shape.rot.y = this->actor.world.rot.y; @@ -293,8 +293,8 @@ void EnBaguo_RetreatUnderground(EnBaguo* this, GlobalContext* globalCtx) { 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 |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnBaguo_UndergroundIdle; } } @@ -352,8 +352,8 @@ void EnBaguo_CheckForDetonation(EnBaguo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BAKUO_DEAD); this->timer = 30; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~1; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.0f); this->collider.elements->dim.scale = 3.0f; this->collider.elements->info.toucher.damage = 8; 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 35be17fd1..193c899c9 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -7,7 +7,7 @@ #include "z_en_baisen.h" #include "objects/object_bai/object_bai.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBaisen*)thisx) @@ -59,7 +59,7 @@ static u16 sTextIds[] = { 0x2ABD, 0x2ABB, 0x2AD5, 0x2AD6, 0x2AD7, 0x2AD8, 0x2AC6 static AnimationHeader* D_80BE8E4C[] = { &object_bai_Anim_0011C0, &object_bai_Anim_0008B4, &object_bai_Anim_008198 }; -static u8 animModes[] = { 0, 0 }; +static u8 animModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) { EnBaisen* this = THIS; @@ -198,8 +198,8 @@ void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((globalCtx->msgCtx.unk11F04 == 0x2AC6) || (globalCtx->msgCtx.unk11F04 == 0x2AC7) || - (globalCtx->msgCtx.unk11F04 == 0x2AC8)) { + if ((globalCtx->msgCtx.currentTextId == 0x2AC6) || (globalCtx->msgCtx.currentTextId == 0x2AC7) || + (globalCtx->msgCtx.currentTextId == 0x2AC8)) { this->skelAnime.playSpeed = 0.0f; this->unk29E = this->actor.yawTowardsPlayer; } @@ -222,7 +222,7 @@ void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) { EnBaisen_ChangeAnimation(this, 0); } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->textIdIndex++; if (this->textIdIndex < 6) { diff --git a/src/overlays/actors/ovl_En_Bal/z_en_bal.c b/src/overlays/actors/ovl_En_Bal/z_en_bal.c index dbfa561c6..2f57c2804 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -6,7 +6,7 @@ #include "z_en_bal.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBal*)thisx) 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 a419d2901..ab76d88c8 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -6,7 +6,7 @@ #include "z_en_bat.h" -#define FLAGS 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnBat*)thisx) 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 cd8c7cac8..82b3ab923 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -5,8 +5,9 @@ */ #include "z_en_bb.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnBb*)thisx) @@ -15,15 +16,25 @@ void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBb_Update(Actor* thisx, GlobalContext* globalCtx); void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808C23EC(EnBb* this, GlobalContext* globalCtx); -void func_808C25E0(EnBb* this, GlobalContext* globalCtx); -void func_808C28CC(EnBb* this, GlobalContext* globalCtx); -void func_808C2B1C(EnBb* this, GlobalContext* globalCtx); -void func_808C2BD0(EnBb* this, GlobalContext* globalCtx); -void func_808C2CB4(EnBb* this, GlobalContext* globalCtx); -void func_808C2D78(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupFlyIdle(EnBb* this); +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupAttack(EnBb* this); +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx); +void EnBb_Down(EnBb* this, GlobalContext* globalCtx); +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx); +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx); +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupWaitForRevive(EnBb* this); +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx); +void EnBb_SetupRevive(EnBb* this); +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx); + +typedef enum { + /* -1 */ BB_BODY_PART_DRAW_STATUS_BROKEN = -1, + /* 0 */ BB_BODY_PART_DRAW_STATUS_ALIVE, + /* 1 */ BB_BODY_PART_DRAW_STATUS_DEAD, +} EnBbBodyPartDrawStatus; -#if 0 const ActorInit En_Bb_InitVars = { ACTOR_EN_BB, ACTORCAT_ENEMY, @@ -36,118 +47,667 @@ const ActorInit En_Bb_InitVars = { (ActorFunc)EnBb_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808C37A0 = { - { COLTYPE_HIT3, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 20 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_808C37CC = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 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(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(1, 0x0), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0x0), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_BB_DMGEFF_NONE, + /* 0x1 */ EN_BB_DMGEFF_STUN, + /* 0x3 */ EN_BB_DMGEFF_ICE_ARROW = 0x3, + /* 0x4 */ EN_BB_DMGEFF_LIGHT_ARROW, + /* 0x5 */ EN_BB_DMGEFF_ZORA_MAGIC, + /* 0xE */ EN_BB_DMGEFF_HOOKSHOT = 0xE, +} EnBbDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, EN_BB_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, EN_BB_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_BB_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_BB_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_BB_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_BB_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808C37EC = { 2, 20, 40, 50 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808C37F4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 28, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; -#endif +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos/Velocity arrays. An index of -1 indicates that the + * limb is not part of the bodyParts arrays. + */ +static s8 sLimbIndexToBodyPartsIndex[] = { + -1, -1, -1, -1, 0, -1, -1, -1, 1, -1, -1, -1, -1, 2, -1, 3, +}; -extern ColliderSphereInit D_808C37A0; -extern DamageTable D_808C37CC; -extern CollisionCheckInfoInit D_808C37EC; -extern InitChainEntry D_808C37F4[]; +/** + * The last element of the bodyParts arrays is a duplicate of the cranium + * limb, which is then offset by a certain amount. There is no display list + * associated with this, so it is only used for effects. + */ +static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -extern UNK_TYPE D_06000184; -extern UNK_TYPE D_06000444; +void EnBb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &gBubbleSkel, &gBubbleFlyingAnim, this->jointTable, this->morphTable, + BUBBLE_LIMB_MAX); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + ActorShape_Init(&this->actor.shape, 1500.0f, ActorShadow_DrawCircle, 35.0f); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Destroy.s") + this->flameScaleY = 0.8f; + this->flameScaleX = 1.0f; + this->actor.world.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1E94.s") + if (EN_BB_ATTACK_RANGE(&this->actor) == 0xFF) { + this->attackRange = 200.0f; + } else { + this->attackRange = EN_BB_ATTACK_RANGE(&this->actor) * 4.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F00.s") + EnBb_SetupFlyIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1F74.s") +void EnBb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C1FF4.s") + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C20D4.s") +/** + * Checks to see if the Bubble is touching a wall. If it is, and if the + * Bubble is facing directly "into" the wall, then rotate it away from + * the wall. + */ +void EnBb_CheckForWall(EnBb* this) { + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2238.s") + if (this->actor.bgCheckFlags & 8) { + 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; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2344.s") + this->targetYRotation = this->actor.shape.rot.y; + this->actor.bgCheckFlags &= ~8; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C23EC.s") +void EnBb_Freeze(EnBb* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffFrozenSteamScale = 0.6f; + this->timer = 80; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C254C.s") +void EnBb_Thaw(EnBb* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.2f, + 0.15f); + this->actor.flags |= ACTOR_FLAG_200; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C25E0.s") +/** + * Updates certain variables that relate to flying like the Bubble's + * Y-position, bob phase, and flame scale. + */ +void EnBb_UpdateStateForFlying(EnBb* this) { + SkelAnime_Update(&this->skelAnime); + if (this->actor.floorHeight > BGCHECK_Y_MIN) { + Math_StepToF(&this->actor.world.pos.y, this->actor.floorHeight + this->flyHeightMod, 0.5f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C272C.s") + this->actor.world.pos.y += Math_CosS(this->bobPhase); + this->bobPhase += 0x826; + 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_ApproachS(&this->actor.shape.rot.y, this->targetYRotation, 5, 0x3E8); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C28CC.s") +void EnBb_SetupFlyIdle(EnBb* this) { + if (this->actionFunc != EnBb_FlyIdle) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2A00.s") + if (this->actionFunc == EnBb_Attack) { + this->attackWaitTimer = 40; + } else { + this->attackWaitTimer = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B1C.s") + this->timer = (s32)Rand_ZeroFloat(20.0f) + 40; + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2B94.s") + if ((this->actor.xzDistToPlayer < (this->attackRange + 120.0f)) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) < 300.0f)) { + this->targetYRotation += (s16)(Rand_Next() >> 0x11); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2BD0.s") + this->collider.base.atFlags |= AT_ON; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 1.0f; + this->actionFunc = EnBb_FlyIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2C38.s") +/** + * Makes the Bubble fly in circles around its home. + */ +void EnBb_FlyIdle(EnBb* this, GlobalContext* globalCtx) { + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CB4.s") + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2CF0.s") + DECR(this->attackWaitTimer); + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2D78.s") + if ((this->attackWaitTimer == 0) && (this->actor.xzDistToPlayer < this->attackRange) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + EnBb_SetupAttack(this); + } else if (this->timer == 0) { + EnBb_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C2E34.s") +void EnBb_SetupAttack(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->timer = (s32)Rand_ZeroFloat(20.0f) + 60; + this->flyHeightMod = (Math_CosS(this->bobPhase) * 10.0f) + 30.0f; + this->targetYRotation = this->actor.yawTowardsPlayer; + this->maxSpeed = Rand_ZeroFloat(1.5f) + 4.0f; + this->actionFunc = EnBb_Attack; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Update.s") +/** + * Makes the Bubble actively move towards the player. + */ +void EnBb_Attack(EnBb* this, GlobalContext* globalCtx) { + this->targetYRotation = this->actor.yawTowardsPlayer; + EnBb_UpdateStateForFlying(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C32EC.s") + if ((Animation_OnFrame(&this->skelAnime, 0.0f)) || (Animation_OnFrame(&this->skelAnime, 5.0f))) { + Actor_PlaySfxAtPos(&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); + } else if ((Animation_OnFrame(&this->skelAnime, 0.0f)) && (Rand_ZeroOne() < 0.1f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_LAUGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/func_808C3324.s") + this->timer--; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bb/EnBb_Draw.s") + if (((this->attackRange + 120.0f) < this->actor.xzDistToPlayer) || (this->timer == 0) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || + (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 400.0f)) { + EnBb_SetupFlyIdle(this); + } +} + +void EnBb_SetupDown(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleFlyingAnim); + this->collider.base.atFlags |= AT_ON; + this->timer = 140; + this->collider.base.acFlags |= AC_ON; + this->actor.speedXZ = 2.0f; + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + this->actor.gravity = -2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_DOWN); + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnBb_Down; +} + +/** + * Makes the Bubble hop along the ground. + */ +void EnBb_Down(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + EnBb_CheckForWall(this); + + if (this->actor.bgCheckFlags & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_UP); + EnBb_SetupFlyIdle(this); + return; + } + + if (this->actor.velocity.y < -14.0f) { + this->actor.velocity.y *= -0.7f; + } else { + this->actor.velocity.y = 10.0f; + } + + this->actor.bgCheckFlags &= ~1; + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 7.0f, 2, 2.0f, 0, 0, 0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(this->actor.yawTowardsPlayer, 0x8000), 0xBB8); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLE_WING); + } + + if (this->timer > 0) { + this->timer--; + } +} + +void EnBb_SetupDead(EnBb* this, GlobalContext* globalCtx) { + Vec3f* bodyPartVelocity; + Vec3f posDiff; + f32 magnitude; + s32 i; + + func_800BE568(&this->actor, &this->collider); + this->timer = 15; + this->actor.shape.rot.x += 0x4E20; + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_BUBLE_DEAD); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x70); + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_DEAD; + this->actor.gravity = -1.5f; + + bodyPartVelocity = &this->bodyPartsVelocity[0]; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++, bodyPartVelocity++) { + Math_Vec3f_Diff(&this->bodyPartsPos[i], &this->actor.world.pos, &posDiff); + magnitude = Math3D_Vec3fMagnitude(&posDiff); + if (magnitude > 1.0f) { + magnitude = 2.5f / magnitude; + } + + bodyPartVelocity->x = posDiff.x * magnitude; + bodyPartVelocity->z = posDiff.z * magnitude; + bodyPartVelocity->y = Rand_ZeroFloat(3.5f) + 10.0f; + } + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnBb_Dead; +} + +void EnBb_Dead(EnBb* this, GlobalContext* globalCtx) { + s32 i; + + this->timer--; + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); + + if (this->timer == 0) { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + func_800B3030(globalCtx, &this->bodyPartsPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->bodyPartsPos[i], 11, NA_SE_EN_EXTINCT); + } + + EnBb_SetupWaitForRevive(this); + } else { + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Sum(&this->bodyPartsPos[i], &this->bodyPartsVelocity[i], &this->bodyPartsPos[i]); + this->bodyPartsVelocity[i].y += this->actor.gravity; + } + } +} + +void EnBb_SetupDamage(EnBb* this) { + this->collider.base.acFlags &= ~AC_ON; + Actor_PlaySfxAtPos(&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); + 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; + } else if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_HOOKSHOT) { + this->actor.speedXZ = 0.0f; + } else { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 7.0f; + } + + this->actor.gravity = -1.0f; + this->actionFunc = EnBb_Damage; +} + +void EnBb_Damage(EnBb* this, GlobalContext* globalCtx) { + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + if ((this->actor.bgCheckFlags & 1) && (this->actor.speedXZ < 0.1f)) { + EnBb_SetupDown(this); + } +} + +void EnBb_SetupFrozen(EnBb* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + this->actor.gravity = -2.0f; + this->actionFunc = EnBb_Frozen; +} + +void EnBb_Frozen(EnBb* this, GlobalContext* globalCtx) { + DECR(this->timer); + + if (this->timer == 0) { + EnBb_Thaw(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDown(this); + } + } +} + +void EnBb_SetupWaitForRevive(EnBb* this) { + this->actor.draw = NULL; + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_ALIVE; + this->drawDmgEffAlpha = 0.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.world.pos.y += 50.0f; + this->timer = 200; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->actionFunc = EnBb_WaitForRevive; +} + +void EnBb_WaitForRevive(EnBb* this, GlobalContext* globalCtx) { + this->timer--; + if (this->timer == 0) { + EnBb_SetupRevive(this); + } +} + +void EnBb_SetupRevive(EnBb* this) { + Animation_PlayLoop(&this->skelAnime, &gBubbleAttackAnim); + this->actor.draw = EnBb_Draw; + this->actor.scale.x = 0.0f; + this->actor.scale.y = 0.015f; + this->actor.scale.z = 0.0f; + this->flameScaleX = 1.0f; + this->flameScaleY = 0.8f; + this->actor.colChkInfo.health = sColChkInfoInit.health; + this->actionFunc = EnBb_Revive; +} + +void EnBb_Revive(EnBb* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y += 0x1F00; + + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_1; + this->collider.base.acFlags |= AC_ON; + this->collider.base.atFlags |= AT_ON; + this->actor.world.rot.y = this->actor.shape.rot.y; + EnBb_SetupFlyIdle(this); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = ((0.01f - this->actor.scale.x) * 0.5f) + 0.01f; +} + +void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + this->collider.base.atFlags &= ~AT_ON; + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + Actor_SetDropFlag(&this->actor, &this->collider.info); + this->flameScaleY = 0.0f; + this->flameScaleX = 0.0f; + EnBb_Thaw(this, globalCtx); + + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_ICE_ARROW) { + EnBb_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnBb_SetupFrozen(this); + } else if (this->actor.colChkInfo.health == 0) { + EnBb_SetupDead(this, globalCtx); + } else { + EnBb_SetupDamage(this); + } + + if (this->actor.colChkInfo.damageEffect == EN_BB_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.4f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } + } + } else { + if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); + if (this->actionFunc != EnBb_Down) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->actor.world.rot.y; + EnBb_SetupDown(this); + } + } else if (this->collider.base.atFlags & AT_HIT) { + 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); + + if (this->flameScaleX > 0.0f) { + gSaveContext.jinxTimer = 1200; + } + + if (this->actionFunc == EnBb_Attack) { + EnBb_SetupFlyIdle(this); + } + } + } +} + +void EnBb_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBb* this = THIS; + + EnBb_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + if ((this->actionFunc != EnBb_Dead) && (this->actionFunc != EnBb_WaitForRevive)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 40.0f, 7); + + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 15.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; + this->collider.dim.worldSphere.radius = this->flameScaleX * 30.0f; + this->collider.dim.worldSphere.radius = CLAMP_MIN(this->collider.dim.worldSphere.radius, 20); + + Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.dim.worldSphere.center); + + if (this->collider.base.atFlags & AT_ON) { + this->actor.flags |= ACTOR_FLAG_1000000; + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->collider.base.ocFlags1 & OC1_ON) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.2f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.4f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.4f, 0.01f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +s32 EnBb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBb* this = THIS; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_BROKEN) { + this->limbDList = *dList; + *dList = NULL; + } + + return false; +} + +void EnBb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + + if (this->bodyPartDrawStatus == BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsIndex[limbIndex] == 0) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->bodyPartsPos[0]); + } else if (sLimbIndexToBodyPartsIndex[limbIndex] == 3) { + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->bodyPartsPos[3]); + Matrix_MultiplyVector3fByState(&sDuplicateCraniumBodyPartOffset, &this->bodyPartsPos[4]); + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + } + } else if (this->bodyPartDrawStatus > BB_BODY_PART_DRAW_STATUS_ALIVE) { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]]); + } + + if (limbIndex == BUBBLE_LIMB_CRANIUM) { + this->bodyPartDrawStatus = BB_BODY_PART_DRAW_STATUS_BROKEN; + } + } else { + if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + currentMatrixState = Matrix_GetCurrentState(); + currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; + currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; + currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; + Matrix_InsertZRotation_s(thisx->world.rot.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->limbDList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void EnBb_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBb* this = THIS; + MtxF* currentMatrixState; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + POLY_OPA_DISP = &gfx[1]; + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBb_OverrideLimbDraw, + EnBb_PostLimbDraw, &this->actor); + + if (this->flameScaleX > 0.0f) { + currentMatrixState = Matrix_GetCurrentState(); + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_RotateY( + ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), + MTXMODE_APPLY); + Matrix_Scale(this->flameScaleX, this->flameScaleY, 1.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + (globalCtx->gameplayFrames * -20) & 0x1FF, 32, 128)); + currentMatrixState->mf[3][1] -= 47.0f * this->flameScaleY; + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.h b/src/overlays/actors/ovl_En_Bb/z_en_bb.h index 513020bd2..7d5da25b3 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.h +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.h @@ -2,16 +2,39 @@ #define Z_EN_BB_H #include "global.h" +#include "objects/object_bb/object_bb.h" + +#define EN_BB_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) struct EnBb; typedef void (*EnBbActionFunc)(struct EnBb*, GlobalContext*); typedef struct EnBb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnBbActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x100]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[BUBBLE_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[BUBBLE_LIMB_MAX]; + /* 0x248 */ EnBbActionFunc actionFunc; + /* 0x24C */ s8 bodyPartDrawStatus; + /* 0x24D */ u8 drawDmgEffType; + /* 0x24E */ UNK_TYPE1 unk_24E[0x2]; + /* 0x250 */ s16 timer; + /* 0x252 */ s16 attackWaitTimer; // Cannot start attacking the player if this is non-zero + /* 0x254 */ s16 targetYRotation; + /* 0x256 */ s16 bobPhase; + /* 0x258 */ f32 maxSpeed; + /* 0x25C */ f32 flyHeightMod; + /* 0x260 */ f32 attackRange; + /* 0x264 */ f32 flameScaleX; + /* 0x268 */ f32 flameScaleY; + /* 0x26C */ f32 drawDmgEffAlpha; + /* 0x270 */ f32 drawDmgEffScale; + /* 0x274 */ f32 drawDmgEffFrozenSteamScale; + /* 0x278 */ Vec3f bodyPartsPos[5]; + /* 0x2B4 */ Vec3f bodyPartsVelocity[5]; + /* 0x2F0 */ Gfx* limbDList; + /* 0x2F4 */ ColliderSphere collider; } EnBb; // size = 0x34C extern const ActorInit En_Bb_InitVars; 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 0ee8d32e3..e502b6637 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 @@ -2,11 +2,20 @@ * File: z_en_bba_01.c * Overlay: ovl_En_Bba_01 * Description: Unused Bomb Shop Lady NPC + * + * Note: This actor was probably written with OOT's object_bba's skeleton in mind, and so this actor is very bugged. + * + * The main offender is that gBbaSkel has 18 limbs, while the system used (EnHy) expects 16 (see @bug in FinishInit + * below). + * + * The draw functions also use different limbs than expected, which results in, for example, EnBba01's right arm and bag + * following the player instead of her head and torso. */ #include "z_en_bba_01.h" +#include "objects/object_bba/object_bba.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBba01*)thisx) @@ -15,12 +24,10 @@ void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx); void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809CC2F0(EnBba01* this, GlobalContext* globalCtx); -void func_809CC370(EnBba01* this, GlobalContext* globalCtx); -void func_809CC3A8(EnBba01* this, GlobalContext* globalCtx); -void func_809CC3CC(EnBba01* this, GlobalContext* globalCtx); +void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx); +void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx); +void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bba_01_InitVars = { ACTOR_EN_BBA_01, ACTORCAT_NPC, @@ -33,84 +40,296 @@ const ActorInit En_Bba_01_InitVars = { (ActorFunc)EnBba01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809CCC80 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_809CCCAC = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809CCCB8 = { - /* 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(0, 0x0), - /* 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(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* 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), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -#endif +u16 D_809CCCD8[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; -extern ColliderCylinderInit D_809CCC80; -extern CollisionCheckInfoInit2 D_809CCCAC; -extern DamageTable D_809CCCB8; +void EnBba01_UpdateModel(EnBba01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f focus; -extern UNK_TYPE D_06005EF0; + EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + focus.x = player->actor.world.pos.x; + focus.y = player->bodyPartsPos[7].y + 3.0f; + focus.z = player->actor.world.pos.z; + func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, + &this->enHy.headRot, &this->enHy.torsoRot, D_809CCCD8); + } else { + Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.y, 0, 4, 0x3E8, 1); + } + SubS_FillLimbRotTables(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, + ARRAY_COUNT(this->enHy.limbRotTableY)); + EnHy_UpdateCollider(&this->enHy, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC060.s") +s32 EnBba01_TestIsTalking(EnBba01* this, GlobalContext* globalCtx) { + s32 isTalking = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC1D4.s") + if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + isTalking = true; + this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox + this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpHeadRot = this->enHy.headRot; + this->enHy.tmpTorsoRot = this->enHy.torsoRot; + this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.actionFunc = EnBba01_Talk; + } + return isTalking; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC270.s") +s32 func_809CC270(EnBba01* this, GlobalContext* globalCtx) { + s16 x; + s16 y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC2F0.s") + Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + //! @bug: Both x and y conditionals are always true, || should be an && + if (!this->enHy.waitingOnInit && ((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + func_800B85E0(&this->enHy.actor, globalCtx, 30.0f, EXCH_ITEM_2E); + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC370.s") +void EnBba01_FinishInit(EnHy* this, GlobalContext* globalCtx) { + //! @bug: gBbaSkel does not match EnHy's skeleton assumptions. + //! Since gBbaSkel has more limbs than expected, joint and morph tables will overflow + if (EnHy_Init(this, globalCtx, &gBbaSkel, ENHY_ANIMATION_BBA_6)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.draw = EnBba01_Draw; + this->waitingOnInit = false; + if (ENBBA01_GET_PATH(&this->actor) == ENBBA01_NO_PATH) { + this->actionFunc = EnBba01_FaceFoward; + } else { + this->actionFunc = EnBba01_Walk; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC3A8.s") +void EnBba01_Walk(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_MoveForwards(this, 1.0f)) { + this->curPoint = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC3CC.s") +void EnBba01_FaceFoward(EnHy* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Init.s") +void EnBba01_Talk(EnHy* this, GlobalContext* globalCtx) { + s16 yaw; + u8 talkState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Destroy.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkState = Message_GetState(&globalCtx->msgCtx); + this->inMsgState3 = (talkState == 3) ? true : false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Update.s") + switch (talkState) { + case 0: + yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); + if (yaw < 0x64) { + Message_StartTextbox(globalCtx, this->textId, NULL); + } + break; + case 2: + this->actor.textId = 0; + this->focusTarget = this->tmpFocusTarget; + this->headRot = this->tmpHeadRot; + this->torsoRot = this->tmpTorsoRot; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = this->tmpActionFunc; + this->tmpActionFunc = NULL; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC6F0.s") +void EnBba01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBba01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CC984.s") + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_BBA, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/func_809CCA5C.s") + if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || + (this->enHy.skelLowerObjIndex < 0)) { + Actor_MarkForDeath(&this->enHy.actor); + } + this->enHy.actor.draw = NULL; + Collider_InitCylinder(globalCtx, &this->enHy.collider); + Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->enHy.actor.flags &= ~ACTOR_FLAG_1; + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENBBA01_GET_PATH(&this->enHy.actor), ENBBA01_NO_PATH); + this->enHy.waitingOnInit = true; + Actor_SetScale(&this->enHy.actor, 0.01f); + this->enHy.actionFunc = EnBba01_FinishInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bba_01/EnBba01_Draw.s") +void EnBba01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->enHy.collider); +} + +void EnBba01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + + EnBba01_TestIsTalking(this, globalCtx); + this->enHy.actionFunc(&this->enHy, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnBba01_UpdateModel(this, globalCtx); + func_809CC270(this, globalCtx); +} + +s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBba01* this = THIS; + s8 bodyPart; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + bodyPart = gEnHyBodyParts[limbIndex]; + if (bodyPart >= 0) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + } + + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == BBA_LIMB_BAG) { + Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) && this->enHy.inMsgState3 && + ((globalCtx->state.frames % 2) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == BBA_LIMB_BAG) || (limbIndex == BBA_LIMB_TORSO) || (limbIndex == BBA_LIMB_LEFT_FOREARM)) { + rot->y += (s16)(Math_SinS(this->enHy.limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->enHy.limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnBba01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnBba01* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == BBA_LIMB_HEAD) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + } +} + +void EnBba01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBba01* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTexIter; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 255, 255, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 55, 55, 255, 0)); + gDPPipeSync(POLY_OPA_DISP++); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + this->enHy.skelAnime.dListCount, EnBba01_OverrideLimbDraw, EnBba01_PostLimbDraw, + EnBba01_TransformLimbDraw, &this->enHy.actor); + Matrix_InsertXRotation_s(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + *shadowTexIter++ = 0; + } + for (i = 0; i < 5; i++) { + func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + } + func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h index 20416b4f9..b670dea01 100644 --- a/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h +++ b/src/overlays/actors/ovl_En_Bba_01/z_en_bba_01.h @@ -1,16 +1,18 @@ #ifndef Z_EN_BBA_01_H #define Z_EN_BBA_01_H -#include "global.h" +#include "z_en_hy_code.h" struct EnBba01; typedef void (*EnBba01ActionFunc)(struct EnBba01*, GlobalContext*); +#define ENBBA01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) +#define ENBBA01_NO_PATH 0x3F + typedef struct EnBba01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBba01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4D4]; + /* 0x000 */ EnHy enHy; + /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnBba01; // size = 0x61C extern const ActorInit En_Bba_01_InitVars; 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 080579156..8af8e650a 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -6,7 +6,7 @@ #include "z_en_bbfall.h" -#define FLAGS 0x00000215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) #define THIS ((EnBbfall*)thisx) 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 1bf4d8d8c..ecb64cb91 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -6,7 +6,7 @@ #include "z_en_bee.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBee*)thisx) 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 da18c1180..8431d6706 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -7,7 +7,7 @@ #include "z_en_bigokuta.h" #include "assets/objects/object_bigokuta/object_bigokuta.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnBigokuta*)thisx) @@ -43,11 +43,6 @@ const ActorInit En_Bigokuta_InitVars = { (ActorFunc)EnBigokuta_Draw, }; -typedef enum { - BIGOCTO_DRAWEFFECT_ICE = 10, - BIGOCTO_DRAWEFFECT_LIGHT_ORBS = 20, -} EnBigokutaDrawEffect; - static ColliderCylinderInit sShellCylinderInit = { { COLTYPE_HARD, @@ -373,8 +368,8 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { if (this->timer != 0) { this->timer--; if (this->timer == 0) { - this->drawEffect = 0; - this->drawEffectAlpha = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); EnBigokuta_SetupDeathEffects(this); } @@ -388,7 +383,7 @@ void EnBigokuta_PlayDeathCutscene(EnBigokuta* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; } - if (this->drawEffect == BIGOCTO_DRAWEFFECT_ICE) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 3; } else { EnBigokuta_SetupDeathEffects(this); @@ -466,8 +461,8 @@ void EnBigokuta_PlayDeathEffects(EnBigokuta* this, GlobalContext* globalCtx) { } } - if (this->drawEffectAlpha > 0.0f) { - this->drawEffectAlpha = this->actor.scale.y * 30.30303f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->actor.scale.y * 30.30303f; } } } else { @@ -494,14 +489,14 @@ void EnBigokuta_CheckOneHitKill(EnBigokuta* this, GlobalContext* globalCtx) { if (this->bodyCollider.base.acFlags & AC_HIT) { if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x1000) { // Ice Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_ICE; - this->drawEffectScale = 1.2f; - this->drawEffectSteamScale = 1.8000001f; - this->drawEffectAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffFrozenSteamScale = 1.8000001f; + this->drawDmgEffAlpha = 1.0f; } else if (this->bodyCollider.info.acHitInfo->toucher.dmgFlags & 0x2000) { // Light Arrow - this->drawEffect = BIGOCTO_DRAWEFFECT_LIGHT_ORBS; - this->drawEffectScale = 1.2f; - this->drawEffectAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 1.2f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->bodyCollider.info.bumper.hitPos.x, this->bodyCollider.info.bumper.hitPos.y, this->bodyCollider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -546,12 +541,12 @@ void EnBigokuta_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 82.5f); } - if (this->drawEffectAlpha > 0.0f) { - if (this->drawEffect != BIGOCTO_DRAWEFFECT_ICE) { - Math_StepToF(&this->drawEffectAlpha, 0.0f, 0.05f); - this->drawEffectScale = (this->drawEffectAlpha + 1.0f) * 0.6f; - this->drawEffectScale = CLAMP_MAX(this->drawEffectScale, 1.2f); - } else if (!Math_StepToF(&this->drawEffectSteamScale, 1.2f, 0.030000001f)) { + 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.6f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.2f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.2f, 0.030000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -676,7 +671,8 @@ void EnBigokuta_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, NULL, EnBigokuta_PostLimbDraw, &this->actor, &gfx[2]); } - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, - this->drawEffectSteamScale, this->drawEffectAlpha, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 ac0cb0158..0f07c4d7f 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -37,15 +37,15 @@ typedef struct EnBigokuta { /* 0x0144 */ EnBigokutaUnkFunc unkFunc; // possibly something to do with photographing /* 0x0148 */ SkelAnime skelAnime; /* 0x018C */ EnBigokutaActionFunc actionFunc; - /* 0x0190 */ u8 drawEffect; + /* 0x0190 */ u8 drawDmgEffType; /* 0x0192 */ s16 timer; /* 0x0194 */ s16 camId; /* 0x0196 */ s16 cutscene; /* 0x0198 */ Vec3s jointTable[BIGOKUTA_LIMB_MAX]; /* 0x0210 */ Vec3s morphTable[BIGOKUTA_LIMB_MAX]; - /* 0x0288 */ f32 drawEffectAlpha; - /* 0x028C */ f32 drawEffectScale; - /* 0x0290 */ f32 drawEffectSteamScale; // only affects DRAWEFFECT_ICE + /* 0x0288 */ f32 drawDmgEffAlpha; + /* 0x028C */ f32 drawDmgEffScale; + /* 0x0290 */ f32 drawDmgEffFrozenSteamScale; // only affects DRAWEFFECT_ICE /* 0x0294 */ Vec3f playerPos; /* 0x02A0 */ Vec3f playerHoldPos; /* 0x02AC */ Vec3f camAt; 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 7608bed53..2fbd60927 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -6,7 +6,7 @@ #include "z_en_bigpamet.h" -#define FLAGS 0x00000435 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_400) #define THIS ((EnBigpamet*)thisx) 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 a2ba96654..38ab1c5d2 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 0x00001215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) #define THIS ((EnBigpo*)thisx) @@ -271,7 +271,7 @@ void EnBigpo_UpdateSpin(EnBigpo* this) { void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) { Camera* subCam; - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { subCam = Play_GetCamera(globalContext, this->cutsceneSubCamId); subCam->eye.y -= this->actor.velocity.y; if (this->actor.velocity.y > 0.0f) { @@ -283,7 +283,7 @@ void EnBigpo_LowerCutsceneSubCamera(EnBigpo* this, GlobalContext* globalContext) } void EnBigpo_InitWellBigpo(EnBigpo* this) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actionFunc = EnBigpo_WellWaitForProximity; this->fireRadius = 200.0f; } @@ -332,7 +332,7 @@ void EnBigpo_SpawnCutsceneStage1(EnBigpo* this, GlobalContext* globalCtx) { this->actor.scale.y = 0.015f; this->actor.scale.z = 0.0f; - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { Vec3f subCamEye; subCamEye.x = ((this->actor.world.pos.x - this->fires[0].pos.x) * 1.8f) + this->actor.world.pos.x; @@ -460,8 +460,8 @@ void EnBigpo_SpawnCutsceneStage8(EnBigpo* this, GlobalContext* globalCtx) { this->idleTimer--; if (this->idleTimer == 0) { subCam = Play_GetCamera(globalCtx, this->cutsceneSubCamId); - Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); - this->cutsceneSubCamId = SUBCAM_FREE; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->cutsceneSubCamId = CAM_ID_MAIN; if (this->actor.params == ENBIGPO_SUMMONED) { dampe = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_TK); if (dampe != NULL) { @@ -483,7 +483,7 @@ void EnBigpo_SetupWarpOut(EnBigpo* this) { this->collider.base.ocFlags1 &= ~OC1_ON; this->rotVelocity = 0x2000; this->idleTimer = 32; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DISAPPEAR); this->actionFunc = EnBigpo_WarpingOut; @@ -544,7 +544,7 @@ void EnBigpo_SetupIdleFlying(EnBigpo* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; this->collider.base.ocFlags1 |= OC1_ON; - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnBigpo_IdleFlying; } @@ -683,25 +683,25 @@ void EnBigpo_SetupDeath(EnBigpo* this) { void EnBigpo_BurnAwayDeath(EnBigpo* this, GlobalContext* globalCtx) { Vec3f tempVec; f32 unkTemp2; // dont really know what these unktemps are doing - s16 cam; + s16 camYaw; s16 unkTemp; s16 modifiedTimer; this->idleTimer++; if (this->idleTimer < 8) { - cam = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + camYaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->idleTimer < 5) { unkTemp = (this->idleTimer << 0xC) - 0x4000; // 1.4.0...1 is NOT 1.4, the rodata demands it tempVec.y = (((Math_SinS(unkTemp) * 23.0f) + 40.0f) * 1.4000001f) + this->actor.world.pos.y; unkTemp2 = Math_CosS(unkTemp) * 32.2f; - tempVec.x = (Math_SinS(cam) * unkTemp2) + this->actor.world.pos.x; - tempVec.z = (Math_CosS(cam) * unkTemp2) + this->actor.world.pos.z; + tempVec.x = (Math_SinS(camYaw) * unkTemp2) + this->actor.world.pos.x; + tempVec.z = (Math_CosS(camYaw) * unkTemp2) + this->actor.world.pos.z; } else { tempVec.y = this->actor.world.pos.y + ((40.0f + (15.0f * (this->idleTimer - 5))) * 1.4000001f); - tempVec.x = (Math_SinS(cam) * 32.2f) + this->actor.world.pos.x; - tempVec.z = (Math_CosS(cam) * 32.2f) + this->actor.world.pos.z; + tempVec.x = (Math_SinS(camYaw) * 32.2f) + this->actor.world.pos.x; + tempVec.z = (Math_CosS(camYaw) * 32.2f) + this->actor.world.pos.z; } // not sure what we're turning this into, but its based on the timer @@ -745,7 +745,7 @@ void EnBigpo_SetupLanternDrop(EnBigpo* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.world.pos.y -= 15.0f; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_MISC); - this->actor.flags &= ~(0x1 | 0x4); // targetable OFF, enemy music OFF + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); // targetable OFF, enemy music OFF this->actor.bgCheckFlags &= ~0x400; this->actionFunc = EnBigpo_LanternFalling; } @@ -813,8 +813,8 @@ void EnBigpo_ScoopSoulAppearing(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SetupScoopSoulIdle(EnBigpo* this) { this->savedHeight = this->actor.world.pos.y; Actor_SetFocus(&this->actor, -10.0f); - this->idleTimer = 400; // 20 seconds - this->actor.flags |= 0x1; // targetable ON + this->idleTimer = 400; // 20 seconds + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnBigpo_ScoopSoulIdle; } @@ -833,7 +833,7 @@ void EnBigpo_ScoopSoulIdle(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_SetupScoopSoulLeaving(EnBigpo* this) { - this->actor.flags &= ~(0x1 | 0x10000); // targetable OFF and unknown OFF + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10000); // targetable OFF and unknown OFF this->actionFunc = EnBigpo_ScoopSoulFadingAway; } @@ -845,7 +845,7 @@ void EnBigpo_ScoopSoulFadingAway(EnBigpo* this, GlobalContext* globalCtx) { } void EnBigpo_InitDampeMainPo(EnBigpo* this) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->actionFunc = EnBigpo_SelectRandomFireLocations; } @@ -891,7 +891,7 @@ void EnBigpo_SelectRandomFireLocations(EnBigpo* this, GlobalContext* globalCtx) randomFirePo->actor.update = EnBigpo_UpdateFire; func_800BC154(globalCtx, &globalCtx->actorCtx, &randomFirePo->actor, ACTORCAT_PROP); randomFirePo->unk20C = fireIndex; - randomFirePo->actor.flags &= ~0x1; // targetable OFF + randomFirePo->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF // make invisible by size: 0 Actor_SetScale(&randomFirePo->actor, 0); @@ -955,7 +955,7 @@ void EnBigpo_SetupFlameCirclePositions(EnBigpo* this, GlobalContext* globalCtx) } // Setup sub camera - if (this->cutsceneSubCamId != SUBCAM_FREE) { + if (this->cutsceneSubCamId != CAM_ID_MAIN) { subCamEye.x = (Math_SinS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.x; subCamEye.y = this->actor.world.pos.y + 150.0f; subCamEye.z = (Math_CosS(this->actor.yawTowardsPlayer) * 360.0f) + this->actor.world.pos.z; @@ -1014,7 +1014,6 @@ void EnBigpo_RevealedFireIdle(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 0) { //! @bug: unreachable code this->actor.params = ENBIGPO_UNK5; - return; } } else { if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.001f)) { @@ -1089,7 +1088,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { // this might be a triple ternary but it matches and is easier to read spread out bplus5 = this->mainColor.b + 5; - if (this->mainColor.b >= 211) { + if (this->mainColor.b > 210) { bminus5 = this->mainColor.b - 5; if (bminus5 < 210) { this->mainColor.b = 210; @@ -1097,7 +1096,7 @@ void EnBigpo_UpdateColor(EnBigpo* this) { this->mainColor.b = bminus5; } } else { - if (bplus5 >= 211) { + if (bplus5 > 210) { this->mainColor.b = 210; } else { this->mainColor.b = bplus5; @@ -1124,7 +1123,7 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { } if (Actor_ApplyDamage(&this->actor) == 0) { - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); if (this->actor.params == ENBIGPO_SUMMONED) { // dampe type @@ -1136,8 +1135,8 @@ s32 EnBigpo_ApplyDamage(EnBigpo* this, GlobalContext* globalCtx) { // light arrows if (this->actor.colChkInfo.damageEffect == 4) { - this->unk21C = 4.0f; - this->unk220 = 1.0f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1153,7 +1152,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ColliderCylinder* thisCollider; - if ((this->actor.flags & 0x2000) == 0x2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->hoverHeightCycleTimer = 0; this->savedHeight = this->actor.world.pos.y; } @@ -1201,15 +1200,15 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &thisCollider->base); } - if (this->unk21C > 0.0f) { - Math_StepToF(&this->unk21C, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->mainColor.a != 255) { // NOT fully visible if (this->mainColor.a * (1.0f / 255.0f) < this->mainColor.a) { - this->unk21C = this->mainColor.a * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->mainColor.a * (1.0f / 255.0f); } } - this->unk220 = ((this->unk21C + 1.0f) * 0.5f); - this->unk220 = CLAMP_MAX(this->unk220, 1.0f); + this->drawDmgEffScale = ((this->drawDmgEffAlpha + 1.0f) * 0.5f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.0f); } } @@ -1219,7 +1218,7 @@ void EnBigpo_Update(Actor* thisx, GlobalContext* globalCtx) { void EnBigpo_UpdateFire(Actor* thisx, GlobalContext* globalCtx) { EnBigpo* this = THIS; - this->actor.shape.rot.y = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); this->actionFunc(this, globalCtx); } @@ -1265,25 +1264,20 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbByte != -1) { if (limbByte < 3) { Matrix_GetStateTranslation(&this->limbPos[limbByte]); - return; - } - if (limbByte == 3) { + } else if (limbByte == 3) { Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[limbByte]); - return; - } - if (limbByte == 4) { + } else if (limbByte == 4) { Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[limbByte]); - return; - } + } else { + v2ptr = &this->limbPos[limbByte + 1]; + v1ptr = D_80B65084; + Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - v2ptr = &this->limbPos[limbByte + 1]; - v1ptr = D_80B65084; - Matrix_GetStateTranslationAndScaledX(-4000.0f, &this->limbPos[limbByte]); - - for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { - Matrix_MultiplyVector3fByState(v1ptr, v2ptr); - v2ptr++; - v1ptr++; + for (i = limbByte + 1; i < ARRAY_COUNT(this->limbPos); i++) { + Matrix_MultiplyVector3fByState(v1ptr, v2ptr); + v2ptr++; + v1ptr++; + } } } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1318,8 +1312,9 @@ void EnBigpo_DrawMainBigpo(Actor* thisx, GlobalContext* globalCtx) { } // 71.428566f might be 500/7 context unknown - func_800BE680(globalCtx, &this->actor, this->limbPos, 9, this->actor.scale.x * 71.428566f * this->unk220, 0, - this->unk21C, 0x14); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 71.428566f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); Matrix_SetCurrentState(&this->drawMtxF); EnBigpo_DrawLantern(&this->actor, globalCtx); @@ -1350,7 +1345,7 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, this->mainColor.r, this->mainColor.g, this->mainColor.b, this->mainColor.a * 2); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1359,10 +1354,6 @@ void EnBigpo_DrawScoopSoul(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -/* - * this matches without OPENDISPS but with it has stack issues, - * might be able to find an alternative match with the macros, so far no success - */ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { EnBigpo* this = THIS; f32 magnitude; @@ -1381,42 +1372,41 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_Copy(&vec1, &gZeroVec3f); } - { - GraphicsContext* gfx = globalCtx->state.gfxCtx; + OPEN_DISPS(globalCtx->state.gfxCtx); - // fully visible OR fully transparent - if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { - Scene_SetRenderModeXlu(globalCtx, 0, 1); - dispHead = gfx->polyOpa.p; - } else { - Scene_SetRenderModeXlu(globalCtx, 1, 2); - dispHead = gfx->polyXlu.p; - } - - gSPDisplayList(&dispHead[0], &sSetupDL[6 * 0x19]); - - gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); - - Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); - Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, - this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); - - gDPSetEnvColor(&dispHead[2], this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, - this->mainColor.a); - - gSPMatrix(&dispHead[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); - - gSPDisplayList(&dispHead[5], &gBigpoDrawLanternPurpleTopDL); - - // fully transparent OR fully invisible - if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { - gfx->polyOpa.p = &dispHead[6]; - } else { - gfx->polyXlu.p = &dispHead[6]; - } + // fully visible OR fully transparent + if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { + Scene_SetRenderModeXlu(globalCtx, 0, 1); + dispHead = POLY_OPA_DISP; + } else { + Scene_SetRenderModeXlu(globalCtx, 1, 2); + dispHead = POLY_XLU_DISP; } + + gSPDisplayList(&dispHead[0], &sSetupDL[6 * 0x19]); + + gSPSegment(&dispHead[1], 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 0, 255, this->mainColor.a)); + + Matrix_GetStateTranslationAndScaledY(1400.0f, &vec2); + Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, + this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->lanternColor.a); + + gDPSetEnvColor(&dispHead[2], this->lanternColor.r, this->lanternColor.g, this->lanternColor.b, this->mainColor.a); + + gSPMatrix(&dispHead[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dispHead[4], &gBigpoDrawLanternMainDL); + + gSPDisplayList(&dispHead[5], &gBigpoDrawLanternPurpleTopDL); + + // fully transparent OR fully invisible + if ((this->mainColor.a == 255) || (this->mainColor.a == 0)) { + POLY_OPA_DISP = &dispHead[6]; + } else { + POLY_XLU_DISP = &dispHead[6]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); } void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { @@ -1430,7 +1420,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_NEW); if (this->actionFunc == EnBigpo_SpawnCutsceneStage6) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); fireRadius = 500; @@ -1447,6 +1437,7 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->fires); i++) { EnBigpoFireEffect* firePtr = &this->fires[i]; + Lights_PointNoGlowSetInfo(&this->fires[i].info, this->fires[i].pos.x, this->fires[i].pos.y, this->fires[i].pos.z, 170, 255, 255, fireRadius); mtfxPtr->wx = firePtr->pos.x; diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h index 9ae87f9f3..c5d0bbe4c 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.h @@ -40,9 +40,8 @@ typedef struct EnBigpo { /* 0x212 */ s16 hoverHeightCycleTimer; // sin wave up and down bobbing /* 0x214 */ f32 fireRadius; // distance from center during conjunction cutscene /* 0x218 */ f32 savedHeight; // actual height while flying moves as part of bobbing - // both unk21C and unk220 are passed to func_800BE680, probably need that to know what they are - /* 0x21C */ f32 unk21C; // tied to color alpha, decremented to zero - /* 0x220 */ f32 unk220; // created from unk21C + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; /* 0x224 */ Vec3f limbPos[9]; /* 0x290 */ Color_RGBA8 mainColor; /* 0x294 */ Color_RGBA8 lanternColor; 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 32875716c..5428e701a 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -9,7 +9,7 @@ #include "objects/object_bigslime/object_bigslime.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000235 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200) #define THIS ((EnBigslime*)thisx) @@ -371,7 +371,7 @@ void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { this->bigslimeFrozenTexAnim = Lib_SegmentedToVirtual(&gBigslimeFrozenTexAnim); this->iceShardTexAnim = Lib_SegmentedToVirtual(&gBigslimeIceShardTexAnim); this->actor.world.pos.y = GBT_ROOM_5_MIN_Y; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.shape.shadowAlpha = 255; this->gekkoScale = 0.007f; this->actor.shape.rot.y = 0; @@ -763,8 +763,8 @@ void EnBigslime_BreakIntoMinislime(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_SetPlayerParams(this, globalCtx); EnBigslime_EndCutscene(this, globalCtx); this->actor.colChkInfo.mass = 50; - this->actor.flags &= ~(0x1 | 0x400); - this->actor.flags |= 0x200; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_400); + this->actor.flags |= ACTOR_FLAG_200; this->actor.hintId = 95; this->gekkoRot.x = 0; this->gekkoRot.y = 0; @@ -843,10 +843,10 @@ void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, GlobalContext* glo void EnBigslime_EndCutscene(EnBigslime* this, GlobalContext* globalCtx) { Camera* subCam; - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { subCam = Play_GetCamera(globalCtx, this->subCamId); - Play_CameraSetAtEye(globalCtx, MAIN_CAM, &subCam->at, &subCam->eye); - this->subCamId = MAIN_CAM; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->cutscene); this->cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); func_800B724C(globalCtx, &this->actor, 6); @@ -863,7 +863,7 @@ void EnBigslime_Scale(EnBigslime* this, s16 pitch, f32 xzScale, f32 yScale) { * Set the params used by the floor shockwave when bigslime shatters into minislime */ void EnBigslime_InitShockwave(EnBigslime* this, GlobalContext* globalCtx) { - globalCtx->envCtx.unk_C3 = 3; + globalCtx->envCtx.lightSettingOverride = 3; Math_Vec3f_Copy(&this->frozenPos, &this->actor.world.pos); this->frozenPos.y = GBT_ROOM_5_MIN_Y; this->shockwaveAlpha = 235; @@ -906,24 +906,24 @@ void EnBigslime_GekkoSfxInsideBigslime(EnBigslime* this, u16 sfxId) { } void EnBigslime_GekkoFreeze(EnBigslime* this) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->gekkoCollider.base.colType = COLTYPE_HIT3; this->gekkoCollider.info.elemType = ELEMTYPE_UNK0; this->stunTimer = 2; - this->unk_38C = 0.75f; - this->unk_390 = 1.125f; - this->unk_388 = 1.0f; - this->actor.flags &= ~0x200; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffFrozenSteamScale = 1.125f; + this->gekkoDrawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; } void EnBigslime_GekkoThaw(EnBigslime* this, GlobalContext* globalCtx) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->gekkoCollider.base.colType = COLTYPE_HIT6; this->gekkoCollider.info.elemType = ELEMTYPE_UNK1; - this->unk_388 = 0.0f; + this->gekkoDrawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } @@ -931,7 +931,7 @@ void EnBigslime_SetupCutsceneStartBattle(EnBigslime* this, GlobalContext* global Player* player = GET_PLAYER(globalCtx); Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); - globalCtx->envCtx.unk_C3 = 4; + globalCtx->envCtx.lightSettingOverride = 4; Animation_PlayLoop(&this->skelAnime, &gGekkoLookAroundAnim); this->bigslimeCollider[0].base.atFlags &= ~AT_ON; @@ -1000,7 +1000,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { if (this->callTimer == 0) { EnBigslime_EndCutscene(this, globalCtx); this->formBigslimeTimer = 2; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; EnBigslime_SetupIdleNoticePlayer(this); } } else if (this->isAnimUpdate) { @@ -1008,7 +1008,7 @@ void EnBigslime_CallMinislime(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_UpdateCameraIntroCs(this, globalCtx, 25); func_801A2E54(0x38); EnBigslime_InitFallMinislime(this); - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; this->callTimer = 35; func_800B7298(globalCtx, &this->actor, 4); } @@ -1019,7 +1019,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->actor.gravity = 0.0f; this->actor.velocity.y = 20.0f; - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { this->actor.speedXZ = 0.0f; this->ceilingMoveTimer = 20; } else { @@ -1030,7 +1030,7 @@ void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.acFlags |= AC_ON; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; this->actionFunc = EnBigslime_MoveOnCeiling; } @@ -1043,7 +1043,7 @@ void EnBigslime_MoveOnCeiling(EnBigslime* this, GlobalContext* globalCtx) { EnBigslime_Scale(this, pitch, 0.04f, 0.04f); EnBigslime_UpdateWavySurface(this); - if (this->subCamId != MAIN_CAM) { + if (this->subCamId != CAM_ID_MAIN) { if (this->ceilingMoveTimer == 0) { EnBigslime_EndCutscene(this, globalCtx); this->ceilingMoveTimer = 320; @@ -1493,7 +1493,7 @@ void EnBigslime_Rise(EnBigslime* this, GlobalContext* globalCtx) { } void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalCtx) { - Camera* mainCam = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); s16 yaw; Play_CameraSetAtEye(globalCtx, this->subCamId, &mainCam->at, &mainCam->eye); @@ -1501,7 +1501,7 @@ void EnBigslime_SetupCutsceneGrabPlayer(EnBigslime* this, GlobalContext* globalC this->wavySurfaceTimer = 0; this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; + yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.world.rot.y; if (yaw > 0x4000) { this->subCamYawGrabPlayer = -0x2000; @@ -1988,7 +1988,7 @@ void EnBigslime_Melt(EnBigslime* this, GlobalContext* globalCtx) { if (this->meltCounter == 100) { EnBigslime_SetTargetVtxFromPreFrozen(this); } else if (this->meltCounter == 50) { - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; } } @@ -2039,7 +2039,7 @@ void EnBigslime_JumpGekko(EnBigslime* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { this->gekkoCollider.base.acFlags |= AC_ON; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->jumpTimer--; @@ -2176,8 +2176,8 @@ void EnBigslime_SetupDamageGekko(EnBigslime* this, s32 isNotFrozen) { } EnBigslime_GekkoSfxOutsideBigslime(this, NA_SE_EN_FROG_DAMAGE); - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnBigslime_DamageGekko; @@ -2211,7 +2211,7 @@ void EnBigslime_SetupStunGekko(EnBigslime* this) { void EnBigslime_StunGekko(EnBigslime* this, GlobalContext* globalCtx) { this->stunTimer--; if (this->stunTimer == 0) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { EnBigslime_GekkoThaw(this, globalCtx); EnBigslime_SetupDamageGekko(this, false); } else { @@ -2350,7 +2350,7 @@ void EnBigslime_SetupCutsceneDefeat(EnBigslime* this, GlobalContext* globalCtx) this->minislime[i]->actor.params = MINISLIME_DEFEAT_IDLE; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnBigslime_GekkoThaw(this, globalCtx); this->actionFunc = EnBigslime_CutsceneDefeat; } @@ -2423,7 +2423,7 @@ void EnBigslime_SetupFrogSpawn(EnBigslime* this, GlobalContext* globalCtx) { Vec3f* worldPos; Vec3f dustPos; Vec3f hahenVel; - s16 yaw = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); s16 yawReverse = yaw + 0x8000; s32 i; @@ -2582,7 +2582,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ICE) { EnMinislime* minislime; - globalCtx->envCtx.unk_C3 = 2; + globalCtx->envCtx.lightSettingOverride = 2; EnBigslime_SetPlayerParams(this, globalCtx); this->rotation = 0; EnBigslime_SetupFreeze(this); @@ -2615,7 +2615,7 @@ void EnBigslime_ApplyDamageEffectBigslime(EnBigslime* this, GlobalContext* globa void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCtx) { if (this->gekkoCollider.base.acFlags & AC_HIT) { this->gekkoCollider.base.acFlags &= ~AC_HIT; - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->gekkoCollider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { EnBigslime_EndThrowMinislime(this); if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { @@ -2627,12 +2627,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 4.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 4.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2645,9 +2645,9 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_ELECTRIC_STUN) { this->stunTimer = 40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_38C = 0.75f; - this->unk_388 = 2.0f; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->gekkoDrawDmgEffScale = 0.75f; + this->gekkoDrawDmgEffAlpha = 2.0f; EnBigslime_SetupStunGekko(this); } else if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_STUN || this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_DEKU_STUN) { @@ -2662,12 +2662,12 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt EnBigslime_GekkoThaw(this, globalCtx); if ((this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) || (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_LIGHT)) { - this->unk_388 = 3.0f; - this->unk_38C = 0.75f; + this->gekkoDrawDmgEffAlpha = 3.0f; + this->gekkoDrawDmgEffScale = 0.75f; if (this->actor.colChkInfo.damageEffect == BIGSLIME_DMGEFF_FIRE) { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_THAW; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else { - this->gekkoDrawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; + this->gekkoDrawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->gekkoCollider.info.bumper.hitPos.x, this->gekkoCollider.info.bumper.hitPos.y, @@ -2755,12 +2755,13 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { } // update actor damage draw effects - if (this->unk_388 > 0.0f) { - if ((this->gekkoDrawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnBigslime_PlayCutscene)) { - Math_StepToF(&this->unk_388, 0.0f, 0.05f); - this->unk_38C = 0.375f * (this->unk_388 + 1.0f); - this->unk_38C = CLAMP_MAX(this->unk_38C, 0.75f); - } else if (!Math_StepToF(&this->unk_390, 0.75f, 0.01875f)) { + if (this->gekkoDrawDmgEffAlpha > 0.0f) { + if ((this->gekkoDrawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnBigslime_PlayCutscene)) { + Math_StepToF(&this->gekkoDrawDmgEffAlpha, 0.0f, 0.05f); + this->gekkoDrawDmgEffScale = 0.375f * (this->gekkoDrawDmgEffAlpha + 1.0f); + this->gekkoDrawDmgEffScale = CLAMP_MAX(this->gekkoDrawDmgEffScale, 0.75f); + } else if (!Math_StepToF(&this->gekkoDrawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -2772,8 +2773,8 @@ void EnBigslime_UpdateBigslime(Actor* thisx, GlobalContext* globalCtx) { Vec3f vtxMax; Vec3f vtxMin; - if (globalCtx->envCtx.unk_C3 == 3) { - globalCtx->envCtx.unk_C3 = 0xFF; + if (globalCtx->envCtx.lightSettingOverride == 3) { + globalCtx->envCtx.lightSettingOverride = 0xFF; } func_8019F540(1); @@ -2817,8 +2818,8 @@ void EnBigslime_UpdateGekko(Actor* thisx, GlobalContext* globalCtx) { Player* player; s32 pad; - if (globalCtx->envCtx.unk_C3 == 3) { - globalCtx->envCtx.unk_C3 = 0xFF; + if (globalCtx->envCtx.lightSettingOverride == 3) { + globalCtx->envCtx.lightSettingOverride = 0xFF; } func_8019F540(0); @@ -2946,7 +2947,7 @@ void EnBigslime_DrawMinislime(EnBigslime* this, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, &gMinislimeNormalDL); if (minislime->frozenAlpha > 0) { - Matrix_InsertTranslation(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, 1); + Matrix_InsertTranslation(0.0f, (0.1f - minislime->frozenScale) * -4000.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(0.1f, minislime->frozenScale, 0.1f, MTXMODE_APPLY); AnimatedMat_Draw(globalCtx, this->minislimeFrozenTexAnim); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, minislime->frozenAlpha); @@ -3074,9 +3075,9 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actionFunc == EnBigslime_CutsceneDefeat) || (this->actionFunc == EnBigslime_GekkoDespawn)) { func_800AE434(globalCtx, &gekkoDamageColor, 20, 20); } else if (this->actionFunc == EnBigslime_StunGekko) { - if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_FROZEN) { + if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { func_800AE434(globalCtx, &gekkoDamageColor, this->stunTimer, 80); - } else if (this->gekkoDrawEffect == GEKKO_DRAW_EFFECT_ELECTRIC_STUN) { + } else if (this->gekkoDrawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); } else { func_800AE434(globalCtx, &gekkoStunColor, this->stunTimer, 40); @@ -3109,10 +3110,10 @@ void EnBigslime_DrawGekko(Actor* thisx, GlobalContext* globalCtx) { EnBigslime_DrawShatteringEffects(this, globalCtx); - // Draw actor damage effects - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), - this->gekkoScale * (999.99991f / 7.0f) * this->unk_38C, this->unk_390, this->unk_388, - this->gekkoDrawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->gekkoScale * (999.99991f / 7.0f) * this->gekkoDrawDmgEffScale, + this->gekkoDrawDmgEffFrozenSteamScale, this->gekkoDrawDmgEffAlpha, + this->gekkoDrawDmgEffType); } void EnBigslime_DrawShatteringEffects(EnBigslime* this, GlobalContext* globalCtx) { 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 3f57f1666..f59a934bc 100644 --- a/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h +++ b/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.h @@ -64,7 +64,7 @@ typedef struct EnBigslime { u8 numGekkoMeleeAttacks; // The Gekko will melee-attack link at 1-3 times at each position while engulfed in bigslime }; /* 0x02B4 */ u8 shockwaveAlpha; - /* 0x02B5 */ u8 gekkoDrawEffect; + /* 0x02B5 */ u8 gekkoDrawDmgEffType; /* 0x02B6 */ s16 gekkoYaw; /* 0x02B8 */ s16 cutscene; /* 0x02BA */ union { // multi-use timer @@ -107,9 +107,9 @@ typedef struct EnBigslime { Vec3f subCamDistToFrog; // Used to zoom into frogs as Gekko despawns/Frog spawns }; /* 0x02F8 */ Vec3f limbPos[12]; - /* 0x0388 */ f32 unk_388; // used as arg to func_800BE680 - /* 0x038C */ f32 unk_38C; // used as arg to func_800BE680 - /* 0x0390 */ f32 unk_390; // used as arg to func_800BE680 + /* 0x0388 */ f32 gekkoDrawDmgEffAlpha; + /* 0x038C */ f32 gekkoDrawDmgEffScale; + /* 0x0390 */ f32 gekkoDrawDmgEffFrozenSteamScale; /* 0x0394 */ f32 gekkoScale; /* 0x0398 */ f32 vtxSurfacePerturbation[BIGSLIME_NUM_VTX]; /* 0x0620 */ f32 vtxScaleX; 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 8cb9634a1..818515446 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 @@ -7,7 +7,7 @@ #include "z_en_bji_01.h" #include "objects/object_bji/object_bji.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBji01*)thisx) @@ -64,11 +64,11 @@ static ColliderCylinderInit sCylinderInit = { }; /* Animations struct */ -static struct_80B8E1A8 D_809CDC7C[] = { - { &object_bji_Anim_000FDC, 1.0f, 0, 0.0f }, /* Looking through telescope */ - { &object_bji_Anim_005B58, 1.0f, 0, 10.0f }, /* Breathing? Unused? */ - { &object_bji_Anim_000AB0, 1.0f, 0, 0.0f }, /* Talking */ - { &object_bji_Anim_00066C, 1.0f, 2, -5.0f }, /* Scratching chin? */ +static AnimationSpeedInfo D_809CDC7C[] = { + { &object_bji_Anim_000FDC, 1.0f, ANIMMODE_LOOP, 0.0f }, /* Looking through telescope */ + { &object_bji_Anim_005B58, 1.0f, ANIMMODE_LOOP, 10.0f }, /* Breathing? Unused? */ + { &object_bji_Anim_000AB0, 1.0f, ANIMMODE_LOOP, 0.0f }, /* Talking */ + { &object_bji_Anim_00066C, 1.0f, ANIMMODE_ONCE, -5.0f }, /* Scratching chin? */ }; void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { @@ -84,7 +84,7 @@ void func_809CCDE0(EnBji01* this, GlobalContext* globalCtx) { } void func_809CCE98(EnBji01* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 0, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 0, &this->animationIndex); this->actor.textId = 0; this->actionFunc = func_809CCEE8; } @@ -93,9 +93,9 @@ void func_809CCEE8(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x444); if (this->actor.params == ENBJI01_PARAMS_DEFAULT) { if ((this->actor.xzDistToPlayer <= 60.0f) && (this->actor.playerHeightRel <= 10.0f)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -183,7 +183,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { tempDay = gSaveContext.save.day; tempTimeBeforeMoonCrash = ((-(tempDay % 5 << 0x10) - ((u16)(gSaveContext.save.time - 0x4000))) + 0x40000); - if (tempTimeBeforeMoonCrash < 2730.6667f) { /* 1 hr */ + if (tempTimeBeforeMoonCrash < CLOCK_TIME_F(1, 0)) { /* 1 hr */ this->textId = 0x5E8; } else { this->textId = 0x5EB; @@ -193,7 +193,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } break; } - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); this->actionFunc = EnBji01_DialogueHandler; } @@ -203,12 +203,12 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x444); func_809CCDE0(this, globalCtx); if (this->actor.shape.rot.y == this->actor.yawTowardsPlayer) { - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } break; case 4: - if (func_80147624(globalCtx) != 0) { - this->actor.flags &= ~0x10000; + if (Message_ShouldAdvance(globalCtx) != 0) { + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -235,11 +235,11 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx) != 0) { - this->actor.flags &= ~0x10000; - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx) != 0) { + this->actor.flags &= ~ACTOR_FLAG_10000; + switch (globalCtx->msgCtx.currentTextId) { case 0x5DE: - func_8013E1C8(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 3, &this->animationIndex); func_80151938(globalCtx, 0x5DF); break; case 0x5E4: @@ -259,7 +259,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5EE: case 0x5F2: case 0x5F5: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x5F0: case 0x5F6: @@ -276,7 +276,7 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { case 0x5F7: case 0x5F8: func_801477B4(globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; func_809CCE98(this, globalCtx); break; @@ -285,12 +285,12 @@ void EnBji01_DialogueHandler(EnBji01* this, GlobalContext* globalCtx) { break; case 6: this->actor.params = ENBJI01_PARAMS_FINISHED_CONVERSATION; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_809CCE98(this, globalCtx); break; } if ((this->animationIndex == 3) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); } } @@ -298,8 +298,8 @@ void func_809CD634(EnBji01* this, GlobalContext* globalCtx) { func_801A5BD0(0x6F); Audio_QueueSeqCmd(0xE0000101); globalCtx->nextEntranceIndex = 0x54A0; /* Termina Field from telescope */ - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(globalCtx); /* Load new entrance? */ + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; + func_80169EFC(&globalCtx->state); /* Load new entrance? */ gSaveContext.respawnFlag = -2; this->actionFunc = EnBji01_DoNothing; } @@ -308,7 +308,7 @@ void EnBji01_DoNothing(EnBji01* this, GlobalContext* globalCtx) { } void func_809CD6C0(EnBji01* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_809CDC7C, 2, &this->animationIndex); this->actionFunc = func_809CD70C; } @@ -341,8 +341,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { this->animationIndex = -1; Actor_SetScale(&this->actor, 0.01f); - func_8013E3B8(&this->actor, this->cutscenes, - ARRAY_COUNT(this->cutscenes)); /* initializes all elements of cutscenes to -1 */ + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->moonsTear = (ObjMoonStone*)SubS_FindActor(globalCtx, NULL, ACTORCAT_PROP, ACTOR_OBJ_MOON_STONE); switch (gSaveContext.save.entranceIndex) { @@ -352,7 +351,7 @@ void EnBji01_Init(Actor* thisx, GlobalContext* globalCtx) { func_809CCE98(this, globalCtx); break; case 0x4C20: /* Observatory from Termina Field telescope */ - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_801A5BD0(0); Audio_QueueSeqCmd(0xE0000100); this->actor.params = ENBJI01_PARAMS_LOOKED_THROUGH_TELESCOPE; 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 f4814fac2..dedb09d4c 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -6,7 +6,7 @@ #include "z_en_bjt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBjt*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c index e070bea5e..5d827f4da 100644 --- a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c +++ b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.c @@ -6,7 +6,7 @@ #include "z_en_boj_01.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj01*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c index 9899a15e0..8e26fa09c 100644 --- a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c +++ b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.c @@ -6,7 +6,7 @@ #include "z_en_boj_02.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj02*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c index 019f80538..4f9325e9d 100644 --- a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c +++ b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.c @@ -6,7 +6,7 @@ #include "z_en_boj_03.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj03*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c index 9952f706d..09eed96c7 100644 --- a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c +++ b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.c @@ -6,7 +6,7 @@ #include "z_en_boj_04.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj04*)thisx) diff --git a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c index a3a9dcff8..d6ccba734 100644 --- a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c +++ b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.c @@ -6,7 +6,7 @@ #include "z_en_boj_05.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBoj05*)thisx) 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 ad3d37973..eeae2b8de 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -7,7 +7,7 @@ #include "z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBom*)thisx) @@ -169,7 +169,7 @@ void EnBom_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider2.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; this->collider2.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_808714D4; @@ -301,7 +301,7 @@ void func_808714D4(EnBom* this, GlobalContext* globalCtx) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->actionFunc = func_80871058; this->actor.room = globalCtx->roomCtx.currRoom.num; - this->actor.flags &= ~0x100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); if (this->isPowderKeg) { @@ -337,7 +337,7 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { Color_RGBA8 sp80; if (this->collider2.elements->dim.modelSphere.radius == 0) { - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } @@ -350,28 +350,28 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); } - if (globalCtx->envCtx.unk_8C.diffuseColor1[0] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[0] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[1] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[1] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[2] != 0) { - globalCtx->envCtx.unk_8C.diffuseColor1[2] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[0] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[0] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[1] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[1] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; } - if (globalCtx->envCtx.unk_8C.ambientColor[2] != 0) { - globalCtx->envCtx.unk_8C.ambientColor[2] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; } if (this->timer == 0) { @@ -455,7 +455,7 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { } else { thisx->gravity = -1.2f; if (this->timer != 0) { - if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !func_801690CC(globalCtx)) { + if (!this->isPowderKeg || (func_808715B8 == this->actionFunc) || !Play_InCsMode(globalCtx)) { this->timer--; } } @@ -533,10 +533,10 @@ void EnBom_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sp80.x, sp80.y - 10.0f, sp80.z, 0, 0, 0, this->isPowderKeg); func_800BC848(thisx, globalCtx, D_80872E98[this->isPowderKeg], D_80872E9C[this->isPowderKeg]); - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = - globalCtx->envCtx.unk_8C.diffuseColor1[2] = 250; - globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.ambientColor[1] = - globalCtx->envCtx.unk_8C.ambientColor[2] = 250; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 250; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[2] = 250; func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); thisx->params = ENBOM_1; this->timer = 10; 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 4ec8ae2b6..321468424 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 @@ -5,8 +5,9 @@ */ #include "z_en_bom_bowl_man.h" +#include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBomBowlMan*)thisx) @@ -15,18 +16,27 @@ void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C52B4(EnBomBowlMan* this); void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C53A4(EnBomBowlMan* this); void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C59A4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C59F0(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5AA4(EnBomBowlMan* this, GlobalContext* globalCtx); void func_809C5B1C(EnBomBowlMan* this, GlobalContext* globalCtx); +void func_809C5BA0(EnBomBowlMan* this); void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx); -#if 0 +s32 D_809C6100 = 0; + +s32 D_809C6104 = 0; + const ActorInit En_Bom_Bowl_Man_InitVars = { ACTOR_EN_BOM_BOWL_MAN, ACTORCAT_NPC, @@ -39,56 +49,644 @@ const ActorInit En_Bom_Bowl_Man_InitVars = { (ActorFunc)EnBomBowlMan_Draw, }; -#endif +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, + &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, + &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, + &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, +}; -extern UNK_TYPE D_060064B8; +u8 D_809C6178[] = { + 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Init.s") +u16 D_809C618C[] = { 0x710, 0x711, 0x715, 0x716, 0x717, 0x718 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Destroy.s") +u16 D_809C6198[] = { 0x74F, 0x750, 0x751, 0x752 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C493C.s") +Vec3f D_809C61A0[] = { + { -730.0f, 200.0f, -2350.0f }, { -690.0f, 200.0f, -2350.0f }, { -650.0f, 200.0f, -2350.0f }, + { -610.0f, 200.0f, -2350.0f }, { -570.0f, 200.0f, -2350.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C49CC.s") +void EnBomBowlMan_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4B50.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -3.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, 21); + this->unk_2F6 = ENBOMBOWLMAN_GET_F0(&this->actor); + this->unk_2F4 = ENBOMBOWLMAN_GET_F(&this->actor); + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4B6C.s") + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + if (this->unk_2F4 == 0) { + func_809C4BC4(this, globalCtx); + } else { + this->unk_2F4--; + func_809C5BA0(this); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4BC4.s") + this->unk_29A = ENBOMBOWLMAN_GET_FF00(&this->actor); + this->path = SubS_GetPathByIndex(globalCtx, this->unk_29A, 0x3F); + this->unk_2C8 = 80.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C4DA4.s") + if ((gSaveContext.save.entranceIndex == 0xD220) && (gSaveContext.save.weekEventReg[73] & 0x80) && + !CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + this->unk_2D6 = this->actor.cutscene; + if (this->unk_2D6 == 0) { + Actor_MarkForDeath(&this->actor); + } + func_809C52B4(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C51B4.s") +void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C52B4.s") +void func_809C493C(EnBomBowlMan* this, s32 arg1, f32 arg2) { + this->unk_2F8 = arg1; + this->unk_2C4 = Animation_GetLastFrame(sAnimations[arg1]); + Animation_Change(&this->skelAnime, sAnimations[this->unk_2F8], arg2, 0.0f, this->unk_2C4, D_809C6178[this->unk_2F8], + -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5310.s") +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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C53A4.s") + 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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5408.s") + 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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5524.s") + if ((this->unk_2F8 == 0xF) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5598.s") + if ((this->unk_2F8 == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5738.s") +void func_809C4B50(EnBomBowlMan* this) { + this->unk_2B8 = 0; + this->unk_2BC = 0; + this->unk_2BA = 0; + this->unk_29E = 0; + this->unk_290 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C59A4.s") +void func_809C4B6C(EnBomBowlMan* this) { + if ((this->unk_29A != ENBOMBOWLMAN_FF00_MINUS1) && (this->path != NULL)) { + if (!SubS_CopyPointFromPath(this->path, this->unk_298, &this->unk_2A0)) { + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C59F0.s") +void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f sp7C; + EnBomBowlMan* bomBowlMan; + s8 code; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5AA4.s") + func_809C4B50(this); + func_809C493C(this, 0, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5B1C.s") + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.bomberCode); i++) { + Math_Vec3f_Copy(&sp7C, &this->actor.home.pos); + code = gSaveContext.save.bomberCode[i]; + if (code == 1) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_809C61A0[i]); + this->unk_2D8[code] = this; + } else { + Math_Vec3f_Copy(&sp7C, &D_809C61A0[i]); + bomBowlMan = + (EnBomBowlMan*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOM_BOWL_MAN, + sp7C.x, sp7C.y, sp7C.z, 0, this->actor.world.rot.y, 0, code); + if (bomBowlMan != NULL) { + if (i == 2) { + this->unk_2D8[0] = bomBowlMan; + } + this->unk_2D8[code] = bomBowlMan; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5BA0.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D0); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { + ActorCutscene_SetIntentToPlay(this->unk_2D0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5BF4.s") + func_809C493C(this, 3, 1.0f); + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_290 = this->actor.yawTowardsPlayer; + gSaveContext.save.weekEventReg[73] &= (u8)~0x10; + gSaveContext.save.weekEventReg[85] &= (u8)~2; + this->unk_29C = 0; + this->actionFunc = func_809C4DA4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Update.s") +void func_809C4DA4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_290, this->unk_2D4, 1, 5000, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/func_809C5F44.s") + if (this->unk_2B8 == 0) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Bowl_Man/EnBomBowlMan_Draw.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D0); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_2D0)) { + ActorCutscene_SetIntentToPlay(this->unk_2D0); + return; + } + + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D0, &this->actor); + this->unk_2B8 = 1; + this->unk_2C0 = 0; + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_290 = this->actor.yawTowardsPlayer; + if (player->transformation == PLAYER_FORM_HUMAN) { + Message_StartTextbox(globalCtx, D_809C618C[0], &this->actor); + } else { + Message_StartTextbox(globalCtx, D_809C6198[0], &this->actor); + } + } + + if ((this->unk_2BC == 0) && (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + s32 sp28 = false; + + func_801477B4(globalCtx); + + switch (this->unk_2C0) { + case 0: + this->unk_2C0 = 1; + D_809C6104 = 1; + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D0)), + &this->unk_2D8[0]->actor); + this->unk_2D4 = 0; + this->unk_2BC = 10; + func_809C493C(this, 17, 1.0f); + break; + + case 1: + D_809C6104 = 0; + func_809C493C(this, 3, 1.0f); + this->unk_2D4 = this->actor.yawTowardsPlayer; + this->unk_2C0 = 2; + if ((player->transformation == PLAYER_FORM_HUMAN) && CHECK_QUEST_ITEM(ITEM_BOTTLE)) { + this->unk_2C0 = 4; + } + break; + + case 2: + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2B8 = 2; + ActorCutscene_Stop(this->unk_2D0); + func_809C59A4(this, globalCtx); + sp28 = true; + } else { + this->unk_2C0 = 3; + globalCtx->msgCtx.unk11F10 = 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); + } + ActorCutscene_Stop(this->unk_2D0); + this->actionFunc = func_809C5B1C; + sp28 = true; + } + break; + + case 3: + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C0 = 4; + } else { + this->actionFunc = func_809C51B4; + return; + } + break; + + case 4: + if (this->unk_2B8 != 2) { + ActorCutscene_Stop(this->unk_2D0); + } + globalCtx->msgCtx.unk11F10 = 0; + func_809C493C(this, 1, 1.0f); + D_809C6100 = 1; + this->actionFunc = func_809C5B1C; + sp28 = true; + break; + + case 5: + func_80151BB4(globalCtx, 0x24); + func_80151BB4(globalCtx, 0x25); + func_80151BB4(globalCtx, 0); + this->actionFunc = func_809C51B4; + sp28 = true; + break; + } + + if (!sp28) { + if (player->transformation == PLAYER_FORM_HUMAN) { + func_80151938(globalCtx, D_809C618C[this->unk_2C0]); + } else { + func_80151938(globalCtx, D_809C6198[this->unk_2C0]); + } + } + } +} + +void func_809C51B4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((globalCtx->msgCtx.unk120B1 == 0) && + ((globalCtx->msgCtx.msgMode == 0) || (Message_GetState(&globalCtx->msgCtx) == 6))) { + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(6); + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x56; + gSaveContext.nextTransition = 3; + gSaveContext.save.weekEventReg[75] &= (u8)~0x40; + if (player->transformation == PLAYER_FORM_HUMAN) { + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[77] &= (u8)~2; + } else { + gSaveContext.save.weekEventReg[73] |= 0x20; + gSaveContext.save.weekEventReg[85] &= (u8)~1; + } + } +} + +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_1; + this->actor.world.pos.x = 1340.0f; + this->actor.world.pos.z = -1795.0f; + this->unk_29C = 3; + this->actionFunc = func_809C5310; +} + +void func_809C5310(EnBomBowlMan* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->actor.world.pos.x < 1510.0f) { + if (player->transformation != PLAYER_FORM_DEKU) { + if (this->actor.xzDistToPlayer < this->unk_2C8) { + func_800B7298(globalCtx, &this->actor, 7); + func_809C53A4(this); + } + } else { + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_809C53A4(EnBomBowlMan* this) { + this->actor.draw = EnBomBowlMan_Draw; + this->actor.world.pos.x = 1360.0f; + this->actor.world.pos.z = -1870.0f; + func_809C493C(this, 18, 1.0f); + this->unk_29C = 3; + this->actionFunc = func_809C5408; +} + +void func_809C5408(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos), 1, + 0x1388, 0); + Math_SmoothStepToS(&player->actor.shape.rot.y, Math_Vec3f_Yaw(&player->actor.world.pos, &this->actor.world.pos), 1, + 0x1388, 0); + player->actor.world.rot.y = player->actor.shape.rot.y; + Math_ApproachF(&this->actor.world.pos.x, 1350.0f, 0.3f, 2.0f); + Math_ApproachF(&this->actor.world.pos.z, -1800.0f, 0.3f, 2.0f); + if (sqrtf(SQ(this->actor.world.pos.x - 1350.0f) + SQ(this->actor.world.pos.z + 1800.0f)) < 4.0f) { + func_809C5524(this, globalCtx); + } +} + +void func_809C5524(EnBomBowlMan* this, GlobalContext* globalCtx) { + this->actor.textId = 0x730; + if (!(gSaveContext.save.weekEventReg[85] & 2)) { + this->actor.textId = 0x72F; + } + func_809C493C(this, 3, 1.0f); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_809C5598; +} + +void func_809C5598(EnBomBowlMan* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + if ((this->actor.textId == 0x72F) || (this->actor.textId == 0x730)) { + this->actor.textId = 0x731; + } else if (this->actor.textId == 0x731) { + this->actor.textId = 0x732; + } else if (this->actor.textId == 0x732) { + this->actor.textId = 0x733; + } else if (this->actor.textId == 0x733) { + this->actor.textId = 0x734; + } else if (this->actor.textId == 0x734) { + this->actor.textId = 0x715; + } else if (this->actor.textId == 0x715) { + func_800B7298(globalCtx, &this->actor, 6); + func_809C493C(this, 17, 1.0f); + func_809C59A4(this, globalCtx); + return; + } else if (this->actor.textId == 0x716) { + this->actor.textId = 0x735; + } else if (this->actor.textId == 0x735) { + this->unk_2C2 = 0; + func_809C493C(this, 17, 1.0f); + func_80151BB4(globalCtx, 0x24); + func_80151BB4(globalCtx, 0x25); + func_80151BB4(globalCtx, 0); + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = func_809C5738; + return; + } + func_80151938(globalCtx, this->actor.textId); + } +} + +void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { + s32 pad[3]; + s16 yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2A0); + + if (this->unk_2C2 == 0) { + if ((globalCtx->msgCtx.unk120B1 == 0) && + ((globalCtx->msgCtx.msgMode == 0) || (Message_GetState(&globalCtx->msgCtx) == 6))) { + 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); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &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); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->actor); + this->unk_2C2 = 2; + func_809C493C(this, 18, 1.0f); + } + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, yaw, 1, 2000, 10); + Math_ApproachF(&this->actor.world.pos.x, this->unk_2A0.x, 0.5f, 6.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_2A0.z, 0.5f, 6.0f); + if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_2A0.x) + SQ(this->actor.world.pos.z - this->unk_2A0.z)) < + 4.0f) && + (this->path != NULL)) { + this->unk_298++; + if (this->unk_298 >= this->path->count) { + gSaveContext.save.weekEventReg[84] |= 0x80; + gSaveContext.save.weekEventReg[83] &= (u8)~4; + ActorCutscene_Stop(this->unk_2D6); + Actor_MarkForDeath(&this->actor); + } else { + func_809C4B6C(this); + } + } + } +} + +void func_809C59A4(EnBomBowlMan* this, GlobalContext* globalCtx) { + Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); + this->unk_29C = 1; + this->actionFunc = func_809C59F0; +} + +void func_809C59F0(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + this->unk_2C0 = 3; + this->actor.textId = D_809C618C[this->unk_2C0]; + } else { + this->actor.textId = 0x716; + } + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + this->actionFunc = func_809C5AA4; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_50, 300.0f, 300.0f); + } +} + +void func_809C5AA4(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->unk_2F6 == ENBOMBOWLMAN_F0_0) { + this->actionFunc = func_809C4DA4; + } else { + this->actionFunc = func_809C5598; + } + } else { + func_800B8500(&this->actor, globalCtx, 400.0f, 400.0f, -1); + } +} + +void func_809C5B1C(EnBomBowlMan* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D2)) { + ActorCutscene_SetIntentToPlay(this->unk_2D2); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D2, &this->actor); + func_809C5BA0(this); + } +} + +void func_809C5BA0(EnBomBowlMan* this) { + if (this->unk_2F4 != 0) { + func_809C493C(this, 0, 1.0f); + } else { + this->unk_2F8 = 0; + } + this->unk_29C = 2; + this->actionFunc = func_809C5BF4; +} + +void func_809C5BF4(EnBomBowlMan* this, GlobalContext* globalCtx) { + f32 sp2C = this->skelAnime.curFrame; + s32 sp28; + + if ((D_809C6104 != 0) && (this->unk_2F8 != 15)) { + func_809C493C(this, 15, 1.0f); + } + + if ((this->unk_2F8 == 15) && (this->unk_2C4 <= sp2C)) { + func_809C493C(this, 0, 1.0f); + } + + if (D_809C6100 != 0) { + if ((this->unk_2F8 == 0) && (D_809C6100 == (this->unk_2F4 + 1))) { + func_809C493C(this, 11, 1.0f); + } + + if ((this->unk_2F8 == 11) && (this->unk_2C4 <= sp2C)) { + func_809C493C(this, 12, 1.0f); + D_809C6100++; + } + + if (this->unk_2F4 == 0) { + sp28 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->unk_2D2)); + + if (D_809C6100 > 5) { + Player* player = GET_PLAYER(globalCtx); + + func_801477B4(globalCtx); + Camera_SetTargetActor(sp28, &this->unk_2D8[0]->actor); + func_809C493C(this, 13, 1.0f); + D_809C6100 = 0; + if (player->transformation == PLAYER_FORM_HUMAN) { + this->unk_2C0 = 5; + Message_StartTextbox(globalCtx, D_809C618C[this->unk_2C0], &this->actor); + } else { + this->unk_2C0 = 3; + Message_StartTextbox(globalCtx, D_809C6198[this->unk_2C0], &this->actor); + } + this->unk_29C = 0; + this->actionFunc = func_809C4DA4; + } else { + s32 idx = D_809C6100 - 1; + + Camera_SetTargetActor(sp28, &this->unk_2D8[1 + idx]->actor); + } + } + } +} + +void EnBomBowlMan_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; + + if (this->unk_2BA != 0) { + this->unk_2BA--; + } + + if (this->unk_2BC != 0) { + this->unk_2BC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_809C49CC(this); + Actor_SetFocus(&this->actor, 20.0f); + + this->actionFunc(this, globalCtx); + + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + + if (this->unk_2F2 == 0) { + this->unk_2F0++; + if (this->unk_2F0 >= 3) { + this->unk_2F0 = 0; + this->unk_2F2 = (s32)Rand_ZeroFloat(60.0f) + 20; + } + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); +} + +s32 EnBomBowlMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBomBowlMan* this = THIS; + + if (limbIndex == 15) { + *dList = NULL; + } + + if (limbIndex == 17) { + rot->x += this->unk_28A; + } + + if ((limbIndex == 19) && (this->unk_2F6 == ENBOMBOWLMAN_F0_2)) { + *dList = NULL; + } + + if ((limbIndex == 20) && (this->unk_2F6 == ENBOMBOWLMAN_F0_0)) { + *dList = NULL; + } + return false; +} + +#include "overlays/ovl_En_Bom_Bowl_Man/ovl_En_Bom_Bowl_Man.c" + +TexturePtr D_809C6200[] = { + gEnBomBowlMan_D_809C61E0, gEnBomBowlMan_D_809C61F0, gEnBomBowlMan_D_809C61F0, + gEnBomBowlMan_D_809C61F0, gEnBomBowlMan_D_809C61F0, +}; + +TexturePtr D_809C6214[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; + +TexturePtr D_809C6220[] = { + object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, +}; + +void EnBomBowlMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBomBowlMan* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_809C6214[this->unk_2F0])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_809C6220[this->unk_2F4])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_809C6200[this->unk_2F4])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBomBowlMan_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 ba90b19c9..6246a6756 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 @@ -7,11 +7,54 @@ struct EnBomBowlMan; typedef void (*EnBomBowlManActionFunc)(struct EnBomBowlMan*, GlobalContext*); +#define ENBOMBOWLMAN_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMBOWLMAN_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +#define ENBOMBOWLMAN_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENBOMBOWLMAN_F0_0 0 +#define ENBOMBOWLMAN_F0_2 2 + +#define ENBOMBOWLMAN_FF00_MINUS1 -1 + typedef struct EnBomBowlMan { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[21]; + /* 0x0206 */ Vec3s morphTable[21]; /* 0x0284 */ EnBomBowlManActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x74]; + /* 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; } EnBomBowlMan; // size = 0x2FC extern const ActorInit En_Bom_Bowl_Man_InitVars; 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 f02ab4ec6..fc63795de 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 @@ -5,21 +5,26 @@ */ #include "z_en_bom_chu.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBomChu*)thisx) +#define BOMBCHU_SCALE 0.01f + void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx); void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_808F7868(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7A84(EnBomChu* this, GlobalContext* globalCtx); -void func_808F7FA0(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_SetupMove(EnBomChu* this); +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx); +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bom_Chu_InitVars = { ACTOR_EN_BOM_CHU, ACTORCAT_EXPLOSIVES, @@ -32,50 +37,536 @@ const ActorInit En_Bom_Chu_InitVars = { (ActorFunc)EnBomChu_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_808F88E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 13 }, 100 }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F890C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), + ICHAIN_VEC3F_DIV1000(scale, 1000 * BOMBCHU_SCALE, ICHAIN_STOP), }; -#endif +static EffectBlureInit2 sBlureInit = { + 0, 0, 0, { 250, 0, 0, 250 }, { 200, 0, 0, 130 }, { 150, 0, 0, 100 }, { 100, 0, 0, 50 }, 16, + 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; -extern ColliderSphereInit D_808F88E0; -extern InitChainEntry D_808F890C[]; +void EnBomChu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Destroy.s") + Effect_Add(globalCtx, &this->blure1Index, EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(globalCtx, &this->blure2Index, EFFECT_BLURE2, 0, 0, &sBlureInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F75D0.s") + this->timer = 120; + this->actor.room = -1; + this->shouldTimerCountDown = true; + this->unk_174 = 0.0f; + this->actionFunc = EnBomChu_WaitForRelease; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F77E4.s") +void EnBomChu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7868.s") + Effect_Destroy(globalCtx, this->blure1Index); + Effect_Destroy(globalCtx, this->blure2Index); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7944.s") +/** + * Returns true if floorPoly is valid for the Bombchu to move on, false otherwise. + */ +s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalContext* globalCtx) { + Vec3f normal; + Vec3f vec; + f32 angle; + f32 magnitude; + f32 normDotUp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F79D4.s") + this->actor.floorPoly = floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7A84.s") + // This NULL check means if the player releases a Bombchu with no collision + // below them, the game will not crash, unlike OoT. + if (floorPoly != NULL) { + normal.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + normal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + normal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + } else { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7E74.s") + normDotUp = DOTXYZ(normal, this->axisUp); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FA0.s") + if (fabsf(normDotUp) >= 0.999f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F7FD0.s") + angle = func_80086C48(normDotUp); + if (angle < 0.001f) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F8080.s") + Math3D_CrossProduct(&this->axisUp, &normal, &vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/func_808F818C.s") + magnitude = Math3D_Vec3fMagnitude(&vec); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Update.s") + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bom_Chu/EnBomChu_Draw.s") + Math_Vec3f_Scale(&vec, 1.0f / magnitude); + Matrix_InsertRotationAroundUnitVector_f(angle, &vec, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&this->axisLeft, &vec); + Math_Vec3f_Copy(&this->axisLeft, &vec); + Math3D_CrossProduct(&this->axisLeft, &normal, &this->axisForwards); + + magnitude = Math3D_Vec3fMagnitude(&this->axisForwards); + if (magnitude < 0.001f) { + EnBomChu_Explode(this, globalCtx); + return false; + } + + Math_Vec3f_Scale(&this->axisForwards, 1.0f / magnitude); + Math_Vec3f_Copy(&this->axisUp, &normal); + return true; +} + +void EnBomChu_UpdateRotation(EnBomChu* this) { + MtxF mf; + + mf.xx = this->axisLeft.x; + mf.xy = this->axisLeft.y; + mf.xz = this->axisLeft.z; + + mf.yx = this->axisUp.x; + mf.yy = this->axisUp.y; + mf.yz = this->axisUp.z; + + mf.zx = this->axisForwards.x; + mf.zy = this->axisForwards.y; + mf.zz = this->axisForwards.z; + + func_8018219C(&mf, &this->actor.world.rot, 0); + this->actor.world.rot.x = -this->actor.world.rot.x; +} + +void EnBomChu_WaitForRelease(EnBomChu* this, GlobalContext* globalCtx) { + Player* player; + + if (this->timer == 0) { + EnBomChu_Explode(this, globalCtx); + } else if (Actor_HasNoParent(&this->actor, globalCtx)) { + player = GET_PLAYER(globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &player->actor.world.pos); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actor.shape.rot.y = player->actor.shape.rot.y; + this->actor.flags |= ACTOR_FLAG_1; + func_800B8EF4(globalCtx, &this->actor); + + this->isMoving = true; + this->actor.speedXZ = 8.0f; + this->movingSpeed = 8.0f; + EnBomChu_SetupMove(this); + } +} + +s32 EnBomChu_IsOnCollisionPoly(GlobalContext* globalCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, + CollisionPoly** poly, s32* bgId) { + if ((BgCheck_EntityLineTest1(&globalCtx->colCtx, posA, posB, posResult, poly, true, true, true, true, bgId)) && + (!(func_800C9A4C(&globalCtx->colCtx, *poly, *bgId) & 0x30))) { + return true; + } + + return false; +} + +void EnBomChu_SetupMove(EnBomChu* this) { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + + Matrix_GetStateTranslationAndScaledY(1.0f, &this->axisUp); + Matrix_GetStateTranslationAndScaledZ(1.0f, &this->axisForwards); + Matrix_GetStateTranslationAndScaledX(1.0f, &this->axisLeft); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actionFunc = EnBomChu_Move; +} + +void EnBomChu_Move(EnBomChu* this, GlobalContext* globalCtx) { + CollisionPoly* polySide = NULL; + CollisionPoly* polyUpDown = NULL; + s32 bgIdSide; + s32 bgIdUpDown; + s32 i; + s32 isFloorPolyValid; + f32 lineLength; + Vec3f posA; + Vec3f posB; + Vec3f posSide; + Vec3f posUpDown; + + bgIdUpDown = bgIdSide = BGCHECK_SCENE; + isFloorPolyValid = false; + + this->actor.speedXZ = this->movingSpeed; + lineLength = 2.0f * this->movingSpeed; + + if ((this->timer == 0) || (this->collider.base.acFlags & AC_HIT) || (this->collider.base.ocFlags1 & OC1_HIT)) { + EnBomChu_Explode(this, globalCtx); + return; + } + + posA.x = this->actor.world.pos.x + (this->axisUp.x * 2.0f); + posA.y = this->actor.world.pos.y + (this->axisUp.y * 2.0f); + posA.z = this->actor.world.pos.z + (this->axisUp.z * 2.0f); + + posB.x = this->actor.world.pos.x - (this->axisUp.x * 4.0f); + posB.y = this->actor.world.pos.y - (this->axisUp.y * 4.0f); + posB.z = this->actor.world.pos.z - (this->axisUp.z * 4.0f); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posUpDown, &polyUpDown, &bgIdUpDown)) { + // forwards + posB.x = (this->axisForwards.x * lineLength) + posA.x; + posB.y = (this->axisForwards.y * lineLength) + posA.y; + posB.z = (this->axisForwards.z * lineLength) + posA.z; + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + this->actor.speedXZ = 0.0f; + } else { + if (this->actor.floorPoly != polyUpDown) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polyUpDown, globalCtx); + } + + Math_Vec3f_Copy(&this->actor.world.pos, &posUpDown); + this->actor.floorBgId = bgIdUpDown; + } + } else { + this->actor.speedXZ = 0.0f; + lineLength *= 3.0f; + Math_Vec3f_Copy(&posA, &posB); + + for (i = 0; i < 3; i++) { + if (i == 0) { + // backwards + posB.x = posA.x - (this->axisForwards.x * lineLength); + posB.y = posA.y - (this->axisForwards.y * lineLength); + posB.z = posA.z - (this->axisForwards.z * lineLength); + } else if (i == 1) { + // left + posB.x = posA.x + (this->axisLeft.x * lineLength); + posB.y = posA.y + (this->axisLeft.y * lineLength); + posB.z = posA.z + (this->axisLeft.z * lineLength); + } else { + // right + posB.x = posA.x - (this->axisLeft.x * lineLength); + posB.y = posA.y - (this->axisLeft.y * lineLength); + posB.z = posA.z - (this->axisLeft.z * lineLength); + } + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &posSide, &polySide, &bgIdSide)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, polySide, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &posSide); + this->actor.floorBgId = bgIdSide; + break; + } + } + + if (i == 3) { + // no collision nearby + EnBomChu_Explode(this, globalCtx); + } + } + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + + if (this->isMoving) { + func_800B8F98(&this->actor, NA_SE_IT_BOMBCHU_MOVE - SFX_FLAG); + } + + if (this->actor.speedXZ != 0.0f) { + this->movingSpeed = this->actor.speedXZ; + } +} + +void EnBomChu_Explode(EnBomChu* this, GlobalContext* globalCtx) { + EnBom* bomb; + s32 i; + + bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + + this->shouldTimerCountDown = true; + this->isMoving = false; + + if (bomb != NULL) { + bomb->timer = 0; + } + + this->timer = 1; + this->actor.speedXZ = 0.0f; + + if (this->actor.depthInWater > 0.0f) { + for (i = 0; i < 40; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 1.0f, 5.0f, 30.0f, 0.25f); + } + } + + this->actor.draw = NULL; + this->actionFunc = EnBomChu_WaitForDeath; +} + +void EnBomChu_WaitForDeath(EnBomChu* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Transform coordinates from actor coordinate space to world space, according to current orientation. + * `offset` is expected to already be at world scale. + */ +void EnBomChu_ActorCoordsToWorld(EnBomChu* this, Vec3f* offset, Vec3f* pos) { + f32 x = offset->x + this->visualJitter; + + pos->x = this->actor.world.pos.x + (this->axisLeft.x * x) + (this->axisUp.x * offset->y) + + (this->axisForwards.x * offset->z); + pos->y = this->actor.world.pos.y + (this->axisLeft.y * x) + (this->axisUp.y * offset->y) + + (this->axisForwards.y * offset->z); + pos->z = this->actor.world.pos.z + (this->axisLeft.z * x) + (this->axisUp.z * offset->y) + + (this->axisForwards.z * offset->z); +} + +void EnBomChu_SpawnRipplesAndSplashes(EnBomChu* this, GlobalContext* globalCtx, f32 y, s32 spawnExtraRipples) { + s32 pad; + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = y; + pos.z = this->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 0); + + if (spawnExtraRipples) { + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 4); + EffectSsGRipple_Spawn(globalCtx, &pos, 70, 500, 8); + } else { + pos.x -= this->axisForwards.x * 10.0f; + pos.z -= this->axisForwards.z * 10.0f; + } + + pos.y += 5.0f; + EffectSsGSplash_Spawn(globalCtx, &pos, NULL, NULL, 1, 450); +} + +void EnBomChu_HandleNonSceneCollision(EnBomChu* this, GlobalContext* globalCtx) { + Vec3f originalWorldPos; + Vec3f posA; + Vec3f posB; + Vec3f originalAxisUp; + s16 yaw; + f32 sin; + f32 cos; + f32 tempX; + CollisionPoly* poly = NULL; + s32 bgId = BGCHECK_SCENE; + s32 isFloorPolyValid; + + Math_Vec3f_Copy(&originalWorldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&originalAxisUp, &this->axisUp); + yaw = this->actor.shape.rot.y; + BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, this->actor.floorBgId, &this->actor); + + if (yaw != this->actor.shape.rot.y) { + yaw = this->actor.shape.rot.y - yaw; + + sin = Math_SinS(yaw); + cos = Math_CosS(yaw); + + tempX = this->axisForwards.x; + this->axisForwards.x = (sin * this->axisForwards.z) + (cos * tempX); + this->axisForwards.z = (cos * this->axisForwards.z) - (sin * tempX); + + tempX = this->axisUp.x; + this->axisUp.x = (sin * this->axisUp.z) + (cos * tempX); + this->axisUp.z = (cos * this->axisUp.z) - (sin * tempX); + + tempX = this->axisLeft.x; + this->axisLeft.x = (sin * this->axisLeft.z) + (cos * tempX); + this->axisLeft.z = (cos * this->axisLeft.z) - (sin * tempX); + } + + posA.x = originalWorldPos.x + (2.0f * originalAxisUp.x); + posA.y = originalWorldPos.y + (2.0f * originalAxisUp.y); + posA.z = originalWorldPos.z + (2.0f * originalAxisUp.z); + + posB.x = this->actor.world.pos.x + (2.0f * this->axisUp.x); + posB.y = this->actor.world.pos.y + (2.0f * this->axisUp.y); + posB.z = this->actor.world.pos.z + (2.0f * this->axisUp.z); + + if (EnBomChu_IsOnCollisionPoly(globalCtx, &posA, &posB, &originalWorldPos, &poly, &bgId)) { + isFloorPolyValid = EnBomChu_UpdateFloorPoly(this, poly, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &originalWorldPos); + this->actor.floorBgId = bgId; + this->actor.speedXZ = 0.0f; + + if (isFloorPolyValid) { + EnBomChu_UpdateRotation(this); + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + } + } +} + +void EnBomChu_Update(Actor* thisx, GlobalContext* globalCtx) { + static Vec3f sBlureP1Offset = { 0.0f, 7.0f, -6.0f }; + static Vec3f sBlureP2LeftOffset = { 12.0f, 0.0f, -5.0f }; + static Vec3f sBlureP2RightOffset = { -12.0f, 0.0f, -5.0f }; + s32 pad; + EnBomChu* this = THIS; + Vec3f blureP1; + Vec3f blureP2; + WaterBox* waterBox; + f32 waterY; + + if (this->actor.floorBgId != BGCHECK_SCENE) { + EnBomChu_HandleNonSceneCollision(this, globalCtx); + } + + if (this->shouldTimerCountDown) { + this->timer--; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnBomChu_WaitForDeath) && + (SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + EnBomChu_Explode(this, globalCtx); + return; + } + + Actor_MoveWithoutGravity(&this->actor); + + 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; + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actionFunc != EnBomChu_WaitForRelease) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->actor.focus.pos.x = this->actor.world.pos.x + (20.0f * this->axisUp.x); + this->actor.focus.pos.y = this->actor.world.pos.y + (20.0f * this->axisUp.y); + this->actor.focus.pos.z = this->actor.world.pos.z + (20.0f * this->axisUp.z); + + if (this->isMoving) { + this->visualJitter = + (5.0f + (Rand_ZeroOne() * 3.0f)) * Math_SinS((((s32)(Rand_ZeroOne() * 512.0f) + 0x3000) * this->timer)); + EnBomChu_ActorCoordsToWorld(this, &sBlureP1Offset, &blureP1); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2LeftOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure1Index), &blureP1, &blureP2); + + EnBomChu_ActorCoordsToWorld(this, &sBlureP2RightOffset, &blureP2); + EffectBlure_AddVertex(Effect_GetByIndex(this->blure2Index), &blureP1, &blureP2); + + waterY = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterY, &waterBox)) { + this->actor.depthInWater = waterY - this->actor.world.pos.y; + + if (this->actor.depthInWater < 0.0f) { + if (this->actor.bgCheckFlags & 0x20) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } + + this->actor.bgCheckFlags &= ~0x20; + return; + } + + if (!(this->actor.bgCheckFlags & 0x20) && (this->timer != 120)) { + EnBomChu_SpawnRipplesAndSplashes(this, globalCtx, waterY, true); + } else { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 3.0f, 15.0f, 0.25f); + } + + this->actor.bgCheckFlags |= 0x20; + } else { + this->actor.bgCheckFlags &= ~0x20; + this->actor.depthInWater = BGCHECK_Y_MIN; + } + } +} + +void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBomChu* this = THIS; + f32 colorIntensity; + s32 blinkHalfPeriod; + s32 blinkTime; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_800B8050(&this->actor, globalCtx, 0); + + if (this->timer >= 40) { + blinkTime = this->timer % 20; + blinkHalfPeriod = 10; + } else if (this->timer >= 10) { + blinkTime = this->timer % 10; + blinkHalfPeriod = 5; + } else { + blinkTime = this->timer & 1; + blinkHalfPeriod = 1; + } + + if (blinkTime > blinkHalfPeriod) { + blinkTime = 2 * blinkHalfPeriod - blinkTime; + } + + colorIntensity = blinkTime / (f32)blinkHalfPeriod; + gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, + (s32)(colorIntensity * -35.0f) + 35, 255); + Matrix_InsertTranslation(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gBombchuDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h index 910ad5174..30a3dab9a 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.h @@ -8,9 +8,21 @@ struct EnBomChu; typedef void (*EnBomChuActionFunc)(struct EnBomChu*, GlobalContext*); typedef struct EnBomChu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBomChuActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x98]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBomChuActionFunc actionFunc; + /* 0x148 */ u8 shouldTimerCountDown; // the actor always sets this to true + /* 0x149 */ u8 isMoving; + /* 0x14A */ s16 timer; + /* 0x14C */ Vec3f axisForwards; + /* 0x158 */ Vec3f axisUp; + /* 0x164 */ Vec3f axisLeft; + /* 0x170 */ f32 visualJitter; + /* 0x174 */ f32 unk_174; // set but never used + /* 0x178 */ UNK_TYPE1 unk_178[0x4]; + /* 0x17C */ f32 movingSpeed; + /* 0x180 */ s32 blure1Index; + /* 0x184 */ s32 blure2Index; + /* 0x188 */ ColliderSphere collider; } EnBomChu; // size = 0x1E0 extern const ActorInit En_Bom_Chu_InitVars; 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 09d0880c6..479df5cd7 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -6,7 +6,7 @@ #include "z_en_bombal.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnBombal*)thisx) 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 2ef45e65d..a76c901eb 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -5,8 +5,10 @@ */ #include "z_en_bombers.h" +#include "overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.h" +#include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBombers*)thisx) @@ -15,12 +17,14 @@ void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80C03ACC(EnBombers* this); void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx); +void func_80C03F64(EnBombers* this); void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx); +void func_80C042F8(EnBombers* this); void func_80C04354(EnBombers* this, GlobalContext* globalCtx); void func_80C043C8(EnBombers* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers_InitVars = { ACTOR_EN_BOMBERS, ACTORCAT_NPC, @@ -33,45 +37,495 @@ const ActorInit En_Bombers_InitVars = { (ActorFunc)EnBombers_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C04770 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 10, 30, 0, { 0, 0, 0 } }, }; -#endif +AnimationHeader* D_80C0479C[] = { + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, + &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, + &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, + &object_cs_Anim_0031C4, +}; -extern ColliderCylinderInit D_80C04770; +u8 D_80C047E0[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +#include "overlays/ovl_En_Bombers/ovl_En_Bombers.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Init.s") +Gfx* D_80C04818[] = { + ovl_En_Bombers_DL_12C8, ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, + ovl_En_Bombers_DL_12D8, ovl_En_Bombers_DL_12D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Destroy.s") +TexturePtr D_80C0482C[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03824.s") +TexturePtr D_80C04838[] = { + object_cs_Tex_00E620, object_cs_Tex_00EA20, object_cs_Tex_00EE20, object_cs_Tex_00DD20, object_cs_Tex_00F220, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C038B4.s") +void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C039A8.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + this->actor.gravity = -1.0f; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphtable, 21); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 0; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03ACC.s") + this->unk_2BC = ENBOMBERS_GET_F0(&this->actor); + this->unk_2BE = ENBOMBERS_GET_F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03AF4.s") + if (this->unk_2BC == ENBOMBERS_F0_0) { + if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_2BE++; + func_80C03ACC(this); + } + } else if (((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) && + (((this->unk_2BE == ENBOMBERS_F_0) && (gSaveContext.save.weekEventReg[76] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[76] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[76] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[76] & 8)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[76] & 0x10)))) { + if (gSaveContext.save.weekEventReg[75] & 0x40) { + if (this->unk_2BE == ENBOMBERS_F_0) { + EnBomBowlMan* bomBowlMan = (EnBomBowlMan*)Actor_Spawn( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM_BOWL_MAN, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03F64.s") + if (bomBowlMan != NULL) { + s32 cs = this->actor.cutscene; + s32 i = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C03FAC.s") + // clang-format off + while (cs != -1) { bomBowlMan->unk_2CC[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } + // clang-format on -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C042F8.s") + gSaveContext.save.weekEventReg[76] &= (u8)~1; + gSaveContext.save.weekEventReg[76] &= (u8)~2; + gSaveContext.save.weekEventReg[76] &= (u8)~4; + gSaveContext.save.weekEventReg[76] &= (u8)~8; + gSaveContext.save.weekEventReg[76] &= (u8)~0x10; + } + } + Actor_MarkForDeath(&this->actor); + } else { + func_80C042F8(this); + } + } else { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C04354.s") +void EnBombers_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C043C8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Update.s") +void func_80C03824(EnBombers* this, s32 arg1, f32 arg2) { + this->unk_2C4 = arg1; + this->unk_2B0 = Animation_GetLastFrame(D_80C0479C[arg1]); + Animation_Change(&this->skelAnime, D_80C0479C[this->unk_2C4], arg2, 0.0f, this->unk_2B0, D_80C047E0[this->unk_2C4], + -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/func_80C045B4.s") +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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers/EnBombers_Draw.s") + 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); + } +} + +void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + this->unk_2A6 = 5; + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->actor.textId = 0x73D; + if (gSaveContext.save.weekEventReg[84] & 0x80) { + this->actor.textId = 0x74B; + } + break; + + case PLAYER_FORM_GORON: + this->actor.textId = 0x73E; + break; + + case PLAYER_FORM_ZORA: + this->actor.textId = 0x73F; + break; + + case PLAYER_FORM_DEKU: + if (gSaveContext.save.weekEventReg[73] & 0x20) { + this->actor.textId = 0x75A; + } else if (gSaveContext.save.weekEventReg[73] & 0x40) { + this->actor.textId = 0x749; + if (((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[74] & 1)) || + ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[74] & 2)) || + ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[74] & 4)) || + ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[74] & 8))) { + this->actor.textId = 0x74A; + } + } else { + this->actor.textId = 0x744; + } + break; + } +} + +void func_80C03ACC(EnBombers* this) { + this->collider.dim.radius = 10; + this->collider.dim.height = 30; + this->unk_2C0 = 0; + this->actionFunc = func_80C03AF4; +} + +void func_80C03AF4(EnBombers* this, GlobalContext* globalCtx) { + CollisionPoly* colPoly; + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + f32 x; + f32 z; + s32 sp48; + s16 abs; + + switch (this->unk_2A0) { + case 0: + if (this->unk_2A8 == 0) { + Math_Vec3f_Copy(&sp60, &this->actor.home.pos); + + sp60.x += randPlusMinusPoint5Scaled(150.0f); + sp60.z += randPlusMinusPoint5Scaled(150.0f); + + abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp60))); + if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, + &colPoly, true, false, false, true, &sp48)) { + func_80C03824(this, 2, 1.0f); + Math_Vec3f_Copy(&this->unk_294, &sp60); + this->unk_2AA = Rand_S16Offset(30, 50); + this->unk_2A0++; + } + } + break; + + case 1: + if (curFrame >= 0.0f) { + this->unk_2A4 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_294); + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 0xA, 0x7D0, 0x14); + } + + if ((s16)ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_2A4)) < 0x100) { + Math_Vec3f_Copy(&sp54, &this->actor.world.pos); + sp54.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + sp54.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, &colPoly, true, + false, false, true, &sp48)) { + this->unk_2A8 = 0; + if (Rand_ZeroOne() < 0.5f) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + break; + } + } + + x = this->unk_294.x - this->actor.world.pos.x; + z = this->unk_294.z - this->actor.world.pos.z; + + if ((this->unk_2AA == 0) || (sqrtf(SQ(x) + SQ(z)) < 4.0f)) { + this->unk_2A8 = Rand_S16Offset(20, 20); + if (!(this->unk_2A8 & 1)) { + func_80C03824(this, 16, 1.0f); + } else { + func_80C03824(this, 0, 1.0f); + } + this->unk_2A0 = 0; + this->unk_2B4 = 0.0f; + } else if (curFrame >= 0.0f) { + Math_ApproachF(&this->actor.world.pos.x, this->unk_294.x, 0.3f, this->unk_2B4); + Math_ApproachF(&this->actor.world.pos.z, this->unk_294.z, 0.3f, this->unk_2B4); + Math_ApproachF(&this->unk_2B4, 1.0f, 0.3f, 0.5f); + } + break; + } + + if (!Text_GetFaceReaction(globalCtx, 0x12)) { + func_80C039A8(this, globalCtx); + } else { + this->unk_2A6 = 5; + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x12); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + this->collider.dim.radius = 20; + this->collider.dim.height = 60; + func_80C03F64(this); + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C03F64(EnBombers* this) { + this->unk_2A4 = this->actor.yawTowardsPlayer; + func_80C03824(this, 1, 1.0f); + this->unk_2C0 = 1; + this->actionFunc = func_80C03FAC; +} + +void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp2A; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A4, 1, 0x1388, 0); + + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + } + + if ((this->unk_2A6 == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + sp2A = 0; + func_801477B4(globalCtx); + this->unk_2A6 = 5; + + if ((this->actor.textId == 0x73D) || (this->actor.textId == 0x73E) || (this->actor.textId == 0x73F)) { + this->actor.textId = 0x740; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x740) { + if (globalCtx->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x742; + sp2A = 1; + } else { + func_8019F230(); + this->actor.textId = 0x741; + sp2A = 1; + } + } else if (this->actor.textId == 0x742) { + this->actor.textId = 0x737; + sp2A = 1; + } else if (this->actor.textId == 0x737) { + this->actor.textId = 0x743; + sp2A = 1; + } else if (this->actor.textId == 0x74B) { + this->actor.textId = 0x74C; + this->unk_2A6 = 4; + sp2A = 1; + } else if (this->actor.textId == 0x74C) { + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F230(); + this->actor.textId = 0x737; + sp2A = 1; + } else { + func_8019F208(); + this->actor.textId = 0x74D; + func_80C03824(this, 14, 1.0f); + sp2A = 1; + } + } else if (this->actor.textId == 0x744) { + s32 day = gSaveContext.save.day - 1; + + if (day == 2) { + this->actor.textId = 0x746; + sp2A = 1; + } else { + this->actor.textId = 0x745; + sp2A = 1; + } + } else if ((this->actor.textId == 0x745) || (this->actor.textId == 0x746)) { + this->actor.textId = 0x747; + sp2A = 1; + } else if (this->actor.textId == 0x747) { + this->actor.textId = 0x748; + sp2A = 1; + } else if (this->actor.textId == 0x748) { + switch (this->unk_2BE) { + case ENBOMBERS_F_1: + gSaveContext.save.weekEventReg[74] |= 1; + break; + + case ENBOMBERS_F_2: + gSaveContext.save.weekEventReg[74] |= 2; + break; + + case ENBOMBERS_F_3: + gSaveContext.save.weekEventReg[74] |= 4; + break; + + case ENBOMBERS_F_4: + gSaveContext.save.weekEventReg[74] |= 8; + break; + } + gSaveContext.save.weekEventReg[73] |= 0x40; + } + + switch (sp2A) { + case 0: + this->unk_28E = 0; + func_80C03ACC(this); + break; + + case 1: + func_80151938(globalCtx, this->actor.textId); + break; + } + } +} + +void func_80C042F8(EnBombers* this) { + if (this->unk_2C4 != 6) { + func_80C03824(this, 6, 1.0f); + } + this->actor.textId = 0x72D; + this->unk_28E = 0x1F40; + this->unk_2C0 = 2; + this->actionFunc = func_80C04354; +} + +void func_80C04354(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_28E = 0; + this->actionFunc = func_80C043C8; + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C043C8(EnBombers* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x3E8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + func_80C042F8(this); + } +} + +void EnBombers_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombers* this = THIS; + + if (this->unk_2AA != 0) { + this->unk_2AA--; + } + + if (this->unk_2A8 != 0) { + this->unk_2A8--; + } + + if (this->unk_2AC != 0) { + this->unk_2AC--; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + func_80C038B4(this); + Actor_SetFocus(&this->actor, 20.0f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0x1388, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0x1388, 0); + + if (this->unk_2BA == 0) { + this->unk_2B8++; + if (this->unk_2B8 >= 3) { + this->unk_2B8 = 0; + this->unk_2BA = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + this->actor.uncullZoneForward = 500.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnBombers_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnBombers* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_0F) { + *dList = NULL; + } + + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + + if (limbIndex == OBJECT_CS_LIMB_13) { + *dList = NULL; + } + + return false; +} + +void EnBombers_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnBombers* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C0482C[this->unk_2B8])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C04838[this->unk_2BE])); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80C04818[this->unk_2BE])); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnBombers_OverrideLimbDraw, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h index 630c26e65..c51150df8 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h @@ -7,11 +7,47 @@ struct EnBombers; typedef void (*EnBombersActionFunc)(struct EnBombers*, GlobalContext*); +#define ENBOMBERS_GET_F(thisx) ((thisx)->params & 0xF) +#define ENBOMBERS_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) + +enum { + /* 0 */ ENBOMBERS_F_0, + /* 1 */ ENBOMBERS_F_1, + /* 2 */ ENBOMBERS_F_2, + /* 3 */ ENBOMBERS_F_3, + /* 4 */ ENBOMBERS_F_4, +}; + +#define ENBOMBERS_F0_0 0 + typedef struct EnBombers { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[21]; + /* 0x0206 */ Vec3s morphtable[21]; /* 0x0284 */ EnBombersActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x8C]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 unk28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0294 */ Vec3f unk_294; + /* 0x02A0 */ s16 unk_2A0; + /* 0x02A2 */ UNK_TYPE1 unk2A2[2]; + /* 0x02A4 */ s16 unk_2A4; + /* 0x02A6 */ s16 unk_2A6; + /* 0x02A8 */ s16 unk_2A8; + /* 0x02AA */ s16 unk_2AA; + /* 0x02AC */ s16 unk_2AC; + /* 0x02B0 */ f32 unk_2B0; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ s16 unk_2B8; + /* 0x02BA */ s16 unk_2BA; + /* 0x02BC */ s16 unk_2BC; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C4 */ s32 unk_2C4; + /* 0x02C8 */ ColliderCylinder collider; } EnBombers; // size = 0x314 extern const ActorInit En_Bombers_InitVars; 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 18aa562e7..8b2fa6d90 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -6,7 +6,7 @@ #include "z_en_bombers2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBombers2*)thisx) @@ -18,8 +18,11 @@ void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx); void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx); void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx); +void func_80C04B40(EnBombers2* this); +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed); +void func_80C04D00(EnBombers2* this); +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Bombers2_InitVars = { ACTOR_EN_BOMBERS2, ACTORCAT_NPC, @@ -32,39 +35,404 @@ const ActorInit En_Bombers2_InitVars = { (ActorFunc)EnBombers2_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C058B0 = { - { 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 u16 sTextIds[] = { + 0x0727, 0x0728, 0x0726, 0x0729, 0x072B, 0x0725, 0x072A, 0x073C, +}; + +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, + }, { 35, 30, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &gBomberIdleAnim, &object_cs_Anim_0053F4, &object_cs_Anim_01007C, &object_cs_Anim_00349C, + &object_cs_Anim_0060E8, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, +}; -extern ColliderCylinderInit D_80C058B0; +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060064B8; +static Gfx sSetPrimColorDL[] = { + gsDPSetPrimColor(0, 0xFF, 198, 140, 0, 255), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Init.s") +static Gfx* sSetPrimColorDlPtr = sSetPrimColorDL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Destroy.s") +static TexturePtr sEyeTextures[] = { + object_cs_Tex_00C520, + object_cs_Tex_00CD20, + object_cs_Tex_00D520, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04AAC.s") +static TexturePtr D_80C05920 = object_cs_Tex_00E220; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04B40.s") +void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { + f32 cos; + EnBombers2* this = (EnBombers2*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04BA0.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->morphTable, + this->jointTable, OBJECT_CS_LIMB_MAX); + this->actor.targetMode = 6; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if ((gSaveContext.save.weekEventReg[73] & 0x80) || (gSaveContext.save.entranceIndex == 0xD220)) { + this->actor.world.pos.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + cos = Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_2AC = 1; + this->actor.world.pos.z += cos; + } + this->cutscene = this->actor.cutscene; + if (this->cutscene == 0) { + Actor_MarkForDeath(&this->actor); + } + func_80C04B40(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D00.s") +void EnBombers2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C04D8C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C050B8.s") +void EnBombers2_ChangeAnim(EnBombers2* this, s32 animIndex, f32 playSpeed) { + f32 lastFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C0520C.s") + this->animIndex = animIndex; + lastFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); + this->lastAnimFrame = lastFrame; + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], playSpeed, 0.0f, lastFrame, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Update.s") +void func_80C04B40(EnBombers2* this) { + if (this->unk_2AC == 0) { + EnBombers2_ChangeAnim(this, 4, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 0, 1.0f); + } + this->unk_2C0 = 0; + this->actionFunc = func_80C04BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/func_80C056D4.s") +void func_80C04BA0(EnBombers2* this, GlobalContext* globalCtx) { + s32 yawDiffAbs; + s16 yawDiff; + Player* player; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombers2/EnBombers2_Draw.s") + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + yawDiffAbs = ABS_ALT(yawDiff); + player = GET_PLAYER(globalCtx); + + switch (player->transformation) { + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->textIdIndex = 1; + this->unk_2CE = 5; + break; + case PLAYER_FORM_DEKU: + case PLAYER_FORM_HUMAN: + this->textIdIndex = 2; + this->unk_2CE = 5; + break; + } + if (this->unk_2AC != 0) { + this->textIdIndex = 7; + } + this->actor.textId = sTextIds[this->textIdIndex]; + + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->actor.textId = Text_GetFaceReaction(globalCtx, 0x15); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_2B6 = this->actor.world.rot.y; + gSaveContext.save.weekEventReg[86] |= 2; + func_80C04D00(this); + return; + } + if (yawDiffAbs < 0x3BB5) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void func_80C04D00(EnBombers2* this) { + if ((this->textIdIndex == 0) || (this->textIdIndex == 1)) { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } + + this->unk_2A8 = 0; + if (this->unk_2AC != 0) { + EnBombers2_ChangeAnim(this, 6, 1.0f); + } + this->unk_2C0 = 1; + this->actionFunc = func_80C04D8C; +} + +void func_80C04D8C(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp = this->skelAnime.curFrame; + + if ((this->unk_2AC == 0) && (this->lastAnimFrame <= temp)) { + if (!(this->unk_2A8 & 1)) { + EnBombers2_ChangeAnim(this, 1, 1.0f); + } else { + EnBombers2_ChangeAnim(this, 5, 1.0f); + } + this->unk_2A8++; + this->unk_2A8 &= 1; + } + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; + default: + break; + } + if ((this->unk_2CE == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_2CE == 0xF) { + s32 i; + s32 correctDigits; + + for (i = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (!(this->correctDigitSlots[i]) && + (globalCtx->msgCtx.unk12054[i] == gSaveContext.save.bomberCode[i])) { + this->correctDigitSlots[i] = true; + } + } + for (i = 0, correctDigits = 0; i < ARRAY_COUNT(this->correctDigitSlots); i++) { + if (this->correctDigitSlots[i]) { + correctDigits++; + } + } + + if (correctDigits >= 5) { + this->textIdIndex = 6; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); + this->unk_2CE = 5; + return; + } + } + if (Text_GetFaceReaction(globalCtx, 0x15) != 0) { + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + } else { + s32 j; + + switch (this->textIdIndex) { + case 0: + case 1: + case 5: + case 7: + this->unk_28E = 0; + func_801477B4(globalCtx); + func_80C04B40(this); + break; + case 2: + this->textIdIndex = 3; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 0xF; + break; + case 3: + for (j = 0; j < ARRAY_COUNT(this->correctDigitSlots); j++) { + this->correctDigitSlots[j] = false; + } + this->textIdIndex = 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 4: + this->textIdIndex = 5; + this->actor.textId = sTextIds[this->textIdIndex]; + func_80151938(globalCtx, this->actor.textId); + this->unk_2CE = 5; + break; + case 6: + globalCtx->msgCtx.unk11F10 = 0; + func_80C050B8(this, globalCtx); + break; + } + } + } +} + +void func_80C050B8(EnBombers2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 homeYawToPlayer; + + EnBombers2_ChangeAnim(this, 2, 1.0f); + this->unk_2A8 = 0; + homeYawToPlayer = Math_Vec3f_Yaw(&this->actor.home.pos, &player->actor.world.pos); + Math_Vec3f_Copy(&this->unk_29C, &this->actor.world.pos); + if (this->actor.home.rot.y < homeYawToPlayer) { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0xC100) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0xC100) * 50.0f; + } else { + this->unk_29C.x += Math_SinS(this->actor.home.rot.y + 0x3F00) * 50.0f; + this->unk_29C.z += Math_CosS(this->actor.home.rot.y + 0x3F00) * 50.0f; + } + this->unk_2B6 = Math_Vec3f_Yaw(&this->actor.home.pos, &this->unk_29C); + this->unk_2C0 = 2; + this->actionFunc = func_80C0520C; +} + +void func_80C0520C(EnBombers2* this, GlobalContext* globalCtx) { + 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); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + this->unk_2A8 = 1; + } + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2B6, 1, 0xBB8, 0); + 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; + if (fabsf(this->actor.world.rot.y - this->actor.yawTowardsPlayer) < 100.0f) { + func_801477B4(globalCtx); + this->unk_2CE = 5; + this->textIdIndex = 7; + EnBombers2_ChangeAnim(this, 6, 1.0f); + this->unk_2A8 = 0; + this->unk_2C0 = 1; + gSaveContext.save.weekEventReg[73] |= 0x80; + ActorCutscene_Stop(this->cutscene); + this->unk_2AC = 1; + this->actor.textId = sTextIds[this->textIdIndex]; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80C04D8C; + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_29C.x, 0.3f, 1.0f); + Math_ApproachF(&this->actor.world.pos.z, this->unk_29C.z, 0.3f, 1.0f); + } + } +} + +void EnBombers2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnBombers2* this = (EnBombers2*)thisx; + f32 temp_f4; + Vec3f sp34; + s32 yawDiffAbs; + + SkelAnime_Update(&this->skelAnime); + if (this->unk_2B2 != 0) { + this->unk_2B2--; + } + 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); + } + this->actor.shape.rot.y = this->actor.world.rot.y; + if (this->unk_2C0 != 2) { + + yawDiffAbs = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); + this->unk_290 = 0; + if (yawDiffAbs < 0x3A98) { + this->unk_290 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->unk_290 >= 0x2711) { + this->unk_290 = 0x2710; + } else if (this->unk_290 < -0x2710) { + this->unk_290 = -0x2710; + } + } + } + Actor_SetFocus(&this->actor, 20.0f); + Actor_SetScale(&this->actor, 0.008f); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Math_SmoothStepToS(&this->unk_28A, this->unk_290, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->unk_288, this->unk_28E, 1, 0xBB8, 0); + if (this->unk_2BE == 0) { + this->eyeIndex += 1; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + this->unk_2BE = (s16)Rand_ZeroFloat(60.0f) + 0x14; + } + } + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + if (this->unk_2AC == 0) { + this->actor.world.pos.x = (Math_SinS((this->actor.world.rot.y + 0x8000)) * 26.0f) + sp34.x; + temp_f4 = Math_CosS(this->actor.world.rot.y + 0x8000) * 26.0f; + this->actor.world.pos.z = temp_f4 + sp34.z; + this->collider.dim.radius = 0x23; + this->collider.dim.height = 0x1E; + } else { + this->collider.dim.radius = 0xA; + this->collider.dim.height = 0x19; + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->unk_2AC == 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + } + Math_Vec3f_Copy(&this->actor.world.pos, &sp34); +} + +s32 func_80C056D4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnBombers2* this = THIS; + + if (limbIndex == OBJECT_CS_LIMB_08) { + rot->x += this->unk_296; + } + if (limbIndex == OBJECT_CS_LIMB_11) { + rot->x += this->unk_28A; + rot->z += this->unk_288; + } + if ((limbIndex == OBJECT_CS_LIMB_0F) || (limbIndex == OBJECT_CS_LIMB_13) || (limbIndex == OBJECT_CS_LIMB_14)) { + *dList = NULL; + } + return false; +} + +void EnBombers2_Draw(Actor* thisx, GlobalContext* globalCtx) { + + EnBombers2* this = THIS; + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C05920)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(sSetPrimColorDlPtr)); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80C056D4, NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 25c5fd773..ed10a84db 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -3,15 +3,42 @@ #include "global.h" +#include "objects/object_cs/object_cs.h" + struct EnBombers2; typedef void (*EnBombers2ActionFunc)(struct EnBombers2*, GlobalContext*); typedef struct EnBombers2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x140]; + /* 0x014C */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; + /* 0x0206 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; /* 0x0284 */ EnBombers2ActionFunc actionFunc; - /* 0x0288 */ char unk_288[0x94]; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ UNK_TYPE1 pad_28C[2]; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ UNK_TYPE1 pad_292[4]; + /* 0x0296 */ s16 unk_296; + /* 0x0298 */ UNK_TYPE1 pad_298[4]; + /* 0x029C */ Vec3f unk_29C; + /* 0x02A8 */ s32 unk_2A8; + /* 0x02AC */ u8 unk_2AC; + /* 0x02AE */ s16 animIndex; + /* 0x02B0 */ s16 cutscene; + /* 0x02B2 */ s16 unk_2B2; + /* 0x02B4 */ s16 unk_2B4; + /* 0x02B6 */ s16 unk_2B6; + /* 0x02B8 */ f32 lastAnimFrame; + /* 0x02BC */ s16 eyeIndex; + /* 0x02BE */ s16 unk_2BE; + /* 0x02C0 */ s16 unk_2C0; + /* 0x02C2 */ s16 textIdIndex; + /* 0x02C4 */ s16 correctDigitSlots[5]; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ ColliderCylinder collider; } EnBombers2; // size = 0x31C extern const ActorInit En_Bombers2_InitVars; 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 292469236..fef26002b 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -5,8 +5,9 @@ */ #include "z_en_bombf.h" +#include "objects/object_bombf/object_bombf.h" -#define FLAGS 0x00000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) #define THIS ((EnBombf*)thisx) @@ -15,13 +16,13 @@ void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx); void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); +void func_808AEAB8(EnBombf* this, s16 arg1); +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx); void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx); void func_808AEF68(EnBombf* this, GlobalContext* globalCtx); void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx); -void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc); - -#if 0 const ActorInit En_Bombf_InitVars = { ACTOR_EN_BOMBF, ACTORCAT_PROP, @@ -34,53 +35,463 @@ const ActorInit En_Bombf_InitVars = { (ActorFunc)EnBombf_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808AFB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00000000, 0x00, 0x00 }, { 0x00013A28, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x00 }, + { 0x00013A28, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 9, 18, 10, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808AFB4C[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000008, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000008, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 0 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808AFB70 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_808AFB4C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -#endif +void EnBombf_SetupAction(EnBombf* this, EnBombfActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_808AFB20; -extern ColliderJntSphElementInit D_808AFB4C[1]; -extern ColliderJntSphInit D_808AFB70; +void EnBombf_Init(Actor* thisx, GlobalContext* globalCtx2) { + f32 yOffset = 0.0f; + GlobalContext* globalCtx = globalCtx2; + EnBombf* this = THIS; -extern UNK_TYPE D_06000340; + Actor_SetScale(thisx, 0.01f); + this->unk_1F8 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_SetupAction.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, thisx, &sCylinderInit); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, thisx, &sJntSphInit, this->colliderJntSphElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Init.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + yOffset = 1000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Destroy.s") + ActorShape_Init(&thisx->shape, yOffset, ActorShadow_DrawCircle, 12.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAB8.s") + thisx->focus.pos = thisx->world.pos; + thisx->colChkInfo.cylRadius = 10; + thisx->colChkInfo.cylHeight = 10; + thisx->targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEAE0.s") + if (ENBOMBF_GET(thisx) == ENBOMBF_0) { + this->timer = 140; + this->unk_1FE = 15; + thisx->gravity = -1.5f; + func_800BC154(globalCtx, &globalCtx->actorCtx, thisx, 3); + thisx->colChkInfo.mass = 200; + thisx->flags &= ~ACTOR_FLAG_1; + EnBombf_SetupAction(this, func_808AEE3C); + } else { + thisx->colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1FC = 1; + this->unk_204 = 1.0f; + func_808AEAB8(this, ENBOMBF_GET(thisx)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEE3C.s") + thisx->uncullZoneScale += 31000.0f; + thisx->uncullZoneForward += 31000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEF68.s") +void EnBombf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnBombf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AEFD4.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Update.s") +void func_808AEAB8(EnBombf* this, s16 arg1) { + EnBombf_SetupAction(this, func_808AEAE0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/func_808AF86C.s") +void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { + s32 pad; + s32 pad2; + EnBombf* bombf; + Player* player = GET_PLAYER(globalCtx); + s32 pad3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombf/EnBombf_Draw.s") + if (this->unk_204 >= 1.0f) { + if (Actor_HasParent(&this->actor, globalCtx)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + func_800B8C20(&this->actor, &bombf->actor, globalCtx); + this->timer = 180; + this->unk_204 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_PULL_UP_ROCK); + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + } + } 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)))) { + this->colliderCylinder.base.acFlags &= ~AC_HIT; + if (this->colliderCylinder.base.ac->category != ACTORCAT_BOSS) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->unk_1F8 = 1; + bombf->timer = 0; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } + } else { + if (func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + bombf = (EnBombf*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOMBF, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, ENBOMBF_0); + if (bombf != NULL) { + bombf->timer = 100; + this->timer = 180; + this->actor.flags &= ~ACTOR_FLAG_1; + this->unk_204 = 0.0f; + } + } else { + if (!Actor_HasParent(&this->actor, globalCtx)) { + Actor_LiftActor(&this->actor, globalCtx); + return; + } + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } + } else { + if (this->timer == 0) { + this->unk_204 += 0.05f; + if (this->unk_204 >= 1.0f) { + this->actor.flags |= ACTOR_FLAG_1; + } + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + this->actor.parent = NULL; + player->stateFlags1 &= ~0x800; + this->actor.world.pos = this->actor.home.pos; + } + } +} + +void func_808AEE3C(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->unk_204 = 0.0f; + EnBombf_SetupAction(this, func_808AEF68); + this->actor.room = -1; + return; + } + + this->unk_204 = 1.0f; + if (!(this->actor.bgCheckFlags & 1)) { + Math_SmoothStepToF(&this->actor.speedXZ, 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) { + func_800B8EF4(globalCtx, &this->actor); + if (this->actor.velocity.y < -6.0f) { + this->actor.velocity.y *= -0.3f; + this->actor.bgCheckFlags &= ~1; + } + } else if (this->timer >= 4) { + Actor_LiftActor(&this->actor, globalCtx); + } +} + +void func_808AEF68(EnBombf* this, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { + EnBombf_SetupAction(this, func_808AEE3C); + this->actor.bgCheckFlags &= ~1; + func_808AEE3C(this, globalCtx); + } else { + this->actor.velocity.y = 0.0f; + } +} + +void func_808AEFD4(EnBombf* this, GlobalContext* globalCtx) { + if (this->colliderJntSph.elements->dim.modelSphere.radius == 0) { + this->actor.flags |= ACTOR_FLAG_20; + func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); + } + + this->colliderJntSph.elements->dim.modelSphere.radius = 100; + this->colliderJntSph.elements->dim.worldSphere.radius = 100; + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_1) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] != 0) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[0] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[1] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; + } + + if (globalCtx->envCtx.lightSettings.ambientColor[2] != 0) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; + } + + if (this->timer == 0) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 0x800) && (&this->actor == player->heldActor)) { + player->actor.child = NULL; + player->heldActor = NULL; + player->interactRangeActor = NULL; + player->stateFlags1 &= ~0x800; + } + Actor_MarkForDeath(&this->actor); + } +} + +void EnBombf_Update(Actor* thisx, GlobalContext* globalCtx) { + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp80 = { 0.0f, 0.1f, 0.0f }; + Vec3f sp74 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp68; + Vec3f sp5C = { 0.0f, 0.6f, 0.0f }; + Color_RGBA8 sp58 = { 255, 255, 255, 255 }; + EnBombf* this = THIS; + s32 pad; + + if ((this->unk_1F8 != 0) && (this->timer != 0)) { + this->timer--; + } + + if ((this->unk_1FC == 0) && !Actor_HasParent(&this->actor, globalCtx) && + ((this->actor.xzDistToPlayer >= 20.0f) || (fabsf(this->actor.playerHeightRel) >= 80.0f))) { + this->unk_1FC = 1; + } + + this->actionFunc(this, globalCtx); + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actor.gravity != 0.0f) { + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + } + + if (ENBOMBF_GET(&this->actor) == ENBOMBF_0) { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + this->actor.velocity.y = -this->actor.velocity.y; + } + + if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + 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_MoveWithGravity(&this->actor); + DREG(6) = 1; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 5.0f, 10.0f, 0.0f, 0x1F); + DREG(6) = 0; + this->actor.speedXZ *= 0.7f; + this->actor.bgCheckFlags &= ~8; + } + + if ((this->colliderCylinder.base.acFlags & AC_HIT) || + ((this->colliderCylinder.base.ocFlags1 & OC1_HIT) && (this->colliderCylinder.base.oc->category == 5))) { + this->unk_1F8 = 1; + this->timer = 0; + } else if ((this->timer > 100) && func_80123F48(globalCtx, &this->actor.world.pos, 30.0f, 50.0f)) { + this->timer = 100; + } + + if (this->unk_1F8 != 0) { + sp5C.y = 0.2f; + sp68 = this->actor.world.pos; + sp68.y += 25.0f; + + if (this->timer < 127) { + if ((globalCtx->gameplayFrames % 2) == 0) { + EffectSsGSpk_SpawnFuse(globalCtx, &this->actor, &sp68, &sp8C, &sp74); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_IGNIT - SFX_FLAG); + sp68.y += 3.0f; + func_800B0DE0(globalCtx, &sp68, &sp8C, &sp5C, &sp58, &sp58, 0x32, 5); + } + + if ((this->timer == 3) || (this->timer == 30) || (this->timer == 50) || (this->timer == 70)) { + this->unk_1FE = this->unk_1FE >> 1; + } + + if ((this->timer < 100) && (this->timer & (this->unk_1FE + 1))) { + Math_SmoothStepToF(&this->unk_200, 150.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } else { + Math_SmoothStepToF(&this->unk_200, 0.0f, 1.0f, 150.0f / this->unk_1FE, 0.0f); + } + + if (this->timer < 3) { + Actor_SetScale(&this->actor, this->actor.scale.x + 0.002f); + } + + if (this->timer == 0) { + sp68 = this->actor.world.pos; + sp68.y += 10.0f; + + if (Actor_HasParent(&this->actor, globalCtx)) { + sp68.y += 30.0f; + } + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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); + + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 250; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[2] = 250; + + func_800DFD04(&globalCtx->mainCamera, 2, 11, 8); + + this->actor.params = ENBOMBF_1; + this->timer = 10; + this->actor.flags |= ACTOR_FLAG_20; + + EnBombf_SetupAction(this, func_808AEFD4); + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 10.0f; + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + if ((this->unk_204 >= 1.0f) && (this->unk_1FC != 0)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if ((this->actor.scale.x >= 0.01f) && (ENBOMBF_GET(&this->actor) != ENBOMBF_1)) { + if (this->actor.depthInWater >= 20.0f) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); + Actor_MarkForDeath(&this->actor); + } else if (this->actor.bgCheckFlags & 0x40) { + this->actor.bgCheckFlags &= ~0x40; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } +} + +Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { + Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); + Gfx* gfx = head; + + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPEndDisplayList(gfx++); + + return head; +} + +void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnBombf* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) <= ENBOMBF_0) { + func_8012C28C(globalCtx->state.gfxCtx); + + if (ENBOMBF_GET(&this->actor) != ENBOMBF_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000340); + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000530); + + Matrix_InsertTranslation(0.0f, 1000.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->unk_204, this->unk_204, this->unk_204, MTXMODE_APPLY); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 255, 200, 255); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, (s8)this->unk_200, 20, 10, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + { + Gfx* gfx = func_808AF86C(globalCtx->state.gfxCtx, globalCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gfx)); + } + + gSPDisplayList(POLY_OPA_DISP++, object_bombf_DL_000408); + } else { + Collider_UpdateSpheres(0, &this->colliderJntSph); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h index 723d254cb..b72edce8c 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h @@ -7,13 +7,23 @@ struct EnBombf; typedef void (*EnBombfActionFunc)(struct EnBombf*, GlobalContext*); +#define ENBOMBF_GET(thisx) ((thisx)->params) + +#define ENBOMBF_0 0 +#define ENBOMBF_1 1 + typedef struct EnBombf { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xAC]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderJntSph colliderJntSph; + /* 0x01B0 */ ColliderJntSphElement colliderJntSphElements[1]; /* 0x01F0 */ s16 timer; - /* 0x01F2 */ char unk_1F2[0x2]; /* 0x01F4 */ EnBombfActionFunc actionFunc; - /* 0x01F8 */ char unk_1F8[0x10]; + /* 0x01F8 */ s32 unk_1F8; + /* 0x01FC */ u8 unk_1FC; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; } EnBombf; // size = 0x208 extern const ActorInit En_Bombf_InitVars; diff --git a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c index 72a46ecc0..300679a4e 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -8,7 +8,7 @@ #include "z_en_bomjima.h" #include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnBomjima*)thisx) @@ -74,44 +74,36 @@ static ColliderCylinderInit sCylinderInit = { { 10, 30, 0, { 0, 0, 0 } }, }; -static u16 D_80C00A44[] = { - 0x0719, - 0x071A, - 0x071B, - 0x0708, +u16 D_80C00A44[] = { 0x719, 0x71A, 0x71B, 0x708 }; + +u16 D_80C00A4C[] = { 0x739, 0x73A, 0x73B, 0x000 }; + +u16 D_80C00A54[] = { + 0x739, 0x73A, 0x73B, 0x714, 0x709, 0x70A, 0x70B, 0x70C, 0x70D, 0x70E, 0x70F, 0x712, 0x713, }; -static u16 D_80C00A4C[] = { - 0x0739, - 0x073A, - 0x073B, - 0x0000, +u16 D_80C00A70[] = { + 0x739, 0x73A, 0x73B, 0x759, 0x753, 0x754, 0x755, 0x756, 0x70D, 0x757, 0x758, 0x712, 0x713, }; -static u16 D_80C00A54[] = { 0x0739, 0x073A, 0x073B, 0x0714, 0x0709, 0x070A, 0x070B, - 0x070C, 0x070D, 0x070E, 0x070F, 0x0712, 0x0713 }; - -static u16 D_80C00A70[] = { 0x0739, 0x073A, 0x073B, 0x0759, 0x0753, 0x0754, 0x0755, - 0x0756, 0x070D, 0x0757, 0x0758, 0x0712, 0x0713 }; - -static u16 D_80C00A8C[] = { - 0x0736, - 0x0737, - 0x0738, - 0x074E, -}; +u16 D_80C00A8C[] = { 0x736, 0x737, 0x738, 0x74E }; static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, &object_cs_Anim_001708, &object_cs_Anim_005DC4, &object_cs_Anim_0026B0, &object_cs_Anim_0036B0, &object_cs_Anim_0031C4, }; -static u8 D_80C00AE4[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, - 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, +u8 D_80C00AE4[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, +}; + +s16 D_80C00AF8[] = { + 0x4000, 60, 0x4000, 30, 0xC000, 30, 0xC000, 60, }; void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -122,10 +114,10 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - gSaveContext.save.weekEventReg[83] &= (u8)~0x4; + gSaveContext.save.weekEventReg[83] &= (u8)~4; this->actor.targetMode = 0; this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); @@ -268,7 +260,7 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp54))); if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp6C, - &sp50, 1, 0, 0, 1, &sp4C)) { + &sp50, true, false, false, true, &sp4C)) { func_80BFE494(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_2A4, &sp54); this->unk_2BE = Rand_S16Offset(30, 50); @@ -290,8 +282,8 @@ void func_80BFE67C(EnBomjima* this, GlobalContext* globalCtx) { sp60.x += Math_SinS(this->actor.world.rot.y) * 60.0f; sp60.z += Math_CosS(this->actor.world.rot.y) * 60.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, 1, 0, 0, 1, - &sp4C)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp60, &sp6C, &sp50, true, + false, false, true, &sp4C)) { this->unk_2C0 = 0; if (Rand_ZeroOne() < 0.5f) { func_80BFE494(this, 19, 1.0f); @@ -469,8 +461,8 @@ void func_80BFF03C(EnBomjima* this, GlobalContext* globalCtx) { } else { player->stateFlags1 &= ~0x20; gSaveContext.save.weekEventReg[83] &= (u8)~4; - this->actor.world.rot.y = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); - this->unk_2DC = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)); + this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); + this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)); ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); func_80BFF120(this); } @@ -589,7 +581,7 @@ void func_80BFF4F4(EnBomjima* this) { } void func_80BFF52C(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { Player* player = GET_PLAYER(globalCtx); @@ -632,7 +624,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { f32 curFrame = this->skelAnime.curFrame; if (this->unk_2CC <= curFrame) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 1, 1.0f); this->actionFunc = func_80BFF754; @@ -640,21 +632,7 @@ void func_80BFF6CC(EnBomjima* this, GlobalContext* globalCtx) { } } -#ifdef NON_EQUIVALENT -// Data indexing is wrong - -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 unk_02; -} EnBombjimaStruct; - void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { - static EnBombjimaStruct D_80C00AF8[] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, - }; Player* player = GET_PLAYER(globalCtx); Vec3f spA0; EnBombal* temp_s3; @@ -688,13 +666,12 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { temp_s3 = (EnBombal*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, spA0.z, 0, 0, 0, i + 32); if (temp_s3 != NULL) { - s32 idx1 = (i * 2) - 1; - s32 idx2 = i * 2; + s32 index = (i * 2) - 2; Math_Vec3f_Copy(&spA0, &this->actor.world.pos); - spA0.x += Math_SinS(D_80C00AF8[idx1 - 1].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; - spA0.z += Math_CosS(D_80C00AF8[idx2].unk_00 + this->actor.world.rot.y) * D_80C00AF8[idx2].unk_02; + spA0.x += Math_SinS(D_80C00AF8[(i * 2) - 2] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; + spA0.z += Math_CosS(D_80C00AF8[index] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); } @@ -704,15 +681,6 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); this->actionFunc = func_80BFF9B0; } -#else -static s16 D_80C00AF8[][2] = { - { 0x4000, 0x003C }, - { 0x4000, 0x001E }, - { 0xC000, 0x001E }, - { 0xC000, 0x003C }, -}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bomjima/func_80BFF754.s") -#endif void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { if (D_80C009F0 >= 4) { @@ -761,7 +729,7 @@ void func_80BFF9B0(EnBomjima* this, GlobalContext* globalCtx) { } void func_80BFFB40(EnBomjima* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80BFE494(this, 15, 1.0f); D_80C009F0 = 100; @@ -937,15 +905,18 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { this->unk_2BC &= 1; } - if ((player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_ZORA)) { - if (player->transformation == PLAYER_FORM_HUMAN) { - this->unk_28E = -4000; - } - } else { - this->unk_28E = -6000; + switch (player->transformation) { + case PLAYER_FORM_HUMAN: + this->unk_28E = -0xFA0; + break; + + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + this->unk_28E = -0x1770; + break; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->collider.dim.radius = 10; this->collider.dim.height = 30; if ((this->unk_2A0 == 4) || (this->unk_2CA == 1) || ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { 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 1a282645f..c18a94209 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Niw/z_en_niw.h" #include "objects/object_cs/object_cs.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnBomjimb*)thisx) @@ -78,8 +78,8 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -2.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &object_cs_Anim_0064B8, this->jointTable, - this->morphTable, 21); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = 6; Actor_SetScale(&this->actor, 0.01f); @@ -160,7 +160,7 @@ void EnBomjimb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80C0113C(EnBomjimb* this, s32 arg1, f32 arg2) { static AnimationHeader* sAnimations[] = { - &object_cs_Anim_0064B8, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, + &gBomberIdleAnim, &object_cs_Anim_00FAF4, &object_cs_Anim_0057C8, &object_cs_Anim_0053F4, &object_cs_Anim_002044, &object_cs_Anim_01007C, &object_cs_Anim_00349C, &object_cs_Anim_004960, &object_cs_Anim_005128, &object_cs_Anim_004C1C, &object_cs_Anim_002930, &object_cs_Anim_001A1C, &object_cs_Anim_003EE4, &object_cs_Anim_00478C, &object_cs_Anim_00433C, &object_cs_Anim_0060E8, @@ -209,7 +209,7 @@ void func_80C012E0(EnBomjimb* this) { s32 func_80C012FC(EnBomjimb* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (!func_801690CC(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && + if (!Play_InCsMode(globalCtx) && (this->actor.xzDistToPlayer < 40.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 50.0f) && (globalCtx->msgCtx.unk11F10 == 0)) { this->actor.speedXZ = 0.0f; func_80C02740(this, globalCtx); @@ -276,7 +276,7 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { abs = ABS_ALT(BINANG_SUB(this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp48))); if ((abs < 0x4000) && !BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp48, &sp60, - &colPoly, 1, 0, 0, 1, &sp44)) { + &colPoly, true, false, false, true, &sp44)) { func_80C0113C(this, 5, 1.0f); Math_Vec3f_Copy(&this->unk_294, &sp48); this->unk_2B0 = Rand_S16Offset(30, 50); @@ -295,8 +295,8 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp54, &this->actor.world.pos); sp54.x += Math_SinS(this->actor.world.rot.y) * 60.0f; sp54.z += Math_CosS(this->actor.world.rot.y) * 60.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp60, &colPoly, 1, 0, 0, - 1, &sp44)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp54, &sp60, &colPoly, true, + false, false, true, &sp44)) { this->unk_2AE = 0; if (Rand_ZeroOne() < 0.5f) { func_80C0113C(this, 20, 1.0f); @@ -556,7 +556,8 @@ void func_80C0217C(EnBomjimb* this, GlobalContext* globalCtx) { sp74.y += 20.0f; sp74.z += Math_CosS(this->actor.world.rot.y) * 50.0f; - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp74, &sp64, &sp70, 1, 0, 0, 1, &sp60)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp74, &sp64, &sp70, true, false, false, + true, &sp60)) { s16 temp = BINANG_SUB((this->actor.world.rot.y - this->actor.yawTowardsPlayer), 0x8000); this->unk_2D6 = temp; @@ -661,7 +662,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { func_80C0113C(this, 21, 1.0f); if ((player->transformation != PLAYER_FORM_DEKU) && (player->transformation != PLAYER_FORM_HUMAN)) { func_80C0113C(this, 17, 1.0f); - func_801518B0(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -673,7 +674,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[73] & 0x10)) || ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.save.weekEventReg[85] & 2))) { func_80C0113C(this, 17, 1.0f); - func_801518B0(globalCtx, 0x72E, &this->actor); + Message_StartTextbox(globalCtx, 0x72E, &this->actor); player->stateFlags1 |= 0x10000000; player->actor.freezeTimer = 3; func_80C012E0(this); @@ -683,7 +684,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { } idx = gSaveContext.save.bombersCaughtNum; - func_801518B0(globalCtx, D_80C03230[idx], &this->actor); + Message_StartTextbox(globalCtx, D_80C03230[idx], &this->actor); idx = gSaveContext.save.bombersCaughtNum; gSaveContext.save.bombersCaughtOrder[idx] = this->unk_2C8 + 1; gSaveContext.save.bombersCaughtNum++; @@ -721,7 +722,7 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { break; } - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { Player* player = GET_PLAYER(globalCtx); player->stateFlags1 |= 0x10000000; @@ -757,7 +758,7 @@ void func_80C02A14(EnBomjimb* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 3; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if ((this->unk_2CA == 8) && (gSaveContext.save.bombersCaughtNum >= 5)) { func_80C02CA4(this, globalCtx); @@ -776,7 +777,7 @@ void func_80C02BCC(EnBomjimb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 5000, 0); if (this->unk_2C0 == 0) { player->actor.freezeTimer = 3; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_2C0 = 1; player->stateFlags1 &= ~0x10000000; 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 b6115a897..930b1b597 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -6,7 +6,7 @@ #include "z_en_boom.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnBoom*)thisx) diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c index 2e6b31a35..e80004a92 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c @@ -6,7 +6,7 @@ #include "z_en_bsb.h" -#define FLAGS 0x02000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnBsb*)thisx) diff --git a/src/overlays/actors/ovl_En_Bu/z_en_bu.c b/src/overlays/actors/ovl_En_Bu/z_en_bu.c index 6dab7f307..937759ff6 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -6,7 +6,7 @@ #include "z_en_bu.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnBu*)thisx) 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 e6ff6864a..0f54995be 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -6,7 +6,7 @@ #include "z_en_bubble.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnBubble*)thisx) 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 54dd34dbc..ea70a1480 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -5,6 +5,8 @@ */ #include "z_en_butte.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,24 +17,40 @@ void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnButte_Update(Actor* thisx, GlobalContext* globalCtx); void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8091C748(EnButte* this); void func_8091C794(EnButte* this, GlobalContext* globalCtx); +void func_8091CB68(EnButte* this); void func_8091CBB4(EnButte* this, GlobalContext* globalCtx); +void func_8091CF64(EnButte* this); void func_8091CFB4(EnButte* this, GlobalContext* globalCtx); +void func_8091D070(EnButte* this); void func_8091D090(EnButte* this, GlobalContext* globalCtx); -#if 0 -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091D2D0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091D2F4 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091D2D0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; const ActorInit En_Butte_InitVars = { @@ -47,54 +65,389 @@ const ActorInit En_Butte_InitVars = { (ActorFunc)EnButte_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091D3B0[] = { +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 unk_10; +} EnButteStruct; // size = 0x14 + +EnButteStruct D_8091D324[] = { + { 5, 35, 0.0f, 0.1f, 0.5f, 0 }, + { 10, 45, 1.1f, 0.1f, 0.25f, 1000 }, + { 10, 40, 1.5f, 0.1f, 0.3f, 2000 }, +}; + +EnButteStruct D_8091D360[] = { + { 3, 3, 0.8f, 0.1f, 0.2f, 0 }, + { 10, 20, 2.0f, 0.3f, 1.0f, 0 }, + { 10, 20, 2.4f, 0.3f, 1.0f, 0 }, +}; + +f32 D_8091D39C = 0.0f; + +s16 D_8091D3A0 = 0; + +Vec3f D_8091D3A4 = { 0.0f, 0.0f, -3.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 60, ICHAIN_STOP), }; -#endif +f32 D_8091D3C0[] = { 50.0f, 80.0f, 100.0f }; -extern ColliderJntSphElementInit D_8091D2D0[1]; -extern ColliderJntSphInit D_8091D2F4; -extern InitChainEntry D_8091D3B0[]; +f32 D_8091D3CC[] = { 30.0f, 40.0f, 50.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C0A0.s") +f32 D_8091D3D8[] = { 15.0f, 20.0f, 25.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C124.s") +f32 D_8091D3E4[] = { 7.5f, 10.0f, 12.5f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C140.s") +s32 D_8091D3F0 = 1500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C178.s") +void func_8091C0A0(EnButte* this, EnButteStruct* arg1) { + if (this->unk_24E == 0) { + if (Rand_ZeroOne() < 0.6f) { + this->unk_24E = 1; + } else { + this->unk_24E = 2; + } + } else { + this->unk_24E = 0; + } + this->unk_24C = Rand_S16Offset(arg1->unk_00, arg1->unk_02); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Init.s") +void func_8091C124(void) { + D_8091D39C = 0.0f; + D_8091D3A0 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Destroy.s") +void func_8091C140(void) { + D_8091D39C += 0.003f; + D_8091D3A0 += 0xFA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C524.s") +void func_8091C178(EnButte* this, GlobalContext* globalCtx) { + Vec3f sp4C; + s32 sp48; + Vec3s sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C5EC.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C6B4.s") + func_8012C240(globalCtx->state.gfxCtx); + sp48 = Math_SinS(D_8091D3A0) * 250.0f; + sp48 = CLAMP(sp48, 0, 255); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C748.s") + func_800DFC90(&sp40, GET_ACTIVE_CAM(globalCtx)); + Matrix_RotateY(sp40.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(sp40.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp40.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_8091D3A4, &sp4C); + Matrix_SetStateRotationAndTranslation(this->actor.focus.pos.x + sp4C.x, this->actor.focus.pos.y + sp4C.y, + this->actor.focus.pos.z + sp4C.z, &sp40); + Matrix_Scale(D_8091D39C, D_8091D39C, D_8091D39C, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091C794.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 180, sp48); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 210, 255); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CB68.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CBB4.s") +void EnButte_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnButte* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CF64.s") + if (ENBUTTE_GET(&this->actor) == ENBUTTE_MINUS1) { + this->actor.params = ENBUTTE_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091CFB4.s") + this->actor.world.rot.y = Rand_Next(); + this->actor.home.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.y = this->actor.world.rot.y; + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091D070.s") + if ((ENBUTTE_GET_1(&this->actor) & 0xFF) == ENBUTTE_1) { + this->actor.uncullZoneScale = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/func_8091D090.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_field_keep_Skel_002FA0, &gameplay_field_keep_Anim_001D20, + this->jointTable, this->morphTable, 8); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colldierElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Update.s") + this->collider.elements[0].dim.worldSphere.radius = + this->collider.elements[0].dim.scale * this->collider.elements[0].dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Butte/EnButte_Draw.s") + this->actor.colChkInfo.mass = 0; + this->unk_254 = Rand_ZeroOne() * 0xFFFF; + this->unk_256 = Rand_ZeroOne() * 0xFFFF; + this->unk_258 = Rand_ZeroOne() * 0xFFFF; + + Animation_Change(&this->skelAnime, &gameplay_field_keep_Anim_001D20, 1.0f, 0.0f, 0.0f, 1, 0.0f); + func_8091C748(this); + this->actor.shape.rot.x -= 0x2320; + this->unk_250 = 1; +} + +void EnButte_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_8091C524(EnButte* this) { + this->actor.shape.yOffset += + (Math_SinS(this->unk_254) * D_8091D3C0[this->unk_24E]) + (Math_SinS(this->unk_256) * D_8091D3CC[this->unk_24E]); + this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -2000.0f, 2000.0f); +} + +void func_8091C5EC(EnButte* this) { + this->actor.shape.yOffset += + (Math_SinS(this->unk_254) * D_8091D3D8[this->unk_24E]) + (Math_SinS(this->unk_256) * D_8091D3E4[this->unk_24E]); + this->actor.shape.yOffset = CLAMP(this->actor.shape.yOffset, -500.0f, 500.0f); +} + +void func_8091C6B4(EnButte* this) { + s16 temp_a1 = BINANG_ROT180(this->actor.world.rot.y); + s16 temp_v0 = temp_a1 - this->actor.shape.rot.y; + + Math_ScaledStepToS(&this->actor.shape.rot.y, temp_a1, ABS_ALT(temp_v0) >> 3); + this->actor.shape.rot.x = (s16)(Math_SinS(this->unk_258) * 600.0f) - 0x2320; +} + +void func_8091C748(EnButte* this) { + func_8091C0A0(this, &D_8091D324[this->unk_24E]); + this->actionFunc = func_8091C794; +} + +void func_8091C794(EnButte* this, GlobalContext* globalCtx) { + EnButteStruct* sp4C = &D_8091D324[this->unk_24E]; + f32 distSq; + Player* player = GET_PLAYER(globalCtx); + f32 distFromHomeSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z); + f32 playSpeed; + f32 sp38; + s32 pad; + s16 sp32; + s16 yaw; + + func_8091C524(this); + Math_SmoothStepToF(&this->actor.speedXZ, sp4C->unk_04, sp4C->unk_08, sp4C->unk_0C, 0.0f); + + if (this->unk_24F == 1) { + distSq = SQ(100.0f); + sp32 = 0x3E8; + } else { + distSq = SQ(35.0f); + sp32 = 0x258; + } + + sp38 = 0.0f; + this->unk_25C = this->actor.home.pos.y; + + if ((this->unk_24E != 0) && ((distSq < distFromHomeSq) || (this->unk_24C < 4))) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + if (!Math_ScaledStepToS(&this->actor.world.rot.y, yaw, sp4C->unk_10)) { + sp38 = 0.5f; + } + } else if ((this->unk_24F == 0) && (this->actor.child != NULL) && (&this->actor != this->actor.child)) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos); + if (!Math_ScaledStepToS(&this->actor.world.rot.y, yaw, sp32)) { + sp38 = 0.3f; + } + } else if (this->unk_24F == 1) { + if (!Math_ScaledStepToS(&this->actor.world.rot.y, + (s32)((Rand_ZeroOne() - 0.5f) * 0x6000) + this->actor.yawTowardsPlayer + 0x8000, + sp32)) { + sp38 = 0.4f; + } + } else { + this->actor.world.rot.y += (s16)(Math_SinS(this->unk_254) * 100.0f); + } + + 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; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_24C <= 0) { + func_8091C0A0(this, &D_8091D324[this->unk_24E]); + } + + if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (player->itemActionParam == 7) && (this->unk_252 <= 0) && + ((Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, this->actor.home.pos.x, + this->actor.home.pos.z) < SQ(120.0f)) || + (this->actor.xzDistToPlayer < 60.0f))) { + func_8091CB68(this); + this->unk_24F = 2; + } else if (this->actor.xzDistToPlayer < 120.0f) { + this->unk_24F = 1; + } else { + this->unk_24F = 0; + } +} + +void func_8091CB68(EnButte* this) { + func_8091C0A0(this, &D_8091D360[this->unk_24E]); + this->actionFunc = func_8091CBB4; +} + +void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { + EnButteStruct* sp5C = &D_8091D360[this->unk_24E]; + Player* player = GET_PLAYER(globalCtx); + f32 playSpeed; + Vec3f sp48; + f32 distSq; + f32 sp40; + s32 pad; + s16 pad2; + s16 yaw; + + func_8091C5EC(this); + Math_SmoothStepToF(&this->actor.speedXZ, sp5C->unk_04, sp5C->unk_08, sp5C->unk_0C, 0.0f); + sp40 = 0.0f; + + if ((this->unk_24E != 0) && (this->unk_24C < 12)) { + sp48.x = player->swordInfo[0].tip.x + (Math_SinS(player->actor.shape.rot.y) * 10.0f); + sp48.y = player->swordInfo[0].tip.y; + sp48.z = player->swordInfo[0].tip.z + (Math_CosS(player->actor.shape.rot.y) * 10.0f); + + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &sp48); + if (Math_ScaledStepToS(&this->actor.world.rot.y, yaw + (s32)(Rand_ZeroOne() * D_8091D3F0), 0x7D0)) { + if ((globalCtx->gameplayFrames & 0x30) == 0x30) { + this->actor.world.rot.y += (s16)(Math_SinS(this->unk_254) * 60.0f); + } + } else { + sp40 = 0.3f; + } + } + + if (player->swordInfo[0].tip.y < player->actor.world.pos.y + 30.0f) { + this->unk_25C = player->actor.world.pos.y + 30.0f; + } else { + this->unk_25C = player->swordInfo[0].tip.y; + } + + 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) + sp40; + this->skelAnime.playSpeed = CLAMP(playSpeed, 0.2f, 1.5f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_24C <= 0) { + func_8091C0A0(this, &D_8091D360[this->unk_24E]); + D_8091D3F0 = -D_8091D3F0; + } + + 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->itemActionParam != 7) || !(fabsf(player->actor.speedXZ) < 1.8f) || (this->unk_252 > 0) || + !(distSq < SQ(320.0f))) { + func_8091C748(this); + } else if ((distSq > SQ(240.0f)) && + (Math3D_XZDistanceSquared(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, + this->actor.world.pos.x, this->actor.world.pos.z) < SQ(60.0f))) { + func_8091CF64(this); + } +} + +void func_8091CF64(EnButte* this) { + this->unk_24C = 9; + this->actor.flags |= ACTOR_FLAG_10; + this->skelAnime.playSpeed = 1.0f; + func_8091C124(); + this->actionFunc = func_8091CFB4; +} + +void func_8091CFB4(EnButte* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + func_8091C140(); + + if (this->unk_24C == 5) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 60, NA_SE_EV_BUTTERFRY_TO_FAIRY); + } else if (this->unk_24C == 4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, this->actor.focus.pos.x, this->actor.focus.pos.y, + this->actor.focus.pos.z, 0, this->actor.shape.rot.y, 0, 2); + this->unk_250 = 0; + } else if (this->unk_24C <= 0) { + func_8091D070(this); + } +} + +void func_8091D070(EnButte* this) { + this->unk_24C = 64; + this->actionFunc = func_8091D090; + this->actor.draw = NULL; +} + +void func_8091D090(EnButte* this, GlobalContext* globalCtx) { + if (this->unk_24C <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnButte_Update(Actor* thisx, GlobalContext* globalCtx) { + EnButte* this = THIS; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { + this->actor.child = NULL; + } + + if (this->unk_24C > 0) { + this->unk_24C--; + } + + this->unk_254 += 0x222; + this->unk_256 += 0x1000; + this->unk_258 += 0x600; + + if (ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) { + if (GET_PLAYER(globalCtx)->swordState == 0) { + if (this->unk_252 > 0) { + this->unk_252--; + } + } else { + this->unk_252 = 80; + } + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + Actor_MoveWithGravity(&this->actor); + Math_StepToF(&this->actor.world.pos.y, this->unk_25C, 0.6f); + if (this->actor.xyzDistToPlayerSq < 5000.0f) { + ColliderJntSphElement* element = &this->collider.elements[0]; + + element->dim.worldSphere.center.x = this->actor.world.pos.x; + element->dim.worldSphere.center.y = this->actor.world.pos.y; + element->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + Actor_SetFocus(&this->actor, this->actor.shape.yOffset * this->actor.scale.y); + } +} + +void EnButte_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnButte* this = THIS; + + if (this->unk_250 != 0) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + } + + if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (this->actionFunc == func_8091CFB4)) { + func_8091C178(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.h b/src/overlays/actors/ovl_En_Butte/z_en_butte.h index 1de720b8d..361096961 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.h +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.h @@ -7,11 +7,30 @@ struct EnButte; typedef void (*EnButteActionFunc)(struct EnButte*, GlobalContext*); +#define ENBUTTE_GET(thisx) ((thisx)->params) +#define ENBUTTE_GET_1(thisx) ((thisx)->params & 1) + +#define ENBUTTE_MINUS1 -1 +#define ENBUTTE_0 0 +#define ENBUTTE_1 1 + typedef struct EnButte { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colldierElements[1]; + /* 0x01A4 */ SkelAnime skelAnime; + /* 0x01E8 */ Vec3s jointTable[8]; + /* 0x0218 */ Vec3s morphTable[8]; /* 0x0248 */ EnButteActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x14]; + /* 0x024C */ s16 unk_24C; + /* 0x024E */ u8 unk_24E; + /* 0x024F */ u8 unk_24F; + /* 0x0250 */ u8 unk_250; + /* 0x0252 */ s16 unk_252; + /* 0x0254 */ s16 unk_254; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ s16 unk_258; + /* 0x025C */ f32 unk_25C; } EnButte; // size = 0x260 extern const ActorInit En_Butte_InitVars; 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 de8c54040..0f340da3a 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -55,13 +55,13 @@ void EnCha_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_UpdateCylinder(&this->actor, &this->collider); Actor_SetScale(&this->actor, 0.01f); this->actor.home.rot.z = 0; this->actionFunc = EnCha_Idle; this->actor.home.rot.x = this->actor.home.rot.z; - gSaveContext.save.weekEventReg[60] &= 0xFB; + gSaveContext.save.weekEventReg[60] &= (u8)~4; } void EnCha_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -85,7 +85,7 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[60] & 4) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); - gSaveContext.save.weekEventReg[60] &= 0xFB; + gSaveContext.save.weekEventReg[60] &= (u8)~4; this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { 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 4b7156ad4..cddff71cc 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 @@ -7,7 +7,7 @@ #include "z_en_clear_tag.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnClearTag*)thisx) @@ -410,7 +410,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { Vec3f vel; Vec3f accel; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (thisx->params >= 0) { this->activeTimer = 70; Math_Vec3f_Copy(&pos, &this->actor.world.pos); @@ -521,7 +521,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Camera* camera; + Camera* mainCam; s32 pad; switch (this->cameraState) { @@ -544,19 +544,19 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { } break; case 1: - func_800EA0D4(globalCtx, &globalCtx->csCtx); - this->camId = func_801694DC(globalCtx); - func_80169590(globalCtx, 0, 1); - func_80169590(globalCtx, this->camId, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + this->subCamId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, this->subCamId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); - this->eye.x = camera->eye.x; - this->eye.y = camera->eye.y; - this->eye.z = camera->eye.z; - this->at.x = camera->at.x; - this->at.y = camera->at.y; - this->at.z = camera->at.z; - func_801518B0(globalCtx, 0xF, NULL); + mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + this->subCamEye.x = mainCam->eye.x; + this->subCamEye.y = mainCam->eye.y; + this->subCamEye.z = mainCam->eye.z; + this->subCamAt.x = mainCam->at.x; + this->subCamAt.y = mainCam->at.y; + this->subCamAt.z = mainCam->at.z; + Message_StartTextbox(globalCtx, 0xF, NULL); this->cameraState = 2; func_8019FDC8(&D_801DB4A4, NA_SE_VO_NA_LISTEN, 0x20); case 2: @@ -568,22 +568,22 @@ void EnClearTag_UpdateCamera(EnClearTag* this, GlobalContext* globalCtx) { player->actor.speedXZ = 0.0f; if (Message_GetState(&globalCtx->msgCtx) == 0) { - camera = Play_GetCamera(globalCtx, MAIN_CAM); - camera->eye = this->eye; - camera->eyeNext = this->eye; - camera->at = this->at; - func_80169AFC(globalCtx, this->camId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + mainCam = Play_GetCamera(globalCtx, CAM_ID_MAIN); + mainCam->eye = this->subCamEye; + mainCam->eyeNext = this->subCamEye; + mainCam->at = this->subCamAt; + func_80169AFC(globalCtx, this->subCamId, 0); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); this->cameraState = 0; - this->camId = 0; + this->subCamId = CAM_ID_MAIN; this->activeTimer = 20; } break; } - if (this->camId != 0) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->at, &this->eye); + if (this->subCamId != CAM_ID_MAIN) { + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->subCamAt, &this->subCamEye); } } diff --git a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 453e6c0ac..61c4a638b 100644 --- a/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -45,10 +45,10 @@ typedef struct EnClearTag { /* 0x2E54 */ u8 cameraState; /* 0x2E56 */ s16 activeTimer; // Actor Marked for Death when timer runs out /* 0x2E58 */ UNK_TYPE1 unk2E58[0xC]; - /* 0x2E64 */ s16 camId; + /* 0x2E64 */ s16 subCamId; /* 0x2E66 */ Color_RGBA8 flashEnvColor; - /* 0x2E6C */ Vec3f eye; // Camera eye - /* 0x2E78 */ Vec3f at; // Camera lookAt + /* 0x2E6C */ Vec3f subCamEye; + /* 0x2E78 */ Vec3f subCamAt; } EnClearTag; // size = 0x2E84 extern const ActorInit En_Clear_Tag_InitVars; 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 698878d71..e7c6ebc6e 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 @@ -5,8 +5,9 @@ */ #include "z_en_cne_01.h" +#include "objects/object_cne/object_cne.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnCne01*)thisx) @@ -15,12 +16,10 @@ void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx); void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809CB520(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5A0(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5D8(EnCne01* this, GlobalContext* globalCtx); -void func_809CB5FC(EnCne01* this, GlobalContext* globalCtx); +void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx); +void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx); +void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Cne_01_InitVars = { ACTOR_EN_CNE_01, ACTORCAT_NPC, @@ -33,85 +32,296 @@ const ActorInit En_Cne_01_InitVars = { (ActorFunc)EnCne01_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809CBF00 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_809CBF2C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809CBF38 = { - /* 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(0, 0x0), - /* 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(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* 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), +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -#endif +u16 D_809CBF58[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6 }; -extern ColliderCylinderInit D_809CBF00; -extern CollisionCheckInfoInit2 D_809CBF2C; -extern DamageTable D_809CBF38; +void EnCne01_UpdateModel(EnCne01* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f focus; -extern UNK_TYPE D_060000F0; -extern UNK_TYPE D_06001300; + EnHy_UpdateSkelAnime(&this->enHy, globalCtx); + if (SubS_AngleDiffLessEqual(this->enHy.actor.shape.rot.y, 0x36B0, this->enHy.actor.yawTowardsPlayer)) { + focus.x = player->actor.world.pos.x; + focus.y = player->bodyPartsPos[7].y + 3.0f; + focus.z = player->actor.world.pos.z; + func_8013D2E0(&focus, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.focusTarget, + &this->enHy.headRot, &this->enHy.torsoRot, D_809CBF58); + } else { + Math_SmoothStepToS(&this->enHy.focusTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.focusTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.headRot.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->enHy.torsoRot.y, 0, 4, 0x3E8, 1); + } + SubS_FillLimbRotTables(globalCtx, this->enHy.limbRotTableY, this->enHy.limbRotTableZ, + ARRAY_COUNT(this->enHy.limbRotTableY)); + EnHy_UpdateCollider(&this->enHy, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB290.s") +s32 EnCne01_TestIsTalking(EnCne01* this, GlobalContext* globalCtx) { + s32 isTalking = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB404.s") + if (Actor_ProcessTalkRequest(&this->enHy.actor, &globalCtx->state)) { + isTalking = true; + this->enHy.textId = 0x10B9; // Invalid textId, produces empty textbox + this->enHy.tmpFocusTarget = this->enHy.focusTarget; + this->enHy.tmpHeadRot = this->enHy.headRot; + this->enHy.tmpTorsoRot = this->enHy.torsoRot; + this->enHy.tmpActionFunc = this->enHy.actionFunc; + this->enHy.actionFunc = EnCne01_Talk; + } + return isTalking; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB4A0.s") +s32 func_809CB4A0(EnCne01* this, GlobalContext* globalCtx) { + s16 x; + s16 y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB520.s") + Actor_GetScreenPos(globalCtx, &this->enHy.actor, &x, &y); + //! @bug: Both x and y conditionals are always true, || should be an && + if (!this->enHy.waitingOnInit && ((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { + func_800B85E0(&this->enHy.actor, globalCtx, 30.0f, EXCH_ITEM_2E); + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5A0.s") +void EnCne01_FinishInit(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_Init(this, globalCtx, &gCneSkel, ENHY_ANIMATION_OS_ANIME_11)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.draw = EnCne01_Draw; + this->waitingOnInit = false; + if (ENCNE01_GET_PATH(&this->actor) == ENCNE01_NO_PATH) { + this->actionFunc = EnCne01_FaceForward; + } else { + this->actionFunc = EnCne01_Walk; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5D8.s") +void EnCne01_Walk(EnHy* this, GlobalContext* globalCtx) { + if (EnHy_MoveForwards(this, 1.0f)) { + this->curPoint = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB5FC.s") +void EnCne01_FaceForward(EnHy* this, GlobalContext* globalCtx) { + this->actor.shape.rot = this->actor.world.rot; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Init.s") +void EnCne01_Talk(EnHy* this, GlobalContext* globalCtx) { + s16 yaw; + u8 talkState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Destroy.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xFA0, 1); + talkState = Message_GetState(&globalCtx->msgCtx); + this->inMsgState3 = (talkState == 3) ? true : false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Update.s") + switch (talkState) { + case 0: + yaw = ABS_ALT(this->actor.shape.rot.y - this->actor.yawTowardsPlayer); + if (yaw < 0x64) { + Message_StartTextbox(globalCtx, this->textId, NULL); + } + break; + case 2: + this->actor.textId = 0; + this->focusTarget = this->tmpFocusTarget; + this->headRot = this->tmpHeadRot; + this->torsoRot = this->tmpTorsoRot; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = this->tmpActionFunc; + this->tmpActionFunc = NULL; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CB920.s") +void EnCne01_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnCne01* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CBBC8.s") + this->enHy.animObjIndex = SubS_GetObjectIndex(OBJECT_OS_ANIME, globalCtx); + this->enHy.headObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); + this->enHy.skelUpperObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); + this->enHy.skelLowerObjIndex = SubS_GetObjectIndex(OBJECT_CNE, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/func_809CBCA0.s") + if ((this->enHy.animObjIndex < 0) || (this->enHy.headObjIndex < 0) || (this->enHy.skelUpperObjIndex < 0) || + (this->enHy.skelLowerObjIndex < 0)) { + Actor_MarkForDeath(&this->enHy.actor); + } + this->enHy.actor.draw = NULL; + Collider_InitCylinder(globalCtx, &this->enHy.collider); + Collider_SetCylinder(globalCtx, &this->enHy.collider, &this->enHy.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->enHy.actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->enHy.actor.flags &= ~ACTOR_FLAG_1; + this->enHy.path = SubS_GetPathByIndex(globalCtx, ENCNE01_GET_PATH(&this->enHy.actor), ENCNE01_NO_PATH); + this->enHy.waitingOnInit = true; + Actor_SetScale(&this->enHy.actor, 0.01f); + this->enHy.actionFunc = EnCne01_FinishInit; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Cne_01/EnCne01_Draw.s") +void EnCne01_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->enHy.collider); +} + +void EnCne01_Update(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + + EnCne01_TestIsTalking(this, globalCtx); + this->enHy.actionFunc(&this->enHy, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->enHy.actor, 0.0f, 0.0f, 0.0f, 4); + EnCne01_UpdateModel(this, globalCtx); + func_809CB4A0(this, globalCtx); +} + +s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnCne01* this = THIS; + s8 bodyPart; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + bodyPart = gEnHyBodyParts[limbIndex]; + if (bodyPart >= 0) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.bodyPartsPos[bodyPart]); + } + + if (limbIndex == CNE_LIMB_HEAD) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.headObjIndex].segment); + *dList = gCneHeadBrownHairDL; + gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + if (limbIndex == CNE_LIMB_HEAD) { + Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->enHy.headRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.headRot.x, MTXMODE_APPLY); + Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if (limbIndex == CNE_LIMB_TORSO) { + Matrix_InsertXRotation_s(-this->enHy.torsoRot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->enHy.torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + + if ((limbIndex == CNE_LIMB_TORSO) || (limbIndex == CNE_LIMB_LEFT_UPPER_ARM) || + (limbIndex == CNE_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->enHy.limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->enHy.limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnCne01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCne01* this = THIS; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == CNE_LIMB_RIGHT_FOOT) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (limbIndex == CNE_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&zeroVec, &this->enHy.actor.focus.pos); + } +} + +void EnCne01_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +} + +void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCne01* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(u8[64][64])); + u8* shadowTexIter; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Gfx_EnvColor(globalCtx->state.gfxCtx, 160, 180, 255, 0)); + gDPPipeSync(POLY_OPA_DISP++); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->enHy.skelAnime.skeleton, this->enHy.skelAnime.jointTable, + this->enHy.skelAnime.dListCount, EnCne01_OverrideLimbDraw, EnCne01_PostLimbDraw, + EnCne01_TransformLimbDraw, &this->enHy.actor); + Matrix_InsertXRotation_s(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < (s32)sizeof(u8[64][64]); i++) { + *shadowTexIter++ = 0; + } + for (i = 0; i < 5; i++) { + func_8013CD64(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, + ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSize, gEnHyBodyPartsIndex); + } + func_8013CF04(&this->enHy.actor, &globalCtx->state.gfxCtx, shadowTex); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h index db0e797e9..840d1cf60 100644 --- a/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h +++ b/src/overlays/actors/ovl_En_Cne_01/z_en_cne_01.h @@ -1,16 +1,18 @@ #ifndef Z_EN_CNE_01_H #define Z_EN_CNE_01_H -#include "global.h" +#include "z_en_hy_code.h" struct EnCne01; typedef void (*EnCne01ActionFunc)(struct EnCne01*, GlobalContext*); +#define ENCNE01_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) +#define ENCNE01_NO_PATH 0x3F + typedef struct EnCne01 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnCne01ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4D4]; + /* 0x000 */ EnHy enHy; + /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnCne01; // size = 0x61C extern const ActorInit En_Cne_01_InitVars; 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 2b95d0706..6817c1830 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 @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00100000 +#define FLAGS (ACTOR_FLAG_100000) #define THIS ((EnColMan*)thisx) @@ -138,7 +138,7 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { } void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { gSaveContext.save.weekEventReg[56] |= 2; Actor_MarkForDeath(&this->actor); } @@ -146,8 +146,8 @@ void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, GlobalContext* globa void func_80AFDF60(EnColMan* this) { this->actor.draw = func_80AFE584; - this->actor.flags |= 0x10; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_20; this->type = EN_COL_MAN_FALLING_ROCK; this->actionFunc = func_80AFDFB4; this->actor.shape.shadowScale = 5.0f; 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 5175f709e..84aae79a7 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -5,9 +5,8 @@ */ #include "z_en_cow.h" -#include "objects/object_cow/object_cow.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnCow*)thisx) @@ -107,9 +106,9 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { switch (EN_COW_TYPE(thisx)) { case EN_COW_TYPE_DEFAULT: case EN_COW_TYPE_ABDUCTED: - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, COW_LIMB_MAX); - Animation_PlayLoop(&this->skelAnime, &gCowBodyChewAnim); + Animation_PlayLoop(&this->skelAnime, &gCowChewAnim); Collider_InitAndSetCylinder(globalCtx, &this->colliders[0], &this->actor, &sCylinderInit); Collider_InitAndSetCylinder(globalCtx, &this->colliders[1], &this->actor, &sCylinderInit); @@ -136,7 +135,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { break; case EN_COW_TYPE_TAIL: SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, - COW_LIMB_MAX); + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailIdleAnim); this->actor.update = EnCow_UpdateTail; @@ -145,7 +144,7 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { EnCow_SetTailPos(this); - this->actor.flags &= ~EN_COW_FLAG_IS_TAIL; + this->actor.flags &= ~ACTOR_FLAG_1; this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; break; } @@ -171,13 +170,13 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { this->animationTimer--; } else { this->animationTimer = Rand_ZeroFloat(500.0f) + 40.0f; - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, this->skelAnime.curFrame, - Animation_GetLastFrame(&gCowBodyChewAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, this->skelAnime.curFrame, + Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_ONCE, 1.0f); } if (this->actor.xzDistToPlayer < 150.0f) { if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { this->animationTimer = 0; } } @@ -201,8 +200,8 @@ void EnCow_UpdateAnimation(EnCow* this, GlobalContext* globalCtx) { } void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_Idle; } @@ -210,7 +209,7 @@ void EnCow_TalkEnd(EnCow* this, GlobalContext* globalCtx) { void EnCow_GiveMilkEnd(EnCow* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnCow_Idle; } } @@ -225,8 +224,8 @@ void EnCow_GiveMilkWait(EnCow* this, GlobalContext* globalCtx) { } void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - this->actor.flags &= ~0x10000; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actor.flags &= ~ACTOR_FLAG_10000; func_801477B4(globalCtx); this->actionFunc = EnCow_GiveMilkWait; Actor_PickUp(&this->actor, globalCtx, GI_MILK, 10000.0f, 100.0f); @@ -234,7 +233,7 @@ void EnCow_GiveMilk(EnCow* this, GlobalContext* globalCtx) { } void EnCow_CheckForEmptyBottle(EnCow* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Inventory_HasEmptyBottle()) { func_80151938(globalCtx, 0x32C9); // Text to give milk. this->actionFunc = EnCow_GiveMilk; @@ -255,7 +254,7 @@ void EnCow_Talk(EnCow* this, GlobalContext* globalCtx) { this->actionFunc = EnCow_TalkEnd; } } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; //! @bug textId is reset to this no matter the intial value } @@ -270,10 +269,10 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { this->flags &= ~EN_COW_FLAG_WONT_GIVE_MILK; D_801BDAA4 = 0; } else if ((this->actor.xzDistToPlayer < 150.0f) && - ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { + ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 25000) { D_801BDAA4 = 0; this->actionFunc = EnCow_Talk; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actor.textId = 0x32C8; // Text to give milk after playing Epona's Song. @@ -297,7 +296,7 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x32CA; // Text if you don't have an empty bottle. } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 170.0f); this->actionFunc = EnCow_Talk; } @@ -344,12 +343,12 @@ void EnCow_Update(Actor* thisx, GlobalContext* globalCtx2) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); if (SkelAnime_Update(&this->skelAnime)) { - if (this->skelAnime.animation == &gCowBodyChewAnim) { + if (this->skelAnime.animation == &gCowChewAnim) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_COW_CRY); - Animation_Change(&this->skelAnime, &gCowBodyMoveHeadAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gCowBodyMoveHeadAnim), ANIMMODE_ONCE, 1.0f); + Animation_Change(&this->skelAnime, &gCowMooAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowMooAnim), + ANIMMODE_ONCE, 1.0f); } else { - Animation_Change(&this->skelAnime, &gCowBodyChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowBodyChewAnim), + Animation_Change(&this->skelAnime, &gCowChewAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gCowChewAnim), ANIMMODE_LOOP, 1.0f); } } diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.h b/src/overlays/actors/ovl_En_Cow/z_en_cow.h index fd865cecb..bb9319ad9 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.h +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.h @@ -2,10 +2,10 @@ #define Z_EN_COW_H #include "global.h" +#include "objects/object_cow/object_cow.h" #define EN_COW_TYPE(thisx) ((thisx)->params & 0xF) -#define EN_COW_FLAG_IS_TAIL (1 << 0) // This is never set but it is cleared for tail types #define EN_COW_FLAG_PLAYER_HAS_APPROACHED (1 << 1) #define EN_COW_FLAG_WONT_GIVE_MILK (1 << 2) @@ -19,16 +19,6 @@ struct EnCow; typedef void (*EnCowActionFunc)(struct EnCow*, GlobalContext*); -typedef enum { - /* 0 */ COW_LIMB_NONE, - /* 1 */ COW_LIMB_ROOT, - /* 2 */ COW_LIMB_HEAD, - /* 3 */ COW_LIMB_JAW, - /* 4 */ COW_LIMB_NOSE, - /* 5 */ COW_LIMB_NOSE_RING, - /* 6 */ COW_LIMB_MAX, -} ObjectCowLimbs; - typedef struct EnCow { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderCylinder colliders[2]; 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 be24037bf..bf77b1897 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 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnCrow*)thisx) @@ -15,14 +15,18 @@ void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8099AC8C(EnCrow* this, GlobalContext* globalCtx); -void func_8099B0CC(EnCrow* this, GlobalContext* globalCtx); -void func_8099B584(EnCrow* this, GlobalContext* globalCtx); -void func_8099B6C4(EnCrow* this, GlobalContext* globalCtx); -void func_8099B838(EnCrow* this, GlobalContext* globalCtx); -void func_8099B9E8(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupFlyIdle(EnCrow* this); +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDiveAttack(EnCrow* this); +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupDie(EnCrow* this); +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_SetupRespawn(EnCrow* this); +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx); +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Crow_InitVars = { ACTOR_EN_CROW, ACTORCAT_ENEMY, @@ -35,25 +39,36 @@ const ActorInit En_Crow_InitVars = { (ActorFunc)EnCrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8099C070[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_HARD, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_HARD, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8099C094 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8099C070, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8099C0A4 = { 1, 15, 30, 30 }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 30, 30 }; -// static DamageTable sDamageTable = { -static DamageTable D_8099C0AC = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -88,60 +103,470 @@ static DamageTable D_8099C0AC = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8099C0D0[] = { +static s32 D_8099C0CC = 0; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +void EnCrow_Init(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -extern ColliderJntSphElementInit D_8099C070[1]; -extern ColliderJntSphInit D_8099C094; -extern CollisionCheckInfoInit D_8099C0A4; -extern DamageTable D_8099C0AC; -extern InitChainEntry D_8099C0D0[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderItems); + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); + D_8099C0CC = 0; + if (this->actor.parent != NULL) { + this->actor.flags &= ~ACTOR_FLAG_1; + } + EnCrow_SetupFlyIdle(this); +} -extern UNK_TYPE D_060000F0; +void EnCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Init.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Destroy.s") +void EnCrow_SetupFlyIdle(EnCrow* this) { + this->timer = 100; + this->collider.base.acFlags |= AC_ON; + this->actionFunc = EnCrow_FlyIdle; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC58.s") +void EnCrow_FlyIdle(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 dist; + s32 onInitialAnimFrame; + s16 yaw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099AC8C.s") + SkelAnime_Update(&this->skelAnime); + onInitialAnimFrame = Animation_OnFrame(&this->skelAnime, 0.0f); + this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B098.s") + 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); + } else { + dist = 450.0f; + this->actor.flags |= ACTOR_FLAG_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B0CC.s") + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 300.0f) { + this->aimRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B318.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 5, 0x300, 0x10) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B384.s") + yaw = (Actor_YawToPoint(&this->actor, &this->actor.home.pos) - this->actor.shape.rot.y); + if (yaw > 0) { + this->aimRotY += Rand_S16Offset(0x1000, 0x1000); + } else { + this->aimRotY -= Rand_S16Offset(0x1000, 0x1000); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B584.s") + if ((this->actor.depthInWater > -40.0f) || (this->actor.bgCheckFlags & 1)) { + this->aimRotX = -0x1000; + } else if (this->actor.world.pos.y < (this->actor.home.pos.y - 50.0f)) { + this->aimRotX = -Rand_S16Offset(0x800, 0x800); + } else if (this->actor.world.pos.y > (this->actor.home.pos.y + 50.0f)) { + this->aimRotX = Rand_S16Offset(0x800, 0x800); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6AC.s") + if ((Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 0xA, 0x100, 8) == 0) && onInitialAnimFrame && + (Rand_ZeroOne() < 0.1f)) { + if (this->actor.home.pos.y < this->actor.world.pos.y) { + this->aimRotX -= Rand_S16Offset(0x400, 0x400); + } else { + this->aimRotX += Rand_S16Offset(0x400, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B6C4.s") + this->aimRotX = CLAMP(this->aimRotX, -0x1000, 0x1000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B778.s") + if (this->actor.bgCheckFlags & 1) { + Math_ScaledStepToS(&this->actor.shape.rot.x, -0x100, 0x400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B838.s") + if (this->timer != 0) { + this->timer--; + } + if ((this->timer == 0) && + (((this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000)) || (dist < 300.0f)) && + (this->actor.depthInWater < -40.0f) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + if (dist < this->actor.xzDistToPlayer) { + this->actor.child = this->actor.parent; + } else { + this->actor.child = &player->actor; + } + EnCrow_SetupDiveAttack(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B8EC.s") +void EnCrow_SetupDiveAttack(EnCrow* this) { + this->timer = 300; + this->actionFunc = EnCrow_DiveAttack; + this->actor.speedXZ = 4.0f; + this->skelAnime.playSpeed = 2.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099B9E8.s") +void EnCrow_DiveAttack(EnCrow* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 isFacingActor; + Vec3f pos; + s16 pitch; + s16 pitchTarget; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BAB4.s") + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + isFacingActor = Actor_ActorAIsFacingActorB(&this->actor, this->actor.child, 0x2800); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Update.s") + if (isFacingActor) { + if (&player->actor == this->actor.child) { + pos.y = this->actor.child->world.pos.y + 20.0f; + } else { + pos.y = this->actor.child->world.pos.y + 40.0f; + } + pos.x = this->actor.child->world.pos.x; + pos.z = this->actor.child->world.pos.z; + pitch = Actor_PitchToPoint(&this->actor, &pos); + pitchTarget = CLAMP(pitch, -0x3000, 0x3000); + Math_SmoothStepToS(&this->actor.shape.rot.x, pitchTarget, 2, 0x400, 64); + } else { + Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 2, 0x100, 16); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BE48.s") + 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 (((this->timer == 0) || ((&player->actor != this->actor.child) && (this->actor.child->home.rot.z != 0)) || + ((&player->actor == this->actor.child) && + ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (player->stateFlags1 & 0x800000))) || + ((this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9))) || + (this->actor.depthInWater > -40.0f)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/func_8099BF20.s") + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_ATTACK); + } + EnCrow_SetupFlyIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Crow/EnCrow_Draw.s") +void EnCrow_CheckIfFrozen(EnCrow* this, GlobalContext* globalCtx) { + if (this->deathMode == 10) { + this->deathMode = 0; + this->effectAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->bodyPartsPos, 4, 2, 0.2f, 0.2f); + } +} + +void EnCrow_SetupDamaged(EnCrow* this, GlobalContext* globalCtx) { + f32 scale; + + this->actor.speedXZ *= 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; + scale = (this->actor.scale.x * 100.0f); + this->actor.world.pos.y += 20.0f * scale; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + + if (this->actor.colChkInfo.damageEffect == 3) { + this->deathMode = 10; // Ice arrows + this->effectAlpha = 1.0f; + this->effectScale = 0.75f; + this->steamScale = 0.5f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->deathMode = 20; // Light Arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements->info.bumper.hitPos.x, + this->collider.elements->info.bumper.hitPos.y, this->collider.elements->info.bumper.hitPos.z, 0, 0, + 0, CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 2) { + this->deathMode = 0; // Fire arrows + this->effectAlpha = 4.0f; + this->steamScale = 0.5f; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + if (this->actor.flags & ACTOR_FLAG_8000) { + this->actor.speedXZ = 0.0f; + } + + this->collider.base.acFlags &= ~AC_ON; + this->actor.flags |= ACTOR_FLAG_10; + + this->actionFunc = EnCrow_Damaged; +} + +void EnCrow_Damaged(EnCrow* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (!(this->actor.flags & ACTOR_FLAG_8000)) { + if (this->deathMode != 10) { + 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)) { + EnCrow_CheckIfFrozen(this, globalCtx); + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, this->actor.scale.x * 10000.0f, + 0, 0); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + + if (this->actor.parent != NULL) { + Actor_MarkForDeath(&this->actor); + return; + } + EnCrow_SetupDie(this); + } + } +} + +void EnCrow_SetupDie(EnCrow* this) { + this->actor.colorFilterTimer = 0; + this->actionFunc = EnCrow_Die; +} + +void EnCrow_Die(EnCrow* this, GlobalContext* globalCtx) { + f32 stepScale; + + if (this->actor.params != 0) { + stepScale = 0.006f; + } else { + stepScale = 0.002f; + } + if (Math_StepToF(&this->actor.scale.x, 0.0f, stepScale) != 0) { + if (this->actor.params == 0) { + D_8099C0CC++; + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x80); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + } + EnCrow_SetupRespawn(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; +} + +void EnCrow_SetupTurnAway(EnCrow* this) { + this->timer = 100; + this->aimRotX = -0x1000; + this->actor.speedXZ = 3.5f; + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + this->skelAnime.playSpeed = 2.0f; + if (this->actor.colChkInfo.damageEffect == 1) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } else { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnCrow_TurnAway; +} + +void EnCrow_TurnAway(EnCrow* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (this->actor.bgCheckFlags & 8) { + this->aimRotY = this->actor.wallYaw; + } else { + this->aimRotY = this->actor.yawTowardsPlayer + 0x8000; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->aimRotY, 3, 0xC00, 0xC0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->aimRotX, 5, 0x100, 0x10); + + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnCrow_SetupFlyIdle(this); + } +} + +void EnCrow_SetupRespawn(EnCrow* this) { + if (D_8099C0CC == 10) { + this->actor.params = 1; + D_8099C0CC = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius * 0.03f * 100.0f; + } else { + this->actor.params = 0; + this->collider.elements->dim.worldSphere.radius = sJntSphInit.elements->dim.modelSphere.radius; + } + Animation_PlayLoop(&this->skelAnime, &gGuayFlyAnim); + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.home.pos); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->timer = 300; + this->actor.draw = NULL; + this->actor.shape.yOffset = 2000.0f; + this->actor.targetArrowOffset = 2000.0; + this->effectAlpha = 0.0f; + this->actionFunc = EnCrow_Respawn; +} + +void EnCrow_Respawn(EnCrow* this, GlobalContext* globalCtx) { + f32 target; + + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + SkelAnime_Update(&this->skelAnime); + this->actor.draw = EnCrow_Draw; + if (this->actor.params != 0) { + target = 0.03f; + } else { + target = 0.01f; + } + if (Math_StepToF(&this->actor.scale.x, target, target * 0.1f)) { + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.colChkInfo.health = 1; + EnCrow_SetupFlyIdle(this); + } + this->actor.scale.z = this->actor.scale.y = this->actor.scale.x; + } +} + +void EnCrow_UpdateDamage(EnCrow* this, GlobalContext* globalCtx) { + + if (this->collider.base.acFlags & AT_HIT) { + this->collider.base.acFlags &= ~AT_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.elements->info); + + if (this->actor.colChkInfo.damageEffect == 1) { + EnCrow_SetupTurnAway(this); + + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->deathMode = 31; // Stunned via deku nuts or zora barrier + this->effectAlpha = 2.0f; + this->steamScale = 0.5f; + EnCrow_SetupTurnAway(this); + + } else { + this->actor.colChkInfo.health = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnCrow_SetupDamaged(this, globalCtx); + } + } +} + +void EnCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + f32 pad; + EnCrow* this = (EnCrow*)thisx; + f32 height; + f32 scale; + + EnCrow_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + scale = this->actor.scale.x * 100.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.x = -this->actor.shape.rot.x; + + if (this->actionFunc != EnCrow_Respawn) { + if (this->actor.colChkInfo.health != 0) { + height = 20.0f * scale; + Actor_MoveWithoutGravity(&this->actor); + } else { + height = 0.0f; + Actor_MoveWithGravity(&this->actor); + } + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 12.0f * scale, 25.0f * scale, 50.0f * scale, 7); + } else { + height = 0.0f; + } + + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y + height; + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; + + if (this->actionFunc == EnCrow_DiveAttack) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (this->actionFunc != EnCrow_Respawn) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + 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); + } + if (this->effectAlpha > 0.0f) { + if (this->deathMode != 10) { + Math_StepToF(&this->effectAlpha, 0.0f, 0.05f); + this->steamScale = (this->effectAlpha + 1.0f) * 0.25f; + if (this->steamScale > 0.5f) { + this->steamScale = 0.5f; + } else { + this->steamScale = this->steamScale; + } + } else if (Math_StepToF(&this->effectScale, 0.5f, 0.0125f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 EnCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (this->actor.colChkInfo.health != 0) { + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { + rot->y += (s16)(0xC00 * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { + rot->y += (s16)(0x1400 * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + } + } + return false; +} + +void EnCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnCrow* this = (EnCrow*)thisx; + + if (limbIndex == OBJECT_CROW_LIMB_BODY) { + Matrix_GetStateTranslationAndScaledX(2500.0f, this->bodyPartsPos); + return; + } + if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + Matrix_GetStateTranslation(&this->bodyPartsPos[(limbIndex >> 1) - 1]); + } +} + +void EnCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnCrow* this = (EnCrow*)thisx; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnCrow_OverrideLimbDraw, EnCrow_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->actor.scale.x * 100.0f * this->steamScale, this->effectScale, this->effectAlpha, + this->deathMode); +} diff --git a/src/overlays/actors/ovl_En_Crow/z_en_crow.h b/src/overlays/actors/ovl_En_Crow/z_en_crow.h index e1d763142..9076a198c 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.h +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.h @@ -2,6 +2,7 @@ #define Z_EN_CROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" struct EnCrow; @@ -9,9 +10,20 @@ typedef void (*EnCrowActionFunc)(struct EnCrow*, GlobalContext*); typedef struct EnCrow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnCrowActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x110]; + /* 0x18C */ u8 deathMode; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 aimRotX; + /* 0x192 */ s16 aimRotY; + /* 0x194 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x200 */ ColliderJntSph collider; + /* 0x220 */ ColliderJntSphElement colliderItems[1]; + /* 0x260 */ Vec3f bodyPartsPos[4]; + /* 0x290 */ f32 effectAlpha; + /* 0x294 */ f32 steamScale; + /* 0x298 */ f32 effectScale; } EnCrow; // size = 0x29C extern const ActorInit En_Crow_InitVars; 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 1ef914e1c..bd7de1418 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -7,7 +7,7 @@ #include "z_en_dai.h" #include "objects/object_dai/object_dai.h" -#define FLAGS 0x02000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnDai*)thisx) @@ -130,16 +130,20 @@ s32 func_80B3E5B4(EnDai* this, GlobalContext* globalCtx) { } s32 func_80B3E5DC(EnDai* this, s32 arg1) { - static ActorAnimationEntryS D_80B3FBFC[] = { - { &object_dai_Anim_0079E4, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0079E4, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_007354, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_000CEC, 1.0f, 0, -1, 2, -4 }, - { &object_dai_Anim_0069DC, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_00563C, 1.0f, 0, -1, 2, 0 }, - { &object_dai_Anim_00563C, 1.0f, 0, -1, 2, -4 }, { &object_dai_Anim_002E58, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_006590, 1.0f, 0, -1, 2, -4 }, + static AnimationInfoS D_80B3FBFC[] = { + { &object_dai_Anim_0079E4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_0079E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_007354, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_000CEC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_0069DC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_00563C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dai_Anim_00563C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_002E58, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_006590, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; s32 phi_v1 = false; - s32 ret = 0; + s32 ret = false; switch (arg1) { case 0: @@ -165,7 +169,7 @@ s32 func_80B3E5DC(EnDai* this, s32 arg1) { if (phi_v1) { this->unk_A70 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80B3FBFC, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80B3FBFC, arg1); } return ret; @@ -175,7 +179,7 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { s32 ret = false; if ((globalCtx->csCtx.state != 0) && (globalCtx->sceneNum == SCENE_12HAKUGINMAE) && - (globalCtx->csCtx.unk_12 == 0) && !(gSaveContext.save.weekEventReg[30] & 1)) { + (globalCtx->csCtx.currentCsIndex == 0) && !(gSaveContext.save.weekEventReg[30] & 1)) { if (!(this->unk_1CE & 0x10)) { Flags_SetSwitch(globalCtx, 20); this->unk_1CE |= (0x80 | 0x10); @@ -202,7 +206,7 @@ s32 func_80B3E7C8(EnDai* this, GlobalContext* globalCtx) { if (this->unk_1CE & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_1CE, 0, 7); + SubS_UpdateFlags(&this->unk_1CE, 0, 7); this->actionFunc = func_80B3EF90; ret = true; } @@ -424,7 +428,7 @@ void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx) { void func_80B3EF90(EnDai* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, D_80B3FC8C, NULL, &this->unk_1D0)) { - func_8013AED4(&this->unk_1CE, 3, 7); + SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1D0 = 0; this->actionFunc = func_80B3F00C; } else { @@ -440,13 +444,12 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { static s32 D_80B3FE38[] = { 0, 0, 6, 7, 8, }; - s32 sp2C = 0; s32 sp28; - if (func_800EE29C(globalCtx, 0x1D8)) { - sp2C = func_800EE200(globalCtx, 0x1D8); - sp28 = globalCtx->csCtx.npcActions[sp2C]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 472)) { + sp2C = Cutscene_GetActorActionIndex(globalCtx, 472); + sp28 = globalCtx->csCtx.actorActions[sp2C]->action; if (this->unk_1CC != (u8)sp28) { func_80B3E5DC(this, D_80B3FE38[sp28]); switch (sp28) { @@ -504,7 +507,7 @@ void func_80B3F044(EnDai* this, GlobalContext* globalCtx) { break; } - func_800EDF24(&this->actor, globalCtx, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, sp2C); } void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -523,7 +526,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1D6 = 0; if (gSaveContext.save.weekEventReg[33] & 0x80) { - func_8013AED4(&this->unk_1CE, 3, 7); + SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1CE |= 0x80; this->unk_1CD = 0xFF; this->actionFunc = func_80B3F00C; @@ -536,7 +539,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_1CD = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1CE |= (0x100 | 0x20); this->unk_1CE |= 0x80; this->actionFunc = func_80B3EEDC; 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 e56e35de8..3d76b7391 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -7,7 +7,7 @@ #include "z_en_daiku.h" #include "objects/object_daiku/object_daiku.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDaiku*)thisx) @@ -67,7 +67,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_278 = ENDAIKU_GET_FF(&this->actor); if (this->unk_278 == ENDAIKU_PARAMS_FF_3) { this->unk_288 = ENDAIKU_GET_FF00(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_288, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_288, 0x3F); } else if (this->unk_278 == ENDAIKU_PARAMS_FF_2) { this->unk_264 = -2000; } @@ -76,7 +76,7 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; if ((gSaveContext.save.weekEventReg[63] & 0x80) || ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { Actor_MarkForDeath(&this->actor); @@ -134,7 +134,7 @@ void func_8094373C(EnDaiku* this, s32 arg1) { void func_809437C8(EnDaiku* this) { if ((this->unk_288 != -1) && (this->unk_258 != 0)) { - if (!func_8013D68C(this->unk_258, this->unk_25C, &this->unk_26C)) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_26C)) { Actor_MarkForDeath(&this->actor); } } @@ -242,7 +242,7 @@ void func_80943BDC(EnDaiku* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80943820(this); } 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 9d716fc25..64a8c3d9b 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -9,7 +9,7 @@ #include "objects/object_daiku/object_daiku.h" #include "objects/object_bombiwa/object_bombiwa.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDaiku2*)thisx) @@ -70,7 +70,7 @@ static ColliderCylinderInit sCylinderInit = { void func_80BE61D0(EnDaiku2* this) { if ((this->unk_27A != -1) && (this->unk_258 != 0)) { - if (func_8013D68C(this->unk_258, this->unk_25C, &this->unk_268) == 0) { + if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_268)) { Actor_MarkForDeath(&this->actor); } } @@ -88,7 +88,7 @@ void EnDaiku2_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->unk_278 = ENDAIKU2_GET_7F(&this->actor); this->unk_27A = ENDAIKU2_GET_1F80(&this->actor); - this->unk_258 = func_8013D648(globalCtx, this->unk_27A, 0x3F); + this->unk_258 = SubS_GetPathByIndex(globalCtx, this->unk_27A, 0x3F); this->unk_280 = ENDAIKU2_GET_8000(&this->actor); Actor_SetScale(&this->actor, 0.01f); if (!this->unk_280) { @@ -292,7 +292,7 @@ void func_80BE6B40(EnDaiku2* this, GlobalContext* globalCtx) { void func_80BE6BC0(EnDaiku2* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0x0); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { s32 day = gSaveContext.save.day - 1; func_801477B4(globalCtx); 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 ec6d57bbf..6292103ee 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -6,7 +6,7 @@ #include "z_en_death.h" -#define FLAGS 0x00001035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000) #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 288ce89a3..1939a5bcc 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -6,7 +6,7 @@ #include "z_en_dekubaba.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnDekubaba*)thisx) 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 1d6863400..7461239d3 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -8,7 +8,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_dekunuts/object_dekunuts.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnDekunuts*)thisx) @@ -130,7 +130,7 @@ void EnDekunuts_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.params == ENDEKUNUTS_GET_FF00_1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.colType = COLTYPE_NONE; this->collider.info.bumperFlags |= (BUMP_NO_HITMARK | BUMP_NO_SWORD_SFX | BUMP_NO_DAMAGE | BUMP_NO_AT_INFO); } else if (this->actor.params == ENDEKUNUTS_GET_FF00_2) { @@ -147,21 +147,21 @@ void EnDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_808BD348(EnDekunuts* this) { - this->unk_18E = 10; - this->unk_214 = 0.55f; - this->unk_218 = 0.82500005f; - this->unk_210 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_190 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808BD3B4(EnDekunuts* this, GlobalContext* globalCtx) { - if (this->unk_18E == 10) { - this->unk_18E = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_210 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_21C, 8, 2, 0.2f, 0.2f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 8, 2, 0.2f, 0.2f); } } @@ -372,7 +372,7 @@ void func_808BDE7C(EnDekunuts* this) { this->actor.colChkInfo.mass = 50; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); this->actor.world.rot.x = 0; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_808BDEF8; } @@ -435,7 +435,7 @@ void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { if ((this->unk_18D == 0) && (Actor_XZDistanceToPoint(&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 &= ~0x20; + this->actor.flags &= ~ACTOR_FLAG_20; this->actor.speedXZ = 0.0f; func_808BDC9C(this); } else if (this->unk_190 == 0) { @@ -568,7 +568,8 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18E != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_808BD3B4(this, globalCtx); if ((this->actor.colChkInfo.mass == 50) || (this->actor.params != ENDEKUNUTS_GET_FF00_0)) { if ((this->actor.params != ENDEKUNUTS_GET_FF00_1) && !Actor_ApplyDamage(&this->actor)) { @@ -599,20 +600,20 @@ void func_808BE73C(EnDekunuts* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; - this->unk_18E = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18E = 32; - this->unk_210 = 4.0f; - this->unk_214 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } func_808BE294(this, 1); @@ -649,12 +650,13 @@ void EnDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_210 > 0.0f) { - if (this->unk_18E != 10) { - Math_StepToF(&this->unk_210, 0.0f, 0.05f); - this->unk_214 = (this->unk_210 + 1.0f) * 0.275f; - this->unk_214 = CLAMP_MAX(this->unk_214, 0.55f); - } else if ((this->unk_18E == 10) && !Math_StepToF(&this->unk_218, 0.55f, (33.0f / 1600.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.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + !Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, (33.0f / 1600.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -709,12 +711,12 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis if (value != -1) { if (value < 3) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_21C[value]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[value]); } else { - Matrix_GetStateTranslation(&this->unk_21C[value]); + Matrix_GetStateTranslation(&this->limbPos[value]); ptr1 = &D_808BEFA4[0]; - ptr2 = &this->unk_21C[value + 1]; - for (i = value + 1; i < ARRAY_COUNT(this->unk_21C); i++) { + ptr2 = &this->limbPos[value + 1]; + for (i = value + 1; i < ARRAY_COUNT(this->limbPos); i++) { Matrix_MultiplyVector3fByState(ptr1, ptr2); ptr1++, ptr2++; } @@ -738,6 +740,6 @@ void EnDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800AE5A0(globalCtx); } Gfx_DrawDListOpa(globalCtx, object_dekunuts_DL_001E50); - func_800BE680(globalCtx, &this->actor, this->unk_21C, 8, this->unk_214, this->unk_218, this->unk_210, - this->unk_18E); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h index aa0b3e1bf..3e1af35eb 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -22,16 +22,16 @@ typedef struct EnDekunuts { /* 0x188 */ EnDekunutsActionFunc actionFunc; /* 0x18C */ u8 unk_18C; /* 0x18D */ u8 unk_18D; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ s16 unk_190; /* 0x192 */ s16 unk_192; /* 0x194 */ s16 unk_194; /* 0x196 */ Vec3s jointTable[10]; /* 0x1D2 */ Vec3s morphTable[10]; - /* 0x210 */ f32 unk_210; - /* 0x214 */ f32 unk_214; - /* 0x218 */ f32 unk_218; - /* 0x21C */ Vec3f unk_21C[8]; + /* 0x210 */ f32 drawDmgEffAlpha; + /* 0x214 */ f32 drawDmgEffScale; + /* 0x218 */ f32 drawDmgEffFrozenSteamScale; + /* 0x21C */ Vec3f limbPos[8]; /* 0x27C */ ColliderCylinder collider; } EnDekunuts; // size = 0x2C8 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 b7e160990..76934448a 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 @@ -5,8 +5,9 @@ */ #include "z_en_demo_heishi.h" +#include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDemoheishi*)thisx) @@ -15,10 +16,22 @@ void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx); void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE975C(EnDemoheishi* this, GlobalContext* globalCtx); -void func_80BE980C(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex); +void EnDemoheishi_SetupIdle(EnDemoheishi* this); +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx); +void EnDemoheishi_SetupTalk(EnDemoheishi* this); +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx); +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx); + +typedef enum { + /* 0 */ DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP, + /* 1 */ DEMOHEISHI_ANIMATION_CHEER_WITH_SPEAR, + /* 2 */ DEMOHEISHI_ANIMATION_WAVE, + /* 3 */ DEMOHEISHI_ANIMATION_SIT_AND_REACH, + /* 4 */ DEMOHEISHI_ANIMATION_STAND_UP +} EnDemoheishiAnimationIndex; -#if 0 const ActorInit En_Demo_heishi_InitVars = { ACTOR_EN_DEMO_HEISHI, ACTORCAT_NPC, @@ -31,37 +44,152 @@ const ActorInit En_Demo_heishi_InitVars = { (ActorFunc)EnDemoheishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE9A50 = { - { 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, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +static u16 sTextIds[] = { 0x1473 }; // Shiro initial intro text -extern ColliderCylinderInit D_80BE9A50; +void EnDemoheishi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -extern UNK_TYPE D_06003BFC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, + this->morphTable, 17); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + EnDemoheishi_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Init.s") +void EnDemoheishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Destroy.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE95EC.s") +void EnDemoheishi_ChangeAnimation(EnDemoheishi* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, + }; + static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9678.s") + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE970C.s") +void EnDemoheishi_SetHeadRotation(EnDemoheishi* this) { + s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE975C.s") + this->headRotXTarget = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (absYawDiff < 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_Demo_heishi/func_80BE97F0.s") +void EnDemoheishi_SetupIdle(EnDemoheishi* this) { + EnDemoheishi_ChangeAnimation(this, DEMOHEISHI_ANIMATION_STAND_HAND_ON_HIP); + this->textIdIndex = 0; + this->actor.textId = sTextIds[this->textIdIndex]; + this->isTalking = false; + this->actionFunc = EnDemoheishi_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE980C.s") +void EnDemoheishi_Idle(EnDemoheishi* this, GlobalContext* globalCtx) { + s32 absYawDiff; + s16 yawDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Update.s") + this->actor.flags &= ~ACTOR_FLAG_8000000; + yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/func_80BE9974.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + EnDemoheishi_SetupTalk(this); + } else if (absYawDiff <= 0x4BB8) { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Demo_heishi/EnDemoheishi_Draw.s") +void EnDemoheishi_SetupTalk(EnDemoheishi* this) { + this->isTalking = true; + this->actionFunc = EnDemoheishi_Talk; +} + +void EnDemoheishi_Talk(EnDemoheishi* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + EnDemoheishi_SetupIdle(this); + } +} + +void EnDemoheishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDemoheishi* this = THIS; + + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_SetScale(&this->actor, 0.01f); + EnDemoheishi_SetHeadRotation(this); + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); +} + +s32 EnDemoheishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDemoheishi* this = THIS; + + if (limbIndex == DEMOHEISHI_LIMB_HEAD) { + rot->x += this->headRotX; + rot->y += this->headRotY; + rot->z += this->headRotZ; + } + + return false; +} + +void EnDemoheishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDemoheishi* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDemoheishi_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h index 8dcdc899d..e6a2f9a91 100644 --- a/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h +++ b/src/overlays/actors/ovl_En_Demo_heishi/z_en_demo_heishi.h @@ -7,12 +7,46 @@ struct EnDemoheishi; typedef void (*EnDemoheishiActionFunc)(struct EnDemoheishi*, GlobalContext*); +typedef enum { + /* 0 */ DEMOHEISHI_LIMB_NONE, + /* 1 */ DEMOHEISHI_LIMB_ROOT, + /* 2 */ DEMOHEISHI_LIMB_PELVIS, + /* 3 */ DEMOHEISHI_LIMB_LEFT_THIGH, + /* 4 */ DEMOHEISHI_LIMB_LEFT_SHIN, + /* 5 */ DEMOHEISHI_LIMB_LEFT_FOOT, + /* 6 */ DEMOHEISHI_LIMB_RIGHT_THIGH, + /* 7 */ DEMOHEISHI_LIMB_RIGHT_SHIN, + /* 8 */ DEMOHEISHI_LIMB_RIGHT_FOOT, + /* 9 */ DEMOHEISHI_LIMB_TORSO, + /* 10 */ DEMOHEISHI_LIMB_LEFT_SHOULDER, + /* 11 */ DEMOHEISHI_LIMB_LEFT_FOREARM, + /* 12 */ DEMOHEISHI_LIMB_LEFT_HAND, + /* 13 */ DEMOHEISHI_LIMB_RIGHT_SHOULDER, + /* 14 */ DEMOHEISHI_LIMB_RIGHT_FOREARM, + /* 15 */ DEMOHEISHI_LIMB_RIGHT_HAND_WITH_SPEAR, + /* 16 */ DEMOHEISHI_LIMB_HEAD, + /* 17 */ DEMOHEISHI_LIMB_MAX +} EnDemoheishiLimbs; + typedef struct EnDemoheishi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; - /* 0x0254 */ EnDemoheishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x68]; -} EnDemoheishi; // size = 0x2C0 + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEMOHEISHI_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[DEMOHEISHI_LIMB_MAX]; + /* 0x254 */ EnDemoheishiActionFunc actionFunc; + /* 0x258 */ s16 headRotY; + /* 0x25A */ s16 headRotX; + /* 0x25C */ s16 headRotZ; + /* 0x25E */ s16 headRotYTarget; + /* 0x260 */ s16 headRotXTarget; + /* 0x262 */ s16 headRotZTarget; + /* 0x264 */ s32 animIndex; + /* 0x268 */ s16 timer; + /* 0x26C */ f32 frameCount; + /* 0x270 */ s16 isTalking; + /* 0x272 */ s16 textIdIndex; + /* 0x274 */ ColliderCylinder colliderCylinder; +} EnDemoheishi; //size = 0x2C0 extern const ActorInit En_Demo_heishi_InitVars; 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 afc9767dd..dce730c48 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -5,9 +5,8 @@ */ #include "z_en_dg.h" -#include "objects/object_dog/object_dog.h" -#define FLAGS 0x00800019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnDg*)thisx) @@ -129,33 +128,33 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dog_Anim_0021C8, 1.0f, 0, -1, 0, 0 }, { &object_dog_Anim_0021C8, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001BD8, 1.0f, 0, -1, 0, 0 }, { &object_dog_Anim_000998, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001FB0, 1.0f, 0, -1, 2, -6 }, { &object_dog_Anim_001FB0, 1.0f, 0, -1, 4, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, -1, 2, -6 }, { &object_dog_Anim_001348, 1.0f, 0, -1, 0, -6 }, - { &object_dog_Anim_001048, 1.0f, 0, 27, 2, -6 }, { &object_dog_Anim_001048, 1.0f, 28, -1, 2, -6 }, - { &object_dog_Anim_001048, 1.0f, 54, 54, 2, -6 }, { &object_dog_Anim_0021C8, -1.5f, -1, 0, 0, -6 }, - { &object_dog_Anim_001560, 1.0f, 0, -1, 2, 0 }, { &object_dog_Anim_001A84, 1.2f, 0, -1, 2, 0 }, - { &object_dog_Anim_0017C0, 1.2f, 0, -1, 2, 0 }, { &object_dog_Anim_0021C8, 0.5f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -void func_80989140(SkelAnime* skelAnime, ActorAnimationEntryS arg1[], s32 arg2) { +void func_80989140(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { f32 frameCount; arg1 += arg2; if (arg1->frameCount < 0) { - frameCount = Animation_GetLastFrame(arg1->animationSeg); + frameCount = Animation_GetLastFrame(arg1->animation); } else { frameCount = arg1->frameCount; } - Animation_Change(skelAnime, arg1->animationSeg, arg1->playbackSpeed + (BREG(88) * 0.1f), arg1->frame, frameCount, - arg1->mode, arg1->transitionRate); + Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, + arg1->mode, arg1->morphFrames); } void func_80989204(EnDg* this, GlobalContext* globalCtx) { @@ -198,7 +197,7 @@ void func_8098933C(EnDg* this, Vec3f* arg1) { } s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { - Vec3s* sp5C = (Vec3s*)Lib_SegmentedToVirtual(arg1->points); + Vec3s* sp5C = Lib_SegmentedToVirtual(arg1->points); s32 count = arg1->count; s32 idx = arg2; s32 sp50 = false; @@ -213,7 +212,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { if (idx == 0) { phi_f12 = sp5C[1].x - sp5C[0].x; phi_f14 = sp5C[1].z - sp5C[0].z; - } else if ((idx + 1) == ((void)0, count)) { + } else if (idx == count - 1) { phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; } else { @@ -221,7 +220,7 @@ s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; } - func_8017B7F8(&sp30, func_80086B30(phi_f12, phi_f14) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_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; } @@ -235,7 +234,7 @@ s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[idx]; diffX = points->x - pos->x; diffZ = points->z - pos->z; @@ -349,10 +348,11 @@ void func_80989BF8(EnDg* this) { if (this->unk_286 < 14) { if (this->unk_286 % 2) { D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & 0xF0) >> 4); + 0x3538 + + ((gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); } else { D_8098C2A8[this->unk_286].unk_04 = - 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & 0xF); + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->unk_286 / 2)] & (1 | 2 | 4 | 8)); } } else { Actor_MarkForDeath(&this->actor); @@ -370,16 +370,16 @@ void func_80989BF8(EnDg* this) { void func_80989D38(EnDg* this, GlobalContext* globalCtx) { if (this->unk_286 == 21) { if (CURRENT_DAY == 1) { - func_801518B0(globalCtx, 0x91C, NULL); + Message_StartTextbox(globalCtx, 0x91C, NULL); } else { - func_801518B0(globalCtx, 0x91E, NULL); + Message_StartTextbox(globalCtx, 0x91E, NULL); } } else if ((this->unk_286 >= 0) && (this->unk_286 < 14)) { - func_801518B0(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); + Message_StartTextbox(globalCtx, D_8098C2A8[this->unk_286].unk_04, NULL); } else if (this->unk_286 == 20) { - func_801518B0(globalCtx, 0x353D, NULL); + Message_StartTextbox(globalCtx, 0x353D, NULL); } else { - func_801518B0(globalCtx, 0x627, NULL); + Message_StartTextbox(globalCtx, 0x627, NULL); } } @@ -387,10 +387,10 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { D_8098C2A8_s* temp; if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->unk_280 |= 1; } else if ((D_8098C2A0 == 0) && (this->unk_280 & 1)) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; this->unk_280 &= ~1; } @@ -399,16 +399,16 @@ void func_80989E18(EnDg* this, GlobalContext* globalCtx) { this->unk_290 = 1; D_8098C2FC = D_8098C2A8[this->unk_286]; if (D_8098C2A0 == 0) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; D_8098C2A0 = 1; this->unk_280 |= 1; } func_80989140(&this->skelAnime, sAnimations, 5); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; if (Player_GetMask(globalCtx) == PLAYER_MASK_TRUTH) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 100.0f); this->actionFunc = func_8098BBEC; } else { @@ -691,7 +691,7 @@ void func_8098A938(EnDg* this, GlobalContext* globalCtx) { this->actionFunc = func_8098AC34; } else { func_80989140(&this->skelAnime, sAnimations, 11); - sAnimations[11].playbackSpeed = -1.0f; + sAnimations[11].playSpeed = -1.0f; this->actionFunc = func_8098B198; } } @@ -766,7 +766,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (sp26 < 9) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { - sAnimations[14].playbackSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + sAnimations[14].playSpeed = randPlusMinusPoint5Scaled(1.0f) + 3.0f; } func_80989864(this, globalCtx); } else { @@ -774,7 +774,7 @@ void func_8098AC34(EnDg* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { f32 rand = randPlusMinusPoint5Scaled(1.5f); - sAnimations[14].playbackSpeed = 1.2f; + sAnimations[14].playSpeed = 1.2f; this->actor.velocity.y = 2.0f * rand + 3.0f; this->actor.speedXZ = 8.0f + rand; } else if (sp26 >= 0x15) { @@ -831,7 +831,7 @@ void func_8098B004(EnDg* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; this->actor.gravity = -3.0f; - if ((this->actor.xzDistToPlayer < 60.0f) && (this->collider.base.ocFlags1 & 2)) { + if ((this->actor.xzDistToPlayer < 60.0f) && (this->collider.base.ocFlags1 & OC1_HIT)) { this->actor.shape.rot.y += 0x71C; } else { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 4, 0xC00); @@ -1047,9 +1047,9 @@ void func_8098B88C(EnDg* this, GlobalContext* globalCtx) { void func_8098BA64(EnDg* this, GlobalContext* globalCtx) { if (Actor_HasNoParent(&this->actor, globalCtx)) { this->unk_290 = 2; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (D_8098C2A0 != 0) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; D_8098C2A0 = 0; this->unk_280 &= ~1; } @@ -1089,7 +1089,7 @@ void func_8098BB10(EnDg* this, GlobalContext* globalCtx) { void func_8098BBEC(EnDg* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80989D38(this, globalCtx); this->actionFunc = func_8098BC54; } else { @@ -1109,13 +1109,12 @@ void EnDg_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, NULL, this->jointTable, this->morphTable, - 13); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_ProcessInitChain(&this->actor, sInitChain); - this->unk_1DC = func_8013D648(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); + this->unk_1DC = SubS_GetPathByIndex(globalCtx, ENDG_GET_FC00(&this->actor), 0x3F); Actor_SetScale(&this->actor, 0.0075f); this->actor.targetMode = 1; this->actor.gravity = -3.0f; @@ -1176,7 +1175,7 @@ void EnDg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec EnDg* this = THIS; Vec3f sp20 = { 0.0f, 20.0f, 0.0f }; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { if (this->actionFunc == func_8098BBEC) { sp20.x = 5000.0f; Matrix_MultiplyVector3fByState(&sp20, &this->actor.focus.pos); diff --git a/src/overlays/actors/ovl_En_Dg/z_en_dg.h b/src/overlays/actors/ovl_En_Dg/z_en_dg.h index cfb474b18..09732ba81 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -2,6 +2,7 @@ #define Z_EN_DG_H #include "global.h" +#include "objects/object_dog/object_dog.h" struct EnDg; @@ -18,8 +19,8 @@ typedef struct EnDg { /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ Path* unk_1DC; /* 0x1E0 */ s32 unk_1E0; - /* 0x1E4 */ Vec3s jointTable[13]; - /* 0x232 */ Vec3s morphTable[13]; + /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; /* 0x280 */ u16 unk_280; /* 0x282 */ s16 unk_282; /* 0x284 */ s16 unk_284; 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 a17c56f40..e06e2e776 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -7,7 +7,7 @@ #include "z_en_dinofos.h" #include "objects/object_dinofos/object_dinofos.h" -#define FLAGS 0x00000435 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_400) #define THIS ((EnDinofos*)thisx) @@ -280,7 +280,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { if (D_8089E364 == 0) { for (i = 0; i < ARRAY_COUNT(D_8089E33C); i++) { - D_8089E33C[i] = (Gfx*)Lib_SegmentedToVirtual(D_8089E33C[i]); + D_8089E33C[i] = Lib_SegmentedToVirtual(D_8089E33C[i]); } D_8089E364 = 1; } @@ -295,7 +295,7 @@ void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { if (thisx->cutscene == -1) { func_8089B7B0(this); } else { - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; D_8089E34C = thisx->cutscene; @@ -363,11 +363,11 @@ void func_8089A9B0(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { - if (this->camId != 0) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + if (this->subCamId != CAM_ID_MAIN) { + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); - Play_CameraSetAtEye(globalCtx, 0, &camera->at, &camera->eye); - this->camId = 0; + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { func_800B724C(globalCtx, &this->actor, 6); @@ -376,23 +376,23 @@ void func_8089ABF4(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089AC70(EnDinofos* this) { - this->unk_28A = 10; - this->unk_2B4 = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; this->colliderJntSph.base.colType = COLTYPE_HIT3; - this->unk_2B8 = 0.82500005f; - this->unk_2B0 = 1.0f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->unk_290 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_8089ACEC(EnDinofos* this, GlobalContext* globalCtx) { - if (this->unk_28A == 10) { - this->unk_28A = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderJntSph.base.colType = COLTYPE_HIT0; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D4, 12, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 12, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; } } @@ -462,14 +462,14 @@ s32 func_8089AE00(EnDinofos* this, GlobalContext* globalCtx) { } void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); Player* player = GET_PLAYER(globalCtx); Vec3f sp3C; Animation_Change(&this->skelAnime, &object_dinofos_Anim_001CCC, 1.0f, Animation_GetLastFrame(&object_dinofos_Anim_001CCC), Animation_GetLastFrame(&object_dinofos_Anim_001CCC), 2, 0.0f); - func_800BE33C(&camera->eye, &camera->at, &this->unk_29A, true); + func_800BE33C(&subCam->eye, &subCam->at, &this->unk_29A, true); Math_Vec3f_Diff(&this->actor.world.pos, &player->actor.world.pos, &sp3C); this->unk_2BC.x = player->actor.world.pos.x + (0.4f * sp3C.x); this->unk_2BC.y = player->actor.world.pos.y + 5.0f; @@ -477,19 +477,19 @@ void func_8089B100(EnDinofos* this, GlobalContext* globalCtx) { this->unk_2C8.x = this->actor.world.pos.x; this->unk_2C8.y = this->actor.focus.pos.y - 400.0f; this->unk_2C8.z = this->actor.world.pos.z; - this->unk_2AC = Math_Vec3f_DistXYZ(&camera->eye, &this->unk_2BC) * 0.05f; - this->unk_2A8 = Math_Vec3f_DistXYZ(&camera->at, &this->unk_2C8) * 0.05f; + this->unk_2AC = Math_Vec3f_DistXYZ(&subCam->eye, &this->unk_2BC) * 0.05f; + this->unk_2A8 = Math_Vec3f_DistXYZ(&subCam->at, &this->unk_2C8) * 0.05f; this->unk_290 = 20; this->actionFunc = func_8089B288; } void func_8089B288(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); this->unk_290--; - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, this->unk_2AC); - Math_Vec3f_StepTo(&camera->at, &this->unk_2C8, this->unk_2A8); - Play_CameraSetAtEye(globalCtx, this->camId, &camera->at, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, this->unk_2AC); + Math_Vec3f_StepTo(&subCam->at, &this->unk_2C8, this->unk_2A8); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCam->eye); if (this->unk_290 == 0) { func_8089B320(this); } @@ -506,24 +506,24 @@ void func_8089B320(EnDinofos* this) { } void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); - Vec3f sp28; + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + Vec3f subCamAt; - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { func_801A2E54(NA_BGM_MINI_BOSS); } - sp28.x = this->actor.world.pos.x; - sp28.z = this->actor.world.pos.z; - if (this->actor.focus.pos.y <= camera->at.y) { - sp28.y = this->actor.focus.pos.y; + subCamAt.x = this->actor.world.pos.x; + subCamAt.z = this->actor.world.pos.z; + if (this->actor.focus.pos.y <= subCam->at.y) { + subCamAt.y = this->actor.focus.pos.y; } else { - sp28.y = camera->at.y; + subCamAt.y = subCam->at.y; } - Play_CameraSetAtEye(globalCtx, this->camId, &sp28, &camera->eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCam->eye); if (this->actor.bgCheckFlags & 1) { func_8089B4A4(this); } @@ -544,27 +544,27 @@ void func_8089B4A4(EnDinofos* this) { } void func_8089B580(EnDinofos* this, GlobalContext* globalCtx) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); this->unk_290++; if (this->unk_290 < 8) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); } if (this->skelAnime.curFrame > 35.0f) { if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 38.0f)) { - globalCtx->envCtx.unk_C3 = 11; + globalCtx->envCtx.lightSettingOverride = 11; } - Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &camera->eye); + Math_Vec3f_StepTo(&subCam->eye, &this->unk_2BC, 10.0f); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCam->eye); if (this->skelAnime.curFrame <= 55.0f) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); } } if ((globalCtx->sceneNum == SCENE_MITURIN) && Animation_OnFrame(&this->skelAnime, 55.0f)) { - globalCtx->envCtx.unk_C3 = 0xFF; + globalCtx->envCtx.lightSettingOverride = 0xFF; } if (SkelAnime_Update(&this->skelAnime)) { @@ -584,7 +584,7 @@ void func_8089B72C(EnDinofos* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { func_8089ABF4(this, globalCtx); - this->actor.flags &= ~0x00100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.cutscene = -1; func_8089B7B0(this); } @@ -1048,13 +1048,13 @@ void func_8089CB10(EnDinofos* this, GlobalContext* globalCtx) { for (i = 6; i < ARRAY_COUNT(this->colliderJntSphElement); i++) { worldSphere = &this->colliderJntSph.elements[i].dim.worldSphere; - worldSphere->center.x = this->unk_34C.x; - worldSphere->center.y = this->unk_34C.y; - worldSphere->center.z = this->unk_34C.z; + worldSphere->center.x = this->limbPos[10].x; + worldSphere->center.y = this->limbPos[10].y; + worldSphere->center.z = this->limbPos[10].z; } if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 11; + globalCtx->envCtx.lightSettingOverride = 11; } this->actionFunc = func_8089CBEC; @@ -1086,7 +1086,7 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { sp7C.y = randPlusMinusPoint5Scaled(0.6f) + 1.4f; sp7C.z = 0.9f * temp_f22; func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp88, &sp7C, 30, 22, 255 - (temp_s0 * 20), 20, 3, 8); for (end = 6, i = 3; i > 0; i--) { if (this->unk_290 < (20 + -(i * 2))) { @@ -1099,9 +1099,9 @@ void func_8089CBEC(EnDinofos* this, GlobalContext* globalCtx) { dim = &this->colliderJntSph.elements[i].dim; temp_s3 = (s32)(cos_rad((this->unk_290 + ((i - 5) << 1)) * (M_PI / 20)) * 0x2C00) + this->actor.shape.rot.y; - dim->worldSphere.center.x = (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.x; - dim->worldSphere.center.y = (s32)this->unk_34C.y + (s32)dim->modelSphere.center.y; - dim->worldSphere.center.z = (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z) + (s32)this->unk_34C.z; + dim->worldSphere.center.x = (s32)this->limbPos[10].x + (s32)(Math_SinS(temp_s3) * dim->modelSphere.center.z); + dim->worldSphere.center.y = (s32)this->limbPos[10].y + (s32)dim->modelSphere.center.y; + dim->worldSphere.center.z = (s32)this->limbPos[10].z + (s32)(Math_CosS(temp_s3) * dim->modelSphere.center.z); } if (this->unk_290 != 0) { @@ -1115,7 +1115,7 @@ void func_8089CF00(EnDinofos* this, GlobalContext* globalCtx) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_0017B8); this->colliderJntSph.base.atFlags &= ~AT_ON; if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 255; + globalCtx->envCtx.lightSettingOverride = 255; } this->actionFunc = func_8089CF70; } @@ -1128,7 +1128,7 @@ void func_8089CF70(EnDinofos* this, GlobalContext* globalCtx) { void func_8089CFAC(EnDinofos* this) { Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00ABD0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_DEAD); this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1151,8 +1151,8 @@ void func_8089D018(EnDinofos* this, GlobalContext* globalCtx) { this->unk_288 = temp_v0; } - if (this->unk_2B0 > 0.0f) { - this->unk_2B0 = this->unk_288 * (1.0f / 255.0f); + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = this->unk_288 * (1.0f / 255.0f); } this->actor.shape.shadowAlpha = this->unk_288; @@ -1201,7 +1201,7 @@ void func_8089D2E0(EnDinofos* this) { } void func_8089D318(EnDinofos* this, GlobalContext* globalCtx) { - Vec3f sp24; + Vec3f subCamEye; if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { if (this->actor.colChkInfo.health == 0) { @@ -1210,12 +1210,12 @@ void func_8089D318(EnDinofos* this, GlobalContext* globalCtx) { } else { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } - this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->subCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); if (this->actor.colChkInfo.health == 0) { - sp24.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; - sp24.y = this->actor.focus.pos.y; - sp24.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.z; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &sp24); + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.x; + subCamEye.y = this->actor.focus.pos.y; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + this->actor.focus.pos.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCamEye); func_8089CFAC(this); } else { func_8089B100(this, globalCtx); @@ -1234,7 +1234,7 @@ void func_8089D42C(EnDinofos* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->unk_28E, cos_rad(M_PI) * 0x2C00, 0x233); } else if (this->actionFunc == func_8089CBEC) { this->unk_28E = cos_rad(this->unk_290 * (M_PI / 20)) * 0x2C00; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { temp_v0_2 = this->unk_28E + this->actor.shape.rot.y; temp_v0_2 = BINANG_SUB(this->actor.yawTowardsPlayer, temp_v0_2); temp_v0_2 = CLAMP(temp_v0_2, -0x300, 0x300); @@ -1260,7 +1260,8 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_28A == 10) && (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderJntSph.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -1285,7 +1286,7 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { func_8089ACEC(this, globalCtx); func_8089AD70(this); if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.unk_C3 = 255; + globalCtx->envCtx.lightSettingOverride = 255; } this->colliderQuad.base.atFlags &= ~(AT_ON | AT_BOUNCED); @@ -1311,22 +1312,22 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 5) { this->unk_290 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); - this->unk_2B4 = 0.55f; - this->unk_2B0 = 2.0f; - this->unk_28A = 31; + 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); func_8089C784(this); return true; } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B0 = 4.0f; - this->unk_2B4 = 0.55f; - this->unk_28A = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderJntSph.elements[i].info.bumper.hitPos.x, this->colliderJntSph.elements[i].info.bumper.hitPos.y, @@ -1359,7 +1360,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->actionFunc != func_8089C7B8) { if ((this->actor.depthInWater > 0.0f) && (this->actor.depthInWater < 10.0f)) { if (!((globalCtx->gameplayFrames % 4) & 1)) { - Math_Vec3f_Copy(&sp30, &this->unk_2D4[1 + (globalCtx->gameplayFrames % 4)]); + Math_Vec3f_Copy(&sp30, &this->limbPos[1 + (globalCtx->gameplayFrames % 4)]); sp30.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp30, 100, 320, 0); } @@ -1373,7 +1374,7 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_ScaledStepToS(&this->unk_28E, 0, 2000); } - Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk_304); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->limbPos[4]); this->actor.focus.rot.y = this->actor.shape.rot.y + this->unk_28E; if (this->colliderJntSph.base.acFlags & AC_ON) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); @@ -1388,12 +1389,12 @@ void EnDinofos_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); } - if (this->unk_2B0 > 0.0f) { - if (this->unk_28A != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * (11.0f / 40.0f); - this->unk_2B4 = CLAMP_MAX(this->unk_2B4, 0.55f); - } else if (!Math_StepToF(&this->unk_2B8, 0.55f, 0.01375f)) { + 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) * (11.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1428,7 +1429,7 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); if (D_8089E3B0[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D4[D_8089E3B0[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_8089E3B0[limbIndex]]); } if ((limbIndex == 14) && (this->unk_292 != this->unk_290) && @@ -1460,7 +1461,7 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; - EffectSsDFire_Spawn(globalCtx, &this->unk_34C, &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); + EffectSsDFire_Spawn(globalCtx, &this->limbPos[10], &sp4C, &gZeroVec3f, 30, 22, 255 - (sp58 * 20), 20, 3, 8); this->unk_292 = this->unk_290; } } @@ -1495,8 +1496,8 @@ void EnDinofos_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, func_8089DC4C, func_8089DC84, &this->actor, POLY_XLU_DISP); } - func_800BE680(globalCtx, &this->actor, this->unk_2D4, 12, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_28A); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h index e6a00853e..f5c7431f0 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.h @@ -15,33 +15,28 @@ typedef struct EnDinofos { /* 0x284 */ EnDinofosActionFunc actionFunc; /* 0x288 */ u8 unk_288; /* 0x289 */ u8 unk_289; - /* 0x28A */ u8 unk_28A; + /* 0x28A */ u8 drawDmgEffType; /* 0x28B */ u8 unk_28B; /* 0x28C */ s16 unk_28C; /* 0x28E */ s16 unk_28E; /* 0x290 */ s16 unk_290; /* 0x292 */ s16 unk_292; /* 0x294 */ UNK_TYPE1 unk_294[4]; - /* 0x298 */ s16 camId; + /* 0x298 */ s16 subCamId; /* 0x29A */ Vec3s unk_29A; /* 0x2A0 */ s32 unk_2A0; /* 0x2A4 */ f32 unk_2A4; /* 0x2A8 */ f32 unk_2A8; /* 0x2AC */ f32 unk_2AC; - /* 0x2B0 */ f32 unk_2B0; - /* 0x2B4 */ f32 unk_2B4; - /* 0x2B8 */ f32 unk_2B8; + /* 0x2B0 */ f32 drawDmgEffAlpha; + /* 0x2B4 */ f32 drawDmgEffScale; + /* 0x2B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2BC */ Vec3f unk_2BC; /* 0x2C8 */ Vec3f unk_2C8; - /* 0x2D4 */ Vec3f unk_2D4[4]; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ UNK_TYPE1 unk_310[0x3C]; - /* 0x34C */ Vec3f unk_34C; - /* 0x358 */ UNK_TYPE1 unk_358[0xC]; + /* 0x2D4 */ Vec3f limbPos[12]; /* 0x364 */ ColliderJntSph colliderJntSph; /* 0x384 */ ColliderJntSphElement colliderJntSphElement[9]; /* 0x5C4 */ ColliderQuad colliderQuad; - } EnDinofos; // size = 0x644 extern const ActorInit En_Dinofos_InitVars; 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 05da2a9b4..d074753be 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 0x000000B0 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80) #define THIS ((EnDnb*)thisx) @@ -107,7 +107,7 @@ void EnDnb_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hanareyama_obj_Colheader_004D8C); - alloc = (s16*)Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); + alloc = Lib_SegmentedToVirtual(object_hanareyama_obj_Vec_004710); for (i = 0; i < ARRAY_COUNT(this->particles); i++) { func_80A4FDD0(&this->particles[i], this, alloc, i); } diff --git a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c index ecd6e8ffc..25fbaefac 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c @@ -6,7 +6,7 @@ #include "z_en_dnh.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnh*)thisx) 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 933381034..969c719fd 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -9,7 +9,7 @@ #include "objects/object_hintnuts/object_hintnuts.h" #include "objects/object_dekunuts/object_dekunuts.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnk*)thisx) @@ -93,25 +93,43 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnk_Anim_000B70, 1.0f, 0, -1, 2, 0 }, { &object_dnk_Anim_000B70, 1.0f, 0, -1, 2, -4 }, - { &object_dnk_Anim_002A08, 1.0f, 0, -1, 0, -4 }, { &object_dnk_Anim_00031C, 1.0f, 0, -1, 0, -4 }, - { &object_dnk_Anim_000430, 1.0f, -1, -1, 2, 0 }, { &object_dnk_Anim_000430, 1.0f, 0, -1, 2, -4 }, - { &object_dnk_Anim_000894, 1.0f, 0, -1, 2, -4 }, { &object_dnk_Anim_002B6C, 1.0f, 0, -1, 0, 0 }, - { &object_dnk_Anim_002B6C, 1.0f, 0, -1, 0, -4 }, { &object_dnk_Anim_0006CC, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_000168, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, 2, 0 }, - { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_0026C4, 1.0f, 0, -1, 2, -4 }, - { &object_hintnuts_Anim_002894, 1.0f, 0, -1, 2, -4 }, { &object_hintnuts_Anim_002B90, 1.0f, 0, -1, 2, -4 }, - { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, 0, 0 }, { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_003128, 1.0f, 0, -1, 0, 0 }, { &object_hintnuts_Anim_003128, 1.0f, 0, -1, 0, -4 }, - { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, 0, -4 }, { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, 0, -4 }, - { &object_dekunuts_Anim_000168, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, 2, 0 }, { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, 2, -4 }, { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_003180, 1.0f, 0, -1, 2, -4 }, - { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, 0, 0 }, { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, 0, -4 }, - { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_003780, 1.0f, 0, -1, 0, 0 }, - { &object_dekunuts_Anim_003780, 1.0f, 0, -1, 0, -4 }, { &object_dekunuts_Anim_002950, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWaitAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardAttackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardDigAnim, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPalaceGuardDigAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuPalaceGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPalaceGuardHappyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_0024CC, 1.0f, -1, -1, ANIMMODE_ONCE, 0 }, + { &object_hintnuts_Anim_0024CC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_0026C4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002894, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002B90, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hintnuts_Anim_002F7C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hintnuts_Anim_003128, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_0029BC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hintnuts_Anim_002E84, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_000168, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_00259C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dekunuts_Anim_002A5C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002BD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002DD4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_002FA4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_003180, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dekunuts_Anim_00326C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_0033E4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dekunuts_Anim_003780, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dekunuts_Anim_002950, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { @@ -124,14 +142,14 @@ s32 func_80A514F0(SkelAnime* skelAnime, s16 animIndex) { sp30 = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - frame = sAnimations[animIndex].frame; + frame = sAnimations[animIndex].startFrame; if (frame < 0) { frame = frameCount; } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - frame, frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, frame, + frameCount, sAnimations[animIndex].mode, sAnimations[animIndex].morphFrames); } } return sp30; @@ -152,7 +170,7 @@ s32 func_80A515C4(EnDnk* this) { } void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { - if (func_8013D8DC(this->unk_28E, globalCtx) == 1) { + if (SubS_IsObjectLoaded(this->unk_28E, globalCtx) == true) { gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->unk_28E].segment); this->actor.draw = func_80A52018; this->actor.objBankIndex = this->unk_28E; @@ -160,7 +178,7 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_0: - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dnk_Skel_002848, NULL, this->jointTable, + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, NULL, this->jointTable, this->morphTable, 11); func_80A514F0(&this->skelAnime, 7); break; @@ -182,12 +200,12 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENDNK_GET_3C(&this->actor) == 4) { - this->actor.flags &= ~1; - this->actor.flags |= (0x10 | 0x20); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actionFunc = func_80A51890; Actor_SetScale(&this->actor, 0.1f); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnDnk_DoNothing; Actor_SetScale(&this->actor, 0.01f); } @@ -195,8 +213,8 @@ void func_80A51648(EnDnk* this, GlobalContext* globalCtx) { } void func_80A51890(EnDnk* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x7E)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x7E)); + if (Cutscene_CheckActorAction(globalCtx, 126)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 126)); } } @@ -209,15 +227,15 @@ void EnDnk_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_28E = -1; switch (ENDNK_GET_3(&this->actor)) { case ENDNK_GET_3_1: - this->unk_28E = func_8013D924(0x12B, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_HINTNUTS, globalCtx); break; case ENDNK_GET_3_0: - this->unk_28E = func_8013D924(0x135, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DNK, globalCtx); break; case ENDNK_GET_3_2: - this->unk_28E = func_8013D924(0x40, globalCtx); + this->unk_28E = SubS_GetObjectIndex(OBJECT_DEKUNUTS, globalCtx); break; } @@ -308,9 +326,9 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* void func_80A51CB8(EnDnk* this, GlobalContext* globalCtx) { static TexturePtr D_80A5245C[] = { - object_dnk_Tex_001680, - object_dnk_Tex_001700, - object_dnk_Tex_001780, + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, }; s32 pad; 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 c15eac2a4..ceffe3d93 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_dno/object_dno.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDno*)thisx) @@ -40,19 +40,17 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx); s32 EnDno_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnDno_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); -extern u8 D_801C20C0; - -static struct_80B8E1A8 sAnimations[] = { - { &object_dno_Anim_000470, 1.0f, 2, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, 2, 0.0f }, - { &object_dno_Anim_000F6C, 1.0f, 0, 0.0f }, { &object_dno_Anim_001A50, 1.0f, 2, 0.0f }, - { &object_dno_Anim_002530, 1.0f, 2, 0.0f }, { &object_dno_Anim_003320, 1.0f, 2, 0.0f }, - { &object_dno_Anim_0036D0, 1.0f, 0, 0.0f }, { &object_dno_Anim_0041CC, 1.0f, 2, 0.0f }, - { &object_dno_Anim_004DD8, 1.0f, 2, 0.0f }, { &object_dno_Anim_005F98, 1.0f, 0, 0.0f }, - { &object_dno_Anim_006488, 1.0f, 2, 0.0f }, { &object_dno_Anim_0073E4, 1.0f, 0, 0.0f }, - { &object_dno_Anim_0077A8, 1.0f, 0, 0.0f }, { &object_dno_Anim_007CA4, 1.0f, 0, 0.0f }, - { &object_dno_Anim_008324, 1.0f, 0, 0.0f }, { &object_dno_Anim_008AE4, 1.0f, 2, 0.0f }, - { &object_dno_Anim_009100, 1.0f, 2, 0.0f }, { &object_dno_Anim_0051E4, 1.0f, 2, 0.0f }, - { &object_dno_Anim_005E20, 1.0f, 0, 0.0f }, { &object_dno_Anim_006F84, 1.0f, 0, 0.0f }, +static AnimationSpeedInfo sAnimations[] = { + { &object_dno_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_002530, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_003320, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_0036D0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_0041CC, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_004DD8, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_005F98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_006488, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0073E4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_0077A8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_007CA4, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_dno_Anim_008324, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_008AE4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_009100, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0051E4, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_dno_Anim_005E20, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_006F84, 1.0f, ANIMMODE_LOOP, 0.0f }, }; const ActorInit En_Dno_InitVars = { @@ -201,9 +199,9 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); Actor_UpdateBgCheckInfo(globalCtx, thisx, 0.0f, 0.0f, 0.0f, 4); - Animation_Change(&this->skelAnime, sAnimations[14].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[14].animationSeg), sAnimations[14].mode, - sAnimations[14].transitionRate); + Animation_Change(&this->skelAnime, sAnimations[14].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[14].animation), sAnimations[14].mode, + sAnimations[14].morphFrames); this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; @@ -216,7 +214,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { Actor_MarkForDeath(thisx); } else { - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); thisx->room = -1; gSaveContext.unk_3DD0[1] = 5; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); @@ -230,7 +228,7 @@ void EnDno_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[23] & 0x20) { Actor_MarkForDeath(thisx); } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); this->unk_460 = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { Actor_MarkForDeath(thisx); @@ -258,7 +256,7 @@ void EnDno_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A71B04(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 0; - func_8013E1C8(&this->skelAnime, sAnimations, 19, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 19, &this->unk_32C); this->actionFunc = EnDno_DoNothing; } @@ -271,14 +269,14 @@ void func_80A71B68(EnDno* this, GlobalContext* globalCtx) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { if (gSaveContext.save.weekEventReg[27] & 1) { if (!(this->unk_3B0 & 0x20)) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); } } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } } else { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } this->actionFunc = func_80A71C3C; } @@ -287,23 +285,23 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 9: case 16: - func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); break; case 3: case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } break; case 11: - func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); break; case 15: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); } case 6: @@ -334,19 +332,19 @@ void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { void func_80A71E54(EnDno* this, GlobalContext* globalCtx) { if (CHECK_QUEST_ITEM(QUEST_SONG_SONATA)) { if (gSaveContext.save.weekEventReg[27] & 1) { - this->unk_464 = 0x811; + this->textId = 0x811; } else { - this->unk_464 = 0x80F; + this->textId = 0x80F; gSaveContext.save.weekEventReg[27] |= 1; } } else if (gSaveContext.save.weekEventReg[26] & 0x80) { - this->unk_464 = 0x80B; + this->textId = 0x80B; } else { - this->unk_464 = 0x80C; + this->textId = 0x80C; gSaveContext.save.weekEventReg[26] |= 0x80; } - if (this->unk_464 != 0x811) { + if (this->textId != 0x811) { this->unk_3B0 |= 0x10; } else { this->unk_3B0 &= ~0x10; @@ -361,21 +359,21 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 0: if (!(this->unk_3B0 & 0x10) || Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xE38)) { - switch (this->unk_464) { + switch (this->textId) { case 0x80B: - func_8013E1C8(&this->skelAnime, sAnimations, 16, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); case 0x811: - func_801518B0(globalCtx, this->unk_464, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); break; case 0x80C: case 0x80F: if (this->unk_32C == 13) { - func_8013E1C8(&this->skelAnime, sAnimations, 4, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 4, &this->unk_32C); } else if ((this->unk_32C == 4) && (this->skelAnime.curFrame == this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 11, &this->unk_32C); - func_801518B0(globalCtx, this->unk_464, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 11, &this->unk_32C); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } break; } @@ -383,11 +381,11 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 3: - if (globalCtx->msgCtx.unk11F04 == 0x80B) { + if (globalCtx->msgCtx.currentTextId == 0x80B) { switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); } Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); @@ -396,7 +394,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); - func_8013E1C8(&this->skelAnime, sAnimations, 0xD, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); func_80A71B68(this, globalCtx); } break; @@ -407,18 +405,18 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x80B: switch (this->unk_32C) { case 16: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); } break; case 9: - if (func_80147624(globalCtx)) { - func_8013E1C8(&this->skelAnime, sAnimations, 10, &this->unk_32C); + if (Message_ShouldAdvance(globalCtx)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); globalCtx->msgCtx.msgMode = 0x44; } break; @@ -426,7 +424,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { case 10: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { func_801477B4(globalCtx); - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); func_80A71B68(this, globalCtx); } break; @@ -434,38 +432,38 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { break; case 0x80C: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80D); } break; case 0x80D: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x80E); } break; case 0x80E: if (this->unk_32C == 11) { - func_8013E1C8(&this->skelAnime, sAnimations, 3, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 3, &this->unk_32C); } else if (this->unk_32C == 3) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); } - } else if ((this->unk_32C == 13) && func_80147624(globalCtx)) { + } else if ((this->unk_32C == 13) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } break; case 0x80F: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x810); } break; case 0x810: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_3B0 |= 0x20; func_801477B4(globalCtx); func_80A71B68(this, globalCtx); @@ -474,19 +472,19 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { switch (this->unk_32C) { case 11: - func_8013E1C8(&this->skelAnime, sAnimations, 15, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); break; case 15: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_8013E1C8(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); } break; } break; case 0x811: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80A71B68(this, globalCtx); } @@ -498,7 +496,7 @@ void func_80A71F18(EnDno* this, GlobalContext* globalCtx) { void func_80A72438(EnDno* this, GlobalContext* globalCtx) { this->unk_452 = 1; - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); this->actor.textId = 0; if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { this->unk_454 = 1.0f; @@ -544,29 +542,29 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 0: if (this->unk_32C == 14) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); } } else if ((this->unk_32C == 5) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { - func_801518B0(globalCtx, 0x801, &this->actor); + Message_StartTextbox(globalCtx, 0x801, &this->actor); } else if (Player_GetMask(globalCtx) == PLAYER_MASK_SCENTS) { - func_801518B0(globalCtx, 0x806, &this->actor); + Message_StartTextbox(globalCtx, 0x806, &this->actor); } else { - func_801518B0(globalCtx, 0x800, &this->actor); + Message_StartTextbox(globalCtx, 0x800, &this->actor); } - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); } break; case 2: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { gSaveContext.save.weekEventReg[93] |= 2; - func_801518B0(globalCtx, 0x802, &this->actor); + Message_StartTextbox(globalCtx, 0x802, &this->actor); } break; case 3: - func_801518B0(globalCtx, 0x804, &this->actor); + Message_StartTextbox(globalCtx, 0x804, &this->actor); break; } break; @@ -574,7 +572,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 1: case 2: case 3: - if (((globalCtx->msgCtx.unk11F04 == 0x800) || (globalCtx->msgCtx.unk11F04 == 0x801)) && + if (((globalCtx->msgCtx.currentTextId == 0x800) || (globalCtx->msgCtx.currentTextId == 0x801)) && (this->unk_32C == 8)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { @@ -589,8 +587,8 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 12, &this->unk_32C); - func_801518B0(globalCtx, 0x803, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 12, &this->unk_32C); + Message_StartTextbox(globalCtx, 0x803, &this->actor); } } break; @@ -598,20 +596,20 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x800: case 0x801: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x44; this->unk_452 = 1; this->unk_454 = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 8, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 8, &this->unk_32C); } break; case 0x802: - if (func_80147624(globalCtx)) { - if (gSaveContext.save.inventory.items[D_801C20C0] == ITEM_MASK_SCENTS) { + if (Message_ShouldAdvance(globalCtx)) { + if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { this->unk_458 = GI_RUPEE_RED; } else { this->unk_458 = GI_MASK_SCENTS; @@ -623,15 +621,15 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x803: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80A72AE4(this, globalCtx); } break; case 0x804: if (this->unk_32C == 14) { - if (func_80147624(globalCtx)) { - func_8013E1C8(&this->skelAnime, sAnimations, 5, &this->unk_32C); + if (Message_ShouldAdvance(globalCtx)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); if (!(this->unk_3B0 & 0x40)) { func_80A72CF8(this, globalCtx); this->unk_3B0 |= 0x40; @@ -644,7 +642,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { break; case 0x806: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x800); } break; @@ -658,7 +656,7 @@ void func_80A725F8(EnDno* this, GlobalContext* globalCtx) { } void func_80A72AE4(EnDno* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); func_80A714B4(this, globalCtx); this->actionFunc = func_80A72B3C; } @@ -685,16 +683,16 @@ void func_80A72BA4(EnDno* this, GlobalContext* globalCtx) { } void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->unk_32C); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(8 | 1); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, - ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); - func_8013DF3C(globalCtx, &this->unk_340); + SubS_ActorPathing_Init(globalCtx, &this->unk_334, &this->actor, &this->actorPath, globalCtx->setupPathList, + ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + SubS_ActorPathing_ComputePointInfo(globalCtx, &this->actorPath); - this->actor.world.rot.y = this->unk_340.unk_54.y; - this->actor.world.rot.x = this->unk_340.unk_54.x; + this->actor.world.rot.y = this->actorPath.rotToCurPoint.y; + this->actor.world.rot.x = this->actorPath.rotToCurPoint.x; Flags_SetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; @@ -706,8 +704,8 @@ void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } -s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; +s32 EnDno_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; s32 pad; s32 ret = false; f32 sp38; @@ -715,52 +713,52 @@ s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 temp_v0_2; s32 sp2C; - actor->gravity = 0.0f; - temp_v0 = actor->yawTowardsPlayer - actor->world.rot.y; + thisx->gravity = 0.0f; + temp_v0 = thisx->yawTowardsPlayer - thisx->world.rot.y; if ((temp_v0 <= 0x4000) && (temp_v0 >= -0x4000)) { - Math_SmoothStepToF(&actor->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); } else { - if (actor->xzDistToPlayer <= 80.0f) { - Math_SmoothStepToF(&actor->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); - } else if (actor->xzDistToPlayer <= 360.0f) { - Math_SmoothStepToF(&actor->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); + if (thisx->xzDistToPlayer <= 80.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 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); } else { - Math_SmoothStepToF(&actor->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); } } - if (arg1->unk_50 < SQ(actor->speedXZ)) { + if (actorPath->distSqToCurPoint < SQ(thisx->speedXZ)) { ret = true; } else { - sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); - sp2C = ABS(arg1->unk_54.x - actor->world.rot.x); + sp38 = thisx->speedXZ / sqrtf(actorPath->distSqToCurPointXZ); + sp2C = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; temp_v0_2 += 0x71C; - sp2C = ABS(arg1->unk_54.y - actor->world.rot.y); + sp2C = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54.x, temp_v0_2); - Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_54.y, (s32)(sp2C * sp38) + 0x71C); + Math_ScaledStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, temp_v0_2); + Math_ScaledStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, (s32)(sp2C * sp38) + 0x71C); } return ret; } -s32 func_80A72FAC(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; - EnDno* dno = (EnDno*)actor; - f32 sp24 = Math_CosS(-actor->world.rot.x) * actor->speedXZ; +s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnDno* this = (EnDno*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; f32 sp20 = gFramerateDivisorHalf; - actor->velocity.x = Math_SinS(actor->world.rot.y) * sp24; - actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * sp24; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - dno->unk_334.x += (dno->actor.velocity.x * sp20) + dno->actor.colChkInfo.displacement.x; - dno->unk_334.y += (dno->actor.velocity.y * sp20) + dno->actor.colChkInfo.displacement.y; - dno->unk_334.z += (dno->actor.velocity.z * sp20) + dno->actor.colChkInfo.displacement.z; + this->unk_334.x += (this->actor.velocity.x * sp20) + this->actor.colChkInfo.displacement.x; + this->unk_334.y += (this->actor.velocity.y * sp20) + this->actor.colChkInfo.displacement.y; + this->unk_334.z += (this->actor.velocity.z * sp20) + this->actor.colChkInfo.displacement.z; - return 0; + return false; } void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { @@ -784,15 +782,17 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } if (phi_a2 >= 0) { - func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } - func_8013DE04(globalCtx, &this->unk_340, func_8013DF3C, func_80A72D8C, func_80A72FAC, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnDno_ActorPathing_UpdateActorInfo, EnDno_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); this->unk_45C += 6553; - this->unk_340.unk_2C.x = 0.0f; - this->unk_340.unk_2C.y = 0.0f; - this->unk_340.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); this->actor.world.pos.y += temp_f10; @@ -800,9 +800,9 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->unk_3AE += 1000; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; func_80A715DC(this, globalCtx); - func_800B9010(&this->actor, 0x2153); - if (this->unk_340.unk_1C & 0x20) { - Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_340.unk_20); + 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.velocity.x = 0.0f; this->actor.velocity.y = 0.0f; @@ -812,8 +812,8 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } void func_80A73244(EnDno* this, GlobalContext* globalCtx) { - this->actor.flags &= ~0x8000000; - this->actor.flags |= (8 | 1); + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->unk_328 = 2; this->actor.speedXZ = 0.0f; Flags_UnsetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); @@ -829,11 +829,11 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { if (Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C)) { this->unk_3B0 |= 4; this->unk_44E = 3; - func_8013E1C8(&this->skelAnime, sAnimations, 7, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 7, &this->unk_32C); } } else if (this->unk_44E == 3) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); func_80A72438(this, globalCtx); } else { if (this->skelAnime.curFrame >= 20.0f) { @@ -854,12 +854,12 @@ void func_80A732C8(EnDno* this, GlobalContext* globalCtx) { void func_80A73408(EnDno* this, GlobalContext* globalCtx) { s32 phi_a2; u8 sp33 = true; - u32 temp_v0; + s32 temp_v0; - if (func_800EE29C(globalCtx, 0x1DB)) { - temp_v0 = func_800EE200(globalCtx, 0x1DB); - if (this->unk_468 != globalCtx->csCtx.npcActions[temp_v0]->unk0) { - switch (globalCtx->csCtx.npcActions[temp_v0]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 475)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 475); + if (this->unk_468 != globalCtx->csCtx.actorActions[temp_v0]->action) { + switch (globalCtx->csCtx.actorActions[temp_v0]->action) { case 1: phi_a2 = 13; break; @@ -875,15 +875,15 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { } if (sp33) { - func_8013E1C8(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); } } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_32C == 17)) { if (0) {}; - func_8013E1C8(&this->skelAnime, sAnimations, 18, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 18, &this->unk_32C); } } 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 ed9ee52c6..dcffee6c9 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -34,7 +34,7 @@ typedef struct EnDno { /* 0x32C */ s32 unk_32C; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; - /* 0x340 */ struct_8013DF3C_arg1 unk_340; + /* 0x340 */ ActorPathing actorPath; /* 0x3AC */ s16 unk_3AC; /* 0x3AE */ s16 unk_3AE; /* 0x3B0 */ u16 unk_3B0; @@ -51,7 +51,7 @@ typedef struct EnDno { /* 0x458 */ s32 unk_458; /* 0x45C */ s16 unk_45C; /* 0x460 */ Actor* unk_460; - /* 0x464 */ u16 unk_464; + /* 0x464 */ u16 textId; /* 0x466 */ s16 unk_466; /* 0x468 */ u8 unk_468; } EnDno; // size = 0x46C 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 aae33de71..27bd5e359 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -7,7 +7,7 @@ #include "z_en_dnp.h" #include "objects/object_dnp/object_dnp.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnDnp*)thisx) @@ -56,20 +56,33 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnp_Anim_0007D8, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_0021DC, 1.0f, 0, -1, 0, 0 }, - { &object_dnp_Anim_0021DC, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_0026B8, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_004D08, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_0071F4, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_007960, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_008588, 1.0f, 0, -1, 2, 0 }, - { &object_dnp_Anim_00A900, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00AEB8, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_00B754, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_00674C, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_00BAD8, 1.0f, 0, -1, 2, -4 }, { &object_dnp_Anim_006B74, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_012428, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00B324, 1.0f, 0, -1, 0, 0 }, - { &object_dnp_Anim_00B324, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_0115B8, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_0115B8, 1.0f, 0, -1, 0, 0 }, { &object_dnp_Anim_00923C, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_009AA0, 1.0f, 0, -1, 0, -4 }, { &object_dnp_Anim_00125C, 1.0f, 0, -1, 2, -4 }, - { &object_dnp_Anim_0017F8, 1.0f, 0, -1, 2, 0 }, { &object_dnp_Anim_001C1C, 1.0f, 0, -1, 0, -4 }, - { &object_dnp_Anim_0057AC, 1.0f, 0, -1, 2, 0 }, { &object_dnp_Anim_00625C, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_dnp_Anim_0007D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0026B8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_004D08, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0071F4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_007960, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_008588, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_00A900, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00AEB8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00B754, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_00674C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00BAD8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_006B74, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_012428, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnp_Anim_00923C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_009AA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_00125C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnp_Anim_0017F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_001C1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnp_Anim_0057AC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnp_Anim_00625C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; static s32 D_80B3DE58[] = { @@ -122,7 +135,7 @@ s32 func_80B3CC38(EnDnp* this, s32 arg1) { if (arg1 != this->unk_340) { this->unk_340 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); } return ret; @@ -189,12 +202,12 @@ s32 func_80B3CF60(EnDnp* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_322 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 |= 8; this->actionFunc = func_80B3D3F8; ret = true; } else if (!(gSaveContext.save.weekEventReg[23] & 0x20) && Actor_HasParent(&this->actor, globalCtx)) { - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 &= ~0x500; this->actor.parent = NULL; this->unk_32E = 0; @@ -211,15 +224,15 @@ s32 func_80B3D044(EnDnp* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_322 & 0x200)) { this->unk_322 |= (0x200 | 0x10); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_324 = 0xFF; } - func_8013AED4(&this->unk_322, 0, 7); + SubS_UpdateFlags(&this->unk_322, 0, 7); this->actionFunc = func_80B3D11C; ret = true; } else if (this->unk_322 & 0x200) { - this->actor.flags |= 1; - func_8013AED4(&this->unk_322, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~(0x200 | 0x10); this->actionFunc = func_80B3D2D4; } @@ -231,18 +244,18 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { static s32 D_80B3DE74[] = { 0, 16, 14, 10, 18, 12, 5, 7, 2, 19, 21, 22, 24, 8, }; - u32 temp_v0; + s32 temp_v0; s32 val; if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; gSaveContext.save.weekEventReg[29] |= 0x40; } - if (func_800EE29C(globalCtx, 0x65)) { - temp_v0 = func_800EE200(globalCtx, 0x65); - val = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 101)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 101); + val = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_324 != (u8)val) { func_80B3CC38(this, D_80B3DE74[val]); if (this->unk_340 == 16) { @@ -268,7 +281,7 @@ void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { func_80B3CC38(this, this->unk_340 + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } @@ -298,7 +311,7 @@ void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) { void func_80B3D3F8(EnDnp* this, GlobalContext* globalCtx) { if (func_8010BF58(&this->actor, globalCtx, D_80B3DE58, NULL, &this->unk_328)) { - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~8; this->actionFunc = func_80B3D2D4; } else { @@ -310,8 +323,8 @@ void func_80B3D47C(EnDnp* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { 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 |= 1; - func_8013AED4(&this->unk_322, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 &= ~0x10; this->unk_322 |= 0x400; this->actor.scale.x = 0.0085f; @@ -345,9 +358,9 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_322 |= (0x100 | 0x80 | 0x10); this->actor.gravity = -1.0f; if (ENDNP_GET_7(&this->actor) == ENDNP_GET_7_1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.00085000007f); - func_8013AED4(&this->unk_322, 0, 7); + 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; @@ -356,7 +369,7 @@ void EnDnp_Init(Actor* thisx, GlobalContext* globalCtx) { !(gSaveContext.save.weekEventReg[23] & 0x20)) || ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.save.weekEventReg[23] & 0x20))) { Actor_SetScale(&this->actor, 0.0085f); - func_8013AED4(&this->unk_322, 3, 7); + SubS_UpdateFlags(&this->unk_322, 3, 7); this->unk_322 |= 0x400; if ((globalCtx->sceneNum == SCENE_MITURIN) && (gSaveContext.save.weekEventReg[29] & 0x40)) { this->unk_322 |= 0x20; 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 31d98007f..d2a29442d 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -7,7 +7,7 @@ #include "z_en_dnq.h" #include "objects/object_dnq/object_dnq.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDnq*)thisx) @@ -57,17 +57,27 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80A5349C[] = { - { &object_dnq_Anim_008328, 1.0f, 0, -1, 0, 0 }, { &object_dnq_Anim_008328, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_007528, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_0006F0, 1.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_000BF8, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_002690, 0.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_002690, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_003408, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_006984, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_005E18, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, 2, -4 }, { &object_dnq_Anim_005284, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_001AEC, 1.0f, 0, -1, 2, 0 }, { &object_dnq_Anim_001100, 1.0f, 0, -1, 2, 0 }, - { &object_dnq_Anim_004EA0, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_00F504, 1.0f, 0, -1, 0, -4 }, - { &object_dnq_Anim_0047B8, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_003DBC, 1.0f, 0, -1, 2, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, 0, -4 }, { &object_dnq_Anim_003DBC, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS D_80A5349C[] = { + { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_007528, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_0006F0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_000BF8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_002690, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_002690, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_003408, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_006984, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005E18, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005284, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_001AEC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_001100, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnq_Anim_004EA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_00F504, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_0047B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; void func_80A52530(GlobalContext* globalCtx, EnDnq* this) { @@ -94,7 +104,7 @@ s32 func_80A5257C(EnDnq* this, s32 arg1) { if (phi_v1) { this->unk_398 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80A5349C, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A5349C, arg1); } return ret; @@ -110,18 +120,18 @@ s32 func_80A52648(EnDnq* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_37C & 0x20)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C |= 0x20; } - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); ret = true; } else { if (this->unk_37C & 0x20) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1DC = 0xFF; this->unk_37C &= ~0x20; - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); } } @@ -244,7 +254,7 @@ s32 func_80A52A78(EnDnq* this, GlobalContext* globalCtx) { s32 func_80A52B68(EnDnq* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; if ((player->stateFlags1 & 0x40) && (player->targetActor == &this->actor)) { switch (temp) { @@ -311,7 +321,7 @@ s32 func_80A52D44(EnDnq* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_37C & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); this->unk_380 = func_80A52CF8(this, globalCtx); this->actionFunc = func_80A52FB8; ret = true; @@ -325,17 +335,17 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { s16 yaw = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if (yaw <= 0x3800) { - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); } else { - func_8013AED4(&this->unk_37C, 0, 7); + SubS_UpdateFlags(&this->unk_37C, 0, 7); } if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { this->unk_390 = 70.0f; - if (Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !func_801690CC(globalCtx) && + if (Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(globalCtx) && (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { - func_801518B0(globalCtx, 0x969, NULL); + Message_StartTextbox(globalCtx, 0x969, NULL); this->unk_384 = 200; } } @@ -366,7 +376,7 @@ void func_80A52FB8(EnDnq* this, GlobalContext* globalCtx) { s16 sp2E = this->actor.yawTowardsPlayer; if (func_8010BF58(&this->actor, globalCtx, this->unk_380, NULL, &this->unk_1E0)) { - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); this->unk_386 = 0; this->actionFunc = func_80A52DC8; } else { @@ -378,12 +388,12 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { static s32 D_80A535FC[] = { 0, 1, 2, 3, 5, 6, }; - u32 temp_v0; + s32 temp_v0; u32 temp_v1; - if (func_800EE29C(globalCtx, 0x69)) { - temp_v0 = func_800EE200(globalCtx, 0x69); - temp_v1 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 105)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 105); + temp_v1 = globalCtx->csCtx.actorActions[temp_v0]->action; if (this->unk_1DC != (u8)temp_v1) { func_80A5257C(this, D_80A535FC[temp_v1]); this->unk_1DC = temp_v1; @@ -398,7 +408,7 @@ void func_80A53038(EnDnq* this, GlobalContext* globalCtx) { func_80A5257C(this, this->unk_398 + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } @@ -416,7 +426,7 @@ void EnDnq_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; this->unk_386 = 0; this->unk_37C = 0; - func_8013AED4(&this->unk_37C, 3, 7); + SubS_UpdateFlags(&this->unk_37C, 3, 7); if (gSaveContext.save.weekEventReg[9] & 0x80) { this->unk_3A4 = 1; } else { 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 213a402af..e2c07cce7 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -5,9 +5,8 @@ */ #include "z_en_dns.h" -#include "objects/object_dns/object_dns.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnDns*)thisx) @@ -20,6 +19,20 @@ void func_8092D330(EnDns* this, GlobalContext* globalCtx); void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx); void func_8092D4D8(EnDns* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ EN_DNS_ANIMATION_IDLE_1, + /* 1 */ EN_DNS_ANIMATION_IDLE_2, + /* 2 */ EN_DNS_ANIMATION_WALK_1, + /* 3 */ EN_DNS_ANIMATION_WALK_2, + /* 4 */ EN_DNS_ANIMATION_SURPRISE_START, + /* 5 */ EN_DNS_ANIMATION_SURPRISE_LOOP, + /* 6 */ EN_DNS_ANIMATION_RUN_START, + /* 7 */ EN_DNS_ANIMATION_RUN_LOOP, + /* 8 */ EN_DNS_ANIMATION_DANCE, + /* 9 */ EN_DNS_ANIMATION_FLIP, + /* 10 */ EN_DNS_ANIMATION_MAX, +} EnDnsAnimationIndex; + static s32 D_8092DCB0[] = { 0x00172000, 0x050E082F, 0x0C100E08, 0x200C1000, 0x00172000, 0x050E0830, 0x0C100E08, 0x210C1000, 0x00172000, 0x050E0831, 0x0C100E08, 0x220C1000, 0x00172000, 0x050E0832, 0x0C100E08, 0x230C1000, @@ -60,18 +73,24 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dns_Anim_003310, 1.0f, 0, -1, 0, 0 }, { &object_dns_Anim_003310, 1.0f, 0, -1, 0, -4 }, - { &object_dns_Anim_0034EC, 1.0f, 0, -1, 0, 0 }, { &object_dns_Anim_0034EC, 1.0f, 0, -1, 0, -4 }, - { &object_dns_Anim_0008F4, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000BD8, 1.0f, 0, -1, 0, 0 }, - { &object_dns_Anim_000D58, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000FEC, 1.0f, 0, -1, 0, 0 }, - { &object_dns_Anim_0002A8, 1.0f, 0, -1, 2, 0 }, { &object_dns_Anim_000734, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKingsChamberDekuGuardSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardRunStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardRunLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKingsChamberDekuGuardDanceAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKingsChamberDekuGuardFlipAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; void func_8092C5C0(EnDns* this) { s32 pad; - if (((this->unk_2F8 == 2) || (this->unk_2F8 == 3) || (this->unk_2F8 == 6) || (this->unk_2F8 == 7)) && + if (((this->animationIndex == EN_DNS_ANIMATION_WALK_1) || (this->animationIndex == EN_DNS_ANIMATION_WALK_2) || + (this->animationIndex == EN_DNS_ANIMATION_RUN_START) || (this->animationIndex == EN_DNS_ANIMATION_RUN_LOOP)) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 3.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); } @@ -79,32 +98,34 @@ void func_8092C5C0(EnDns* this) { s32 func_8092C63C(EnDns* this, s32 arg1) { s32 phi_v1 = false; - s32 ret = 0; + s32 ret = false; switch (arg1) { - case 0: - case 1: - if ((this->unk_2F8 != 0) && (this->unk_2F8 != 1)) { + case EN_DNS_ANIMATION_IDLE_1: + case EN_DNS_ANIMATION_IDLE_2: + if ((this->animationIndex != EN_DNS_ANIMATION_IDLE_1) && + (this->animationIndex != EN_DNS_ANIMATION_IDLE_2)) { phi_v1 = true; } break; - case 2: - case 3: - if ((this->unk_2F8 != 2) && (this->unk_2F8 != 3)) { + case EN_DNS_ANIMATION_WALK_1: + case EN_DNS_ANIMATION_WALK_2: + if ((this->animationIndex != EN_DNS_ANIMATION_WALK_1) && + (this->animationIndex != EN_DNS_ANIMATION_WALK_2)) { phi_v1 = true; } break; default: - if (this->unk_2F8 != arg1) { + if (this->animationIndex != arg1) { phi_v1 = true; } } if (phi_v1) { - this->unk_2F8 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + this->animationIndex = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); } return ret; @@ -149,11 +170,11 @@ void func_8092C86C(EnDns* this, GlobalContext* globalCtx) { } void func_8092C934(EnDns* this) { - if ((this->unk_2C6 & 0x40) && (DECR(this->unk_2DE) == 0)) { - this->unk_2E0++; - if (this->unk_2E0 >= 4) { - this->unk_2DE = Rand_S16Offset(30, 30); - this->unk_2E0 = 0; + if ((this->unk_2C6 & 0x40) && (DECR(this->blinkTimer) == 0)) { + this->eyeIndex++; + if (this->eyeIndex >= 4) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeIndex = 0; } } } @@ -189,16 +210,16 @@ s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) { s32 func_8092CA74(EnDns* this) { switch (ENDNS_GET_7(&this->actor)) { case ENDNS_GET_7_0: - return 0x1D1; + return 465; case ENDNS_GET_7_1: - return 0x1D2; + return 466; case ENDNS_GET_7_2: - return 0x1D3; + return 467; case ENDNS_GET_7_3: - return 0x1D4; + return 468; } return 0; @@ -209,13 +230,13 @@ s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) { if (this->unk_2C6 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_2C6, 0, 7); + SubS_UpdateFlags(&this->unk_2C6, 0, 7); this->unk_2C6 &= ~0x10; if (ENDNS_GET_4000(&this->actor)) { this->unk_2F0 = 0.0f; if (this->unk_2D2 != 0) { this->unk_2F0 = this->skelAnime.curFrame; - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); } this->unk_2DA = this->actor.world.rot.y; } @@ -233,15 +254,15 @@ s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) { if (globalCtx->csCtx.state != 0) { if (!(this->unk_2C6 & 0x80)) { this->unk_2C8 = func_8092CA74(this); - this->actor.flags &= ~0x1; - func_8013AED4(&this->unk_2C6, 0, 7); + this->actor.flags &= ~ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_2C6, 0, 7); this->unk_2C6 |= 0x80; this->unk_1D8 = 0xFF; } phi_v1 = 1; } else if (this->unk_2C6 & 0x80) { - this->actor.flags |= 1; - func_8013AED4(&this->unk_2C6, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 &= ~0x80; } return phi_v1; @@ -253,7 +274,7 @@ s32 func_8092CC68(GlobalContext* globalCtx) { s32 ret = false; s16 bgId; - if (!func_801690CC(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { + if (!Play_InCsMode(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) { bgId = player->actor.floorBgId; if (SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) { ret = true; @@ -285,7 +306,7 @@ s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) { } s32 func_8092CE38(EnDns* this) { - static s32 D_8092DE00[] = { 8, 8, 9 }; + static s32 D_8092DE00[] = { EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_DANCE, EN_DNS_ANIMATION_FLIP }; s16 frame; s32 pad; Vec3f sp2C; @@ -364,7 +385,7 @@ void func_8092D108(EnDns* this, GlobalContext* globalCtx) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_dns_DL_002C48); + gSPDisplayList(POLY_OPA_DISP++, gKingsChamberDekuGuardDekuFlower); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -382,15 +403,15 @@ void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) { func_8092CC68(globalCtx)) { player->stateFlags1 |= 0x20; this->unk_2C6 |= 0x100; - func_8013AED4(&this->unk_2C6, 4, 7); + SubS_UpdateFlags(&this->unk_2C6, 4, 7); play_sound(NA_SE_SY_FOUND); gSaveContext.eventInf[1] |= 0x20; this->unk_2F4 = func_8092CCEC; - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); this->actionFunc = EnDns_DoNothing; } else if (gSaveContext.eventInf[1] & 0x40) { func_8092CCEC(this, globalCtx); - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); this->actionFunc = func_8092D330; } Math_ApproachS(&this->actor.shape.rot.y, sp22, 3, 0x2AA8); @@ -432,16 +453,16 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { if (ENDNS_GET_4000(&this->actor) && (this->unk_2D2 == 0)) { if (func_8092CE38(this)) { - func_8092C63C(this, 2); + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); } } else if (func_8010BF58(&this->actor, globalCtx, this->unk_1E0, this->unk_2F4, &this->unk_1DC)) { - func_8013AED4(&this->unk_2C6, 3, 7); + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2F4 = NULL; if (ENDNS_GET_4000(&this->actor)) { if (!(gSaveContext.eventInf[1] & 0x20)) { this->skelAnime.curFrame = this->unk_2F0; this->actor.world.rot.y = this->unk_2DA; - func_8092C63C(this, 8); + func_8092C63C(this, EN_DNS_ANIMATION_DANCE); } this->unk_2CC = 0; this->unk_2CE = 0; @@ -454,24 +475,30 @@ void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) { } void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) { - static s32 D_8092DE0C[] = { 0, 0, 4, 6 }; - u32 temp_v0; + static s32 D_8092DE0C[] = { + EN_DNS_ANIMATION_IDLE_1, + EN_DNS_ANIMATION_IDLE_1, + EN_DNS_ANIMATION_SURPRISE_START, + EN_DNS_ANIMATION_RUN_START, + }; + s32 temp_v0; u32 temp_v1; - if (func_800EE29C(globalCtx, this->unk_2C8)) { - temp_v0 = func_800EE200(globalCtx, this->unk_2C8); - temp_v1 = globalCtx->csCtx.npcActions[temp_v0]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->unk_2C8)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, this->unk_2C8); + temp_v1 = globalCtx->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 (((this->unk_2F8 == 4) || (this->unk_2F8 == 6)) && + if (((this->animationIndex == EN_DNS_ANIMATION_SURPRISE_START) || + (this->animationIndex == EN_DNS_ANIMATION_RUN_START)) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8092C63C(this, this->unk_2F8 + 1); + func_8092C63C(this, this->animationIndex + 1); } - func_800EDF24(&this->actor, globalCtx, temp_v0); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, temp_v0); } } @@ -484,9 +511,10 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &object_dns_Skel_002DD8, NULL, this->jointTable, this->morphTable, 13); - this->unk_2F8 = -1; - func_8092C63C(this, 2); + SkelAnime_Init(globalCtx, &this->skelAnime, &gKingsChamberDekuGuardSkel, NULL, this->jointTable, this->morphTable, + KINGS_CHAMBER_DEKU_GUARD_LIMB_MAX); + this->animationIndex = -1; + func_8092C63C(this, EN_DNS_ANIMATION_WALK_1); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); @@ -494,7 +522,7 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -0.8f; this->unk_2D2 = 0; this->unk_2C6 = 0; - func_8013AED4(&this->unk_2C6, 3, 7); + SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 |= (0x40 | 0x10); this->unk_2C6 |= 0x200; if (gSaveContext.save.weekEventReg[9] & 0x80) { @@ -586,7 +614,7 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } - if (limbIndex == 2) { + if (limbIndex == KINGS_CHAMBER_DEKU_GUARD_LIMB_HEAD) { func_8092D954(this->unk_2CC, this->unk_2CE + this->actor.shape.rot.y, &this->unk_218, &this->unk_224, phi_v1, phi_v0); Matrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW); @@ -605,15 +633,19 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_8092DE1C[] = { object_dns_Tex_0028E8, object_dns_Tex_002968, object_dns_Tex_0029E8, - object_dns_Tex_002968 }; + static TexturePtr sEyeTextures[] = { + gKingsChamberDekuGuardEyeOpenTex, + gKingsChamberDekuGuardEyeHalfTex, + gKingsChamberDekuGuardEyeClosedTex, + gKingsChamberDekuGuardEyeHalfTex, + }; EnDns* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_8092DE1C[this->unk_2E0])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); gDPPipeSync(POLY_OPA_DISP++); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDns_OverrideLimbDraw, 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 598dfff3b..257717502 100644 --- a/src/overlays/actors/ovl_En_Dns/z_en_dns.h +++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.h @@ -2,6 +2,7 @@ #define Z_EN_DNS_H #include "global.h" +#include "objects/object_dns/object_dns.h" struct EnDns; @@ -31,8 +32,8 @@ typedef struct EnDns { /* 0x1E4 */ Gfx* unk_1E4[13]; /* 0x218 */ Vec3f unk_218; /* 0x224 */ Vec3s unk_224; - /* 0x22A */ Vec3s jointTable[13]; - /* 0x278 */ Vec3s morphTable[13]; + /* 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; /* 0x2CA */ UNK_TYPE1 unk_2CA[0x2]; @@ -45,14 +46,14 @@ typedef struct EnDns { /* 0x2D8 */ s16 unk_2D8; /* 0x2DA */ s16 unk_2DA; /* 0x2DC */ s16 unk_2DC; - /* 0x2DE */ s16 unk_2DE; - /* 0x2E0 */ s16 unk_2E0; + /* 0x2DE */ s16 blinkTimer; + /* 0x2E0 */ s16 eyeIndex; /* 0x2E4 */ f32 unk_2E4; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x4]; /* 0x2EC */ f32 unk_2EC; /* 0x2F0 */ f32 unk_2F0; /* 0x2F4 */ EnDnsFunc unk_2F4; - /* 0x2F8 */ s32 unk_2F8; + /* 0x2F8 */ s32 animationIndex; /* 0x2FC */ s32 unk_2FC; } EnDns; // size = 0x300 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 6b198106b..20a44c01d 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" #include "objects/object_dodongo/object_dodongo.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnDodongo*)thisx) @@ -399,13 +399,13 @@ void func_80876B08(EnDodongo* this, GlobalContext* globalCtx) { void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_300 = 0; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_300 = 20; - this->unk_340 = 0.75f; - this->unk_33C = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider1.elements[arg2].info.bumper.hitPos.x, this->collider1.elements[arg2].info.bumper.hitPos.y, @@ -414,26 +414,26 @@ void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { } void func_80876CAC(EnDodongo* this) { - this->unk_300 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; - this->unk_340 = 0.75f; - this->unk_344 = 1.125f; - this->unk_33C = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; this->timer = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { - if (this->unk_300 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->timer = 0; this->actor.colorFilterTimer = 0; - this->unk_300 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; - this->unk_33C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -448,7 +448,7 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { f32 temp_f22; f32 temp_f20; - Math_Vec3f_Copy(&sp68, &this->unk_348[0]); + Math_Vec3f_Copy(&sp68, &this->limbPos[0]); sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; temp_f20 = Math_CosS(sp66); temp_f22 = Math_SinS(sp66); @@ -496,8 +496,8 @@ void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f22 * this->unk_334; func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); - sp68.x = this->unk_348[0].x + (temp_f20 * 6.0f * this->unk_334); - sp68.z = this->unk_348[0].z - (temp_f22 * 6.0f * this->unk_334); + sp68.x = this->limbPos[0].x + (temp_f20 * 6.0f * this->unk_334); + sp68.z = this->limbPos[0].z - (temp_f22 * 6.0f * this->unk_334); sp80.x *= -1.0f; sp80.z = sp80.z * -1.0f; sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; @@ -622,9 +622,9 @@ void func_808777A8(EnDodongo* this) { for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { sph = &this->collider3.elements[i].dim.worldSphere; - sph->center.x = this->unk_348[0].x; - sph->center.y = this->unk_348[0].y; - sph->center.z = this->unk_348[0].z; + sph->center.x = this->limbPos[0].x; + sph->center.y = this->limbPos[0].y; + sph->center.z = this->limbPos[0].z; sph->radius = 0; } @@ -658,10 +658,10 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { temp_f12 = Math_CosS(this->actor.shape.rot.y) * this->unk_334; for (i = 0; i < end; i++, element++) { - element->dim.worldSphere.center.x = this->unk_348[0].x + (element->dim.modelSphere.center.z * temp_f2); + element->dim.worldSphere.center.x = this->limbPos[0].x + (element->dim.modelSphere.center.z * temp_f2); element->dim.worldSphere.center.y = - this->unk_348[0].y + (element->dim.modelSphere.center.y * this->unk_334); - element->dim.worldSphere.center.z = this->unk_348[0].z + (element->dim.modelSphere.center.z * temp_f12); + this->limbPos[0].y + (element->dim.modelSphere.center.y * this->unk_334); + element->dim.worldSphere.center.z = this->limbPos[0].z + (element->dim.modelSphere.center.z * temp_f12); element->dim.worldSphere.radius = element->dim.modelSphere.radius; } @@ -669,7 +669,7 @@ void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { D_80879348.x = 2.5f * temp_f2; D_80879348.y = this->unk_334 * 1.4f; D_80879348.z = 2.5f * temp_f12; - EffectSsDFire_Spawn(globalCtx, &this->unk_348[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, + EffectSsDFire_Spawn(globalCtx, &this->limbPos[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, this->unk_334 * 35.0f, 0xFF - (frame * 10), 5, 0, 8); } else if ((this->skelAnime.curFrame >= 2.0f) && (this->skelAnime.curFrame <= 20.0f)) { func_800B9010(&this->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); @@ -694,7 +694,7 @@ void func_80877D90(EnDodongo* this, GlobalContext* globalCtx) { void func_80877DE0(EnDodongo* this) { Animation_Change(&this->skelAnime, &object_dodongo_Anim_0028F0, -1.0f, 35.0f, 0.0f, 2, -4.0f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->timer = 25; this->actionFunc = func_80877E60; this->actor.speedXZ = 0.0f; @@ -734,7 +734,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { Actor_MarkForDeath(this->actor.child); this->actor.child = NULL; } - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; } else if (this->skelAnime.playSpeed > -0.5f) { this->timer--; if (this->timer == 10) { @@ -772,13 +772,13 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { } else { sp5E = this->unk_334 * 50.0f; sp5C = this->unk_334 * 5.0f; - Math_Vec3f_Copy(&sp64, &this->unk_348[0]); + Math_Vec3f_Copy(&sp64, &this->limbPos[0]); func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); sp64.x -= Math_CosS(this->actor.shape.rot.y) * 6.0f * this->unk_334; sp64.z += Math_SinS(this->actor.shape.rot.y) * 6.0f * this->unk_334; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); - sp64.x = (2.0f * this->unk_348[0].x) - sp64.x; - sp64.z = (2.0f * this->unk_348[0].z) - sp64.z; + sp64.x = (2.0f * this->limbPos[0].x) - sp64.x; + sp64.z = (2.0f * this->limbPos[0].z) - sp64.z; func_800B0DE0(globalCtx, &sp64, &gZeroVec3f, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); } } @@ -845,7 +845,7 @@ void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { sp20.z = this->collider1Elements[2].dim.worldSphere.center.z; func_80876930(this, globalCtx, &sp20); CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; } void func_80878594(EnDodongo* this) { @@ -895,7 +895,7 @@ void func_80878724(EnDodongo* this) { this->timer = 0; this->unk_304 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->actionFunc = func_808787B0; @@ -953,7 +953,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider2Elements)) && - ((this->unk_300 != 10) || !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); Math_Vec3s_ToVec3f(&sp3C, &this->collider2.elements[i].info.bumper.hitPos); if (this->actor.colChkInfo.damageEffect == 0xF) { @@ -976,7 +977,8 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { } if ((i != ARRAY_COUNT(this->collider1Elements)) && - ((this->unk_300 != 10) || !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_80876D28(this, globalCtx); if (this->actor.colChkInfo.damageEffect != 0xF) { if (!Actor_ApplyDamage(&this->actor)) { @@ -1000,9 +1002,9 @@ void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { this->timer = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_300 = 30; - this->unk_340 = 0.75f; - this->unk_33C = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; func_80878594(this); } else if (this->actor.colChkInfo.damageEffect == 3) { func_80876CAC(this); @@ -1043,12 +1045,12 @@ void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); } - if (this->unk_33C > 0.0f) { - if (this->unk_300 != 10) { - Math_StepToF(&this->unk_33C, 0.0f, 0.05f); - this->unk_340 = (this->unk_33C + 1.0f) * 0.375f; - this->unk_340 = (this->unk_340 > 0.75f) ? 0.75f : this->unk_340; - } else if (!Math_StepToF(&this->unk_344, 0.75f, 0.01875f)) { + 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 = (this->drawDmgEffScale > 0.75f) ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1079,20 +1081,20 @@ void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Collider_UpdateSpheres(limbIndex, &this->collider1); Collider_UpdateSpheres(limbIndex, &this->collider2); if (D_80879388[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_348[D_80879388[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80879388[limbIndex]]); } if (limbIndex == 7) { Matrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); - Matrix_MultiplyVector3fByState(&D_8087937C, &this->unk_348[0]); + Matrix_MultiplyVector3fByState(&D_8087937C, &this->limbPos[0]); Matrix_GetStateTranslation(&this->actor.focus.pos); - Matrix_GetStateTranslationAndScaledY(-200.0f, &this->unk_348[1]); + Matrix_GetStateTranslationAndScaledY(-200.0f, &this->limbPos[1]); } else if (limbIndex == 13) { Matrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); } if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { - EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->unk_348[4]); + EffectBlure_AddVertex(Effect_GetByIndex(this->unk_338), &this->unk_320, &this->limbPos[4]); this->unk_304 = this->timer; } } @@ -1103,6 +1105,7 @@ void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDodongo_OverrideLimbDraw, EnDodongo_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_348, ARRAY_COUNT(this->unk_348), this->unk_340 * this->unk_334, - this->unk_344 * this->unk_334, this->unk_33C, this->unk_300); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->unk_334, this->drawDmgEffFrozenSteamScale * this->unk_334, + this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h index 4a7fe8e9d..30562404f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h @@ -13,7 +13,7 @@ typedef struct EnDodongo { /* 0x188 */ Vec3s jointTable[31]; /* 0x242 */ Vec3s morphTable[31]; /* 0x2FC */ EnDodongoActionFunc actionFunc; - /* 0x300 */ u8 unk_300; + /* 0x300 */ u8 drawDmgEffType; /* 0x302 */ s16 timer; /* 0x304 */ s16 unk_304; /* 0x306 */ s16 unk_306; @@ -24,10 +24,10 @@ typedef struct EnDodongo { /* 0x330 */ Color_RGBA8 unk_330; /* 0x334 */ f32 unk_334; /* 0x338 */ s32 unk_338; - /* 0x33C */ f32 unk_33C; - /* 0x340 */ f32 unk_340; - /* 0x344 */ f32 unk_344; - /* 0x348 */ Vec3f unk_348[9]; + /* 0x33C */ f32 drawDmgEffAlpha; + /* 0x340 */ f32 drawDmgEffScale; + /* 0x344 */ f32 drawDmgEffFrozenSteamScale; + /* 0x348 */ Vec3f limbPos[9]; /* 0x3B4 */ ColliderJntSph collider1; /* 0x3D4 */ ColliderJntSphElement collider1Elements[10]; /* 0x654 */ ColliderJntSph collider2; 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 a410aabdd..bb1c574e2 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -5,8 +5,22 @@ */ #include "z_en_door.h" +#include "objects/object_mkk/object_mkk.h" +#include "objects/object_dor01/object_dor01.h" +#include "objects/object_dor02/object_dor02.h" +#include "objects/object_dor03/object_dor03.h" +#include "objects/object_dor04/object_dor04.h" +#include "objects/object_wdor01/object_wdor01.h" +#include "objects/object_wdor02/object_wdor02.h" +#include "objects/object_wdor03/object_wdor03.h" +#include "objects/object_wdor04/object_wdor04.h" +#include "objects/object_wdor05/object_wdor05.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_numa_obj/object_numa_obj.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnDoor*)thisx) @@ -15,7 +29,115 @@ void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx); void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80866B20(EnDoor*, GlobalContext*); +void func_8086704C(EnDoor*, GlobalContext*); +void func_80866F94(EnDoor*, GlobalContext*); +void func_80867080(EnDoor*, GlobalContext*); +void func_80867144(EnDoor*, GlobalContext*); +void func_808670F0(EnDoor*, GlobalContext*); +void func_80866A5C(EnDoor*, GlobalContext*); + +u8 D_808675D0[] = { + 0x0C, 0x00, 0x03, 0x0E, 0x02, 0x06, 0x00, 0x17, 0x00, 0x08, + 0x02, 0x00, 0x00, 0x06, 0x00, 0x02, 0x09, 0x07, 0x05, 0x00, +}; + +u8 D_808675E4[] = { + 0x0F, 0x09, 0x00, 0x47, 0x0F, 0x0C, 0x00, 0x15, 0x0C, 0x00, 0x01, 0x13, 0x11, 0x00, 0x0F, 0x0D, + 0x00, 0x0A, 0x0F, 0x0F, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x02, 0x09, 0x09, 0x05, 0x09, 0x08, 0x0C, + 0x00, 0x02, 0x19, 0x00, 0x1C, 0x08, 0x07, 0x0F, 0x0D, 0x00, 0x02, 0x09, 0x09, 0x05, 0x0F, 0x0D, + 0x00, 0xEA, 0x0F, 0x11, 0x00, 0xE7, 0x0F, 0x00, 0x00, 0xE2, 0x09, 0x09, 0x0F, 0x0D, 0x00, 0xDC, + 0x0F, 0x0D, 0x00, 0xD9, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x00, +}; + +u8 D_80867634[] = { + 0x02, 0x06, 0x00, 0x17, 0x00, 0x02, 0x09, 0x1C, 0x05, 0x00, 0x00, 0x00, +}; + +u8 D_80867640[] = { + 0x02, 0x15, 0x00, 0x16, 0x00, 0x01, 0x05, 0x09, 0x0B, 0x00, 0x00, 0x00, +}; +u8 D_8086764C[] = { + 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, 0x09, 0x0A, 0x05, 0x00, 0x00, 0x00, +}; +u8 D_80867658[] = { + 0x0C, 0x00, 0x02, 0x0F, 0x00, 0x1C, 0x08, 0x02, 0x09, 0x0C, 0x02, 0x0F, 0x0A, 0x16, 0x00, + 0x02, 0x09, 0x0C, 0x05, 0x0C, 0x00, 0x03, 0x11, 0x0F, 0x0D, 0x00, 0x0D, 0x00, 0x33, 0x08, + 0x02, 0x09, 0x0C, 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0C, 0x05, 0x09, 0x0C, 0x00, 0x00, +}; + +u8 D_80867684[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_80867688[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0F, 0x05, 0x00 }; + +u8 D_80867690[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x10, 0x05, 0x00 }; + +u8 D_80867698[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x11, 0x05, 0x00 }; + +u8 D_808676A0[] = { + 0x02, 0x0A, 0x00, 0x15, 0x00, 0x0F, 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, + 0x09, 0x12, 0x08, 0x02, 0x02, 0x09, 0x22, 0x09, 0x21, 0x05, 0x00, 0x00, +}; + +u8 D_808676B8[] = { + 0x08, 0x00, 0x14, 0x0C, 0x00, 0x03, 0x07, 0x0F, 0x08, 0x00, 0x01, 0x05, + 0x09, 0x13, 0x02, 0x08, 0x00, 0x14, 0x1E, 0x02, 0x09, 0x13, 0x05, 0x05, +}; + +u8 D_808676D0[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_808676D4[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_808676D8[] = { 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x14, 0x00 }; + +u8 D_808676E4[] = { 0x08, 0x00, 0x02, 0x09, 0x16, 0x05, 0x00, 0x00 }; + +u8 D_808676EC[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_808676F0[] = { + 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x0A, 0x00, 0x07, 0x05, 0x02, + 0x0A, 0x00, 0x14, 0x00, 0xF9, 0x09, 0x15, 0x00, 0x00, 0x00, +}; + +u8 D_80867704[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867708[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_8086770C[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867710[] = { 0x05, 0x00, 0x00, 0x00 }; + +u8 D_80867714[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x17, 0x05, 0x00 }; + +u8 D_8086771C[] = { + 0x0C, 0x00, 0x01, 0x07, 0x0F, 0x02, 0x1E, 0x02, 0x09, 0x18, 0x05, 0x0C, + 0x00, 0x03, 0xFB, 0x0F, 0x14, 0x00, 0xF7, 0x09, 0x0C, 0x00, 0x00, 0x00, +}; + +u8 D_80867734[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x19, 0x05, 0x00 }; + +u8 D_8086773C[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x1A, 0x05, 0x00 }; + +u8 D_80867744[] = { + 0x0C, 0x00, 0x02, 0x04, 0x00, 0x63, 0x80, 0x06, 0x0F, 0x14, 0x00, 0x08, + 0x09, 0x1B, 0x0F, 0x12, 0x00, 0x02, 0x09, 0x1B, 0x05, 0x00, 0x00, 0x00, +}; + +u8 D_8086775C[] = { + 0x00, 0x34, 0x20, 0x17, 0x00, 0x4B, 0x20, 0x13, 0x00, 0x0E, 0x04, 0x02, 0x09, 0x1D, + 0x00, 0x3B, 0x01, 0x08, 0x00, 0x3D, 0x02, 0x02, 0x09, 0x1E, 0x09, 0x1F, 0x05, 0x05, +}; + +u8 D_80867778[] = { 0x09, 0x20, 0x00, 0x00 }; +u8 D_8086777C[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867780[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867784[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x23, 0x05, 0x00 }; + +// void* seems to keep the compiler happy. +void* D_8086778C[] = { + &D_808675D0, &D_808675E4, &D_80867634, &D_80867640, &D_8086764C, &D_80867658, &D_80867684, &D_80867688, + &D_80867690, &D_80867698, &D_808676A0, &D_808676B8, &D_808676D0, &D_808676D4, &D_808676D8, &D_808676E4, + &D_808676EC, &D_808676F0, &D_80867704, &D_80867708, &D_8086770C, &D_80867710, &D_80867714, &D_8086771C, + &D_80867734, &D_8086773C, &D_80867744, &D_8086775C, &D_80867778, &D_8086777C, &D_80867780, &D_80867784, +}; + const ActorInit En_Door_InitVars = { ACTOR_EN_DOOR, ACTORCAT_DOOR, @@ -28,38 +150,395 @@ const ActorInit En_Door_InitVars = { (ActorFunc)EnDoor_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80867954[] = { +typedef struct { + /* 0x00 */ s16 sceneNum; + /* 0x02 */ u8 dListIndex; + /* 0x04 */ s16 objectId; +} EnDoorInfo; + +static EnDoorInfo sObjInfo[] = { + { SCENE_MITURIN, 0x01, OBJECT_NUMA_OBJ }, + { SCENE_TENMON_DAI, 0x02, OBJECT_DOR01 }, + { SCENE_00KEIKOKU, 0x02, OBJECT_DOR01 }, + { SCENE_30GYOSON, 0x02, OBJECT_DOR01 }, + { SCENE_LABO, 0x02, OBJECT_DOR01 }, + { SCENE_33ZORACITY, 0x03, OBJECT_DOR02 }, + { SCENE_UNSET_31, 0x03, OBJECT_DOR02 }, + { SCENE_BANDROOM, 0x03, OBJECT_DOR02 }, + { SCENE_20SICHITAI, 0x04, OBJECT_DOR03 }, + { SCENE_20SICHITAI2, 0x04, OBJECT_DOR03 }, + { SCENE_MAP_SHOP, 0x04, OBJECT_DOR03 }, + { SCENE_KAIZOKU, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_PIRATE, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_TORIDE, 0x0B, OBJECT_KAIZOKU_OBJ }, + { SCENE_KINDAN2, 0x0C, OBJECT_KINSTA2_OBJ }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x07, OBJECT_WDOR02 }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x07, OBJECT_WDOR02 }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x09, OBJECT_WDOR04 }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x08, OBJECT_WDOR03 }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x06, OBJECT_WDOR01 }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x00, GAMEPLAY_KEEP }, + { -1, 0x0A, OBJECT_WDOR05 }, + { -1, 0x0D, GAMEPLAY_FIELD_KEEP }, + { -1, 0x05, OBJECT_DOR04 }, + { -1, 0x09, OBJECT_WDOR04 }, + { -1, 0x04, OBJECT_DOR03 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.x, 0, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.z, 0, ICHAIN_STOP), }; -#endif +static AnimationHeader* sAnimations[] = { + &gameplay_keep_Anim_020658, &gameplay_keep_Anim_022CA8, &gameplay_keep_Anim_020658, &gameplay_keep_Anim_022E68, + &gameplay_keep_Anim_0204B4, &gameplay_keep_Anim_022BE8, &gameplay_keep_Anim_022D90, &gameplay_keep_Anim_022BE8, + &gameplay_keep_Anim_022FF0, &gameplay_keep_Anim_0205A0, +}; +static u8 sAnimOpenFrames[10] = { + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +}; -extern InitChainEntry D_80867954[]; +static u8 sAnimCloseFrames[10] = { + 60, 60, 60, 70, 70, 60, 60, 60, 60, 70, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Init.s") +static Gfx* D_808679A4[14][2] = { + { gDoorLeftDL, gDoorRightDL }, + { gWoodfallDoorDL, gWoodfallDoorDL }, + { object_dor01_DL_000448, object_dor01_DL_000448 }, + { gZoraHallDoorDL, gZoraHallDoorDL }, + { gSwampDoorDL, gSwampDoorDL }, + { gMagicHagPotionShopDoorDL, gMagicHagPotionShopDoorDL }, + { object_wdor01_DL_000548, object_wdor01_DL_000548 }, // Lottery Shop / Curiosity Shop / Mayor's House Door + { object_wdor02_DL_000548, object_wdor02_DL_000548 }, // Trading Post / Post Office Door + { object_wdor03_DL_000548, object_wdor03_DL_000548 }, // Stockpot Inn & Swordsman's School Door + { gMilkBarDoorDL, gMilkBarDoorDL }, + { gMusicBoxHouseDoorDL, gMusicBoxHouseDoorDL }, + { gPiratesFortressDoorDL, gPiratesFortressDoorDL }, + { object_mkk_DL_000310, object_mkk_DL_000310 }, + { gFieldWoodDoorLeftDL, gFieldWoodDoorRightDL }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Destroy.s") +void EnDoor_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 objectBankIndex; + EnDoorInfo* objectInfo = sObjInfo; + EnDoor* this = THIS; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866A5C.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866B20.s") + this->unk_1A4 = ENDOOR_GET_PARAMS_7(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80866F94.s") + this->switchFlag = ENDOOR_GET_PARAMS_7F(thisx); + if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gDoorCol); + } + SkelAnime_Init(globalCtx, &this->skelAnime, &gDoorSkel, &gameplay_keep_Anim_020658, this->limbTable, + this->limbTable, 5); + if (this->unk_1A4 == 5) { + objectInfo = &sObjInfo[17 + this->switchFlag]; + } else { + for (i = 0; i < ARRAY_COUNT(sObjInfo) - 34; i++, objectInfo++) { + if (globalCtx->sceneNum == objectInfo->sceneNum) { + break; + } + } + if ((i >= ARRAY_COUNT(sObjInfo) - 34) && (Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { + objectInfo++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_8086704C.s") + this->dlIndex = objectInfo->dListIndex; + objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + if (objectBankIndex < 0) { + objectInfo = &sObjInfo[15]; + objectBankIndex = Object_GetIndex(&globalCtx->objectCtx, objectInfo->objectId); + if (objectBankIndex != 0) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + } + this->requiredObjBankIndex = objectBankIndex; + this->dlIndex = objectInfo->dListIndex; // Set twice? + if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + func_80866A5C(this, globalCtx); + } else { + this->actionFunc = func_80866A5C; + } + Actor_SetFocus(&this->dyna.actor, 35.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867080.s") +void EnDoor_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = (EnDoor*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_808670F0.s") + if (this->unk_1A4 != 7) { + TransitionActorEntry* transitionEntry = + &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + if (transitionEntry->id < 0) { + transitionEntry->id = -transitionEntry->id; + } + } else if (this->switchFlag == 0) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867144.s") +void func_80866A5C(EnDoor* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->requiredObjBankIndex)) { + this->dyna.actor.objBankIndex = this->requiredObjBankIndex; + this->actionFunc = func_80866B20; + this->dyna.actor.world.rot.y = 0; + if (this->unk_1A4 == 1) { + if (!Flags_GetSwitch(globalCtx, this->switchFlag)) { + this->unk_1A6 = 10; + } + } else if ((this->unk_1A4 == 4) && + (Actor_XZDistanceBetweenActors(&this->dyna.actor, &GET_PLAYER(globalCtx)->actor) > 120.0f)) { + this->actionFunc = func_8086704C; + this->dyna.actor.world.rot.y = -0x1800; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Update.s") +void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { + static s32 D_80867BC0[4]; + Player* player = GET_PLAYER(globalCtx); + Vec3f playerPosRelToDoor; + s16 temp_a2; + s16 yawDiff; + s32 temp_a1_2; + s32 temp_t0; + u8 temp_a1; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/func_80867350.s") + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { + D_80867BC0[0] = 1; + } + if (this->unk_1A1 != 0) { + this->actionFunc = func_80867144; + Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], + (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); + if (this->unk_1A6 != 0) { + gSaveContext.save.inventory.dungeonKeys[gSaveContext.mapIndex]--; + Flags_SetSwitch(globalCtx, this->switchFlag); + Actor_PlaySfxAtPos(&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); + } else if (!Player_InCsMode(&globalCtx->state)) { + Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); + if ((D_80867BC0[0] != 0) || ((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; + if (playerPosRelToDoor.z > 0.0f) { + yawDiff = (0x8000 - yawDiff); + } + if (ABS_ALT(yawDiff) < 0x3000) { + player->doorType = 1; + 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) { + player->doorType = -1; + this->dyna.actor.textId = 0x1802; + } else { + player->doorTimer = 10; + } + } else if (this->unk_1A4 == 4) { + player->doorType = -1; + this->dyna.actor.textId = 0x1800; + } else if ((this->unk_1A4 == 0) || (this->unk_1A4 == 2) || (this->unk_1A4 == 3)) { + s32 textIdOffset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door/EnDoor_Draw.s") + temp_t0 = (globalCtx->actorCtx.unkC & 0x2AA) >> 1; + temp_a2 = D_801AED48[this->switchFlag & 7]; + temp_a1_2 = globalCtx->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))) { + s16 baseTextId = 0x182D; + + if (this->unk_1A4 == 3) { + baseTextId = 0x180D; + } else if (this->unk_1A4 == 2) { + baseTextId = 0x181D; + } + player->doorType = -1; + this->dyna.actor.textId = baseTextId + textIdOffset; + } + } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { + struct_80133038_arg2 sp30; + + if (func_80133038(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { + this->dyna.actor.textId = sp30.unk0 + 0x1800; + + player->doorType = ((this->dyna.actor.textId == 0x1821) && (D_80867BC0[0] != 0)) ? 5 : -1; + } + } + 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); + this->actionFunc = func_80867080; + } + } +} + +void func_80866F94(EnDoor* this, GlobalContext* globalCtx) { + s32 direction; + + if (this->unk_1A7 != 0) { + if (this->unk_1A7 >= 0) { + direction = 1; + } else { + direction = -1; + } + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, direction * 0x3E80, 0x7D0)) { + Math_StepToC(&this->unk_1A7, 0, 1); + } + } 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); + } + } +} + +void func_8086704C(EnDoor* this, GlobalContext* globalCtx) { + if (this->dyna.actor.xzDistToPlayer < 120.0f) { + this->actionFunc = func_808670F0; + } +} + +void func_80867080(EnDoor* this, GlobalContext* globalCtx) { + if (this->dyna.actor.xzDistToPlayer < 120.0f) { + this->actionFunc = func_808670F0; + } else if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, -0x1800, 0x100)) { + this->actionFunc = func_8086704C; + } +} + +void func_808670F0(EnDoor* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x700)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + this->actionFunc = func_80866B20; + } +} + +void func_80867144(EnDoor* this, GlobalContext* globalCtx) { + s32 numEffects; + s32 i; + + if (DECR(this->unk_1A6) == 0) { + if (SkelAnime_Update(&this->skelAnime) != 0) { + 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); + if (this->skelAnime.playSpeed < 1.5f) { + numEffects = (s32)(Rand_ZeroOne() * 30.0f) + 50; + for (i = 0; i < numEffects; i++) { + EffectSsBubble_Spawn(globalCtx, &this->dyna.actor.world.pos, 60.0, 100.0f, 50.0f, 0.15f); + } + } + } else if (Animation_OnFrame(&this->skelAnime, sAnimCloseFrames[this->animIndex])) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + } + } +} + +void EnDoor_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnDoor_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + TransitionActorEntry* transitionEntry; + EnDoor* this = THIS; + + if (limbIndex == 4) { + Gfx** dl = D_808679A4[this->dlIndex]; + s16 temp; + s32 dlIndex; + + transitionEntry = NULL; + + if (this->unk_1A4 != 7) { + transitionEntry = &globalCtx->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + } + rot->z += this->dyna.actor.world.rot.y; + if ((this->unk_1A4 == 7) || (globalCtx->roomCtx.prevRoom.num >= 0) || + (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { + s32 pad; + + temp = (this->dyna.actor.shape.rot.y + this->skelAnime.jointTable[3].z + rot->z) - + Math_Vec3f_Yaw(&globalCtx->view.eye, &this->dyna.actor.world.pos); + *dList = (ABS_ALT(temp) < 0x4000) ? dl[0] : dl[1]; + + } else { + dlIndex = 0; + if (transitionEntry->sides[0].room != this->dyna.actor.room) { + dlIndex = 1; + } + *dList = dl[dlIndex]; + } + } + return false; +} + +void EnDoor_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDoor* this = THIS; + + if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + OPEN_DISPS(globalCtx->state.gfxCtx); + if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { + Gfx_DrawDListOpa(globalCtx, gameplay_keep_DL_0221B8); + } else { + func_8012C28C(globalCtx->state.gfxCtx); + } + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDoor_OverrideLimbDraw, + NULL, &this->dyna.actor); + if (this->dyna.actor.world.rot.y != 0) { + if (this->dyna.actor.world.rot.y > 0) { + gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); + } + } + if (this->unk_1A6) { + Actor_DrawDoorLock(globalCtx, this->unk_1A6, 0); + } + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index 6ed5aac15..bc94e150e 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -7,19 +7,24 @@ struct EnDoor; typedef void (*EnDoorActionFunc)(struct EnDoor*, GlobalContext*); +#define ENDOOR_GET_PARAMS_7(thisx) (((thisx)->params >> 7) & 7) +#define ENDOOR_GET_PARAMS_7F(thisx) (((thisx)->params) & 0x7F) + + typedef struct EnDoor { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x5C]; - /* 0x1A0 */ s8 unk_1A0; - /* 0x1A1 */ s8 unk_1A1; - /* 0x1A2 */ char unk_1A2[0x2]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ u8 animIndex; + /* 0x1A1 */ u8 unk_1A1; + /* 0x1A2 */ s8 requiredObjBankIndex; + /* 0x1A3 */ s8 dlIndex; /* 0x1A4 */ u8 unk_1A4; - /* 0x1A5 */ u8 unk_1A5; - /* 0x1A6 */ s8 unk_1A6; + /* 0x1A5 */ u8 switchFlag; + /* 0x1A6 */ u8 unk_1A6; /* 0x1A7 */ s8 unk_1A7; - /* 0x1A8 */ char unk_1A8[0x20]; + /* 0x1A8 */ Vec3s limbTable[5]; /* 0x1C8 */ EnDoorActionFunc actionFunc; -} EnDoor; // size = 0x1CC +} EnDoor; extern const ActorInit En_Door_InitVars; diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c index 688aa7a42..9b53c36d2 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c @@ -6,7 +6,7 @@ #include "z_en_door_etc.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnDoorEtc*)thisx) 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 2068ca8ff..5b7091d02 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -6,7 +6,7 @@ #include "z_en_dragon.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDragon*)thisx) @@ -15,16 +15,51 @@ void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx); void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B5ED90(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EE3C(EnDragon* this, GlobalContext* globalCtx); -void func_80B5EFD0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F418(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F508(EnDragon* this, GlobalContext* globalCtx); -void func_80B5F8D8(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FCC0(EnDragon* this, GlobalContext* globalCtx); -void func_80B5FD68(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupRetreatOrIdle(EnDragon* this); +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupExtend(EnDragon* this); +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_SetupAttack(EnDragon* this); +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx); +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY, + /* 1 */ DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY, + /* 2 */ DEEP_PYTHON_ANIMATION_VERTICAL_SWAY, + /* 3 */ DEEP_PYTHON_ANIMATION_IDLE +} DeepPythonAnimationIndex; + +typedef enum { + /* 0 */ DEEP_PYTHON_ACTION_IDLE, + /* 1 */ DEEP_PYTHON_ACTION_EXTEND, + /* 2 */ DEEP_PYTHON_ACTION_GRAB, + /* 3 */ DEEP_PYTHON_ACTION_DAMAGE, + /* 4 */ DEEP_PYTHON_ACTION_RETREAT, + /* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD, + /* 6 */ DEEP_PYTHON_ACTION_DEAD, +} DeepPythonAction; + +typedef enum { + /* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED, + /* 1 */ DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED, + /* 2 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY, + /* 3 */ DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY, +} DeepPythonExtendState; + +typedef enum { + /* 0 */ DEEP_PYTHON_GRAB_STATE_START, + /* 1 */ DEEP_PYTHON_GRAB_STATE_GRABBED, +} DeepPythonGrabState; + +typedef enum { + /* 0 */ DEEP_PYTHON_ATTACK_STATE_START, + /* 1 */ DEEP_PYTHON_ATTACK_STATE_RELEASED, +} DeepPythonAttackState; + +static s32 sNumPythonsDead = 0; -#if 0 const ActorInit En_Dragon_InitVars = { ACTOR_EN_DRAGON, ACTORCAT_ENEMY, @@ -37,130 +72,779 @@ const ActorInit En_Dragon_InitVars = { (ActorFunc)EnDragon_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B605F4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(0, 0x0), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(0, 0x0), - /* 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(0, 0x0), - /* Ice arrow */ DMG_ENTRY(0, 0x0), - /* Light arrow */ DMG_ENTRY(0, 0x0), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* 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(1, 0xF), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(0, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* 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(1, 0xF), +typedef enum { + /* 0x0 */ DEEP_PYTHON_DMGEFF_NONE, + /* 0xF */ DEEP_PYTHON_DMGEFF_DAMAGE = 0xF +} DeepPythonDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Goron spikes */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Normal shield */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, DEEP_PYTHON_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, DEEP_PYTHON_DMGEFF_DAMAGE), }; -// static ColliderJntSphElementInit sJntSphElementsInit[8] = { -static ColliderJntSphElementInit D_80B60614[8] = { +static ColliderJntSphElementInit sJntSphElementsInit[8] = { { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 13, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_HEAD, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 12, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_COLLAR, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 10, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_1, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { DEEP_PYTHON_LIMB_BODY_SEGMENT_2, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B60734 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 8, D_80B60614, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -extern DamageTable D_80B605F4; -extern ColliderJntSphElementInit D_80B60614[8]; -extern ColliderJntSphInit D_80B60734; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDeepPythonSkel, &gDeepPythonSmallSideSwayAnim, this->jointTable, + this->morphTable, DEEP_PYTHON_LIMB_MAX); -extern UNK_TYPE D_060048B8; + this->actor.colChkInfo.health = 4; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 0xA; + Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Init.s") + this->collider.elements[0].dim.scale = this->collider.elements[1].dim.scale = this->collider.elements[2].dim.scale = + this->collider.elements[3].dim.scale = this->collider.elements[4].dim.scale = + this->collider.elements[5].dim.scale = this->collider.elements[6].dim.scale = + this->collider.elements[7].dim.scale = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Destroy.s") + this->collider.elements[0].dim.modelSphere.radius = 150; + this->collider.elements[0].dim.modelSphere.center.x = 420; + this->collider.elements[1].dim.modelSphere.radius = 160; + this->collider.elements[1].dim.modelSphere.center.x = 630; + this->collider.elements[2].dim.modelSphere.radius = 130; + this->collider.elements[2].dim.modelSphere.center.x = 630; + this->collider.elements[3].dim.modelSphere.radius = 170; + this->collider.elements[3].dim.modelSphere.center.x = 920; + this->collider.elements[4].dim.modelSphere.radius = 150; + this->collider.elements[4].dim.modelSphere.center.x = 530; + this->collider.elements[5].dim.modelSphere.radius = 140; + this->collider.elements[5].dim.modelSphere.center.x = 730; + this->collider.elements[6].dim.modelSphere.radius = 120; + this->collider.elements[6].dim.modelSphere.center.x = 430; + this->collider.elements[7].dim.modelSphere.radius = 110; + this->collider.elements[7].dim.modelSphere.center.x = 160; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EAA0.s") + this->pythonIndex = EN_DRAGON_GET_PYTHON_INDEX(&this->actor); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->action = DEEP_PYTHON_ACTION_IDLE; + this->actor.hintId = 0xE; + this->scale = 0.5f; + this->actor.flags &= ~ACTOR_FLAG_8000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EB40.s") + EnDragon_SetupRetreatOrIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5ED90.s") +void EnDragon_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EDF0.s") + Collider_DestroyJntSph(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EE3C.s") +static AnimationHeader* sAnimations[] = { + &gDeepPythonSmallSideSwayAnim, + &gDeepPythonLargeSideSwayAnim, + &gDeepPythonVerticalSwayAnim, + &gDeepPythonSmallSideSwayAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EF88.s") +static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5EFD0.s") +void EnDragon_ChangeAnimation(EnDragon* this, s32 animationIndex) { + f32 startFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F3A4.s") + this->animationIndex = animationIndex; + this->endFrame = Animation_GetLastFrame(sAnimations[animationIndex]); + startFrame = 0.0f; + if (this->animationIndex == DEEP_PYTHON_ANIMATION_IDLE) { + startFrame = this->endFrame; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F418.s") + Animation_Change(&this->skelAnime, sAnimations[animationIndex], 1.0f, startFrame, this->endFrame, + sAnimationModes[this->animationIndex], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F508.s") +static Color_RGBA8 sBubblePrimColors[] = { + { 255, 255, 255, 255 }, + { 150, 255, 255, 255 }, + { 100, 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F888.s") +static Color_RGBA8 sBubbleEnvColors[] = { + { 150, 150, 150, 0 }, + { 0, 100, 0, 255 }, + { 0, 0, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5F8D8.s") +void EnDragon_SpawnBubbles(EnDragon* this, GlobalContext* globalCtx, Vec3f basePos) { + static Vec3f sBubbleVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f sBubbleAccel = { 0.0f, 0.1f, 0.0f }; + s32 bubbleCount; + s16 colorIndex; + s16 scale; + Vec3f bubblePos; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FCC0.s") + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + colorIndex = 0; + if (this->action == DEEP_PYTHON_ACTION_DEAD) { + colorIndex = 1; + bubbleCount = (s32)randPlusMinusPoint5Scaled(5.0f) + 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B5FD68.s") + for (i = 0; i < bubbleCount; i++) { + Math_Vec3f_Copy(&bubblePos, &basePos); + sBubbleVelocity.x = Rand_ZeroFloat(1.0f) * 23.0f; + sBubbleVelocity.y = Rand_ZeroFloat(1.0f) * 10.0f; + sBubbleVelocity.z = Rand_ZeroFloat(1.0f) * 23.0f; + bubblePos.x += randPlusMinusPoint5Scaled(i * 30.0f); + bubblePos.y += randPlusMinusPoint5Scaled(5.0f); + bubblePos.z += randPlusMinusPoint5Scaled(i * 30.0f); + sBubbleAccel.y = Rand_ZeroFloat(1.0f) * 20.0f * 3.0f; + scale = Rand_S16Offset(380, 240); + EffectSsDtBubble_SpawnCustomColor(globalCtx, &bubblePos, &sBubbleVelocity, &sBubbleAccel, + &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60138.s") +void EnDragon_RetreatOnceTimerEnds(EnDragon* this, GlobalContext* globalCtx) { + if (this->timer == 0) { + func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 8); + EnDragon_SetupRetreatOrIdle(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Update.s") +void EnDragon_SetupRetreatOrIdle(EnDragon* this) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->state = 0; + this->unk_2CC = 0; + this->hasGrabbedPlayer = false; + this->grabTimer = 0; + this->timer = 30; + this->actionFunc = EnDragon_RetreatOrIdle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B6043C.s") +void EnDragon_RetreatOrIdle(EnDragon* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->action == DEEP_PYTHON_ACTION_EXTEND) { + 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; + } else { + this->actor.speedXZ = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/func_80B60494.s") + 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)) { + Math_ApproachF(&this->actor.world.pos.x, this->actor.home.pos.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 200.0f); + } else if (this->action != DEEP_PYTHON_ACTION_IDLE) { + this->action = DEEP_PYTHON_ACTION_IDLE; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dragon/EnDragon_Draw.s") +void EnDragon_SetupExtend(EnDragon* this) { + this->state = 0; + this->behindJawRetreatTimer = this->state; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_APPEAR_TRG); + this->retreatTimer = 250; + this->actionFunc = EnDragon_Extend; +} + +void EnDragon_Extend(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + s16 yaw; + + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + if (this->action >= DEEP_PYTHON_ACTION_DAMAGE) { + Actor_PlaySfxAtPos(&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); + 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); + 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; + 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; + 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) && + (fabsf(this->actor.world.pos.z - extendedPos.z) < 4.0f)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED; + } + } + } else { + Math_SmoothStepToS(&this->jawZRotation, 0, 5, 0xBB8, 0x14); + SkelAnime_Update(&this->skelAnime); + if (this->state == DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED) { + if (currentFrame < this->endFrame) { + return; + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + yaw = ABS_ALT(BINANG_SUB(Math_Vec3f_Yaw(&this->jawPos, &player->actor.world.pos), this->actor.shape.rot.y)); + if (yaw < 0x5000) { + // Player is in front of the jaw + if ((this->endFrame <= currentFrame) && (this->largeSwayWaitTimer == 0)) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY; + } + + this->behindJawRetreatTimer = 0; + } else { + // Player is in behind the jaw + if (this->state == DEEP_PYTHON_EXTEND_STATE_REPEAT_LARGE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_SMALL_SIDE_SWAY); + this->largeSwayWaitTimer = Rand_ZeroFloat(20.0f) + this->endFrame; + this->state = DEEP_PYTHON_EXTEND_STATE_REPEAT_SMALL_SWAY; + } + + this->behindJawRetreatTimer++; + if (this->behindJawRetreatTimer > 60) { + this->action = DEEP_PYTHON_ACTION_RETREAT; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BACK); + EnDragon_SetupRetreatOrIdle(this); + } + } + } +} + +void EnDragon_CameraSetAtEye(EnDragon* this, GlobalContext* globalCtx, Vec3f eye, Vec3f at) { + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->cameraEye, &eye); + Math_Vec3f_Copy(&this->cameraAt, &at); + Play_CameraSetAtEye(globalCtx, this->cameraId, &this->cameraAt, &this->cameraEye); +} + +void EnDragon_SetupGrab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f extendedPos; + s16 yaw; + + if (!ActorCutscene_GetCanPlayNext(this->grabCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->grabCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->grabCutsceneIndex, &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; + Math_Vec3f_Copy(&this->actor.world.pos, &extendedPos); + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &this->jawPos); + player->actor.shape.rot.y = yaw; + player->actor.world.rot.y = yaw; + this->state = DEEP_PYTHON_GRAB_STATE_START; + this->grabTimer = 0; + this->hasGrabbedPlayer = false; + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_IDLE); + this->actionFunc = EnDragon_Grab; + } +} + +static Vec3f sCameraEyePerPython[] = { + { 1600.0f, 0.0f, 1400.0f }, { 1400.0f, 0.0f, 400.0f }, { 1800.0f, 0.0f, 1400.f }, { 1100.0f, -200.0f, 1500.0f }, + { 2000.0f, 0.0f, 1500.0f }, { 1900.0f, 0.0f, 1800.0f }, { 1700.0f, 0.0f, 1100.0f }, { 1700.0f, 0.0f, 1100.0f }, +}; + +static Vec3f sCameraAtPerPython[] = { + { 300.0f, -100.0f, 1300.0f }, { 1500.0f, 0.0f, 2400.0f }, { 300.0f, -100.0f, 1300.0f }, { 1900.0f, 500.0f, 600.0f }, + { -1000.0f, 0.0f, 1000.0f }, { 1200.0f, 0.0f, 1500.0f }, { 1100.0f, 0.0f, 2000.0f }, { 1100.0f, 0.0f, 2000.0f }, +}; + +static s16 sZRotPerPython[] = { 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x07D0, 0x0BB8, 0x0000, 0x0000 }; + +static s32 sMaxGrabTimerPerPython[] = { 5, 5, 5, 4, 5, 8, 5, 5 }; + +void EnDragon_Grab(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp50; // used as both the extended position and the camera eye + Vec3f at; + + this->cameraId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + SkelAnime_Update(&this->skelAnime); + + if (this->grabTimer == 0) { + if (!this->hasGrabbedPlayer) { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + Math_Vec3f_Copy(&this->playerGrabPositionTemp, &this->playerGrabPosition); + this->hasGrabbedPlayer = true; + } else { + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPositionTemp); + } + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * -930.0f; + sp50.z += Math_CosS(this->actor.world.rot.y) * -930.0f; + Math_Vec3f_Copy(&this->actor.world.pos, &sp50); + this->jawZRotation = 0x1450; + this->actor.speedXZ = 60.0f; + } + + this->grabTimer++; + Math_SmoothStepToS(&this->actor.shape.rot.z, sZRotPerPython[this->pythonIndex], 0xA, 0x1F4, 0x14); + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + Math_Vec3f_Copy(&sp50, &this->burrowEntrancePos); + sp50.x += Math_SinS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].x; + sp50.y += sCameraEyePerPython[this->pythonIndex].y; + sp50.z += Math_CosS(this->actor.world.rot.y) * sCameraEyePerPython[this->pythonIndex].z; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].x; + at.y += sCameraAtPerPython[this->pythonIndex].y; + at.z += Math_CosS(this->actor.world.rot.y) * sCameraAtPerPython[this->pythonIndex].z; + + EnDragon_CameraSetAtEye(this, globalCtx, sp50, at); + + if (this->grabTimer > sMaxGrabTimerPerPython[this->pythonIndex]) { + if (this->state == DEEP_PYTHON_GRAB_STATE_START) { + func_800B7298(globalCtx, &this->actor, 6); + this->state = DEEP_PYTHON_GRAB_STATE_GRABBED; + } + + globalCtx->unk_18770(globalCtx, player); + player->actor.parent = &this->actor; + player->unk_AE8 = 50; + this->action = DEEP_PYTHON_ACTION_GRAB; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_EAT); + EnDragon_SetupAttack(this); + } +} + +void EnDragon_SetupAttack(EnDragon* this) { + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->behindJawRetreatTimer = 0; + this->grabTimer = 0; + this->state = DEEP_PYTHON_ATTACK_STATE_START; + this->actionFunc = EnDragon_Attack; +} + +void EnDragon_Attack(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 currentFrame = this->skelAnime.curFrame; + Vec3f sp4C; // used as both the extended position and the camera eye + Vec3f at; + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 0xA, 0x1388, 0); + if ((globalCtx->gameplayFrames % 16) == 0) { + globalCtx->damagePlayer(globalCtx, -2); + + //! @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->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_BITE); + CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); + } + + Math_Vec3f_Copy(&sp4C, &this->actor.world.pos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * 3000.0f; + sp4C.y += 600.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * 3000.0f; + + Math_Vec3f_Copy(&at, &this->actor.world.pos); + at.x += Math_SinS(this->actor.world.rot.y) * 1200.0f; + at.y += -100.0f; + at.z += Math_CosS(this->actor.world.rot.y) * 1200.0f; + + EnDragon_CameraSetAtEye(this, globalCtx, sp4C, at); + + player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; + player->actor.world.rot.x = player->actor.shape.rot.x = this->actor.world.rot.x; + player->actor.world.rot.z = player->actor.shape.rot.z = this->actor.world.rot.z - 0x36B0; + Math_Vec3f_Copy(&player->actor.world.pos, &this->playerGrabPosition); + this->jawZRotation = 0xC8; + + Math_Vec3f_Copy(&sp4C, &this->burrowEntrancePos); + sp4C.x += Math_SinS(this->actor.world.rot.y) * -530.0f; + sp4C.z += Math_CosS(this->actor.world.rot.y) * -530.0f; + Math_ApproachF(&this->actor.world.pos.x, sp4C.x, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.y, sp4C.y, 0.3f, 200.0f); + Math_ApproachF(&this->actor.world.pos.z, sp4C.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); + if (this->animationIndex != DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY) { + EnDragon_ChangeAnimation(this, DEEP_PYTHON_ANIMATION_LARGE_SIDE_SWAY); + } + + this->state++; + } + + if (((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) || + (!(player->stateFlags2 & 0x80)) || ((this->collider.elements[0].info.bumperFlags & BUMP_HIT)) || + (this->collider.elements[1].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[2].info.bumperFlags & BUMP_HIT)) { + player->actor.parent = NULL; + this->grabWaitTimer = 30; + ActorCutscene_Stop(this->grabCutsceneIndex); + if (player->stateFlags2 & 0x80) { + player->unk_AE8 = 100; + } + + this->actor.flags &= ~ACTOR_FLAG_100000; + + if ((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) { + this->timer = 3; + this->actionFunc = EnDragon_RetreatOnceTimerEnds; + } else { + EnDragon_SetupRetreatOrIdle(this); + } + } +} + +void EnDragon_SetupDead(EnDragon* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(this->deathCutsceneIndex)) { + ActorCutscene_SetIntentToPlay(this->deathCutsceneIndex); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->deathCutsceneIndex, &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; + this->actionFunc = EnDragon_Dead; + } +} + +void EnDragon_Dead(EnDragon* this, GlobalContext* globalCtx) { + Vec3f seahorsePos; + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.z += 0x1000; + this->jawZRotation = 0xFA0; + EnDragon_SpawnBubbles(this, globalCtx, this->jawPos); + + 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; + if (((this->pythonIndex & 1) == 0) && (Rand_ZeroOne() < 0.5f)) { + //! @bug: !globalCtx->gameplayFrames is 0 essentially all the time, so this code never runs. + if (((!globalCtx->gameplayFrames) & 0x1F)) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->jawPos, 0x90); + } + } + + this->action = DEEP_PYTHON_ACTION_DEAD; + return; + } + + this->actor.speedXZ = 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); + Math_ApproachF(&this->actor.world.pos.z, this->actor.home.pos.z, 0.3f, 300.0f); + return; + } + + sNumPythonsDead++; + if (sNumPythonsDead >= (BREG(39) + 8)) { + Math_Vec3f_Copy(&seahorsePos, &this->actor.parent->world.pos); + seahorsePos.x += (Math_SinS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + seahorsePos.y += -100.0f + BREG(33); + seahorsePos.z += (Math_CosS((this->actor.parent->world.rot.y + 0x8000)) * (500.0f + BREG(38))); + if (Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, seahorsePos.x, seahorsePos.y, + seahorsePos.z, 0, this->actor.shape.rot.y, 0, 0x4000, this->actor.cutscene, + this->actor.unk20, NULL)) { + gSaveContext.save.weekEventReg[13] |= 1; + switch (this->pythonIndex) { + case 0: + gSaveContext.save.weekEventReg[83] |= 0x10; + break; + + case 1: + gSaveContext.save.weekEventReg[83] |= 0x20; + break; + + case 2: + gSaveContext.save.weekEventReg[83] |= 0x40; + break; + + case 3: + gSaveContext.save.weekEventReg[83] |= 0x80; + break; + case 4: + gSaveContext.save.weekEventReg[84] |= 1; + break; + + case 5: + gSaveContext.save.weekEventReg[84] |= 2; + break; + + case 6: + gSaveContext.save.weekEventReg[84] |= 4; + break; + + case 7: + gSaveContext.save.weekEventReg[84] |= 8; + break; + } + } + } + + Actor_MarkForDeath(&this->actor); +} + +void EnDragon_UpdateDamage(EnDragon* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u32 sp30; + + if ((this->action == DEEP_PYTHON_ACTION_EXTEND)) { + if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[3].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[4].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[5].info.bumperFlags & BUMP_HIT) || + (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); + if (this->actor.colChkInfo.health > 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DAMAGE); + this->action = DEEP_PYTHON_ACTION_DAMAGE; + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_UTSUBO_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_100000; + this->action = DEEP_PYTHON_ACTION_SETUP_DEAD; + this->actionFunc = EnDragon_SetupDead; + } + } + } + + if ((this->action == DEEP_PYTHON_ACTION_EXTEND) && (this->grabWaitTimer == 0) && + (player->invincibilityTimer == 0) && (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) && + (!(func_800B64FC(globalCtx, 1000.0f, &this->actor.world.pos, &sp30) >= 0.0f) || (sp30 != 1))) { + this->actor.speedXZ = 0.0f; + this->action = DEEP_PYTHON_ACTION_GRAB; + this->actor.flags |= ACTOR_FLAG_100000; + this->actionFunc = EnDragon_SetupGrab; + } +} + +void EnDragon_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnDragon* this = THIS; + + if (this->retreatTimer != 0) { + this->retreatTimer--; + } + + if (this->timer != 0) { + this->timer--; + } + + if (this->largeSwayWaitTimer != 0) { + this->largeSwayWaitTimer--; + } + + if (this->grabWaitTimer != 0) { + this->grabWaitTimer--; + } + + EnDragon_UpdateDamage(this, globalCtx); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_Vec3f_Copy(&this->actor.focus.pos, &this->focusPos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + Actor_SetScale(&this->actor, this->scale); + + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + + if (this->action != DEEP_PYTHON_ACTION_GRAB) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->action < DEEP_PYTHON_ACTION_DAMAGE) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnDragon_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDragon* this = THIS; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + rot->x += this->jawXRotation; + rot->y += this->jawYRotation; + rot->z += this->jawZRotation; + } + + return false; +} + +void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDragon* this = THIS; + Vec3f playerGrabOffsetFromJawPos = { 350.0f, -120.0f, -60.0f }; + + if (limbIndex == DEEP_PYTHON_LIMB_JAW) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->jawPos); + playerGrabOffsetFromJawPos.x = 350.0f; + playerGrabOffsetFromJawPos.y = -120.0f; + playerGrabOffsetFromJawPos.z = -60.0f; + Matrix_MultiplyVector3fByState(&playerGrabOffsetFromJawPos, &this->playerGrabPosition); + } + + if (limbIndex == DEEP_PYTHON_LIMB_HEAD_AND_COLLAR_ROOT) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->focusPos); + } + + Collider_UpdateSpheres(limbIndex, &this->collider); +} + +void EnDragon_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDragon* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDragon_OverrideLimbDraw, EnDragon_PostLimbDraw, &this->actor); +} 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 f22874804..c7ec4d81e 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -2,16 +2,53 @@ #define Z_EN_DRAGON_H #include "global.h" +#include "objects/object_utubo/object_utubo.h" + +#define EN_DRAGON_GET_PYTHON_INDEX(thisx) (((thisx)->params >> 7) & 0x1F) struct EnDragon; typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*); typedef struct EnDragon { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; - /* 0x0248 */ EnDragonActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x2B0]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[DEEP_PYTHON_LIMB_MAX]; + /* 0x248 */ EnDragonActionFunc actionFunc; + /* 0x24C */ s32 animationIndex; + /* 0x250 */ s32 pythonIndex; + /* 0x254 */ Vec3f jawPos; + /* 0x260 */ Vec3f burrowEntrancePos; // Vertically and horizontally centered on the burrow opening. Set by Bg_Sinkai_Kabe + /* 0x26C */ Vec3f playerGrabPosition; + /* 0x278 */ Vec3f cameraEye; + /* 0x278 */ Vec3f cameraAt; + /* 0x290 */ Vec3f playerGrabPositionTemp; + /* 0x29C */ Vec3f focusPos; + /* 0x2A8 */ s16 jawZRotation; + /* 0x2AA */ s16 jawYRotation; // Never initialized by the actor + /* 0x2AC */ s16 jawXRotation; // Never initialized by the actor + /* 0x2AE */ s16 retreatTimer; // If the Deep Python is extended and this timer reaches 0, it is forced to retreat back to its burrow + /* 0x2B0 */ s16 behindJawRetreatTimer; // If the player is behind the jaw, then this will count up. When it reaches 60, the Deep Python will retreat + /* 0x2B2 */ s16 largeSwayWaitTimer; // If the player is in front of the jaw, it won't play or replay the large sway animation unless this is zero. + /* 0x2B4 */ s16 timer; + /* 0x2B6 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x2B8 */ s16 hasGrabbedPlayer; + /* 0x2BA */ s16 action; + /* 0x2BC */ UNK_TYPE1 unk_2BC[0x2]; + /* 0x2BE */ s16 state; + /* 0x2C0 */ s16 grabCutsceneIndex; + /* 0x2C2 */ s16 deathCutsceneIndex; + /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; + /* 0x2C8 */ s16 cameraId; + /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking + /* 0x2CC */ s16 unk_2CC; // Initialized, but never used + /* 0x2CE */ UNK_TYPE1 unk_2CE[0x2]; + /* 0x2D0 */ f32 endFrame; + /* 0x2D4 */ f32 scale; + /* 0x2D8 */ UNK_TYPE1 unk_2D8[0x4]; + /* 0x2DC */ ColliderJntSph collider; + /* 0x2FC */ ColliderJntSphElement colliderElements[8]; } EnDragon; // size = 0x4FC extern const ActorInit En_Dragon_InitVars; diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.c b/src/overlays/actors/ovl_En_Drs/z_en_drs.c index 81acb58cf..74f4f19cc 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -1,7 +1,7 @@ /* * File: z_en_drs.c * Overlay: ovl_En_Drs - * Description: Wedding dress manequin + * Description: Anju's Wedding Dress Mannequin */ #include "z_en_drs.h" @@ -13,11 +13,10 @@ void EnDrs_Init(Actor* thisx, GlobalContext* globalCtx); void EnDrs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDrs_Update(Actor* thisx, GlobalContext* globalCtx); +void EnDrs_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80C1E2D4(EnDrs* this, GlobalContext* globalCtx); -void func_80C1E3DC(EnDrs* this, GlobalContext* globalCtx); +void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Drs_InitVars = { ACTOR_EN_DRS, ACTORCAT_PROP, @@ -30,36 +29,98 @@ const ActorInit En_Drs_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C1E5E0 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 16, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80C1E60C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations = { &gWeddingDressMannequinIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }; -extern ColliderCylinderInit D_80C1E5E0; -extern CollisionCheckInfoInit2 D_80C1E60C; +void EnDrs_CollisionUpdate(EnDrs* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_06000E70; -extern UNK_TYPE D_06005A78; +void EnDrs_Setup(EnDrs* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E290.s") + if ((this->moonMaskObjBankIndex >= 0) && SubS_IsObjectLoaded(this->moonMaskObjBankIndex, globalCtx)) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWeddingDressMannequinSkel, NULL, this->jointTable, + this->morphTable, WEDDING_DRESS_MANNEQUIN_LIMB_MAX); + SubS_ChangeAnimationByInfoS(&this->skelAnime, &sAnimations, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actor.draw = EnDrs_Draw; + this->actionFunc = EnDrs_Idle; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E2D4.s") +void EnDrs_Idle(EnDrs* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E3DC.s") +void EnDrs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Init.s") + this->moonMaskObjBankIndex = SubS_GetObjectIndex(OBJECT_MSMO, globalCtx); + this->actionFunc = EnDrs_Setup; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Destroy.s") +void EnDrs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/EnDrs_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E4B0.s") +void EnDrs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Drs/func_80C1E568.s") + this->actionFunc(this, globalCtx); + if (this->actor.draw != NULL) { + SkelAnime_Update(&this->skelAnime); + EnDrs_CollisionUpdate(this, globalCtx); + } +} + +void EnDrs_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDrs* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s8 temp = this->moonMaskObjBankIndex; + s8 temp2 = this->actor.objBankIndex; + + // Anju removes the Moon Mask at the start of the Couple's Mask cutscene + // after that it will no longer be rendered. + if (!(gSaveContext.save.weekEventReg[87] & 2) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp].segment); + gSPDisplayList(POLY_OPA_DISP++, &gMoonMaskDL); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[temp2].segment); + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnDrs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDrs* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnDrs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Drs/z_en_drs.h b/src/overlays/actors/ovl_En_Drs/z_en_drs.h index 191f272d6..1f59d601b 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.h +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.h @@ -2,17 +2,22 @@ #define Z_EN_DRS_H #include "global.h" +#include "objects/object_drs/object_drs.h" +#include "objects/object_msmo/object_msmo.h" struct EnDrs; typedef void (*EnDrsActionFunc)(struct EnDrs*, GlobalContext*); typedef struct EnDrs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnDrsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x80]; -} EnDrs; // size = 0x20C + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnDrsActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[WEDDING_DRESS_MANNEQUIN_LIMB_MAX]; + /* 0x1F0 */ Vec3s morphTable[WEDDING_DRESS_MANNEQUIN_LIMB_MAX]; + /* 0x208 */ s8 moonMaskObjBankIndex; +} EnDrs; // size = 0x20C */ extern const ActorInit En_Drs_InitVars; diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c index 1ca8d69fc..c47961a6d 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -6,7 +6,7 @@ #include "z_en_ds2n.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnDs2n*)thisx) diff --git a/src/overlays/actors/ovl_En_Dt/z_en_dt.c b/src/overlays/actors/ovl_En_Dt/z_en_dt.c index d76c0c919..0501b728c 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.c +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.c @@ -6,7 +6,7 @@ #include "z_en_dt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnDt*)thisx) 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 69eb19f58..40e06787c 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 @@ -7,7 +7,7 @@ #include "z_en_dy_extra.h" #include "objects/object_dy_obj/object_dy_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnDyExtra*)thisx) 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 8d72af042..bea655d9a 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c @@ -6,7 +6,7 @@ #include "z_en_egblock.h" -#define FLAGS 0x08000000 +#define FLAGS (ACTOR_FLAG_8000000) #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 fe3e0e09e..0111c6cd7 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -6,7 +6,7 @@ #include "z_en_egol.h" -#define FLAGS 0x80000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80000000) #define THIS ((EnEgol*)thisx) 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 5f175cdb8..fcaf6063d 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -7,7 +7,7 @@ #include "z_en_elf.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnElf*)thisx) @@ -855,8 +855,8 @@ void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { glowLightRadius = 0; } - if (func_800EE29C(globalCtx, 0xC9)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 == 6) { + if (Cutscene_CheckActorAction(globalCtx, 201)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action == 6) { glowLightRadius = 0; } } @@ -889,12 +889,12 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { func_8088E5A8(this, globalCtx); xScale = 0.0f; - if (func_800EE29C(globalCtx, 0xC9)) { - sp38 = func_800EE200(globalCtx, 0xC9); + if (Cutscene_CheckActorAction(globalCtx, 201)) { + sp38 = Cutscene_GetActorActionIndex(globalCtx, 201); func_808908D0(&nextPos, globalCtx, sp38); - this->actor.shape.rot.y = globalCtx->csCtx.npcActions[sp38]->unk8; - this->actor.shape.rot.x = globalCtx->csCtx.npcActions[sp38]->unk6; - if (globalCtx->csCtx.npcActions[sp38]->unk0 == 5) { + this->actor.shape.rot.y = globalCtx->csCtx.actorActions[sp38]->urot.y; + this->actor.shape.rot.x = globalCtx->csCtx.actorActions[sp38]->urot.x; + if (globalCtx->csCtx.actorActions[sp38]->action == 5) { func_8088F5F4(this, globalCtx, 16); } @@ -905,14 +905,14 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { } if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.unk_12 == 0) && - ((globalCtx->csCtx.frames == 0x95) || (globalCtx->csCtx.frames == 0x17D) || - (globalCtx->csCtx.frames == 0x24F))) { + (globalCtx->csCtx.currentCsIndex == 0) && + ((globalCtx->csCtx.frames == 149) || (globalCtx->csCtx.frames == 381) || + (globalCtx->csCtx.frames == 591))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } if ((globalCtx->sceneNum == SCENE_SECOM) && (gSaveContext.sceneSetupIndex == 0) && - (globalCtx->csCtx.unk_12 == 4) && (globalCtx->csCtx.frames == 0x5F)) { + (globalCtx->csCtx.currentCsIndex == 4) && (globalCtx->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { @@ -1017,7 +1017,7 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { func_8088E60C(this, globalCtx); - if (!func_800EE29C(globalCtx, 0xC9)) { + if (!Cutscene_CheckActorAction(globalCtx, 0xC9)) { this->actor.shape.rot.y = this->unk_258; } } @@ -1108,8 +1108,8 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { s32 pad; if (globalCtx->csCtx.state != 0) { - if (func_800EE29C(globalCtx, 0xC9)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 201)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action) { case 4: sp34 = 7; break; @@ -1361,8 +1361,8 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0x202) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0x202) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F230(); @@ -1376,19 +1376,19 @@ void func_8088FE64(Actor* thisx, GlobalContext* globalCtx2) { switch (globalCtx->msgCtx.choiceIndex) { case 0: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 - 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId - 1); break; case 1: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; } } break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 576: func_80151938(globalCtx, 0x245); break; @@ -1504,7 +1504,7 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { } else { this->actionFunc(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { if (gSaveContext.save.playerData.tatlTimer < 25800) { gSaveContext.save.playerData.tatlTimer++; } else if (!(this->fairyFlags & 0x80)) { @@ -1578,8 +1578,8 @@ void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { if (player->currentMask != PLAYER_MASK_GIANT) { if (!(this->fairyFlags & 8) && - (!func_800EE29C(globalCtx, 0xC9) || - (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0xC9)]->unk0 != 6)) && + (!Cutscene_CheckActorAction(globalCtx, 201) || + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 201)]->action != 6)) && (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z))) { Gfx* dListHead = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); f32 alphaScale; @@ -1622,17 +1622,17 @@ void EnElf_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_808908D0(Vec3f* vec, GlobalContext* globalCtx, u32 action) { Vec3f startPos; Vec3f endPos; - CsCmdActorAction* npcAction = globalCtx->csCtx.npcActions[action]; + CsCmdActorAction* npcAction = globalCtx->csCtx.actorActions[action]; f32 lerp; - startPos.x = npcAction->unk0C.x; - startPos.y = npcAction->unk0C.y; - startPos.z = npcAction->unk0C.z; + startPos.x = npcAction->startPos.x; + startPos.y = npcAction->startPos.y; + startPos.z = npcAction->startPos.z; - endPos.x = npcAction->unk18.x; - endPos.y = npcAction->unk18.y; - endPos.z = npcAction->unk18.z; + endPos.x = npcAction->endPos.x; + endPos.y = npcAction->endPos.y; + endPos.z = npcAction->endPos.z; - lerp = func_800F5A8C(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames, globalCtx); + lerp = Environment_LerpWeight(npcAction->endFrame, npcAction->startFrame, globalCtx->csCtx.frames); VEC3F_LERPIMPDST(vec, &startPos, &endPos, lerp); } diff --git a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c index 264efc2b2..3693b258b 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" #include "objects/object_bubble/object_bubble.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnElfbub*)thisx) @@ -82,7 +82,7 @@ void EnElfbub_Init(Actor* thisx, GlobalContext* globalCtx) { } this->oscillationAngle = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnElfbub_Destroy(Actor* thisx, GlobalContext* globalCtx) { 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 bb19fa61a..605edd6d4 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -5,8 +5,9 @@ */ #include "z_en_elfgrp.h" +#include "overlays/actors/ovl_En_Elforg/z_en_elforg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnElfgrp*)thisx) @@ -14,7 +15,24 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2); +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1); +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3); +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx); +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx); + const ActorInit En_Elfgrp_InitVars = { ACTOR_EN_ELFGRP, ACTORCAT_PROP, @@ -27,54 +45,547 @@ const ActorInit En_Elfgrp_InitVars = { (ActorFunc)NULL, }; -#endif +void func_80A396B0(EnElfgrp* this, s32 arg1) { + while (arg1 > 0) { + if (this->actor.cutscene == -1) { + break; + } + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A396B0.s") + arg1--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Init.s") +void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnElfgrp* this = THIS; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Destroy.s") + this->unk_147 = ENELFGRP_GET(&this->actor); + this->unk_148 = 0; + this->unk_14A = 0; + this->actor.focus.pos.y += 40.0f; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39BD0.s") + switch (this->unk_147) { + case ENELFGRP_1: + case ENELFGRP_2: + case ENELFGRP_3: + case ENELFGRP_4: + this->unk_148 = this->unk_147 - 1; + sp24 = func_80A39C1C(globalCtx, this->unk_147); + this->unk_146 = 1 << this->unk_147; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39C1C.s") + if (sp24 < 25) { + func_80A39DC8(this, globalCtx, sp24, 0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39CD4.s") + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + func_80A396B0(this, 2); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39DC8.s") + if ((func_80A39BD0(globalCtx, this->unk_147) + sp24) >= 25) { + this->actionFunc = func_80A3A398; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39F50.s") + switch (this->unk_147) { + case ENELFGRP_1: + if (gSaveContext.save.weekEventReg[23] & 2) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 4; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A39FBC.s") + case ENELFGRP_2: + if (gSaveContext.save.playerData.doubleMagic == true) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A044.s") + case ENELFGRP_3: + if (gSaveContext.save.playerData.doubleDefense) { + func_80A396B0(this, 1); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0AC.s") + case ENELFGRP_4: + if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { + func_80A396B0(this, 1); + } else { + this->unk_14A |= 0x10; + } + break; + } + } else if (func_80A39BD0(globalCtx, this->unk_147)) { + this->actionFunc = func_80A3A7FC; + this->actor.textId = (this->unk_147 * 3) + 0x581; + } else { + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + this->actor.textId = (this->unk_147 * 3) + 0x580; + } else { + this->actor.textId = (this->unk_147 * 3) + 0x57F; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A0F4.s") + default: + sp24 = func_80A39C1C(globalCtx, 0); + this->unk_146 = ENELFGRP_1; + if (sp24 >= 25) { + this->actionFunc = func_80A3A520; + if ((this->actor.home.rot.z != 0) && Flags_GetSwitch(globalCtx, this->actor.home.rot.z)) { + this->actionFunc = func_80A3A600; + } else if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 4); + } else if (INV_CONTENT(ITEM_MASK_DEKU) != ITEM_MASK_DEKU) { + func_80A396B0(this, 5); + } else { + this->unk_14A |= 2; + func_80A396B0(this, 6); + } + } else if ((gSaveContext.save.weekEventReg[8] & 0x80)) { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A398; + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + func_80A396B0(this, 2); + } else { + func_80A396B0(this, 3); + this->unk_14A |= 2; + } + } else if (gSaveContext.save.playerData.magicAcquired == true) { + func_80A396B0(this, 1); + } + } else { + func_80A39DC8(this, globalCtx, 24, 0); + this->actionFunc = func_80A3A8F8; + if ((gSaveContext.save.weekEventReg[9] & this->unk_146)) { + this->actor.textId = 0x580; + } else { + this->actor.textId = 0x578; + } + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A210.s") +void EnElfgrp_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A274.s") +s32 func_80A39BD0(GlobalContext* globalCtx, s32 arg2) { + s8 sp1F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A398.s") + if ((arg2 < 1) || (arg2 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A484.s") + sp1F = gSaveContext.save.inventory.strayFairies[arg2 - 1]; + return (sp1F - func_80A39C1C(globalCtx, arg2)) + 10; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A4AC.s") +s32 func_80A39C1C(GlobalContext* globalCtx, s32 arg1) { + // the permanentSceneFlags access here is in the form + // struct { + // u32 clockTown : 1; + // u32 fountains[4] : 5; + // } FairyFountains; + // where arg1 is: + // 0: clocktown + // 1: woodfall, + // 2: snowhead, + // 3: great bay, + // 4: stone tower + // clocktown is handled separately, and then the fountains are looked up as array indexing -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A520.s") + s32 temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A600.s") + if ((arg1 < 0) || (arg1 >= 5)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A610.s") + if (arg1 == 0) { + if (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1) { + return 25; + } + return 24; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A6F4.s") + temp_v1 = (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; + if (temp_v1 < 10) { + temp_v1 = 10; + } else if (temp_v1 > 25) { + temp_v1 = 25; + } + return temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A77C.s") +void func_80A39CD4(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + if ((arg1 < 0) || (arg1 > 4) || (arg2 < 10) || (arg2 > 25)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A7FC.s") + if (arg1 == 0) { + if (arg2 == 25) { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 1; + } else { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; + } + } else { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg2 << ((arg1 * 5) - 4); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/func_80A3A8F8.s") +void func_80A39DC8(EnElfgrp* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { + s32 pad; + s32 i; + Actor* elforg; + s32 temp; + Vec3f sp6C; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Elfgrp/EnElfgrp_Update.s") + if (arg3 == 0) { + this->unk_14A |= 8; + } + + if (arg3 == 0) { + sp6C = this->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN; + } else { + sp6C = player->actor.world.pos; + sp6C.y += 20.0f; + temp = ((this->unk_147 & 7) << 6) | STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN; + } + + for (i = 0; i < arg2; i++) { + elforg = + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, randPlusMinusPoint5Scaled(20.0f) + sp6C.x, + sp6C.y, randPlusMinusPoint5Scaled(20.0f) + sp6C.z, 0, 0, 0, temp); + if (elforg == NULL) { + continue; + } + elforg->home.pos.x = this->actor.home.pos.x; + elforg->home.pos.y = this->actor.home.pos.y + 20.0f; + elforg->home.pos.z = this->actor.home.pos.z; + } +} + +s32 func_80A39F50(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_MOVES_QUICKLY_TO_HOME; + } + itemAction = itemAction->next; + } + + return 0; +} + +s32 func_80A39FBC(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + s32 phi_v1 = 30; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + if (!(elfOrg->flags & STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN)) { + elfOrg->flags |= STRAY_FAIRY_FLAG_CIRCLES_QUICKLY_IN_FOUNTAIN; + if (phi_v1 >= 100) { + return phi_v1; + } + elfOrg->secondaryTimer = phi_v1; + phi_v1 += 5; + } + + itemAction = itemAction->next; + } + + return phi_v1; +} + +void func_80A3A044(GlobalContext* globalCtx) { + Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + EnElforg* elfOrg; + + while (itemAction != NULL) { + if ((itemAction->id != ACTOR_EN_ELFORG) || + ((STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_FAIRY_FOUNTAIN) && + (STRAY_FAIRY_TYPE(itemAction) != STRAY_FAIRY_TYPE_TURN_IN_TO_FAIRY_FOUNTAIN))) { + itemAction = itemAction->next; + continue; + } + + elfOrg = (EnElforg*)itemAction; + elfOrg->actor.home.rot.x = 0x14; + elfOrg->flags |= STRAY_FAIRY_FLAG_SPARKLES_AND_SHRINKS; + + itemAction = itemAction->next; + } +} + +void func_80A3A0AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (!Cutscene_CheckActorAction(globalCtx, 0x64)) { + this->actionFunc = func_80A3A600; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80A3A0F4(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 10) { + play_sound(NA_SE_SY_WHITE_OUT_T); + if (ENELFGRP_GET(&this->actor) < ENELFGRP_4) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, + ENELFGRP_GET(&this->actor) + ENELFGRP_4); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y + 30.0f, this->actor.world.pos.z, 0, 0, 0, 4); + } + } + + if ((this->unk_144 > 10) && (this->unk_14A & 1)) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0AC; + } +} + +void func_80A3A210(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + func_80A3A044(globalCtx); + this->unk_144 = 30; + } + + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } +} + +void func_80A3A274(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + if (this->unk_14A & 1) { + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); + } + + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action) { + case 2: + if (!(this->unk_14A & 1)) { + if (this->unk_147 == ENELFGRP_0) { + func_80A39DC8(this, globalCtx, 1, 1); + } else { + func_80A39DC8(this, globalCtx, func_80A39BD0(globalCtx, this->unk_147), 1); + } + this->unk_14A |= 1; + func_80A39CD4(globalCtx, this->unk_147, 25); + } + break; + + case 3: + func_80A39F50(globalCtx); + this->actionFunc = func_80A3A210; + this->unk_144 = 90; + break; + } + } +} + +void func_80A3A398(EnElfgrp* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A274; + Flags_UnsetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if ((this->unk_14A & 4) != 0) { + gSaveContext.save.weekEventReg[23] |= 2; + } + + if (this->unk_14A & 0x10) { + Item_Give(globalCtx, ITEM_SWORD_GREAT_FAIRY); + } + this->unk_14A &= ~8; + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A484(EnElfgrp* this, GlobalContext* globalCtx) { + if (this->unk_144 == 0) { + this->actionFunc = func_80A3A0F4; + this->unk_144 = 30; + } +} + +void func_80A3A4AC(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x64)) { + s32 temp = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x64)]->action; + if (temp == 3) { + this->actionFunc = func_80A3A484; + this->unk_144 = 90; + } + } +} + +void func_80A3A520(EnElfgrp* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x67)) { + this->actionFunc = func_80A3A600; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = func_80A3A4AC; + Flags_SetSwitch(globalCtx, ENELFGRP_GET_FE00(&this->actor)); + + if (this->unk_14A & 2) { + Item_Give(globalCtx, ITEM_MASK_GREAT_FAIRY); + } + + if (this->actor.home.rot.z != 0) { + Flags_SetSwitch(globalCtx, this->actor.home.rot.z); + } + } else if (this->actor.xzDistToPlayer < 350.0f) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80A3A600(EnElfgrp* this, GlobalContext* globalCtx) { +} + +void func_80A3A610(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_144 == 60) { + Interface_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + gSaveContext.healthAccumulator = 320; + } + + if (this->unk_144 > 0) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_HEAL - SFX_FLAG); + } else { + player->actor.freezeTimer = 0; + player->stateFlags1 &= ~0x20000000; + this->actionFunc = func_80A3A600; + this->unk_14A |= 8; + } +} + +void func_80A3A6F4(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A77C(EnElfgrp* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->unk_144 = func_80A39FBC(globalCtx); + this->actionFunc = func_80A3A610; + this->unk_14A &= ~8; + } +} + +void func_80A3A7FC(EnElfgrp* this, GlobalContext* globalCtx) { + s32 temp_s0; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + temp_s0 = func_80A39BD0(globalCtx, this->unk_147); + func_80A39DC8(this, globalCtx, temp_s0, 1); + temp_s0 += func_80A39C1C(globalCtx, this->unk_147); + if (temp_s0 > 25) { + temp_s0 = 25; + } + func_80A39CD4(globalCtx, this->unk_147, temp_s0); + } else if (this->actor.xzDistToPlayer < 280.0f) { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 300.0f); + } +} + +void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[9] |= this->unk_146; + this->actionFunc = func_80A3A6F4; + return; + } + + if (this->unk_147 != ENELFGRP_0) { + if (func_80A39BD0(globalCtx, this->unk_147) > 0) { + this->actionFunc = func_80A3A7FC; + return; + } + } + + if (this->actor.xzDistToPlayer < 30.0f) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + this->actor.flags &= ~ACTOR_FLAG_10000; + player->actor.freezeTimer = 100; + player->stateFlags1 |= 0x20000000; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80A3A77C; + gSaveContext.save.weekEventReg[9] |= this->unk_146; + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + } else { + this->actor.flags &= ~ACTOR_FLAG_10000; + } +} + +void EnElfgrp_Update(Actor* thisx, GlobalContext* globalCtx) { + EnElfgrp* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_14A & 8) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_FRY - SFX_FLAG); + } + + if (this->unk_144 != 0) { + this->unk_144--; + } +} diff --git a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h index 7ecb7d71d..375dad55b 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.h @@ -7,9 +7,24 @@ struct EnElfgrp; typedef void (*EnElfgrpActionFunc)(struct EnElfgrp*, GlobalContext*); +#define ENELFGRP_GET(thisx) ((thisx)->params & 0xF) +#define ENELFGRP_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +enum { + /* 0 */ ENELFGRP_0, + /* 2 */ ENELFGRP_1, + /* 2 */ ENELFGRP_2, + /* 3 */ ENELFGRP_3, + /* 4 */ ENELFGRP_4, +}; + typedef struct EnElfgrp { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x8]; + /* 0x0144 */ s16 unk_144; + /* 0x0146 */ u8 unk_146; + /* 0x0147 */ u8 unk_147; + /* 0x0148 */ s8 unk_148; + /* 0x014A */ u16 unk_14A; /* 0x014C */ EnElfgrpActionFunc actionFunc; } EnElfgrp; // size = 0x150 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 71f15a6a2..0ab1e4210 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -7,7 +7,7 @@ #include "z_en_elforg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnElforg*)thisx) @@ -456,7 +456,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { if (STRAY_FAIRY_TYPE(&this->actor) == STRAY_FAIRY_TYPE_CLOCK_TOWN) { player->actor.freezeTimer = 100; player->stateFlags1 |= 0x20000000; - func_801518B0(globalCtx, 0x579, NULL); + Message_StartTextbox(globalCtx, 0x579, NULL); this->actionFunc = EnElforg_ClockTownFairyCollected; ActorCutscene_SetIntentToPlay(0x7C); return; @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { if (func_8010A074(globalCtx)) { gSaveContext.save.inventory.strayFairies[gSaveContext.unk_48C8]++; - func_801518B0(globalCtx, 0x11, NULL); + Message_StartTextbox(globalCtx, 0x11, NULL); if (gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { func_801A3098(NA_BGM_GET_ITEM | 0x900); } 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 2672c209f..b9a186057 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -6,7 +6,7 @@ #include "z_en_encount1.h" -#define FLAGS 0x08100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_8000000) #define THIS ((EnEncount1*)thisx) 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 72638d9a6..3cf01bd8a 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -10,7 +10,11 @@ typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, GlobalContext*); typedef struct EnEncount1 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnEncount1ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x1C]; + /* 0x0148 */ char unk_148[0x6]; + /* 0x014E */ s16 unk_14E; + /* 0x0150 */ char unk_150[0xA]; + /* 0x015A */ s16 unk_15A; + /* 0x015C */ char unk_15C[0x8]; } EnEncount1; // size = 0x164 extern const ActorInit En_Encount1_InitVars; 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 07187d90d..83f04b013 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -8,7 +8,7 @@ #include "objects/object_fusen/object_fusen.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnEncount2*)thisx) @@ -277,7 +277,7 @@ void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { Matrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_079B10)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); 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 184eb8728..b9681b5e1 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 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #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 d4f6c4487..eaadd8133 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 0x08000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #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 34fa659a8..b366a4dec 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 @@ -7,7 +7,7 @@ #include "z_en_ending_hero.h" #include "objects/object_dt/object_dt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero_InitVars = { void EnEndingHero_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; 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 ddb5535a7..f3515787c 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 @@ -7,7 +7,7 @@ #include "z_en_ending_hero2.h" #include "objects/object_bai/object_bai.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero2*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero2_InitVars = { void EnEndingHero2_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero2* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; 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 9cb297c5c..91c44e741 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 @@ -7,7 +7,7 @@ #include "z_en_ending_hero3.h" #include "objects/object_toryo/object_toryo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero3*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero3_InitVars = { void EnEndingHero3_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero3* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; 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 59e1fd836..1e54ee8b9 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 @@ -7,7 +7,7 @@ #include "z_en_ending_hero4.h" #include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero4*)thisx) @@ -34,11 +34,11 @@ const ActorInit En_Ending_Hero4_InitVars = { void EnEndingHero4_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero4* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sdn_Skel_00D640, &object_sdn_Anim_002A84, this->jointTable, + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierCheerWithSpear, this->jointTable, this->morphTable, 17); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); func_80C23748(this); 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 ba77613bd..23ac531f3 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 @@ -7,7 +7,7 @@ #include "z_en_ending_hero5.h" #include "objects/object_daiku/object_daiku.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero5*)thisx) @@ -34,7 +34,7 @@ const ActorInit En_Ending_Hero5_InitVars = { void EnEndingHero5_Init(Actor* thisx, GlobalContext* globalCtx) { EnEndingHero5* this = THIS; - this->actor.colChkInfo.mass = 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); this->actor.targetMode = 6; this->actor.gravity = -3.0f; 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 1b296098f..82df507c2 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 @@ -11,7 +11,7 @@ #include "objects/object_toryo/object_toryo.h" #include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnEndingHero6*)thisx) @@ -38,13 +38,13 @@ const ActorInit En_Ending_Hero6_InitVars = { static FlexSkeletonHeader* sSkeletons[] = { &object_dt_Skel_00B0CC, &object_bai_Skel_007908, &object_toryo_Skel_007150, - &object_sdn_Skel_00D640, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, + &gSoldierSkeleton, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, &object_daiku_Skel_00A850, }; static AnimationHeader* sAnimations[] = { &object_dt_Anim_000BE0, &object_bai_Anim_0011C0, &object_toryo_Anim_000E50, - &object_sdn_Anim_002A84, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, + &gSoldierCheerWithSpear, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, &object_daiku_Anim_002FA0, }; 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 7cc45bb5a..b1ac6673a 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.c +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.c @@ -6,7 +6,7 @@ #include "z_en_estone.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnEstone*)thisx) 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 13e4ab023..dabd62e0f 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -21,7 +21,7 @@ #include "objects/object_lodmoon/object_lodmoon.h" #include "objects/object_moonston/object_moonston.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFall*)thisx) @@ -218,7 +218,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_Moon_Draw; this->actionFunc = EnFall_StoppedClosedMouthMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); - if (!(gSaveContext.save.weekEventReg[0x19] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); } break; @@ -227,7 +227,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); this->actor.draw = EnFall_Moon_Draw; - if (gSaveContext.save.weekEventReg[0x19] & 2) { + if (gSaveContext.save.weekEventReg[25] & 2) { Actor_MarkForDeath(&this->actor); } break; @@ -313,7 +313,8 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globalCtx) { static s32 sGiantsCutsceneState = 0; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && globalCtx->csCtx.unk_12 == 0) { + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 1 && + globalCtx->csCtx.currentCsIndex == 0) { switch (sGiantsCutsceneState) { case 0: if (globalCtx->csCtx.state != 0) { @@ -324,7 +325,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa case 2: if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (gSaveContext.save.weekEventReg[0x5D] & 4) { + if (gSaveContext.save.weekEventReg[93] & 4) { if (ActorCutscene_GetCanPlayNext(0xC)) { ActorCutscene_Start(0xC, &this->actor); sGiantsCutsceneState++; @@ -333,7 +334,7 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa } } else if (ActorCutscene_GetCanPlayNext(0xB)) { ActorCutscene_Start(0xB, &this->actor); - gSaveContext.save.weekEventReg[0x5D] |= 4; + gSaveContext.save.weekEventReg[93] |= 4; sGiantsCutsceneState++; } else { ActorCutscene_SetIntentToPlay(0xB); @@ -357,14 +358,15 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { EnFall_CrashingMoon_HandleGiantsCutscene(this, globalCtx); - if (func_800EE29C(globalCtx, 0x85)) { - if (func_800EE29C(globalCtx, 0x85) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 0x85)) { + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { this->actor.draw = NULL; } else { this->actor.draw = EnFall_Moon_Draw; - if (func_800EE29C(globalCtx, 0x85) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 2) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); } } } else { @@ -373,8 +375,8 @@ void EnFall_CrashingMoon_PerformCutsceneActions(EnFall* this, GlobalContext* glo } void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x85)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { case 3: if (this->eyeGlowIntensity == 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MOON_EYE_FLASH); @@ -393,10 +395,10 @@ void EnFall_StoppedOpenMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCont } void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x85)) { - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action) { case 2: - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); break; case 4: @@ -406,7 +408,7 @@ void EnFall_StoppedClosedMouthMoon_PerformCutsceneActions(EnFall* this, GlobalCo } if (globalCtx->sceneNum == SCENE_OKUJOU && gSaveContext.sceneSetupIndex == 2) { - switch (globalCtx->csCtx.unk_12) { + switch (globalCtx->csCtx.currentCsIndex) { case 0: switch (globalCtx->csCtx.frames) { case 1060: @@ -460,15 +462,16 @@ void EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions(EnFall* this, Glo void EnFall_Moon_PerformDefaultActions(EnFall* this, GlobalContext* globalCtx) { u16 currentDay; - if (func_800EE29C(globalCtx, 0x85)) { - if (func_800EE29C(globalCtx, 0x85) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 133)) { + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 1) { this->actor.draw = NULL; } else { Actor_SetScale(&this->actor, this->scale * 3.6f); this->actor.draw = EnFall_Moon_Draw; - if (func_800EE29C(globalCtx, 0x85) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x85)]->unk0 == 2) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x85)); + if (Cutscene_CheckActorAction(globalCtx, 133) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 133)]->action == 2) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 133)); } } } else { @@ -506,7 +509,8 @@ void EnFall_MoonsTear_DoNothing(EnFall* this, GlobalContext* globalCtx) { void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { s32 pad; - if (func_800EE29C(globalCtx, 0x205) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x205)]->unk0 == 2 && + if (Cutscene_CheckActorAction(globalCtx, 517) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 517)]->action == 2 && this->actor.draw == NULL) { EnFall_MoonsTear_Initialize(this); } @@ -514,8 +518,8 @@ void EnFall_MoonsTear_Fall(EnFall* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); - gSaveContext.save.weekEventReg[0x4A] |= 0x80; - gSaveContext.save.weekEventReg[0x4A] |= 0x20; + gSaveContext.save.weekEventReg[74] |= 0x80; + gSaveContext.save.weekEventReg[74] |= 0x20; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -2); Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -569,11 +573,12 @@ void EnFall_Fireball_SetPerVertexAlpha(f32 fireballAlpha) { void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 2) { + if (globalCtx->sceneNum == SCENE_00KEIKOKU && gSaveContext.sceneSetupIndex == 0 && + globalCtx->csCtx.currentCsIndex == 2) { globalCtx->skyboxCtx.rotY -= 0.05f; } - if (func_800EE29C(globalCtx, 0x1C2)) { + if (Cutscene_CheckActorAction(globalCtx, 450)) { this->actor.draw = EnFall_Fireball_Draw; if (this->flags & FLAG_FIRE_BALL_INTENSIFIES) { this->fireballIntensity += 0.01f; @@ -581,9 +586,9 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->fireballIntensity = 1.0f; } } - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1C2)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 450)); - switch (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0) { + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action) { default: this->actor.draw = NULL; this->fireballAlpha = 0; @@ -620,7 +625,7 @@ void EnFall_Fireball_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = NULL; } - if (func_800EE29C(globalCtx, 0x1C2) && this->fireballAlpha > 0) { + if (Cutscene_CheckActorAction(globalCtx, 0x1C2) && this->fireballAlpha > 0) { func_8019F128(NA_SE_EV_MOON_FALL_LAST - SFX_FLAG); } Actor_SetScale(&this->actor, this->scale * 1.74f); @@ -677,9 +682,9 @@ s32 EnFall_RisingDebris_InitializeParticles(EnFall* this) { void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (func_800EE29C(globalCtx, 0x1C3)) { - if (func_800EE29C(globalCtx, 0x1C3) && - globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C3)]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 451)) { + if (Cutscene_CheckActorAction(globalCtx, 451) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 451)]->action == 2) { EnFall_RisingDebris_UpdateParticles(this); EnFall_RisingDebris_InitializeParticles(this); } else if (this->activeDebrisParticleCount != 0) { @@ -694,7 +699,8 @@ void EnFall_RisingDebris_Update(Actor* thisx, GlobalContext* globalCtx) { void EnFall_FireRing_Update(Actor* thisx, GlobalContext* globalCtx) { EnFall* this = THIS; - if (func_800EE29C(globalCtx, 0x1C2) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1C2)]->unk0 == 5) { + if (Cutscene_CheckActorAction(globalCtx, 450) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 450)]->action == 5) { if (!(this->flags & FLAG_FIRE_RING_APPEARS)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_DM_RING_EXPLOSION); } 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 a9e27fec7..46c365cd3 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -6,7 +6,7 @@ #include "z_en_fall2.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFall2*)thisx) 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 de24735c7..23da2fb30 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -6,7 +6,7 @@ #include "z_en_famos.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnFamos*)thisx) 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 ea0c82027..060678506 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -8,7 +8,7 @@ #include "objects/object_fr/object_fr.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00004209 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_200 | ACTOR_FLAG_4000) #define THIS ((EnFg*)thisx) @@ -95,11 +95,11 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_fr_Anim_001534, 1.0f, 0, -1, 0, 0 }, - { &object_fr_Anim_001534, 1.0f, 0, -1, 0, -4 }, - { &object_fr_Anim_0011C0, 1.0f, 0, -1, 0, -4 }, - { &object_fr_Anim_0007BC, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_fr_Anim_001534, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_fr_Anim_001534, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_fr_Anim_0011C0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_fr_Anim_0007BC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; s32 EnFg_UpdateAnimation(SkelAnime* skelAnime, s16 animIndex) { @@ -111,11 +111,11 @@ s32 EnFg_UpdateAnimation(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return ret; } @@ -177,7 +177,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_DEKUSTICK: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_1); this->skelAnime.playSpeed = 0.0f; this->actor.shape.shadowDraw = NULL; @@ -190,7 +190,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_HOOKSHOT: break; case FG_DMGEFFECT_ARROW: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->skelAnime.playSpeed = 0.0f; rotY = this->collider.base.ac->world.rot.y; rotX = this->collider.base.ac->world.rot.x; @@ -203,7 +203,7 @@ void EnFg_Idle(EnFg* this, GlobalContext* globalCtx) { this->actionFunc = EnFg_DoNothing; break; case FG_DMGEFFECT_EXPLOSION: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); if (1) {} this->actor.params = FG_BLACK; @@ -238,7 +238,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { switch (EnFg_GetDamageEffect(this)) { case FG_DMGEFFECT_ARROW: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->skelAnime.playSpeed = 0.0f; ac = this->collider.base.ac; rotY = ac->world.rot.y; @@ -254,7 +254,7 @@ void EnFg_Jump(EnFg* this, GlobalContext* globalCtx) { case FG_DMGEFFECT_HOOKSHOT: break; case FG_DMGEFFECT_EXPLOSION: - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FROG_CRY_0); EnFg_UpdateAnimation(&this->skelAnime, 0); this->actor.params = FG_BLACK; @@ -321,7 +321,7 @@ void EnFg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - this->actor.flags |= 0x4000; + this->actor.flags |= ACTOR_FLAG_4000; Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -1.6f; this->actionFunc = EnFg_Idle; diff --git a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c index 765e69488..77909d2ee 100644 --- a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c +++ b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c @@ -6,7 +6,7 @@ #include "z_en_fire_rock.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFireRock*)thisx) 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 af00d0344..711b4ca6e 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 0x00005005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnFirefly*)thisx) @@ -131,7 +131,7 @@ void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (this->actor.params & KEESE_INVISIBLE) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; this->actor.params = KEESE_GET_MAIN_TYPE(thisx); this->isInvisible = true; } @@ -168,10 +168,10 @@ void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) { - if (this->unk_18F == 0xA) { - this->unk_18F = 0; - this->unk_2E8.x = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, &this->limbPos[0], 3, 2, 0.2f, 0.2f); } } @@ -331,7 +331,7 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; Animation_Change(&this->skelAnime, &object_firefly_Anim_00017C, 0.0f, 6.0f, 6.0f, 2, 0.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FFLY_DEAD); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (this->isInvisible) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0x2000, 40); @@ -340,28 +340,28 @@ void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 3) { - this->unk_18F = 0xA; - this->unk_2E8.x = 1.0f; - this->unk_2E8.y = 0.55f; - this->unk_2E8.z = 0.82500005f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18F = 0x14; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_SMALL_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18F = 0; - this->unk_2E8.x = 4.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; } - if (this->unk_2E8.x > 0.0f) { + if (this->drawDmgEffAlpha > 0.0f) { this->auraType = KEESE_AURA_NONE; } - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { this->actor.speedXZ = 0.0f; } @@ -373,8 +373,8 @@ void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) { this->actor.colorFilterTimer = 40; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); - if (!(this->actor.flags & 0x8000)) { - if (this->unk_18F != 0xA) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x6800, 0x200); this->actor.shape.rot.y -= 0x300; } @@ -566,8 +566,8 @@ void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx) { } else { this->actor.colorFilterTimer = 40; - if (this->unk_2E8.x > 0.0f) { - this->unk_2E8.x = 2.0f; + if (this->drawDmgEffAlpha > 0.0f) { + this->drawDmgEffAlpha = 2.0f; } } } @@ -638,14 +638,14 @@ void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) { EnFirefly_SetupStunned(this); } else if (this->actor.colChkInfo.damageEffect == 5) { this->timer = 40; - this->unk_18F = 0x1F; - this->unk_2E8.x = 2.0f; - this->unk_2E8.y = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffScale = 0.55f; EnFirefly_SetupStunned(this); } else { Enemy_StartFinishingBlow(globalCtx, &this->actor); this->actor.colChkInfo.health = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; // Negate effects of fire on Fire Keese and Ice on Ice Keese if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == 2)) || @@ -678,7 +678,7 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { EnFirefly_UpdateDamage(this, globalCtx); this->actionFunc(this, globalCtx); - if (!(this->actor.flags & 0x8000)) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) { Actor_MoveWithGravity(&this->actor); } else { @@ -710,12 +710,12 @@ void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2E8.x > 0.0f) { - if (this->unk_18F != 0xA) { - Math_StepToF(&this->unk_2E8.x, 0.0f, 0.05f); - this->unk_2E8.y = (this->unk_2E8.x + 1.0f) * 0.275f; - this->unk_2E8.y = CLAMP_MAX(this->unk_2E8.y, 0.55f); - } else if (!Math_StepToF(&this->unk_2E8.z, 0.55f, 0.01375f)) { + 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.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -793,11 +793,11 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == 15) { - Matrix_GetStateTranslation(&this->unk_2F8); + Matrix_GetStateTranslation(&this->limbPos[0]); } else if (limbIndex == 21) { - Matrix_GetStateTranslation(&this->unk_304); + Matrix_GetStateTranslation(&this->limbPos[1]); } else if (limbIndex == 10) { - Matrix_GetStateTranslation(&this->unk_310); + Matrix_GetStateTranslation(&this->limbPos[2]); } } @@ -830,8 +830,9 @@ void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_OPA_DISP = gfx; } - func_800BE680(globalCtx, NULL, &this->unk_2F8, 3, this->unk_2E8.y * this->actor.scale.y * 200.0f, this->unk_2E8.z, - this->unk_2E8.x, this->unk_18F); + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.y * 200.0f, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); this->unk_2F4 = globalCtx->gameplayFrames; CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h index e4439ec36..c8e24aa4f 100644 --- a/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h +++ b/src/overlays/actors/ovl_En_Firefly/z_en_firefly.h @@ -24,17 +24,17 @@ typedef struct EnFirefly { /* 0x18C */ u8 auraType; /* 0x18D */ u8 currentType; /* 0x18E */ u8 isInvisible; - /* 0x18F */ u8 unk_18F; + /* 0x18F */ u8 drawDmgEffType; /* 0x190 */ s16 timer; /* 0x192 */ s16 targetPitch; /* 0x194 */ Vec3s jointTable[28]; /* 0x23C */ Vec3s morphTable[28]; /* 0x2E4 */ f32 maxAltitude; - /* 0x2E8 */ Vec3f unk_2E8; + /* 0x2E8 */ f32 drawDmgEffAlpha; + /* 0x2E8 */ f32 drawDmgEffScale; + /* 0x2E8 */ f32 drawDmgEffFrozenSteamScale; /* 0x2F4 */ u32 unk_2F4; - /* 0x2F8 */ Vec3f unk_2F8; - /* 0x304 */ Vec3f unk_304; - /* 0x310 */ Vec3f unk_310; + /* 0x2F8 */ Vec3f limbPos[3]; /* 0x31C */ ColliderSphere collider; } EnFirefly; // size = 0x374 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 62417b95e..b076e2885 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 0x00005015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | 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 419e9edd4..6c9f813fd 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -214,7 +214,7 @@ void EnFish_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_246 = (u32)Rand_Next() >> 0x10; if (sp36 == ENFISH_0) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); func_8091E810(this); } else if (sp36 == ENFISH_1) { @@ -605,7 +605,7 @@ void func_8091ECF4(EnFish* this) { this->actor.gravity = 0.0f; this->actor.terminalVelocity = 0.0f; this->actor.shape.yOffset = 0.0f; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_240 = 200; func_8091D660(this); this->unkFunc = func_8091ED70; @@ -666,7 +666,7 @@ void func_8091EF30(EnFish* this) { if (this->actor.velocity.y < -1.0f) { this->actor.velocity.y = -1.0f; } - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actor.home.pos.x = this->actor.world.pos.x; this->actor.home.pos.y = this->actor.world.pos.y - 20.0f; this->actor.home.pos.z = this->actor.world.pos.z; 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 a009de48a..f86cda7d8 100644 --- a/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c +++ b/src/overlays/actors/ovl_En_Fish2/z_en_fish2.c @@ -10,7 +10,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_fb/object_fb.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnFish2*)thisx) @@ -209,7 +209,7 @@ void EnFish2_Init(Actor* thisx, GlobalContext* globalCtx) { } else if (this->actor.params != 0) { this->unk_2B4 = 10; this->actor.draw = NULL; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->actionFunc = func_80B2A01C; } } @@ -434,7 +434,7 @@ void func_80B29128(EnFish2* this) { } void func_80B2913C(EnFish2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B28B5C(this); } @@ -894,8 +894,8 @@ void func_80B2A498(EnFish2* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[81] &= (u8)~0x20; gSaveContext.save.weekEventReg[81] &= (u8)~0x40; gSaveContext.save.weekEventReg[81] &= (u8)~0x80; - gSaveContext.save.weekEventReg[82] &= (u8)~0x1; - gSaveContext.save.weekEventReg[82] &= (u8)~0x2; + gSaveContext.save.weekEventReg[82] &= (u8)~1; + gSaveContext.save.weekEventReg[82] &= (u8)~2; } } @@ -1094,9 +1094,9 @@ void func_80B2ADB0(EnFish2* this, Vec3f* vec, s16 arg2) { TexturePtr phi_v0; if (Rand_ZeroOne() < 0.5f) { - phi_v0 = gameplay_keep_Tex_091CE0; + phi_v0 = gEffBubble2Tex; } else { - phi_v0 = gameplay_keep_Tex_091BE0; + phi_v0 = gEffBubble1Tex; } ptr->unk_20 = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(phi_v0)); @@ -1168,7 +1168,7 @@ void func_80B2B180(EnFish2* this, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); gSPSegment(POLY_OPA_DISP++, 0x08, ptr->unk_20); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0301B0); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); } } 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 e6a928f00..2a8722fd7 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -4,11 +4,12 @@ * Description: Fishing Pond Elements (Owner, Fish, Props, Effects...) */ +#include "prevent_bss_reordering.h" #include "z_en_fishing.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnFishing*)thisx) @@ -118,86 +119,86 @@ typedef struct { #define LINE_SEG_COUNT 200 #define SINKING_LURE_SEG_COUNT 20 -static f32 D_809101B0; -static f32 D_809101B4; -static s16 D_809101B8; -static f32 D_809101BC; -static f32 D_809101C0; -static f32 D_809101C4; -static f32 D_809101C8; -static s16 D_809101CC; -static f32 D_809101D0; -static Vec3f sRodTipPos; -static Vec3f sReelLinePos[LINE_SEG_COUNT]; -static Vec3f sReelLineRot[LINE_SEG_COUNT]; -static Vec3f sReelLineUnk[LINE_SEG_COUNT]; -static Vec3f sLureHookRefPos[2]; -static f32 sLureHookRotY[2]; -static u8 D_80911E28; -static Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; -static s16 D_80911F20; -static f32 sProjectedW; -static Vec3f sCameraEye; -static Vec3f sCameraAt; -static s16 sCameraId; -static f32 D_80911F48; -static f32 D_80911F4C; -static f32 D_80911F50; -static Vec3f sSinkingLureBasePos; -static f32 D_80911F64; -static s32 sRandSeed0; -static s32 sRandSeed1; -static s32 sRandSeed2; -static FishingProp sPondProps[POND_PROP_COUNT]; -static FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; -static f32 sFishGroupAngle1; -static f32 sFishGroupAngle2; -static f32 sFishGroupAngle3; -static FishingEffect sFishingEffects[EFFECT_COUNT]; -static Vec3f sStreamSoundProjectedPos; -static EnFishing* sFishingMain; -static u8 D_809171C8; -static u8 sLinkAge; -static u8 D_809171CA; -static u8 D_809171CB; -static f32 D_809171CC; -static u8 D_809171D0; -static u8 D_809171D1; -static u8 D_809171D2; -static s16 D_809171D4; -static u8 D_809171D6; -static u16 D_809171D8; -static u16 D_809171DA; -static s8 D_809171DC; -static Vec3f sOwnerHeadPos; -static Vec3s sEffOwnerHatRot; -static u8 D_809171F2; -static s16 D_809171F4; -static s16 D_809171F6; -static EnFishing* sFishingHookedFish; -static s16 D_809171FC; -static s16 D_809171FE; -static s16 D_80917200; -static s16 D_80917202; -static s16 D_80917204; -static u8 D_80917206; -static Vec3f sLurePos; -static Vec3f D_80917218; -static Vec3f sLureRot; -static Vec3f D_80917238; -static Vec3f D_80917248; -static f32 D_80917254; -static f32 D_80917258; -static f32 D_8091725C; -static f32 D_80917260; -static s8 D_80917264; -static s16 D_80917266; -static u8 D_80917268; -static f32 D_8091726C; -static u8 D_80917270; -static s16 D_80917272; -static u8 D_80917274; -static Vec3f D_80917278; +f32 D_809101B0; +f32 D_809101B4; +s16 D_809101B8; +f32 D_809101BC; +f32 D_809101C0; +f32 D_809101C4; +f32 D_809101C8; +s16 D_809101CC; +f32 D_809101D0; +Vec3f sRodTipPos; +Vec3f sReelLinePos[LINE_SEG_COUNT]; +Vec3f sReelLineRot[LINE_SEG_COUNT]; +Vec3f sReelLineUnk[LINE_SEG_COUNT]; +Vec3f sLureHookRefPos[2]; +f32 sLureHookRotY[2]; +u8 D_80911E28; +Vec3f sSinkingLurePos[SINKING_LURE_SEG_COUNT]; +s16 D_80911F20; +f32 sProjectedW; +Vec3f sCameraEye; +Vec3f sCameraAt; +s16 sCameraId; +f32 D_80911F48; +f32 D_80911F4C; +f32 D_80911F50; +Vec3f sSinkingLureBasePos; +f32 D_80911F64; +s32 sRandSeed0; +s32 sRandSeed1; +s32 sRandSeed2; +FishingProp sPondProps[POND_PROP_COUNT]; +FishingGroupFish sGroupFishes[GROUP_FISH_COUNT]; +f32 sFishGroupAngle1; +f32 sFishGroupAngle2; +f32 sFishGroupAngle3; +FishingEffect sFishingEffects[EFFECT_COUNT]; +Vec3f sStreamSoundProjectedPos; +EnFishing* sFishingMain; +u8 D_809171C8; +u8 sLinkAge; +u8 D_809171CA; +u8 D_809171CB; +f32 D_809171CC; +u8 D_809171D0; +u8 D_809171D1; +u8 D_809171D2; +s16 D_809171D4; +u8 D_809171D6; +u16 D_809171D8; +u16 D_809171DA; +s8 D_809171DC; +Vec3f sOwnerHeadPos; +Vec3s sEffOwnerHatRot; +u8 D_809171F2; +s16 D_809171F4; +s16 D_809171F6; +EnFishing* sFishingHookedFish; +s16 D_809171FC; +s16 D_809171FE; +s16 D_80917200; +s16 D_80917202; +s16 D_80917204; +u8 D_80917206; +Vec3f sLurePos; +Vec3f D_80917218; +Vec3f sLureRot; +Vec3f D_80917238; +Vec3f D_80917248; +f32 D_80917254; +f32 D_80917258; +f32 D_8091725C; +f32 D_80917260; +s8 D_80917264; +s16 D_80917266; +u8 D_80917268; +f32 D_8091726C; +u8 D_80917270; +s16 D_80917272; +u8 D_80917274; +Vec3f D_80917278; const ActorInit En_Fishing_InitVars = { ACTOR_EN_FISHING, @@ -211,38 +212,38 @@ const ActorInit En_Fishing_InitVars = { (ActorFunc)EnFishing_DrawFish, }; -static f32 D_8090CCD0 = 0.0f; -static u8 D_8090CCD4 = 0; -static f32 D_8090CCD8 = 0.0f; -static Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; -static f32 D_8090CCE8 = 0.0f; -static u8 sSinkingLureLocation = 0; -static f32 D_8090CCF0 = 0.0f; -static u8 D_8090CCF4 = true; -static u16 D_8090CCF8 = 0; -static u8 D_8090CCFC = 0; -static s32 D_8090CD00 = 0; -static s16 D_8090CD04 = 0; -static u8 D_8090CD08 = 0; -static u8 D_8090CD0C = 0; -static u8 D_8090CD10 = 0; -static s16 D_8090CD14 = 0; -static Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; -static u8 D_8090CD24 = 0; -static f32 D_8090CD28 = 0; -static f32 D_8090CD2C = 0; -static f32 D_8090CD30 = 0.0f; -static f32 D_8090CD34 = 0.0f; -static f32 D_8090CD38 = 0.0f; -static f32 D_8090CD3C = 0.0f; -static f32 D_8090CD40 = 0.0f; -static s16 D_8090CD44 = 0; -static s16 D_8090CD48 = 0; -static u8 D_8090CD4C = 0; -static u8 D_8090CD50 = 0; -static u8 D_8090CD54 = 0; +f32 D_8090CCD0 = 0.0f; +u8 D_8090CCD4 = 0; +f32 D_8090CCD8 = 0.0f; +Vec3f D_8090CCDC = { 0.0f, 0.0f, 0.0f }; +f32 D_8090CCE8 = 0.0f; +u8 sSinkingLureLocation = 0; +f32 D_8090CCF0 = 0.0f; +u8 D_8090CCF4 = true; +u16 D_8090CCF8 = 0; +u8 D_8090CCFC = 0; +s32 D_8090CD00 = 0; +s16 D_8090CD04 = 0; +u8 D_8090CD08 = 0; +u8 D_8090CD0C = 0; +u8 D_8090CD10 = 0; +s16 D_8090CD14 = 0; +Vec3f sFishMouthOffset = { 500.0f, 500.0f, 0.0f }; +u8 D_8090CD24 = 0; +f32 D_8090CD28 = 0; +f32 D_8090CD2C = 0; +f32 D_8090CD30 = 0.0f; +f32 D_8090CD34 = 0.0f; +f32 D_8090CD38 = 0.0f; +f32 D_8090CD3C = 0.0f; +f32 D_8090CD40 = 0.0f; +s16 D_8090CD44 = 0; +s16 D_8090CD48 = 0; +u8 D_8090CD4C = 0; +u8 D_8090CD50 = 0; +u8 D_8090CD54 = 0; -static ColliderJntSphElementInit sJntSphElementsInit[12] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { { ELEMTYPE_UNK0, @@ -386,13 +387,13 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 12, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; -static u8 D_8090CF18 = 0; +u8 D_8090CF18 = 0; static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused +Vec3f D_8090CF28 = { 0.0f, 0.0f, 2000.0f }; // Unused void EnFishing_SetColliderElement(s32 index, ColliderJntSph* collider, Vec3f* pos, f32 scale) { collider->elements[index].dim.worldSphere.center.x = pos->x; @@ -579,7 +580,7 @@ void EnFishing_SpawnRainDrop(FishingEffect* effect, Vec3f* pos, Vec3f* rot) { } } -static FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { +FishingPropInit sPondPropInits[POND_PROP_COUNT + 1] = { { FS_PROP_ROCK, { 529, -53, -498 } }, { FS_PROP_ROCK, { 461, -66, -480 } }, { FS_PROP_ROCK, { 398, -73, -474 } }, @@ -779,7 +780,7 @@ void EnFishing_InitPondProps(EnFishing* this, GlobalContext* globalCtx) { } } -static FishingFishInit sFishInits[] = { +FishingFishInit sFishInits[] = { { 0, { 666, -45, 354 }, 38, 0.1f }, { 0, { 681, -45, 240 }, 36, 0.1f }, { 0, { 670, -45, 90 }, 41, 0.05f }, { 0, { 615, -45, -450 }, 35, 0.2f }, { 0, { 500, -45, -420 }, 39, 0.1f }, { 0, { 420, -45, -550 }, 44, 0.05f }, { 0, { -264, -45, -640 }, 40, 0.1f }, { 0, { -470, -45, -540 }, 34, 0.2f }, { 0, { -557, -45, -430 }, 54, 0.01f }, @@ -1123,11 +1124,11 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { } if (effect->unk_2C == 30) { - func_801518B0(globalCtx, 0x40B3, NULL); + Message_StartTextbox(globalCtx, 0x40B3, NULL); } if ((effect->unk_2C >= 100) && (Message_GetState(&globalCtx->msgCtx) == 5)) { - if (func_80147624(globalCtx) || !Message_GetState(&globalCtx->msgCtx)) { + if (Message_ShouldAdvance(globalCtx) || Message_GetState(&globalCtx->msgCtx) == 0) { func_801477B4(globalCtx); Rupees_ChangeBy(-50); effect->unk_2C = -1; @@ -1699,7 +1700,7 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { } } -static f32 sSinkingLureSizes[] = { +f32 sSinkingLureSizes[] = { 1.0f, 1.5f, 1.8f, 2.0f, 1.8f, 1.6f, 1.4f, 1.2f, 1.0f, 1.0f, 0.9f, 0.85f, 0.8f, 0.7f, 0.8f, 1.0f, 1.2f, 1.1f, 1.0f, 0.8f, }; @@ -1904,18 +1905,18 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* CLOSE_DISPS(globalCtx->state.gfxCtx); } -static f32 sRodScales[22] = { +f32 sRodScales[22] = { 1.0f, 1.0f, 1.0f, 0.9625f, 0.925f, 0.8875f, 0.85f, 0.8125f, 0.775f, 0.73749995f, 0.7f, 0.6625f, 0.625f, 0.5875f, 0.54999995f, 0.5125f, 0.47499996f, 0.4375f, 0.39999998f, 0.36249995f, 0.325f, 0.28749996f, }; -static f32 sRodBendRatios[22] = { +f32 sRodBendRatios[22] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.06f, 0.12f, 0.18f, 0.24f, 0.30f, 0.36f, 0.42f, 0.48f, 0.54f, 0.60f, 0.60f, 0.5142f, 0.4285f, 0.3428f, 0.2571f, 0.1714f, 0.0857f, }; -static Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; +Vec3f sRodTipOffset = { 0.0f, 0.0f, 0.0f }; void EnFishing_DrawRod(GlobalContext* globalCtx) { s16 i; @@ -2056,34 +2057,25 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -static Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_8090D614 = { 0.0f, 0.0f, 0.0f }; -#ifdef NON_MATCHING -// Stack memes, the pad on line ~2410 makes stack too big, but needed for ordering void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { f32 spE4; f32 spE0; - s16 phi_v0; + s16 i; s16 spDC; f32 spD8; f32 spD4; f32 spD0; f32 phi_f16; f32 spC8; - s16 i; + f32 phi_f0; Player* player = GET_PLAYER(globalCtx); Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f spA8; Vec3f sp9C; Vec3f sp90; Input* input = CONTROLLER1(globalCtx); - // Vec3f sp80; - - f32 phi_f0; - // f32 sp70; - // Vec3f sp64; - // Vec3f sp58; - // s32 pad; D_809171FE++; @@ -2240,8 +2232,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { spC8 = SQ(sLurePos.x) + SQ(sLurePos.z); if (spC8 > SQ(920.0f)) { - f32 temp; - if ((sLurePos.y > 160.0f) || (sLurePos.x < 80.0f) || (sLurePos.x > 180.0f) || (sLurePos.z > 1350.0f) || (sLurePos.z < 1100.0f) || (sLurePos.y < 45.0f)) { Vec3f sp80 = this->actor.world.pos; @@ -2266,10 +2256,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } - temp = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - // spE4 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); - if (sLurePos.y <= temp) { - sLurePos.y = temp; + spE0 = ((sqrtf(spC8) - 920.0f) * 0.11f) + WATER_SURFACE_Y(globalCtx); + if (sLurePos.y <= spE0) { + sLurePos.y = spE0; D_80917238.x = D_80917238.y = D_80917238.z = 0.0f; D_8090CD14 = 3; D_809101D0 = 0.0; @@ -2281,7 +2270,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } else { f32 sp7C = WATER_SURFACE_Y(globalCtx); f32 sp78; - // spE4 = WATER_SURFACE_Y(globalCtx); if (sLurePos.y <= sp7C) { D_8090CD14 = 2; @@ -2356,7 +2344,10 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; case 3: { + f32 pad; f32 sp70; + Vec3f sp64; + Vec3f sp58; D_80911F20 = 0; @@ -2432,7 +2423,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sLurePos.y += D_80917278.y; } } else if (CHECK_BTN_ALL(input->cur.button, BTN_A)) { - s32 pad; + s8 requiredScopeTemp; spDC = 0x500; D_809101B0 = sReelLineRot[LINE_SEG_COUNT - 2].y + M_PI; @@ -2483,7 +2474,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Matrix_InsertYRotation_f(sLureRot.y, MTXMODE_NEW); if (D_80917206 == 2) { - Vec3f sp64; + s8 requiredScopeTemp; Matrix_MultiplyVector3fByState(&sp90, &sp64); D_80917278.x = sp64.x; @@ -2506,7 +2497,9 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { } } else if (sReelLinePos[LINE_SEG_COUNT - 1].y < (WATER_SURFACE_Y(globalCtx) + phi_f0)) { if (D_80917206 == 2) { - Vec3f sp58 = this->actor.world.pos; + s8 requiredScopeTemp; + + sp58 = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos = sLurePos; Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 30.0f, 30.0f, 0x44); this->actor.world.pos = sp58; @@ -2579,7 +2572,8 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { if ((sLurePos.y <= (WATER_SURFACE_Y(globalCtx) + 4.0f)) && (sLurePos.y >= (WATER_SURFACE_Y(globalCtx) - 4.0f))) { - phi_v0 = 63; + s8 phi_v0 = 63; + if (CHECK_BTN_ALL(input->cur.button, BTN_A) || (D_809101B4 > 1.0f)) { phi_v0 = 1; } @@ -2590,8 +2584,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { EnFishing_SpawnRipple(NULL, globalCtx->specialEffects, &spA8, 30.0f, 300.0f, 150, 90); } } - break; - } + } break; // must be outside of the block case 4: if (this->unk_14F != 0) { @@ -2626,10 +2619,6 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { break; } } -#else -static Vec3f D_8090D620 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateLure.s") -#endif s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) { s16 i; @@ -2833,7 +2822,7 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { if (this->unk_1CB == 0) { if (this->unk_1CC == 0) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { D_8090CCF8 = D_809171CC; @@ -2843,7 +2832,7 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } } else { this->unk_1CC--; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } else if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->unk_1CB = 0; @@ -2851,8 +2840,6 @@ void EnFishing_HandleAquariumDialog(EnFishing* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// D_80917266 in case 5 around the large branching void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 i; s16 sp134 = 10; @@ -2868,7 +2855,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { s16 spFE; s16 spFC; s16 spFA; - s16 phi_v0; + s16 spF8; s16 spF6; s16 spF4; s16 spF2; @@ -2883,11 +2870,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { f32 phi_f2; Vec3f spC4; Vec3f spB8; - u8 phi_v0_2; f32 temp_f0; f32 temp; - s32 pad; - f32 spA4; + f32 temp2; this->actor.uncullZoneForward = 700.0f; this->actor.uncullZoneScale = 50.0f; @@ -2898,11 +2883,11 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp118 = (player->actor.speedXZ * 0.3f) + 0.25f; } - if ((D_80917200 != 0) || (sCameraId != MAIN_CAM) || + if ((D_80917200 != 0) || (sCameraId != CAM_ID_MAIN) || ((player->actor.world.pos.z > 1150.0f) && (this->unk_150 != 100))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (D_8090CD14 != 0) { if (D_80917202 == 0) { this->actor.focus.pos = sLurePos; @@ -3079,12 +3064,12 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_172[1] = 50; } - if (!Message_GetState(&globalCtx->msgCtx)) { - if ((gSaveContext.save.time >= 0xC000) && (gSaveContext.save.time <= 0xC01B)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { + if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && (gSaveContext.save.time <= 0xC01B)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } - if ((gSaveContext.save.time >= 0x3AAA) && (gSaveContext.save.time <= 0x3AC5)) { + if ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= 0x3AC5)) { this->unk_150 = 7; this->unk_172[3] = Rand_ZeroFloat(150.0f) + 200.0f; } @@ -3112,7 +3097,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (D_80917206 == 2) { func_809038A4(this, input); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } break; @@ -3149,7 +3134,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (D_80917206 == 2) { func_809038A4(this, input); } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } break; @@ -3192,7 +3177,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1AC.z = Rand_ZeroFloat(50.0f); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; break; case -2: @@ -3231,7 +3216,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } Math_ApproachF(&this->unk_1A8, 2048.0f, 1.0f, 128.0f); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } break; @@ -3435,6 +3420,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { this->unk_188 = 1.0f; this->unk_18C = 2000.0f; } else if (sp124 < 10.0f) { + s16 phi_v0; + if (func_809033F0(this, globalCtx, false)) { func_80903C60(this, 0); } @@ -3565,15 +3552,15 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { D_809171F6 = 0; if (this->unk_148 == 1) { - spA4 = (this->unk_1A4 * 3.0f) + 120.0f; + temp2 = (this->unk_1A4 * 3.0f) + 120.0f; } else { - spA4 = (2.0f * this->unk_1A4) + 120.0f; + temp2 = (2.0f * this->unk_1A4) + 120.0f; } - if (spA4 > 255.0f) { - spA4 = 255.0f; + if (temp2 > 255.0f) { + temp2 = 255.0f; } - func_8013EC44(0.0f, spA4, 120, 5); + func_8013EC44(0.0f, temp2, 120, 5); D_809171F4 = 40; D_80911E28 = 10; play_sound(NA_SE_IT_FISHING_HIT); @@ -3581,6 +3568,9 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } if (this->actor.world.pos.y < WATER_SURFACE_Y(globalCtx)) { + u8 phi_v0_2; + f32 spA4; + if (this->unk_172[1] > 30) { phi_v0_2 = 7; } else { @@ -3793,7 +3783,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { player->unk_B28 = 3; func_8013EC44(0.0f, 1, 3, 1); D_809171D8++; - func_800EA0D4(globalCtx, &globalCtx->csCtx); + Cutscene_Start(globalCtx, &globalCtx->csCtx); D_8090CD4C = 100; D_80911F48 = 45.0f; D_8090CD14 = 5; @@ -3875,8 +3865,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { if (this->unk_172[0] <= 50) { switch (this->unk_1CD) { case 0: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { - if (func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { if (D_8090CCF0 == 0.0f) { @@ -3888,7 +3878,7 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { ((s16)this->unk_1A4 < (s16)D_8090CCF0)) { this->unk_1CD = 1; this->unk_172[0] = 0x3C; - func_801518B0(globalCtx, 0x4098, NULL); + Message_StartTextbox(globalCtx, 0x4098, NULL); } else { f32 temp1 = D_8090CCF0; s16 temp2 = D_809171D0; @@ -3906,8 +3896,8 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { - if (func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex != 0) { f32 temp1 = D_8090CCF0; @@ -4181,9 +4171,6 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateFish.s") -#endif s32 EnFishing_FishOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -4359,7 +4346,7 @@ void EnFishing_UpdatePondProps(GlobalContext* globalCtx) { prop++; } - if (sCameraId == MAIN_CAM) { + if (sCameraId == CAM_ID_MAIN) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &sFishingMain->collider.base); } } @@ -4698,7 +4685,7 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -static u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; +u16 D_8090D638[] = { 0x4096, 0x408D, 0x408E, 0x408F, 0x4094, 0x4095 }; void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { switch (this->unk_154) { @@ -4736,7 +4723,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 1: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4764,7 +4751,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 2: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80151938(globalCtx, 0x407F); this->unk_154 = 4; @@ -4772,7 +4759,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 3: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } @@ -4782,7 +4769,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 4: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4799,7 +4786,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 5: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); globalCtx->interfaceCtx.unk_27E = 1; @@ -4816,7 +4803,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 10: if (D_8090CD0C != 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4832,7 +4819,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } } else { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -4904,8 +4891,8 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 11: - if (((Message_GetState(&globalCtx->msgCtx) == 5) || !Message_GetState(&globalCtx->msgCtx)) && - func_80147624(globalCtx)) { + if (((Message_GetState(&globalCtx->msgCtx) == 5) || Message_GetState(&globalCtx->msgCtx) == 0) && + Message_ShouldAdvance(globalCtx)) { s32 getItemId; func_801477B4(globalCtx); @@ -4919,7 +4906,6 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { gSaveContext.save.unk_EE4 &= 0xFFFFFF00; gSaveContext.save.unk_EE4 |= ((s16)D_809171CC & 0x7F); - temp = (gSaveContext.save.unk_EE4 & 0x7F000000) >> 0x18; if (temp < D_809171CC) { gSaveContext.save.unk_EE4 &= 0xFFFFFF; @@ -4981,14 +4967,14 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 20: - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->unk_154 = 0; } break; case 21: - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { @@ -5008,7 +4994,7 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { break; case 22: - if (!Message_GetState(&globalCtx->msgCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 0) { this->unk_154 = 0; if (D_8090CD0C != 0) { D_8090CD08 = 1; @@ -5030,11 +5016,11 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { case 24: D_8090CCF4 = false; - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { if (D_809171D0 == 0) { this->unk_154 = 0; } else { - func_801518B0(globalCtx, 0x409C, NULL); + Message_StartTextbox(globalCtx, 0x409C, NULL); this->unk_154 = 20; } } @@ -5042,19 +5028,17 @@ void EnFishing_HandleOwnerDialog(EnFishing* this, GlobalContext* globalCtx) { } } -static s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; +s16 D_8090D644[] = { 0, 1, 2, 2, 1 }; -static Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; +Vec3f sStreamSoundPos = { 670.0f, 0.0f, -600.0f }; -static Vec3s sSinkingLureLocationPos[] = { +Vec3s sSinkingLureLocationPos[] = { { -364, -30, -269 }, { 1129, 3, -855 }, { -480, 0, -1055 }, { 553, -48, -508 }, }; -#ifdef NON_MATCHING -// Register flip around target near the end of the function void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; EnFishing* this = THIS; @@ -5066,10 +5050,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { f32 target; f32 camAtFraction; f32 lureDistXZ; - s32 pad; + Camera* camera; Player* player = GET_PLAYER(globalCtx); Input* input = CONTROLLER1(globalCtx); - Camera* camera; playerShadowAlpha = player->actor.shape.shadowAlpha; @@ -5084,9 +5067,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { SkelAnime_Update(&this->skelAnime); if ((D_8090CD04 != 0) || Message_GetState(&globalCtx->msgCtx)) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else { - this->actor.flags |= 0x21; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_20); } if ((this->actor.xzDistToPlayer < 120.0f) || Message_GetState(&globalCtx->msgCtx)) { @@ -5125,7 +5108,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if ((sqrtf(SQ(dx) + SQ(dy) + SQ(dz)) < 25.0f)) { D_8090CD08 = 0; D_8090CD0C = 1; - func_801518B0(globalCtx, 0x4087, NULL); + Message_StartTextbox(globalCtx, 0x4087, NULL); } } @@ -5138,7 +5121,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { if (D_8090CCFC != 0) { D_8090CCFC--; if (D_8090CCFC == 0) { - func_801518B0(globalCtx, D_809171DA, NULL); + Message_StartTextbox(globalCtx, D_809171DA, NULL); } } @@ -5185,10 +5168,10 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; case 1: - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; @@ -5201,7 +5184,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { // fallthrough case 2: - ShrinkWindow_SetLetterboxTarget(0x1B); + ShrinkWindow_SetLetterboxTarget(27); spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; @@ -5295,36 +5278,36 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; case 3: { - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; camera->at = sCameraAt; } func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; player->unk_B28 = -5; D_80917200 = 5; break; case 10: - func_800EA0D4(globalCtx, &globalCtx->csCtx); - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; sCameraAt.x = camera->at.x; sCameraAt.y = camera->at.y; sCameraAt.z = camera->at.z; - func_801518B0(globalCtx, 0x409E, NULL); + Message_StartTextbox(globalCtx, 0x409E, NULL); D_8090CD4C = 11; func_8013EC44(0.0f, 150, 10, 10); // fallthrough @@ -5333,44 +5316,44 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { player->actor.world.pos.z = 1360.0f; player->actor.speedXZ = 0.0f; - if (!Message_GetState(&globalCtx->msgCtx)) { - camera = Play_GetCamera(globalCtx, MAIN_CAM); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); camera->eye = sCameraEye; camera->eyeNext = sCameraEye; camera->at = sCameraAt; func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; D_8090CD50 = 30; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } break; case 20: - func_800EA0D4(globalCtx, &globalCtx->csCtx); - sCameraId = func_801694DC(globalCtx); - func_80169590(globalCtx, MAIN_CAM, 1); - func_80169590(globalCtx, sCameraId, 7); + Cutscene_Start(globalCtx, &globalCtx->csCtx); + sCameraId = Play_CreateSubCamera(globalCtx); + Play_CameraChangeStatus(globalCtx, CAM_ID_MAIN, 1); + Play_CameraChangeStatus(globalCtx, sCameraId, 7); func_800B7298(globalCtx, &this->actor, 4); - camera = Play_GetCamera(globalCtx, MAIN_CAM); + camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); sCameraEye.x = camera->eye.x; sCameraEye.y = camera->eye.y; sCameraEye.z = camera->eye.z; sCameraAt.x = camera->at.x; sCameraAt.y = camera->at.y; sCameraAt.z = camera->at.z; - func_801518B0(globalCtx, 0x409A, NULL); + Message_StartTextbox(globalCtx, 0x409A, NULL); D_8090CD4C = 21; D_80911F48 = 45.0f; D_8090CD50 = 10; // fallthrough case 21: - if ((D_8090CD50 == 0) && func_80147624(globalCtx)) { + if ((D_8090CD50 == 0) && Message_ShouldAdvance(globalCtx)) { D_8090CD4C = 22; D_8090CD50 = 40; // func_800B7298 call removed in MM @@ -5426,9 +5409,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { } if (D_8090CD50 == 0) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) || !Message_GetState(&globalCtx->msgCtx)) { - if (func_80147624(globalCtx)) { - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); + if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 0) { + if (Message_ShouldAdvance(globalCtx)) { + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); func_801477B4(globalCtx); if (globalCtx->msgCtx.choiceIndex == 0) { @@ -5440,16 +5423,16 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { camera->eyeNext = sCameraEye; camera->at = sCameraAt; func_80169AFC(globalCtx, sCameraId, 0); - func_800EA0EC(globalCtx, &globalCtx->csCtx); + Cutscene_End(globalCtx, &globalCtx->csCtx); func_800B7298(globalCtx, &this->actor, 6); // arg2 changed from 7 to 6 in MM D_8090CD4C = 0; - sCameraId = MAIN_CAM; + sCameraId = CAM_ID_MAIN; player->unk_B28 = -5; D_80917200 = 5; D_8090CD54 = 0; D_809171F6 = 20; func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } } } @@ -5459,20 +5442,20 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { break; } - if (sCameraId != MAIN_CAM) { + if (sCameraId != CAM_ID_MAIN) { Play_CameraSetAtEye(globalCtx, sCameraId, &sCameraAt, &sCameraEye); Math_ApproachF(&D_80911F4C, 1.0f, 1.0f, 0.02f); if (sCameraEye.y <= (WATER_SURFACE_Y(globalCtx) + 1.0f)) { func_800F6834(globalCtx, 1); if (D_809171CA != 0) { - globalCtx->envCtx.unk_8C.fogNear = -0xB2; + globalCtx->envCtx.lightSettings.fogNear = -0xB2; } else { - globalCtx->envCtx.unk_8C.fogNear = -0x2E; + globalCtx->envCtx.lightSettings.fogNear = -0x2E; } } else { func_800F6834(globalCtx, 0); - globalCtx->envCtx.unk_8C.fogNear = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; } } @@ -5518,7 +5501,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { D_809171CB--; } - if ((D_809171CB == 1) && !Message_GetState(&globalCtx->msgCtx) && ((D_8090CD00 & 0xFFF) == 0xFFF)) { + if ((D_809171CB == 1) && Message_GetState(&globalCtx->msgCtx) == 0 && ((D_8090CD00 & 0xFFF) == 0xFFF)) { D_809171CB = 200; if (Rand_ZeroOne() < 0.5f) { @@ -5533,7 +5516,8 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachF(&D_8090CCD0, D_8090CCD4, 1.0f, 0.05f); if (D_8090CCD0 > 0.0f) { - target = (D_8090CCD0 * 0.03f) + 0.8f; + f32 target = (D_8090CCD0 * 0.03f) + 0.8f; + if (target > 1.2f) { target = 1.2f; } @@ -5556,14 +5540,13 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachZeroF(&D_8090CCD8, 1.0f, 2.0f); } - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.diffuseColor1[1] = - globalCtx->envCtx.unk_8C.diffuseColor1[2] = D_8090CCD8; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = D_8090CCD8; if ((u8)D_8090CCD0 > 0) { s32 pad; - Camera* camera = Play_GetCamera(globalCtx, MAIN_CAM); s16 i; - s32 pad1; + Camera* camera = Play_GetCamera(globalCtx, CAM_ID_MAIN); Vec3f pos; Vec3f rot; Vec3f projectedPos; @@ -5571,7 +5554,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { rot.x = 1.6707964f; rot.y = 1.0f; - rot.z = (func_800DFC68(camera) * -(M_PI / 32768)) + rot.y; + rot.z = (Camera_GetInputDirYaw(camera) * -(M_PI / 32768)) + rot.y; for (i = 0; i < (u8)D_8090CCD0; i++) { pos.x = randPlusMinusPoint5Scaled(700.0f) + globalCtx->view.eye.x; @@ -5601,9 +5584,6 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { gSaveContext.minigameScore = (SQ((f32)D_8090CCF8) * 0.0036f) + 0.5f; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fishing/EnFishing_UpdateOwner.s") -#endif s32 EnFishing_OwnerOverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -5632,10 +5612,10 @@ void EnFishing_OwnerPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } } -static UNK_TYPE sFishingOwnerEyeTexs[] = { - &gFishingOwnerEyeOpenTex, - &gFishingOwnerEyeHalfTex, - &gFishingOwnerEyeClosedTex, +TexturePtr sFishingOwnerEyeTexs[] = { + gFishingOwnerEyeOpenTex, + gFishingOwnerEyeHalfTex, + gFishingOwnerEyeClosedTex, }; void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { 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 8b8531a47..de7d34024 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -5,9 +5,8 @@ */ #include "z_en_floormas.h" -#include "objects/object_wallmaster/object_wallmaster.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnFloormas*)thisx) @@ -154,8 +153,8 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wallmaster_Skel_008FB0, &object_wallmaster_Anim_009DB0, - this->jointTable, this->morphTable, 25); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -164,13 +163,13 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.params = ENFLOORMAS_GET_7FFF(&this->actor); if (params != 0) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; this->actor.draw = func_808D3754; } if (this->actor.params == ENFLOORMAS_GET_7FFF_10) { this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_808D2AA8; return; } @@ -233,33 +232,33 @@ void func_808D0930(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D09CC(EnFloormas* this) { - this->unk_18C = 10; - this->unk_2C8 = 0.55f; - this->unk_2CC = 0.82500005f; - this->unk_2C4 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_18E = 80; - this->actor.flags &= ~(0x400 | 0x200); + this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_400); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT0; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), 2, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, this->actor.scale.x * 30.000002f, this->actor.scale.x * 20.0f); if (this->actor.scale.x > 0.009f) { - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } else { - this->actor.flags |= 0x200; + this->actor.flags |= ACTOR_FLAG_200; } } } void func_808D0B08(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0B50; } @@ -278,7 +277,7 @@ void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0C14(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_00A054, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterStandUpAnim, -3.0f); this->actionFunc = func_808D0C58; } @@ -296,7 +295,7 @@ void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx) { void func_808D0CE4(EnFloormas* this) { if (this->actionFunc != func_808D0F80) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 1.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 1.5f); } else { this->skelAnime.playSpeed = 1.5f; } @@ -334,7 +333,7 @@ void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0ECC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009244); + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0F14; } @@ -373,10 +372,10 @@ void func_808D108C(EnFloormas* this) { this->actor.speedXZ = 0.0f; if (sp36 > 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_002158, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gFloormasterTurnAnim, -3.0f); } else { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_002158, -1.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_002158.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gFloormasterTurnAnim, -1.0f, Animation_GetLastFrame(&gFloormasterTurnAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); } if (this->actor.scale.x > 0.009f) { @@ -418,8 +417,8 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_009520, 3.0f, 0.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_009520.common), 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterHoverAnim), + ANIMMODE_ONCE, -3.0f); this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); @@ -492,7 +491,7 @@ void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1740(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, 42.0f, 2, 5.0f); + 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)) { this->unk_18E = 30; } else { @@ -538,7 +537,7 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { if ((this->unk_18E == 0) && (sp24 != 0)) { if (this->skelAnime.endFrame < 45.0f) { - this->skelAnime.endFrame = Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common); + this->skelAnime.endFrame = Animation_GetLastFrame(&gWallmasterJumpAnim); } else if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { func_808D2700(this); } else { @@ -556,10 +555,10 @@ void func_808D19D4(EnFloormas* this) { Actor* parent; this->actor.colorFilterTimer = 0; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SetScale(&this->actor, 0.004f); - this->actor.flags |= 0x10; - if ((this->actor.flags & 0x80) == 0x80) { + this->actor.flags |= ACTOR_FLAG_10; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { this->actor.draw = func_808D3754; } else { this->actor.draw = EnFloormas_Draw; @@ -569,12 +568,12 @@ void func_808D19D4(EnFloormas* this) { this->actor.shape.rot.y = parent->shape.rot.y + 0x5555; this->actor.world.pos = parent->world.pos; this->actor.params = ENFLOORMAS_GET_7FFF_10; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, 0.0f); this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; this->collider.dim.height = sCylinderInit.dim.height * 0.6f; - this->actor.flags &= ~0x400; - this->actor.flags |= 0x200; + this->actor.flags &= ~ACTOR_FLAG_400; + this->actor.flags |= ACTOR_FLAG_200; this->actor.colChkInfo.health = 1; this->actor.speedXZ = 4.0f; this->actor.velocity.y = 7.0f; @@ -584,7 +583,7 @@ void func_808D19D4(EnFloormas* this) { void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (SkelAnime_Update(&this->skelAnime)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_194 = 50; func_808D0C14(this); } @@ -596,7 +595,7 @@ void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1BCC(EnFloormas* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1C1C; } @@ -623,7 +622,7 @@ void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { void func_808D1D0C(EnFloormas* this) { if (this->actionFunc != func_808D1C1C) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); } this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1D6C; @@ -686,7 +685,7 @@ void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1FD4(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D2040; } @@ -716,8 +715,8 @@ void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; u8 playerForm; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 36.0f, 45.0f, 2, -3.0f); - this->actor.flags &= ~1; + 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.velocity.y = 0.0f; func_808D08D0(this); @@ -761,7 +760,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = 0; this->actor.velocity.y = 6.0f; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.speedXZ = -3.0f; func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { @@ -772,7 +771,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2484(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D24F0; } @@ -816,7 +815,7 @@ void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2700(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; this->unk_194 = 1500; this->actor.params = ENFLOORMAS_GET_7FFF_40; @@ -873,18 +872,18 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.scale.x >= 0.01f) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_808D0908(this); this->actor.params = ENFLOORMAS_GET_7FFF_0; - this->actor.flags &= ~0x200; - this->actor.flags |= 0x400; + this->actor.flags &= ~ACTOR_FLAG_200; + this->actor.flags |= ACTOR_FLAG_400; this->actor.colChkInfo.health = sColChkInfoInit.health; func_808D0C14(this); } else if (this->unk_18E == 0) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_0039B0); + Animation_PlayOnce(&this->skelAnime, &gFloormasterTapFingerAnim); this->unk_18E = 1; } else { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; } } @@ -896,7 +895,7 @@ void func_808D2A20(EnFloormas* this) { EnFloormas* parent = (EnFloormas*)this->actor.parent; EnFloormas* child = (EnFloormas*)this->actor.child; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; if ((parent->actionFunc == func_808D2AA8) && (child->actionFunc == func_808D2AA8)) { func_808D2AB8(parent); @@ -904,7 +903,7 @@ void func_808D2A20(EnFloormas* this) { Actor_MarkForDeath(&this->actor); } else { this->actor.draw = NULL; - this->actor.flags &= ~(0x10 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); this->actionFunc = func_808D2AA8; } } @@ -924,7 +923,7 @@ void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2B18(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_000590, -3.0f); + 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; @@ -967,7 +966,7 @@ void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2CDC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_000EA4); + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1009,16 +1008,17 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_18C != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.colChkInfo.damageEffect == 0xE) { func_808D0908(this); this->actor.colorFilterTimer = 0; this->actor.colChkInfo.damage = 4; this->unk_192 = -1600; this->actor.gravity = -1.0f; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; } if (this->collider.base.colType != COLTYPE_HARD) { @@ -1029,7 +1029,7 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_DEAD); } Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else if (this->actor.colChkInfo.damage != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); } @@ -1053,19 +1053,19 @@ void func_808D2E34(EnFloormas* this, GlobalContext* globalCtx) { this->unk_18E = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2C8 = 0.55f; - this->unk_2C4 = 2.0f; - this->unk_18C = 31; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; func_808D2D6C(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.55f; - this->unk_18C = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, @@ -1107,7 +1107,7 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, this->actor.scale.x * 3000.0f, 0.0f, 0x1D); Collider_UpdateCylinder(&this->actor, &this->collider); if (this->actionFunc == func_808D1650) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } @@ -1133,12 +1133,12 @@ void EnFloormas_Update(Actor* thisx, GlobalContext* globalCtx) { } } - if (this->unk_2C4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.275f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.55f); - } else if (!Math_StepToF(&this->unk_2CC, 0.55f, 0.01375f)) { + 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.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1150,9 +1150,10 @@ s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d Actor* thisx, Gfx** gfx) { EnFloormas* this = THIS; - if (limbIndex == 1) { + if (limbIndex == WALLMASTER_LIMB_ROOT) { pos->z += this->unk_192; } + return false; } @@ -1161,16 +1162,13 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis EnFloormas* this = THIS; if (D_808D393C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_808D393C[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); } - if (limbIndex == 19) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_2D0[9]); - Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->unk_2D0[10]); - return; - } - - if (limbIndex == 2) { + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { Matrix_StatePush(); Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); @@ -1178,7 +1176,7 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, object_wallmaster_DL_008688); + gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); Matrix_StatePop(); } @@ -1203,9 +1201,10 @@ void EnFloormas_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - 100.0f * (this->unk_2C8 * this->actor.scale.x), 100.0f * (this->unk_2CC * this->actor.scale.x), - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + 100.0f * (this->drawDmgEffScale * this->actor.scale.x), + 100.0f * (this->drawDmgEffFrozenSteamScale * this->actor.scale.x), this->drawDmgEffAlpha, + this->drawDmgEffType); } void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { @@ -1227,7 +1226,8 @@ void func_808D3754(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), - this->unk_2C8 * this->actor.scale.x * 100.0f, this->unk_2CC * this->actor.scale.x * 100.0f, - this->unk_2C4, this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale * this->actor.scale.x * 100.0f, + this->drawDmgEffFrozenSteamScale * this->actor.scale.x * 100.0f, this->drawDmgEffAlpha, + this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index ebfa17777..5c33ba886 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -2,6 +2,7 @@ #define Z_EN_FLOORMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" struct EnFloormas; @@ -21,17 +22,17 @@ typedef struct EnFloormas { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnFloormasActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[25]; - /* 0x022C */ Vec3s morphTable[25]; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[11]; + /* 0x0196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x022C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[11]; /* 0x0354 */ ColliderCylinder collider; } EnFloormas; // size = 0x3A0 diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index fb5b56451..34b43ef66 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -6,7 +6,7 @@ #include "z_en_fr.h" -#define FLAGS 0x40000000 +#define FLAGS (ACTOR_FLAG_40000000) #define THIS ((EnFr*)thisx) @@ -45,8 +45,8 @@ void EnFr_Update(Actor* thisx, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, ENFR_GET_SWITCHFLAG(&this->actor))) { Actor_MarkForDeath(&this->actor); } else if (this->actor.xyzDistToPlayerSq < SQ(IREG(29))) { - this->actor.flags &= ~0x40000000; + this->actor.flags &= ~ACTOR_FLAG_40000000; } else { - this->actor.flags |= 0x40000000; + this->actor.flags |= ACTOR_FLAG_40000000; } } 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 b75c65c94..c48c26471 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -5,10 +5,9 @@ */ #include "z_en_fsn.h" -#include "objects/object_fsn/object_fsn.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnFsn*)thisx) @@ -47,6 +46,29 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx); void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx); void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx); +typedef enum { + /* 0 */ ENFSN_CUTSCENESTATE_STOPPED, + /* 1 */ ENFSN_CUTSCENESTATE_WAITING, + /* 2 */ ENFSN_CUTSCENESTATE_PLAYING +} EnFsnCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + const ActorInit En_Fsn_InitVars = { ACTOR_EN_FSN, ACTORCAT_NPC, @@ -59,14 +81,20 @@ const ActorInit En_Fsn_InitVars = { (ActorFunc)EnFsn_Draw, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, 0, 0 }, { &object_fsn_Anim_0131FC, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C58C, -1.0f, 0, -1, 2, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00F00C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00D354, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_01430C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C26C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static ColliderCylinderInit sCylinderInit = { @@ -125,7 +153,7 @@ u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { switch (this->textId) { case 0: - if (!(gSaveContext.save.weekEventReg[0x50] & 0x10)) { + if (!(gSaveContext.save.weekEventReg[80] & 0x10)) { this->textId = 0x29E0; break; } else { @@ -138,7 +166,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.save.weekEventReg[0x50] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; } else { @@ -158,7 +186,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.save.weekEventReg[0x50] |= 0x10; + gSaveContext.save.weekEventReg[80] |= 0x10; this->textId = 0x29F1; break; case 0x29F1: @@ -166,7 +194,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_END_CONVERSATION; break; } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); if (this->flags & ENFSN_END_CONVERSATION) { if (this->flags & ENFSN_GAVE_LETTER_TO_MAMA) { this->flags &= ~ENFSN_GAVE_LETTER_TO_MAMA; @@ -181,7 +209,8 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleSetupResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx) && this->cutsceneState == 0) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) && + this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); if (ENFSN_IS_SHOP(&this->actor)) { @@ -199,19 +228,19 @@ void EnFsn_UpdateCollider(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_HandleLookToShopkeeperBuyingCutscene(EnFsn* this) { - if (this->cutsceneState == 2 && this->lookToShopkeeperBuyingCutscene != this->cutscene && - this->actor.textId == 0x29CE) { + 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); } this->cutscene = this->lookToShopkeeperBuyingCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -272,8 +301,8 @@ void EnFsn_CursorLeftRight(EnFsn* this) { } s16 EnFsn_GetThirdDayItemId(void) { - if (!(gSaveContext.save.weekEventReg[0x21] & 4) && CURRENT_DAY == 3) { - if (!(gSaveContext.save.weekEventReg[0x21] & 8) && !(gSaveContext.save.weekEventReg[0x4F] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[33] & 4) && CURRENT_DAY == 3) { + if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { return SI_BOMB_BAG_30_1; } return SI_MASK_ALL_NIGHT; @@ -299,22 +328,23 @@ s16 EnFsn_GetStolenItemId(u32 stolenItem) { s32 EnFsn_HasItemsToSell(void) { if (CURRENT_DAY != 3) { - if (((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.save.stolenItems & 0xFF0000) >> 0x10)) { - return true; - } - return false; - } else { - if (((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) || ((gSaveContext.save.stolenItems & 0xFF0000) >> 0x10) || - !(gSaveContext.save.weekEventReg[0x21] & 4)) { + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE)) { return true; } return false; } + + if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE) || + !(gSaveContext.save.weekEventReg[33] & 4)) { + return true; + } + + return false; } void EnFsn_GetShopItemIds(EnFsn* this) { - u32 stolenItem1 = (gSaveContext.save.stolenItems & 0xFF000000) >> 0x18; - u32 stolenItem2 = (gSaveContext.save.stolenItems & 0xFF0000) >> 0x10; + u32 stolenItem1 = STOLEN_ITEM_1; + u32 stolenItem2 = STOLEN_ITEM_2; s16 itemId; this->stolenItem1 = this->stolenItem2 = 0; @@ -356,9 +386,9 @@ void EnFsn_SpawnShopItems(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); globalCtx->msgCtx.msgMode = 0x43; @@ -376,7 +406,7 @@ void EnFsn_EndInteraction(EnFsn* this, GlobalContext* globalCtx) { s32 EnFsn_TestEndInteraction(EnFsn* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; @@ -394,14 +424,14 @@ s32 EnFsn_TestCancelOption(EnFsn* this, GlobalContext* globalCtx, Input* input) } void EnFsn_UpdateCursorPos(EnFsn* this, GlobalContext* globalCtx) { - s16 sp2E; - s16 sp2C; + s16 x; + s16 y; f32 xOffset = 0.0f; f32 yOffset = 17.0f; - Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &sp2E, &sp2C); - this->cursorPos.x = sp2E + xOffset; - this->cursorPos.y = sp2C + yOffset; + Actor_GetScreenPos(globalCtx, &this->items[this->cursorIdx]->actor, &x, &y); + this->cursorPos.x = x + xOffset; + this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; } @@ -411,19 +441,19 @@ s32 EnFsn_FacingShopkeeperDialogResult(EnFsn* this, GlobalContext* globalCtx) { func_8019F208(); if (CURRENT_DAY != 3) { this->actor.textId = 0x29FB; - } else if (gSaveContext.save.weekEventReg[0x21] & 4) { + } else if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x29FF; - } else if (!(gSaveContext.save.weekEventReg[0x21] & 8) && !(gSaveContext.save.weekEventReg[0x4F] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D7; } else { this->actor.textId = 0x29D8; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); return true; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; return true; @@ -573,8 +603,7 @@ void EnFsn_UpdateCursorAnim(EnFsn* this) { void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -601,54 +630,51 @@ void EnFsn_UpdateStickDirectionPromptAnim(EnFsn* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { - EnFsn* this2; - s32 maxColor = 255; - if (EnFsn_HasItemsToSell()) { EnFsn_SpawnShopItems(this, globalCtx); - this2 = this; - this2->cursorPos.x = 100.0f; - this2->cursorPos.y = 100.0f; - this2->stickAccumY = 0; - this2->stickAccumX = 0; + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; + this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this->cursorAnimTween = 0.0f; this->stickLeftPrompt.stickColor.r = 200; this->stickLeftPrompt.stickColor.g = 200; @@ -656,8 +682,8 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickLeftPrompt.stickColor.a = 180; this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexY = 95.0f; - this->stickLeftPrompt.arrowColor.r = maxColor; - this->stickLeftPrompt.arrowColor.g = maxColor; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; this->stickLeftPrompt.arrowColor.b = 0; this->stickLeftPrompt.arrowColor.a = 200; this->stickLeftPrompt.arrowTexX = 33.0f; @@ -671,7 +697,7 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.stickColor.a = 180; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexY = 95.0f; - this->stickRightPrompt.arrowColor.r = maxColor; + this->stickRightPrompt.arrowColor.r = 255; this->stickRightPrompt.arrowColor.g = 0; this->stickRightPrompt.arrowColor.b = 0; this->stickRightPrompt.arrowColor.a = 200; @@ -685,21 +711,21 @@ void EnFsn_InitShop(EnFsn* this, GlobalContext* globalCtx) { this->stickAnimTween = this->arrowAnimTween = 0.0f; } this->blinkTimer = 20; - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->eyeTextureIdx = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_Idle; } void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 4) { + if (this->animationIndex == FSN_ANIMATION_HANDS_ON_COUNTER_START) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (curFrame == frameCount) { - this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } return; } @@ -710,16 +736,16 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; } this->actor.textId = EnFsn_GetWelcome(globalCtx); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); player->actor.world.pos.x = 1.0f; player->actor.world.pos.z = -34.0f; this->actionFunc = EnFsn_BeginInteraction; @@ -732,29 +758,29 @@ void EnFsn_Idle(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags & ENFSN_ANGRY) { this->flags &= ~ENFSN_ANGRY; - this->animationIdx = 11; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if (this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } if (this->flags & ENFSN_CALM_DOWN) { this->flags &= ~ENFSN_CALM_DOWN; - this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else if (this->flags & ENFSN_OFFER_FINAL_PRICE) { this->flags &= ~ENFSN_OFFER_FINAL_PRICE; - this->animationIdx = 12; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_MAKE_OFFER; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { - if (this->animationIdx == 12) { + if (this->animationIndex == FSN_ANIMATION_MAKE_OFFER) { if (curFrame == frameCount) { - this->animationIdx = 5; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); } else { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); @@ -770,10 +796,10 @@ void EnFsn_Haggle(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_BeginInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 1) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { Interface_SetDoAction(globalCtx, DO_ACTION_NEXT); if (EnFsn_HasItemsToSell()) { @@ -796,20 +822,20 @@ void EnFsn_StartBuying(EnFsn* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: this->actor.textId = 0x29CD; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29CD: this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29CE: this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 0x29CF: @@ -824,7 +850,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->actor.textId) { case 0x29CC: if (CURRENT_DAY != 3) { @@ -832,40 +858,39 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D2; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D2: - if (gSaveContext.save.weekEventReg[0x21] & 4) { + if (gSaveContext.save.weekEventReg[33] & 4) { this->actor.textId = 0x2A01; - } else if (!(gSaveContext.save.weekEventReg[0x21] & 8) && - !(gSaveContext.save.weekEventReg[0x4F] & 0x40)) { + } else if (!(gSaveContext.save.weekEventReg[33] & 8) && + !(gSaveContext.save.weekEventReg[79] & 0x40)) { this->actor.textId = 0x29D3; } else { this->actor.textId = 0x29D4; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; case 0x29D3: case 0x29D4: case 0x29FA: case 0x2A01: this->actor.textId = 0x29D5; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); break; } } } else if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { - u32 trueTmp = true; + if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - this->isSelling = trueTmp; + this->isSelling = true; this->stickLeftPrompt.isEnabled = false; - this->stickRightPrompt.isEnabled = trueTmp; + this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_FaceShopkeeperSelling; break; case 1: @@ -873,7 +898,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { this->isSelling = false; this->actor.textId = 0x29CE; EnFsn_HandleLookToShopkeeperBuyingCutscene(this); - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; } @@ -884,7 +909,7 @@ void EnFsn_AskBuyOrSell(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_SetupDeterminePrice(EnFsn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; } } @@ -919,7 +944,7 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { } else { this->actor.textId = 0x29D1; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); this->actionFunc = EnFsn_SetupEndInteraction; } @@ -930,15 +955,15 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if (talkState == 4 && func_80147624(globalCtx)) { + if (talkState == 4 && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } switch (this->price) { case 5: @@ -970,7 +995,7 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - if (this->isSelling == true && this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT) { + if ((this->isSelling == true) && (this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT)) { func_80151BB4(globalCtx, 45); func_80151BB4(globalCtx, 3); } @@ -1006,7 +1031,7 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { this->cutscene = this->lookToShopkeeperCutscene; this->actor.textId = (this->numSellingItems <= 0) ? 0x29DE : 0x29D6; } - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } @@ -1022,10 +1047,10 @@ void EnFsn_ResumeInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; if (!this->isSelling) { this->actionFunc = EnFsn_AskCanBuyMore; } else if (this->actor.textId != 0x29D6) { @@ -1047,18 +1072,18 @@ void EnFsn_ResumeShoppingInteraction(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene) != 0) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; EnFsn_UpdateCursorPos(this, globalCtx); this->actionFunc = EnFsn_BrowseShelf; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); @@ -1095,18 +1120,18 @@ void EnFsn_BrowseShelf(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } this->cutscene = this->lookToShopkeeperFromShelfCutscene; ActorCutscene_SetIntentToPlay(this->cutscene); - this->cutsceneState = 1; - } else if (this->cutsceneState == 1) { + this->cutsceneState = ENFSN_CUTSCENESTATE_WAITING; + } else if (this->cutsceneState == ENFSN_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actor.textId = 0x29D6; @@ -1124,11 +1149,11 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { switch (item->canBuyFunc(globalCtx, item)) { case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - gSaveContext.save.weekEventReg[0x21] |= 4; + gSaveContext.save.weekEventReg[33] |= 4; case CANBUY_RESULT_SUCCESS_1: - if (this->cutsceneState == 2) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); - this->cutsceneState = 0; + this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } func_8019F208(); item = this->items[this->cursorIdx]; @@ -1142,9 +1167,9 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { item = this->items[this->cursorIdx]; item->boughtFunc(globalCtx, item); if (this->stolenItem1 == this->cursorIdx) { - gSaveContext.save.stolenItems &= ~0xFF000000; + SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); } else if (this->stolenItem2 == this->cursorIdx) { - gSaveContext.save.stolenItems &= ~0xFF0000; + SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); } this->numSellingItems--; this->itemIds[this->cursorIdx] = -1; @@ -1166,7 +1191,7 @@ void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_SetupEndInteraction(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1185,7 +1210,7 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { if (EnFsn_TakeItemOffShelf(this) && talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnFsn_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnFsn_HandleCanPlayerBuyItem(this, globalCtx); @@ -1200,7 +1225,7 @@ void EnFsn_SelectItem(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1209,10 +1234,10 @@ void EnFsn_PlayerCannotBuy(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1222,23 +1247,23 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); this->actor.textId = 0xFF; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_DeterminePrice; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1255,10 +1280,10 @@ void EnFsn_AskCanBuyMore(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if (this->cutsceneState == 0) { + if (this->cutsceneState == ENFSN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - this->cutsceneState = 2; + this->cutsceneState = ENFSN_CUTSCENESTATE_PLAYING; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -1268,24 +1293,24 @@ void EnFsn_AskCanBuyAterRunningOutOfItems(EnFsn* this, GlobalContext* globalCtx) } } if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); this->isSelling = false; this->actor.textId = 0x29CE; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); this->actionFunc = EnFsn_StartBuying; break; case 1: func_8019F230(); this->actor.textId = (CURRENT_DAY == 3) ? 0x29DF : 0x29D1; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); func_80151BB4(globalCtx, 3); break; } } - } else if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + } else if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { if (globalCtx->msgCtx.unk120B1 == 0) { EnFsn_EndInteraction(this, globalCtx); @@ -1306,7 +1331,7 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); if (!EnFsn_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && + (!Message_ShouldAdvance(globalCtx) || !EnFsn_FacingShopkeeperDialogResult(this, globalCtx)) && this->stickAccumX > 0) { cursorIdx = EnFsn_SetCursorIndexFromNeutral(this); if (cursorIdx != CURSOR_INVALID) { @@ -1317,15 +1342,15 @@ void EnFsn_FaceShopkeeperSelling(EnFsn* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_CURSOR); } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { this->actor.textId = 0x29D6; - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); if (globalCtx) {} } } void EnFsn_SetupEndInteractionImmediately(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnFsn_EndInteraction(this, globalCtx); } } @@ -1341,7 +1366,7 @@ void EnFsn_IdleBackroom(EnFsn* this, GlobalContext* globalCtx) { } void EnFsn_ConverseBackroom(EnFsn* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->flags & ENFSN_END_CONVERSATION) { this->flags &= ~ENFSN_END_CONVERSATION; globalCtx->msgCtx.msgMode = 0x43; @@ -1381,19 +1406,19 @@ void EnFsn_Blink(EnFsn* this) { } void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { - EnFsn* this = THIS; s32 pad; + EnFsn* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + FSN_LIMB_MAX + 1); if (ENFSN_IS_SHOP(&this->actor)) { this->actor.shape.rot.y = BINANG_ROT180(this->actor.shape.rot.y); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnFsn_GetCutscenes(this); EnFsn_InitShop(this, globalCtx); } else { - if ((gSaveContext.save.weekEventReg[0x21] & 8) || (gSaveContext.save.weekEventReg[0x4F] & 0x40)) { + if ((gSaveContext.save.weekEventReg[33] & 8) || (gSaveContext.save.weekEventReg[79] & 0x40)) { Actor_MarkForDeath(&this->actor); return; } @@ -1401,10 +1426,10 @@ void EnFsn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->blinkTimer = 20; this->eyeTextureIdx = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; - this->animationIdx = 0; - func_8013BC6C(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = FSN_ANIMATION_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = EnFsn_IdleBackroom; } } @@ -1421,7 +1446,7 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unk27A, this->actor.focus.pos); - func_8013D9C8(globalCtx, this->limbRotYTable, this->limbRotZTable, 19); + SubS_FillLimbRotTables(globalCtx, this->limbRotYTable, this->limbRotZTable, ARRAY_COUNT(this->limbRotYTable)); EnFsn_Blink(this); if (ENFSN_IS_SHOP(&this->actor) && EnFsn_HasItemsToSell()) { EnFsn_UpdateJoystickInputState(this, globalCtx); @@ -1436,7 +1461,10 @@ void EnFsn_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1446,8 +1474,8 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1462,9 +1490,14 @@ void EnFsn_DrawCursor(EnFsn* this, GlobalContext* globalCtx, f32 x, f32 y, f32 z void EnFsn_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1494,15 +1527,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1515,15 +1542,9 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnFsn_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1542,21 +1563,20 @@ void EnFsn_DrawStickDirectionPrompts(EnFsn* this, GlobalContext* globalCtx) { s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - s16 tmp; s32 limbRotTableIdx; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } if (ENFSN_IS_BACKROOM(&this->actor)) { switch (limbIndex) { - case 8: + case FSN_LIMB_TORSO: limbRotTableIdx = 0; break; - case 11: + case FSN_LIMB_LEFT_HAND: limbRotTableIdx = 1; break; - case 16: + case FSN_LIMB_HEAD: limbRotTableIdx = 2; break; default: @@ -1564,13 +1584,11 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, break; } if (limbRotTableIdx < 9) { - tmp = (s32)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); - rot->y += tmp; - tmp = (s32)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); - rot->z += tmp; + rot->y += (s16)(Math_SinS(this->limbRotYTable[limbRotTableIdx]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotZTable[limbRotTableIdx]) * 200.0f); } } - if (limbIndex == 17) { + if (limbIndex == FSN_LIMB_TOUPEE) { *dList = NULL; } return false; @@ -1579,22 +1597,22 @@ s32 EnFsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnFsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFsn* this = THIS; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { this->actor.focus.pos.x = this->actor.world.pos.x; this->actor.focus.pos.y = this->actor.world.pos.y + 60.0f; this->actor.focus.pos.z = this->actor.world.pos.z; OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F180); - gSPDisplayList(POLY_OPA_DISP++, object_fsn_DL_00F218); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesFrameDL); + gSPDisplayList(POLY_OPA_DISP++, gFsnGlassesLensesDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } } void EnFsn_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnFsn* this = THIS; + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnFsn* this = THIS; s16 i; OPEN_DISPS(globalCtx->state.gfxCtx); 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 139e145da..5fabf59ad 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -3,6 +3,7 @@ #include "global.h" #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_fsn/object_fsn.h" #define ENFSN_IS_BACKROOM(thisx) ((thisx)->params & 1) #define ENFSN_IS_SHOP(thisx) (!((thisx)->params & 1)) @@ -27,8 +28,8 @@ typedef struct EnFsn { /* 0x24E */ s16 limbRotZTable[19]; /* 0x274 */ Vec3s headRot; /* 0x27A */ Vec3s unk27A; // Set but never used - /* 0x280 */ Vec3s jointTable[19]; - /* 0x2F2 */ Vec3s morphTable[19]; + /* 0x280 */ Vec3s jointTable[FSN_LIMB_MAX + 1]; + /* 0x2F2 */ Vec3s morphTable[FSN_LIMB_MAX + 1]; /* 0x364 */ s16 eyeTextureIdx; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; @@ -63,7 +64,7 @@ typedef struct EnFsn { /* 0x444 */ u8 arrowAnimState; /* 0x445 */ u8 stickAnimState; /* 0x448 */ f32 shopItemSelectedTween; - /* 0x44C */ s16 animationIdx; + /* 0x44C */ s16 animationIndex; /* 0x44E */ u16 flags; } EnFsn; // size = 0x450 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 da6cb040d..6100e5ea8 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -4,16 +4,15 @@ * Description: Honey & Darling */ +#include "z_en_fu.h" #include "overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h" #include "overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h" -#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" #include "overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" -#include "z_en_fu.h" #include "objects/object_mu/object_mu.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x0A000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnFu*)thisx) @@ -74,11 +73,14 @@ static Vec3f D_80964B0C = { 0.0f, 60.0f, -8.0f }; static Vec3f D_80964B18 = { 0.0f, 55.0f, 12.0f }; static Vec3f D_80964B24 = { 0.0f, 60.0f, 0.0f }; -static ActorAnimationEntry sAnimations[] = { - { &object_mu_Anim_0053E0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_mu_Anim_001F74, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_mu_Anim_002F64, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_mu_Anim_004904, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_mu_Anim_00BAC4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_mu_Anim_0053E0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_001F74, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_002F64, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_mu_Anim_004904, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_mu_Anim_00BAC4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -173,7 +175,7 @@ void func_809619D0(EnFu* this, GlobalContext* globalCtx) { } this->unk_520 = path->count; - this->unk_538 = (Vec3s*)Lib_SegmentedToVirtual(path->points); + this->unk_538 = Lib_SegmentedToVirtual(path->points); func_809616E0(this, globalCtx); } @@ -198,7 +200,7 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.gravity = -0.2f; this->actor.shape.rot.y += 0x4000; this->actor.world.rot = this->actor.shape.rot; @@ -227,8 +229,8 @@ void EnFu_Init(Actor* thisx, GlobalContext* globalCtx) { void EnFu_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnFu* this = THIS; - gSaveContext.save.weekEventReg[63] &= (u8)~0x1; - gSaveContext.save.weekEventReg[8] &= (u8)~0x1; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -369,7 +371,7 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { } void func_809622FC(EnFu* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80962340; } @@ -377,40 +379,40 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->unk_54A == 2) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_54A == 2) { if (this->unk_552 == 0x287D) { if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - func_801518B0(globalCtx, 0x287E, &this->actor); + Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; } else if ((CURRENT_DAY == 3) && (gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { if ((gSaveContext.save.weekEventReg[22] & 0x40)) { - func_801518B0(globalCtx, 0x2883, &this->actor); + Message_StartTextbox(globalCtx, 0x2883, &this->actor); this->unk_552 = 0x2883; } else { - func_801518B0(globalCtx, 0x2880, &this->actor); + Message_StartTextbox(globalCtx, 0x2880, &this->actor); this->unk_552 = 0x2880; } } else { - func_801518B0(globalCtx, 0x287E, &this->actor); + Message_StartTextbox(globalCtx, 0x287E, &this->actor); this->unk_552 = 0x287E; } } else if ((gSaveContext.unk_3DE0[4] == 0) && (this->unk_552 != 0x2888)) { - func_801518B0(globalCtx, 0x2886, &this->actor); + Message_StartTextbox(globalCtx, 0x2886, &this->actor); this->unk_552 = 0x2886; } else { - func_801518B0(globalCtx, 0x2889, &this->actor); + Message_StartTextbox(globalCtx, 0x2889, &this->actor); this->unk_552 = 0x2889; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~0x20; this->unk_54A = 1; } else { - func_801518B0(globalCtx, 0x283C, &this->actor); + Message_StartTextbox(globalCtx, 0x283C, &this->actor); this->unk_552 = 0x283C; } func_809628BC(this); @@ -423,7 +425,7 @@ void func_80962340(EnFu* this, GlobalContext* globalCtx) { } void func_80962588(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) && (this->unk_552 == 0x2871)) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_552 == 0x2871)) { if (1) {} if (globalCtx->msgCtx.choiceIndex == 0) { if (gSaveContext.save.playerData.rupees >= 10) { @@ -432,12 +434,12 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { func_80963DE4(this, globalCtx); } else { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x2873, &this->actor); + Message_StartTextbox(globalCtx, 0x2873, &this->actor); this->unk_552 = 0x2873; } } else { func_8019F230(); - func_801518B0(globalCtx, 0x2872, &this->actor); + Message_StartTextbox(globalCtx, 0x2872, &this->actor); this->unk_552 = 0x2872; } } @@ -446,7 +448,7 @@ void func_80962588(EnFu* this, GlobalContext* globalCtx) { void func_80962660(EnFu* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x283C: func_80963F44(this, globalCtx); @@ -465,7 +467,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { break; case 0x2846: - func_801518B0(globalCtx, 0x2849, &this->actor); + Message_StartTextbox(globalCtx, 0x2849, &this->actor); this->unk_552 = 0x2849; break; @@ -516,7 +518,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x286A: case 0x286C: case 0x286E: - func_801518B0(globalCtx, 0x2871, &this->actor); + Message_StartTextbox(globalCtx, 0x2871, &this->actor); this->unk_552 = 0x2871; break; @@ -524,17 +526,17 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { case 0x2878: case 0x287A: case 0x287C: - func_801518B0(globalCtx, 0x287D, &this->actor); + Message_StartTextbox(globalCtx, 0x287D, &this->actor); this->unk_552 = 0x287D; break; case 0x287D: - gSaveContext.save.weekEventReg[63] |= 0x1; - gSaveContext.save.weekEventReg[63] &= (u8)~0x2; + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_801477B4(globalCtx); player->stateFlags1 |= 0x20; this->unk_53C = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { @@ -593,7 +595,7 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk_54A = 1; switch (this->unk_552) { case 0x287F: @@ -602,8 +604,8 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { case 0x2884: case 0x2887: case 0x288A: - gSaveContext.save.weekEventReg[63] &= (u8)~0x1; - gSaveContext.save.weekEventReg[63] &= (u8)~0x2; + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; func_809622FC(this); break; @@ -727,14 +729,15 @@ void func_80962D60(EnFu* this, GlobalContext* globalCtx) { void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { if (this->unk_542 != 0) { if (this->actor.cutscene != -1) { - func_800DFB14(globalCtx->cameraPtrs[MAIN_CAM], ActorCutscene_GetCutscene(this->actor.cutscene)->unk4); + Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); } } } void func_80962F10(EnFu* this) { this->unk_548 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; gSaveContext.save.weekEventReg[8] |= 1; this->actionFunc = func_80962F4C; } @@ -770,7 +773,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { } if (func_80961D10(this)) { - func_801518B0(globalCtx, 0x288B, &this->actor); + Message_StartTextbox(globalCtx, 0x288B, &this->actor); } if ((!DynaPolyActor_IsInRidingRotatingState((DynaPolyActor*)this->actor.child) && @@ -781,10 +784,10 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; if (this->unk_548 < this->unk_54C) { if (gSaveContext.unk_3DE0[4] == 0) { - func_801518B0(globalCtx, 0x2885, &this->actor); + Message_StartTextbox(globalCtx, 0x2885, &this->actor); this->unk_552 = 0x2885; } else { - func_801518B0(globalCtx, 0x2888, &this->actor); + Message_StartTextbox(globalCtx, 0x2888, &this->actor); this->unk_552 = 0x2888; } func_801A2C20(); @@ -822,7 +825,7 @@ void func_809632D0(EnFu* this) { Interface_ChangeAlpha(50); } - gSaveContext.save.weekEventReg[8] &= (u8)~0x1; + gSaveContext.save.weekEventReg[8] &= (u8)~1; if (this->unk_2D4 != NULL) { BgFuMizu* mizu = this->unk_2D4; @@ -830,7 +833,7 @@ void func_809632D0(EnFu* this) { mizu->unk_160 = 0; } - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80963350; } @@ -838,7 +841,7 @@ void func_80963350(EnFu* this, GlobalContext* globalCtx) { static s32 D_80964C24 = 0; BgFuKaiten* fuKaiten = (BgFuKaiten*)this->actor.child; - if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) || + if ((this->unk_54A == 0) && (((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) || ((Message_GetState(&globalCtx->msgCtx) == 2) && (globalCtx->msgCtx.unk12023 == 1)))) { func_801477B4(globalCtx); this->unk_54A = 2; @@ -895,22 +898,22 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20) && (CURRENT_DAY == 3) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { if (gSaveContext.save.weekEventReg[22] & 0x40) { - func_801518B0(globalCtx, 0x2884, &this->actor); + Message_StartTextbox(globalCtx, 0x2884, &this->actor); this->unk_552 = 0x2884; } else if (!(gSaveContext.save.weekEventReg[22] & 0x80)) { gSaveContext.save.weekEventReg[22] |= 0x80; - func_801518B0(globalCtx, 0x2882, &this->actor); + Message_StartTextbox(globalCtx, 0x2882, &this->actor); this->unk_552 = 0x2882; } else { - func_801518B0(globalCtx, 0x2881, &this->actor); + Message_StartTextbox(globalCtx, 0x2881, &this->actor); this->unk_552 = 0x2881; } } else { - func_801518B0(globalCtx, 0x287F, &this->actor); + Message_StartTextbox(globalCtx, 0x287F, &this->actor); this->unk_552 = 0x287F; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.child->freezeTimer = 0; func_809628BC(this); @@ -965,46 +968,46 @@ s32 func_80963810(GlobalContext* globalCtx, Vec3f pos) { s32 func_809638F8(GlobalContext* globalCtx) { s32 ret = true; - if (globalCtx->envCtx.unk_8C.diffuseColor1[0] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[0] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[0] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[0] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[1] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[1] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[1] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; } - if (globalCtx->envCtx.unk_8C.diffuseColor1[2] > 25) { - globalCtx->envCtx.unk_8C.diffuseColor1[2] -= 25; + if (globalCtx->envCtx.lightSettings.diffuseColor1[2] > 25) { + globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.diffuseColor1[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[0] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[0] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[0] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[0] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[0] = 0; + globalCtx->envCtx.lightSettings.ambientColor[0] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[1] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[1] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[1] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[1] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[1] = 0; + globalCtx->envCtx.lightSettings.ambientColor[1] = 0; } - if (globalCtx->envCtx.unk_8C.ambientColor[2] > 25) { - globalCtx->envCtx.unk_8C.ambientColor[2] -= 25; + if (globalCtx->envCtx.lightSettings.ambientColor[2] > 25) { + globalCtx->envCtx.lightSettings.ambientColor[2] -= 25; ret = false; } else { - globalCtx->envCtx.unk_8C.ambientColor[2] = 0; + globalCtx->envCtx.lightSettings.ambientColor[2] = 0; } return ret; } @@ -1014,50 +1017,50 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { case 1: if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - func_801518B0(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; } else if (gSaveContext.save.weekEventReg[22] & 0x10) { - func_801518B0(globalCtx, 0x284D, &this->actor); + Message_StartTextbox(globalCtx, 0x284D, &this->actor); this->unk_552 = 0x284D; } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x284F, &this->actor); + Message_StartTextbox(globalCtx, 0x284F, &this->actor); this->unk_552 = 0x284F; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2851, &this->actor); + Message_StartTextbox(globalCtx, 0x2851, &this->actor); this->unk_552 = 0x2851; } } else { - func_801518B0(globalCtx, 0x286F, &this->actor); + Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } break; case 2: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - func_801518B0(globalCtx, 0x286F, &this->actor); + Message_StartTextbox(globalCtx, 0x286F, &this->actor); this->unk_552 = 0x286F; } else if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { - func_801518B0(globalCtx, 0x2853, &this->actor); + Message_StartTextbox(globalCtx, 0x2853, &this->actor); this->unk_552 = 0x2853; } else if (!(gSaveContext.save.weekEventReg[22] & 0x10)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x285B, &this->actor); + Message_StartTextbox(globalCtx, 0x285B, &this->actor); this->unk_552 = 0x285B; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x285D, &this->actor); + Message_StartTextbox(globalCtx, 0x285D, &this->actor); this->unk_552 = 0x285D; } } else if (gSaveContext.save.weekEventReg[22] & 0x20) { - func_801518B0(globalCtx, 0x2855, &this->actor); + Message_StartTextbox(globalCtx, 0x2855, &this->actor); this->unk_552 = 0x2855; } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2857, &this->actor); + Message_StartTextbox(globalCtx, 0x2857, &this->actor); this->unk_552 = 0x2857; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2859, &this->actor); + Message_StartTextbox(globalCtx, 0x2859, &this->actor); this->unk_552 = 0x2859; } break; @@ -1067,44 +1070,44 @@ void func_809639D0(EnFu* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { func_80963EAC(this, globalCtx); } else { - func_801518B0(globalCtx, 0x2841, &this->actor); + Message_StartTextbox(globalCtx, 0x2841, &this->actor); this->unk_552 = 0x2841; } } else if (CUR_UPG_VALUE(UPG_QUIVER) == 0) { - func_801518B0(globalCtx, 0x284B, &this->actor); + Message_StartTextbox(globalCtx, 0x284B, &this->actor); this->unk_552 = 0x284B; } else if (gSaveContext.save.weekEventReg[22] & 0x40) { if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { - func_801518B0(globalCtx, 0x285F, &this->actor); + Message_StartTextbox(globalCtx, 0x285F, &this->actor); this->unk_552 = 0x285F; } else { - func_801518B0(globalCtx, 0x2861, &this->actor); + Message_StartTextbox(globalCtx, 0x2861, &this->actor); this->unk_552 = 0x2861; } } else if ((gSaveContext.save.weekEventReg[22] & 0x10) && (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2863, &this->actor); + Message_StartTextbox(globalCtx, 0x2863, &this->actor); this->unk_552 = 0x2863; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2865, &this->actor); + Message_StartTextbox(globalCtx, 0x2865, &this->actor); this->unk_552 = 0x2865; } } else if ((gSaveContext.save.weekEventReg[22] & 0x10) || (gSaveContext.save.weekEventReg[22] & 0x20)) { if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x2867, &this->actor); + Message_StartTextbox(globalCtx, 0x2867, &this->actor); this->unk_552 = 0x2867; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x2869, &this->actor); + Message_StartTextbox(globalCtx, 0x2869, &this->actor); this->unk_552 = 0x2869; } } else if (this->unk_53E == 1) { - func_801518B0(globalCtx, 0x286B, &this->actor); + Message_StartTextbox(globalCtx, 0x286B, &this->actor); this->unk_552 = 0x286B; } else { this->unk_53E = 1; - func_801518B0(globalCtx, 0x286D, &this->actor); + Message_StartTextbox(globalCtx, 0x286D, &this->actor); this->unk_552 = 0x286D; } break; @@ -1115,21 +1118,21 @@ void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { switch (this->unk_542) { case 0: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - func_801518B0(globalCtx, 0x2875, &this->actor); + Message_StartTextbox(globalCtx, 0x2875, &this->actor); this->unk_552 = 0x2875; } else { - func_801518B0(globalCtx, 0x2877, &this->actor); + Message_StartTextbox(globalCtx, 0x2877, &this->actor); this->unk_552 = 0x2877; } break; case 1: - func_801518B0(globalCtx, 0x2879, &this->actor); + Message_StartTextbox(globalCtx, 0x2879, &this->actor); this->unk_552 = 0x2879; break; case 2: - func_801518B0(globalCtx, 0x287B, &this->actor); + Message_StartTextbox(globalCtx, 0x287B, &this->actor); this->unk_552 = 0x287B; break; } @@ -1138,15 +1141,15 @@ void func_80963DE4(EnFu* this, GlobalContext* globalCtx) { void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerData.magicAcquired) { if (this->unk_540 == 1) { - func_801518B0(globalCtx, 0x2847, &this->actor); + Message_StartTextbox(globalCtx, 0x2847, &this->actor); this->unk_552 = 0x2847; } else { this->unk_540 = 1; - func_801518B0(globalCtx, 0x2845, &this->actor); + Message_StartTextbox(globalCtx, 0x2845, &this->actor); this->unk_552 = 0x2845; } } else { - func_801518B0(globalCtx, 0x2843, &this->actor); + Message_StartTextbox(globalCtx, 0x2843, &this->actor); this->unk_552 = 0x2843; } } @@ -1154,17 +1157,17 @@ void func_80963EAC(EnFu* this, GlobalContext* globalCtx) { void func_80963F44(EnFu* this, GlobalContext* globalCtx) { u16 sp1E = this->unk_552 + 1; - func_801518B0(globalCtx, sp1E, &this->actor); + Message_StartTextbox(globalCtx, sp1E, &this->actor); this->unk_552 = sp1E; } void func_80963F88(EnFu* this, GlobalContext* globalCtx) { if (this->unk_542 == 1) { - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); globalCtx->unk_1887E = 0; } else if (this->unk_542 == 2) { globalCtx->unk_1887D = 0; - func_800DFAC8(globalCtx->cameraPtrs[MAIN_CAM], 75); + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 75); } } @@ -1206,12 +1209,12 @@ void func_8096413C(EnFu* this, GlobalContext* globalCtx) { } void func_80964190(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2842: case 0x2844: case 0x2848: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 0x2840: @@ -1237,28 +1240,28 @@ void func_80964190(EnFu* this, GlobalContext* globalCtx) { case 0x286B: case 0x286D: case 0x2871: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 0x2860: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; case 0x285F: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); break; case 0x287E: case 0x2880: case 0x2883: - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); break; } } } void func_8096426C(EnFu* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_552) { case 0x2840: case 0x2841: @@ -1418,7 +1421,7 @@ void func_80964694(EnFu* this, EnFuUnkStruct* ptr, Vec3f* arg2, s32 len) { void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; - s16 activeCam = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 yaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); s32 i; for (i = 0; i < len; i++, ptr++) { @@ -1431,7 +1434,7 @@ void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { ptr->unk_08.z += 2.0f * Math_CosS(ptr->unk_2C); Matrix_StatePush(); Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_RotateY(activeCam, MTXMODE_APPLY); + Matrix_RotateY(yaw, MTXMODE_APPLY); Matrix_MultiplyVector3fByState(&sp44, &ptr->unk_08); Matrix_StatePop(); ptr->unk_2C += 6000; diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.h b/src/overlays/actors/ovl_En_Fu/z_en_fu.h index b16ea4620..6af75768f 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -2,6 +2,7 @@ #define Z_EN_FU_H #include "global.h" +#include "overlays/actors/ovl_Bg_Fu_Mizu/z_bg_fu_mizu.h" struct EnFu; 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 ec03de695..ad92b34d6 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 @@ -5,8 +5,11 @@ */ #include "z_en_fu_kago.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuKago*)thisx) @@ -15,7 +18,15 @@ void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACF994(EnFuKago* this); +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACF9DC(EnFuKago* this); +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx); +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx); +void func_80AD0274(EnFuKago* this); +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Kago_InitVars = { ACTOR_EN_FU_KAGO, ACTORCAT_BG, @@ -28,46 +39,368 @@ const ActorInit En_Fu_Kago_InitVars = { (ActorFunc)EnFuKago_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80AD05F0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_NO_PUSH | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80AD061C[] = { + object_fu_mato_DL_0006A0, object_fu_mato_DL_000740, object_fu_mato_DL_0007E0, + object_fu_mato_DL_000880, object_fu_mato_DL_000920, object_fu_mato_DL_0009C0, +}; -extern ColliderSphereInit D_80AD05F0; +Vec3f D_80AD0634[] = { + { -1.0f, 0.5f, 1.73f }, { 1.0f, 0.5f, 1.73f }, { 2.0f, 0.5f, 0.0f }, + { 1.0f, 0.5f, -1.73f }, { -1.0f, 0.5f, -1.73f }, { -2.0f, 0.5f, 0.0f }, +}; -extern UNK_TYPE D_060006A0; -extern UNK_TYPE D_060015C0; +Vec3f D_80AD067C[] = { + { -0.5f, 0.5f, 0.87f }, { 0.5f, 0.5f, 0.87f }, { 1.0f, 0.5f, 0.0f }, + { 0.5f, 0.5f, -0.87f }, { -0.5f, 0.5f, -0.87f }, { -1.0f, 0.5f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Init.s") +Vec3f D_80AD06C4[] = { + { -13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 15.5f }, { 13.7f, 9.0f, 0.0f }, + { 13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, -15.5f }, { -13.7f, 9.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Destroy.s") +void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + CollisionHeader* sp34 = NULL; + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF8B8.s") + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0015C0, &sp34); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp34); + Actor_SetScale(&this->dyna.actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF994.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_FU) { + this->dyna.actor.parent = npc; + break; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9A8.s") + if (npc == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9DC.s") + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 10; + this->unk_33A = 0; + this->unk_33C = 0; + this->dyna.actor.colChkInfo.health = 1; + func_80ACF994(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACF9FC.s") +void EnFuKago_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFA78.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80ACFDAC.s") +s32 func_80ACF8B8(EnFuKago* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y + 10.0f; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0028.s") + if (this->collider.base.ocFlags1 & OC1_HIT) { + this->collider.base.ocFlags1 &= ~OC1_HIT; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0274.s") + if (this->collider.base.oc->id == ACTOR_EN_BOM) { + this->dyna.actor.child = this->collider.base.oc; + } else if (this->collider.base.oc->id == ACTOR_PLAYER) { + func_80ACFA78(this, globalCtx); + return false; + } else { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0288.s") + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + return true; + } else { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Update.s") +void func_80ACF994(EnFuKago* this) { + this->actionFunc = func_80ACF9A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/func_80AD0340.s") +void func_80ACF9A8(EnFuKago* this, GlobalContext* globalCtx) { + if (func_80ACF8B8(this, globalCtx)) { + func_80ACF9DC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Kago/EnFuKago_Draw.s") +void func_80ACF9DC(EnFuKago* this) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + + bom->timer = 20; + this->actionFunc = func_80ACF9FC; +} + +void func_80ACF9FC(EnFuKago* this, GlobalContext* globalCtx) { + EnBom* bom = (EnBom*)this->dyna.actor.child; + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + func_80ACF994(this); + } else if (bom->timer == 1) { + fu->unk_548++; + func_80ACFA78(this, globalCtx); + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } +} + +void func_80ACFA78(EnFuKago* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3s sp90; + Vec3s sp88 = { 0, 0, 0 }; + EnFuKagoStruct* ptr; + s16 y; + + this->dyna.actor.colChkInfo.health = 0; + sp98 = this->dyna.actor.world.pos; + sp90 = this->dyna.actor.shape.rot; + + ptr = &this->unk_1B8[0]; + y = sp90.y; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + ptr->unk_00 = sp98; + ptr->unk_30 = sp88; + + ptr->unk_0C.x = (Math_CosS(y) * D_80AD0634[i].x) + (Math_SinS(y) * D_80AD0634[i].z); + ptr->unk_0C.y = D_80AD0634[i].y + Rand_Centered(); + ptr->unk_0C.z = (Math_CosS(y) * D_80AD0634[i].z) - (Math_SinS(y) * D_80AD0634[i].x); + + ptr->unk_18.x = (Math_CosS(y) * D_80AD067C[i].x) + (Math_SinS(y) * D_80AD067C[i].z); + ptr->unk_18.y = D_80AD067C[i].y; + ptr->unk_18.z = (Math_CosS(y) * D_80AD067C[i].z) - (Math_SinS(y) * D_80AD067C[i].x); + + ptr->unk_36.x = (s16)Rand_Next() >> 5; + ptr->unk_36.y = 0; + ptr->unk_36.z = (s16)Rand_Next() >> 5; + + ptr->unk_24.x = D_80AD06C4[i].x; + ptr->unk_24.y = D_80AD06C4[i].y; + ptr->unk_24.z = D_80AD06C4[i].z; + + ptr->unk_3C = 0; + + ptr->unk_00.x += 18.0f * ptr->unk_0C.x; + ptr->unk_00.y += 18.0f * ptr->unk_0C.y; + ptr->unk_00.z += 18.0f * ptr->unk_0C.z; + + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 17.0f, 0, 15, 13, 20, -1, 10, NULL); + + this->unk_338 = 60; + this->unk_33A = 1; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODBOX_BREAK); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AD0028; +} + +Vec3f D_80AD0714 = { 0.0f, 0.0f, 0.0f }; + +void func_80ACFDAC(EnFuKago* this, GlobalContext* globalCtx, EnFuKagoStruct* arg2) { + Vec3f sp34; + f32 temp_f0; + + if (arg2->unk_3C == 0) { + if (arg2->unk_00.y < 15.0f) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 800); + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + arg2->unk_3C = 1; + } + + Math_SmoothStepToF(&arg2->unk_18.x, 0.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.y, -1.0f, 0.1f, 0.1f, 0.1f); + Math_SmoothStepToF(&arg2->unk_18.z, 0.0f, 0.1f, 0.1f, 0.1f); + return; + } + + temp_f0 = Math_Vec3f_DistXZ(&arg2->unk_00, &D_80AD0714); + + arg2->unk_18.y = ((15.0f - arg2->unk_00.y) * 0.1f) - (0.2f * arg2->unk_0C.y); + arg2->unk_18.x = arg2->unk_0C.x * -0.1f; + arg2->unk_18.z = arg2->unk_0C.z * -0.1f; + + if (temp_f0 < 190.0f) { + arg2->unk_00.x *= 190.0f / temp_f0; + arg2->unk_00.z *= 190.0f / temp_f0; + } + + if (ABS_ALT(arg2->unk_36.x) > 100) { + Math_SmoothStepToS(&arg2->unk_36.x, 0, 0xA, 0x64, 0xA); + } + + if (ABS_ALT(arg2->unk_36.z) > 100) { + Math_SmoothStepToS(&arg2->unk_36.z, 0, 0xA, 0x64, 0xA); + } + + if ((globalCtx->gameplayFrames % 8) == 0) { + sp34 = arg2->unk_00; + sp34.y = 30.0f; + EffectSsGRipple_Spawn(globalCtx, &sp34, 250, 650, 0); + } +} + +void func_80AD0028(EnFuKago* this, GlobalContext* globalCtx) { + EnFuKagoStruct* ptr = this->unk_1B8; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_1B8); i++) { + func_80ACFDAC(this, globalCtx, ptr); + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + + ptr++; + } + + if (this->unk_338 == 59) { + this->unk_1B8[3].unk_0C.x *= -1.0f; + this->unk_1B8[3].unk_0C.z *= -1.0f; + + this->unk_1B8[4].unk_0C.x *= -1.0f; + this->unk_1B8[4].unk_0C.z *= -1.0f; + } else if (this->unk_338 == 58) { + Vec3f sp34 = this->unk_1B8[5].unk_0C; + + this->unk_1B8[5].unk_0C.x = sp34.z; + this->unk_1B8[5].unk_0C.z = -sp34.x; + + sp34 = this->unk_1B8[2].unk_0C; + this->unk_1B8[2].unk_0C.x = -sp34.z; + this->unk_1B8[2].unk_0C.z = sp34.x; + + this->unk_1B8[5].unk_36.x *= -1; + this->unk_1B8[5].unk_36.y *= -1; + this->unk_1B8[5].unk_36.z *= -1; + + this->unk_1B8[2].unk_36.x *= -1; + this->unk_1B8[2].unk_36.y *= -1; + this->unk_1B8[2].unk_36.z *= -1; + } else if (this->unk_338 == 0) { + func_80AD0274(this); + } + this->unk_338--; +} + +void func_80AD0274(EnFuKago* this) { + this->actionFunc = func_80AD0288; +} + +void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->z = scale->x; + scale->y = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void EnFuKago_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuKago* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->unk_33C == 1) { + func_80AD0274(this); + } +} + +void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { + s32 pad[2]; + EnFuKagoStruct* ptr = &this->unk_1B8[0]; + s32 i; + Vec3f* scale = &this->dyna.actor.scale; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80AD061C); i++, ptr++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &this->dyna.actor.shape.rot); + Matrix_InsertTranslation(ptr->unk_24.x, ptr->unk_24.y, ptr->unk_24.z, MTXMODE_APPLY); + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_InsertTranslation(-ptr->unk_24.x, -ptr->unk_24.y, -ptr->unk_24.z, MTXMODE_APPLY); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80AD061C[i]); + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuKago_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuKago* this = THIS; + + if (this->unk_33A == 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0006A0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000740); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0007E0); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000880); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_000920); + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_0009C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + func_80AD0340(this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h index db37f2f2d..19022093e 100644 --- a/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h +++ b/src/overlays/actors/ovl_En_Fu_Kago/z_en_fu_kago.h @@ -7,11 +7,23 @@ struct EnFuKago; typedef void (*EnFuKagoActionFunc)(struct EnFuKago*, GlobalContext*); +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; + /* 0x3C */ s16 unk_3C; +} EnFuKagoStruct; // size = 0x40 + typedef struct EnFuKago { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuKagoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1DC]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuKagoStruct unk_1B8[6]; + /* 0x0338 */ s16 unk_338; + /* 0x033A */ s16 unk_33A; /* 0x033C */ s16 unk_33C; } EnFuKago; // size = 0x340 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 400bd6d67..ec0209729 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 @@ -5,8 +5,10 @@ */ #include "z_en_fu_mato.h" +#include "overlays/actors/ovl_En_Fu/z_en_fu.h" +#include "objects/object_fu_mato/object_fu_mato.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnFuMato*)thisx) @@ -15,7 +17,15 @@ void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx); void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80ACE4B4(EnFuMato* this); +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE508(EnFuMato* this); +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx); +void func_80ACEFC4(EnFuMato* this); +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx); + const ActorInit En_Fu_Mato_InitVars = { ACTOR_EN_FU_MATO, ACTORCAT_BG, @@ -28,52 +38,447 @@ const ActorInit En_Fu_Mato_InitVars = { (ActorFunc)EnFuMato_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80ACF610 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 200 }, 100 }, }; -#endif +Gfx* D_80ACF63C[] = { + object_fu_mato_DL_001C80, object_fu_mato_DL_001D68, object_fu_mato_DL_001E50, + object_fu_mato_DL_001F38, object_fu_mato_DL_002020, object_fu_mato_DL_002108, +}; -extern ColliderSphereInit D_80ACF610; +Vec2f D_80ACF654[] = { + { -1.0f, -1.73f }, { 1.0f, -1.73f }, { 2.0f, 0.0f }, { 1.0f, 1.73f }, { -1.0f, 1.73f }, { -2.0f, 0.0f }, +}; -extern UNK_TYPE D_060023D4; -extern UNK_TYPE D_06002720; +void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + CollisionHeader* sp2C = NULL; + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; + EnFu* fu; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Init.s") + DynaPolyActor_Init(&this->dyna, 3); + CollisionHeader_GetVirtual(&object_fu_mato_Colheader_0023D4, &sp2C); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp2C); + Actor_SetScale(&this->dyna.actor, 0.1f); + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->dyna.actor, &sSphereInit); + this->collider.dim.worldSphere.radius = 20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Destroy.s") + while (actor != NULL) { + if (actor->id == ACTOR_EN_FU) { + this->dyna.actor.parent = actor; + break; + } + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4B4.s") + if (actor == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE4C8.s") + fu = (EnFu*)this->dyna.actor.parent; + if (fu->unk_542 == 2) { + this->collider.info.elemType = ELEMTYPE_UNK0; + this->collider.dim.worldSphere.radius = 30; + } else { + this->collider.dim.worldSphere.radius = 17; + this->unk_2F8 = fu->unk_538; + this->unk_2F4 = fu->unk_520; + this->unk_2F0 = ENFUMATO_GET(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE508.s") + this->unk_302 = 0; + this->unk_304 = 0; + func_80ACE4B4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE51C.s") +void EnFuMato_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE680.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroySphere(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE718.s") +void func_80ACE4B4(EnFuMato* this) { + this->actionFunc = func_80ACE4C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACE850.s") +void func_80ACE4C8(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEB2C.s") + if ((fu->unk_54A == 0) && (fu->unk_542 == 0)) { + func_80ACE508(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACECFC.s") +void func_80ACE508(EnFuMato* this) { + this->actionFunc = func_80ACE51C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFC4.s") +void func_80ACE51C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + Vec3f sp30; + f32 sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACEFD8.s") + sp30.x = this->unk_2F8[this->unk_2F0].x; + sp30.y = this->unk_2F8[this->unk_2F0].y; + sp30.z = this->unk_2F8[this->unk_2F0].z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF04C.s") + sp2C = Math_Vec3f_DistXZ(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &sp30); + this->dyna.actor.world.rot.x = Math_Vec3f_Pitch(&this->dyna.actor.world.pos, &sp30); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Update.s") + if (sp2C < 10.0f) { + if (this->unk_2F0 < (this->unk_2F4 - 1)) { + this->unk_2F0++; + } else { + this->unk_2F0 = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF1F4.s") + this->dyna.actor.speedXZ = 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/func_80ACF3F4.s") + if (fu->unk_54A != 0) { + func_80ACE4B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Fu_Mato/EnFuMato_Draw.s") +void func_80ACE680(EnFuMato* this) { + this->dyna.actor.gravity = -0.5f; + this->dyna.actor.velocity.y = 1.0f; + this->dyna.actor.velocity.x = 2.0f * Rand_Centered(); + this->dyna.actor.velocity.z = 2.0f * Rand_Centered(); + this->unk_2FC.x = Rand_Next() & 0xFFF; + 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); + this->actionFunc = func_80ACE718; +} + +void func_80ACE718(EnFuMato* this, GlobalContext* globalCtx) { + this->dyna.actor.shape.rot.x += this->unk_2FC.x; + this->dyna.actor.shape.rot.y += this->unk_2FC.y; + this->dyna.actor.shape.rot.z += this->unk_2FC.z; + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + + Actor_UpdatePos(&this->dyna.actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + + if ((this->dyna.actor.bgCheckFlags & 1) || (this->dyna.actor.world.pos.y < -500.0f)) { + Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp30 = { 0.0f, 2.0f, 0.0f }; + + func_800B3030(globalCtx, &this->dyna.actor.world.pos, &sp3C, &sp30, 20, 40, 2); + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void func_80ACE850(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s16 temp_s4 = this->dyna.actor.shape.rot.y; + s32 phi_s2; + s32 i; + + this->unk_308 = (u32)Rand_Next() % ARRAY_COUNT(this->unk_1B8); + this->unk_302 = 1; + this->dyna.actor.gravity = -1.0f; + this->dyna.actor.velocity.y = Rand_ZeroOne(); + + phi_s2 = this->unk_308; + + for (i = 0; i < 2; i++) { + ptr->unk_00 = this->dyna.actor.world.pos; + + ptr->unk_0C.x = Math_CosS(temp_s4) * D_80ACF654[phi_s2].x; + ptr->unk_0C.y = D_80ACF654[phi_s2].z; + ptr->unk_0C.z = -Math_SinS(temp_s4) * D_80ACF654[phi_s2].x; + + ptr->unk_0C.x += Rand_Centered(); + ptr->unk_0C.y += Rand_ZeroOne() * 0.5f; + ptr->unk_0C.z += Rand_Centered(); + + ptr->unk_18.x = 0.0f; + ptr->unk_18.y = -1.0f; + ptr->unk_18.z = 0.0f; + + ptr->unk_00.x += 9.0f * ptr->unk_0C.x; + ptr->unk_00.y += 9.0f * ptr->unk_0C.y; + ptr->unk_00.z += 9.0f * ptr->unk_0C.z; + + ptr->unk_24 = this->dyna.actor.shape.rot; + + ptr->unk_2A.x = (s16)Rand_Next() >> 6; + ptr->unk_2A.y = (s16)Rand_Next() >> 6; + ptr->unk_2A.z = (s16)Rand_Next() >> 6; + ptr->unk_30 = 1; + + phi_s2 = (phi_s2 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + this->dyna.actor.freezeTimer = 2; + EffectSsHahen_SpawnBurst(globalCtx, &this->dyna.actor.world.pos, 13.0f, 0, 7, 8, 20, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + this->actionFunc = func_80ACECFC; +} + +void func_80ACEB2C(EnFuMato* this) { + EnFuMatoStruct sp18[2]; + s32 phi_v0 = this->unk_308; + s32 i; + s32 phi_v1; + s32 phi_a1; + + sp18[0] = this->unk_1B8[0]; + sp18[1] = this->unk_1B8[1]; + + for (i = 0; i < ARRAY_COUNT(sp18); i++) { + if (phi_v0 == 0) { + phi_v1 = 5; + } else { + phi_v1 = phi_v0 - 1; + } + + if (phi_v0 == 5) { + phi_a1 = 0; + } else { + phi_a1 = phi_v0 + 1; + } + + this->unk_1B8[phi_v0] = sp18[i]; + this->unk_1B8[phi_v1] = sp18[i]; + this->unk_1B8[phi_a1] = sp18[i]; + + phi_v0 = (phi_v0 + 3) % ARRAY_COUNT(this->unk_1B8); + } + + this->unk_302 = 2; + this->actionFunc = func_80ACECFC; +} + +void func_80ACECFC(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 phi_s3; + s32 i; + + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + Actor_UpdatePos(&this->dyna.actor); + + if (this->dyna.actor.world.pos.y < -500.0f) { + this->dyna.actor.world.pos.y = -500.0f; + } + + if (this->unk_302 == 1) { + phi_s3 = 2; + } else { + phi_s3 = ARRAY_COUNT(this->unk_1B8); + } + + for (i = 0; i < phi_s3; i++, ptr++) { + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + ptr->unk_0C.x += ptr->unk_18.x; + ptr->unk_0C.y += ptr->unk_18.y; + ptr->unk_0C.z += ptr->unk_18.z; + + ptr->unk_24.x += ptr->unk_2A.x; + ptr->unk_24.y += ptr->unk_2A.y; + ptr->unk_24.z += ptr->unk_2A.z; + + if ((this->unk_302 == 2) && (ptr->unk_30 == 1) && (ptr->unk_00.y < (this->dyna.actor.floorHeight + 10.0f))) { + if (ptr->unk_0C.y < 0.0f) { + ptr->unk_0C.y = -ptr->unk_0C.y; + } else { + ptr->unk_0C.y = ptr->unk_0C.y; + } + ptr->unk_0C.y *= 0.5f; + ptr->unk_0C.x *= (Rand_Centered() * 1.5f) + 2.0f; + ptr->unk_0C.z *= (Rand_Centered() * 1.5f) + 2.0f; + + ptr->unk_2A.x = (s16)Rand_Next() >> 5; + ptr->unk_2A.y = (s16)Rand_Next() >> 5; + ptr->unk_2A.z = (s16)Rand_Next() >> 5; + + ptr->unk_30 = 0; + } + } + + if (this->unk_302 == 1) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 60.0f, 5); + if (this->dyna.actor.bgCheckFlags & 1) { + func_80ACEB2C(this); + } + } + + if (this->unk_304 < 60) { + this->unk_304++; + } else { + func_80ACEFC4(this); + } +} + +void func_80ACEFC4(EnFuMato* this) { + this->actionFunc = func_80ACEFD8; +} + +void func_80ACEFD8(EnFuMato* this, GlobalContext* globalCtx) { + Vec3f* scale = &this->dyna.actor.scale; + + Math_SmoothStepToF(&scale->x, 0.0f, 0.1f, 0.005f, 0.005f); + scale->y = scale->z = scale->x; + if (scale->x == 0.0f) { + Actor_MarkForDeath(&this->dyna.actor); + } +} + +s32 func_80ACF04C(EnFuMato* this, GlobalContext* globalCtx) { + EnFu* fu = (EnFu*)this->dyna.actor.parent; + + this->collider.dim.worldSphere.center.x = this->dyna.actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->dyna.actor.world.pos.y; + this->collider.dim.worldSphere.center.z = this->dyna.actor.world.pos.z; + + if ((this->unk_302 == 0) && (((fu->unk_542 == 0) && (this->collider.base.acFlags & AC_HIT)) || + ((fu->unk_542 == 2) && (this->collider.base.ocFlags1 & OC1_HIT)))) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.ocFlags1 &= ~OC1_HIT; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_SY_TRE_BOX_APPEAR); + + fu->unk_548++; + if ((fu->unk_542 == 2) || (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { + fu->unk_546 = 1; + func_80ACE680(this); + } else { + func_80ACE850(this, globalCtx); + } + return true; + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} + +void EnFuMato_Update(Actor* thisx, GlobalContext* globalCtx) { + EnFuMato* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80ACF04C(this, globalCtx); + + if (this->unk_30A == 1) { + func_80ACEFC4(this); + } +} + +void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + s32 temp_s4 = this->unk_308; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < 2; i++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4]); + + switch (temp_s4) { + case 0: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[5]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + + case 5: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[0]); + break; + + default: + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 - 1]); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[temp_s4 + 1]); + break; + } + + Matrix_StatePop(); + + temp_s4 = (temp_s4 + 3) % ARRAY_COUNT(this->unk_1B8); + ptr++; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80ACF3F4(EnFuMato* this, GlobalContext* globalCtx) { + EnFuMatoStruct* ptr = this->unk_1B8; + Vec3f* scale = &this->dyna.actor.scale; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(D_80ACF63C); i++, ptr++) { + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, &ptr->unk_24); + Matrix_Scale(scale->x, scale->y, scale->z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80ACF63C[i]); + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnFuMato_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnFuMato* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if ((this->unk_302 == 0) || (this->unk_302 == 3)) { + gSPDisplayList(POLY_OPA_DISP++, object_fu_mato_DL_002720); + } else if (this->unk_302 == 1) { + func_80ACF1F4(this, globalCtx); + } else { + func_80ACF3F4(this, globalCtx); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h index 51dbf177f..5666b71fc 100644 --- a/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h +++ b/src/overlays/actors/ovl_En_Fu_Mato/z_en_fu_mato.h @@ -7,11 +7,30 @@ struct EnFuMato; typedef void (*EnFuMatoActionFunc)(struct EnFuMato*, GlobalContext*); +#define ENFUMATO_GET(thisx) ((thisx)->params) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3s unk_24; + /* 0x2A */ Vec3s unk_2A; + /* 0x30 */ s16 unk_30; +} EnFuMatoStruct; // size = 0x34 + typedef struct EnFuMato { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ EnFuMatoActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1AA]; + /* 0x0160 */ ColliderSphere collider; + /* 0x01B8 */ EnFuMatoStruct unk_1B8[6]; + /* 0x02F0 */ s32 unk_2F0; + /* 0x02F4 */ s32 unk_2F4; + /* 0x02F8 */ Vec3s* unk_2F8; + /* 0x02FC */ Vec3s unk_2FC; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 unk306[2]; + /* 0x0308 */ s16 unk_308; /* 0x030A */ s16 unk_30A; } EnFuMato; // size = 0x30C 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 1efcd42e7..067e8c50d 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -9,7 +9,7 @@ #include "objects/object_fz/object_fz.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnFz*)thisx) @@ -180,7 +180,7 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_BC8 = 0; this->unk_BCF = 0; this->unk_BCC = 1; @@ -227,9 +227,9 @@ void EnFz_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->unk_BA4 = 0; - this->unk_BA0 = 0.0f; - this->unk_B9C = 0.0f; + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; func_80932784(this, globalCtx); } @@ -266,7 +266,8 @@ void func_80932784(EnFz* this, GlobalContext* globalCtx) { sp44.z = 440.0f; Matrix_MultiplyVector3fByState(&sp44, &this->unk_22C); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, 1, 0, 0, 1, &sp40)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, true, false, false, true, + &sp40)) { Math_Vec3f_Copy(&this->unk_22C, &sp50); } @@ -415,8 +416,8 @@ void func_80932C98(EnFz* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_BA4 = 0x28; - this->unk_B9C = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; case 15: Actor_ApplyDamage(&this->actor); @@ -472,7 +473,7 @@ void func_80933014(EnFz* this) { void func_809330D4(EnFz* this) { this->unk_BD6 = 2; this->unk_BCE = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80933104; } @@ -543,7 +544,7 @@ void func_80933324(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_80933368; } @@ -619,7 +620,7 @@ void func_809334B8(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -653,7 +654,7 @@ void func_809336C0(EnFz* this, GlobalContext* globalCtx) { this->unk_BCC = 1; this->unk_BCE = 0; this->unk_BD8 = 1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_BD7 = 0; this->unk_BCA = 60; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); @@ -671,7 +672,7 @@ void func_80933790(EnFz* this) { this->unk_BD6 = 3; this->unk_BCE = 0; this->unk_BD8 = 1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->unk_BBC = 0.0f; this->actionFunc = func_809337D4; @@ -702,7 +703,7 @@ void func_8093389C(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_809338E0; } @@ -736,7 +737,7 @@ void func_809338E0(EnFz* this, GlobalContext* globalCtx) { sp58.y = this->actor.world.pos.y + 20.0f; sp58.z = this->actor.world.pos.z; - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); sp64.x = 0.0f; sp64.y = -2.0f; @@ -763,7 +764,7 @@ void func_80933AF4(EnFz* this) { this->unk_BCA = 40; this->unk_BCC = 1; this->unk_BCE = 1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actionFunc = func_80933B38; } @@ -772,16 +773,16 @@ void func_80933B38(EnFz* this, GlobalContext* globalCtx) { } void func_80933B48(EnFz* this, GlobalContext* globalCtx) { - if (this->unk_BA4 != 0) { - if (this->unk_BA4 > 0) { - this->unk_BA4--; + if (this->drawDmgEffTimer != 0) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_BA4 < 20) { - Math_SmoothStepToF(&this->unk_BA0, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_B9C = this->unk_BA4 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_BA0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -861,17 +862,17 @@ void EnFz_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80934464(this, globalCtx); - if (this->unk_BA4 > 0) { + if (this->drawDmgEffTimer > 0) { s32 pad2[6]; - Vec3f sp58; - Vec3f sp4C; + Vec3f limbPos[2]; s32 pad3; - sp4C = this->actor.world.pos; - sp58 = this->actor.world.pos; - sp4C.y += 20.0f; - sp58.y += 40.0f; - func_800BE680(globalCtx, NULL, &sp4C, 2, this->unk_BA0 * 4.0f, 0.5f, this->unk_B9C, 20); + limbPos[0] = this->actor.world.pos; + limbPos[1] = this->actor.world.pos; + limbPos[0].y += 20.0f; + limbPos[1].y += 40.0f; + Actor_DrawDamageEffects(globalCtx, NULL, limbPos, ARRAY_COUNT(limbPos), this->drawDmgEffScale * 4.0f, 0.5f, + this->drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1003,7 +1004,7 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051180); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); flag++; } @@ -1017,7 +1018,7 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { Matrix_Scale(ptr->unk_30, ptr->unk_30, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_051238); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); } } diff --git a/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 5e76eadf9..19f462d0a 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -43,9 +43,9 @@ typedef struct EnFz { /* 0x22C */ Vec3f unk_22C; /* 0x238 */ f32 unk_238; /* 0x23C */ EnFzStruct unk_23C[40]; - /* 0xB9C */ f32 unk_B9C; - /* 0xBA0 */ f32 unk_BA0; - /* 0xBA4 */ s16 unk_BA4; + /* 0xB9C */ f32 drawDmgEffAlpha; + /* 0xBA0 */ f32 drawDmgEffScale; + /* 0xBA4 */ s16 drawDmgEffTimer; /* 0xBA8 */ f32 unk_BA8; /* 0xBAC */ f32 unk_BAC; /* 0xBB0 */ f32 unk_BB0; 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 c5f663108..1d9175b49 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -5,8 +5,9 @@ */ #include "z_en_gakufu.h" +#include "interface/parameter_static/parameter_static.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGakufu*)thisx) @@ -15,13 +16,15 @@ void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx); void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AFCB94(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCBD4(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCC14(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCD44(EnGakufu* this, GlobalContext* globalCtx); -void func_80AFCDC8(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_ProcessNotes(EnGakufu* this); +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx); +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Gakufu_InitVars = { ACTOR_EN_GAKUFU, ACTORCAT_ITEMACTION, @@ -34,28 +37,257 @@ const ActorInit En_Gakufu_InitVars = { (ActorFunc)EnGakufu_Draw, }; -#endif +Vec3f sRewardDropsSpawnTerminaFieldPos = { + -710.0f, + -123.0f, + -3528.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFC960.s") +/** + * Determines which set of `sRewardDrops` to collect when successfully playing the notes on the wall. + * Rewards come in batches of three, and the reward you get depends on the time of day. + */ +u8 sRewardDropsIndex[] = { + 3, // CLOCK_TIME(0, 0) to CLOCKTIME(1, 0) + 12, // CLOCK_TIME(1, 0) to CLOCKTIME(2, 0) + 6, // CLOCK_TIME(2, 0) to CLOCKTIME(3, 0) + 12, // CLOCK_TIME(3, 0) to CLOCKTIME(4, 0) + 9, // CLOCK_TIME(4, 0) to CLOCKTIME(5, 0) + 12, // CLOCK_TIME(5, 0) to CLOCKTIME(6, 0) + 0, // CLOCK_TIME(6, 0) to CLOCKTIME(7, 0) + 12, // CLOCK_TIME(7, 0) to CLOCKTIME(8, 0) + 3, // CLOCK_TIME(8, 0) to CLOCKTIME(9, 0) + 12, // CLOCK_TIME(9, 0) to CLOCKTIME(10, 0) + 6, // CLOCK_TIME(10, 0) to CLOCKTIME(11, 0) + 12, // CLOCK_TIME(11, 0) to CLOCKTIME(12, 0) + 3, // CLOCK_TIME(12, 0) to CLOCKTIME(13, 0) + 12, // CLOCK_TIME(13, 0) to CLOCKTIME(14, 0) + 6, // CLOCK_TIME(14, 0) to CLOCKTIME(15, 0) + 12, // CLOCK_TIME(15, 0) to CLOCKTIME(16, 0) + 3, // CLOCK_TIME(16, 0) to CLOCKTIME(17, 0) + 12, // CLOCK_TIME(17, 0) to CLOCKTIME(18, 0) + 6, // CLOCK_TIME(18, 0) to CLOCKTIME(19, 0) + 12, // CLOCK_TIME(19, 0) to CLOCKTIME(20, 0) + 9, // CLOCK_TIME(20, 0) to CLOCKTIME(21, 0) + 12, // CLOCK_TIME(21, 0) to CLOCKTIME(22, 0) + 6, // CLOCK_TIME(22, 0) to CLOCKTIME(23, 0) + 12, // CLOCK_TIME(23, 0) to CLOCKTIME(0, 0) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Init.s") +/** + * The set of rewards when the song notes on the wall are played. + * Should be thought of as a 2D array: sRewardDrops[5][3] + * i.e. there are 5 sets of possible rewards. And each set gives out three rewards + */ +u8 sRewardDrops[] = { + ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, ITEM00_RUPEE_RED, // Set 1 (index 0) + ITEM00_RUPEE_RED, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 2 (index 3) + ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 3 (index 6) + ITEM00_RUPEE_RED, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_BLUE, // Set 4 (index 9) + ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_GREEN, // Set 5 (index 12) +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Destroy.s") +// y-offsets of ocarina buttons drawn on wall +f32 sOcarinaBtnWallYOffsets[] = { + -4.0f, -2.0f, 0.0f, 1.0f, 3.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCB94.s") +TexturePtr sOcarinaBtnWallTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCBD4.s") +#include "overlays/ovl_En_Gakufu/ovl_En_Gakufu.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC14.s") +void EnGakufu_ProcessNotes(EnGakufu* this) { + OcarinaStaff* playbackStaff; + OcarinaSongButtons* ocarinaSongButtons; + s32 songNumButtons; + s32 i; + s32 songIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC24.s") + AudioOcarina_TerminaWallGenerateNotes(); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << this->songIndex) | 0x80000000); + playbackStaff = AudioOcarina_GetPlaybackStaff(); + playbackStaff->pos = 0; + playbackStaff->state = 0xFF; + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCC58.s") + songIndex = this->songIndex; + ocarinaSongButtons = &gOcarinaSongButtons[songIndex]; + songNumButtons = gOcarinaSongButtons[this->songIndex].numButtons; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCD44.s") + for (i = 0; i < songNumButtons; i++) { + this->buttonIndex[i] = ocarinaSongButtons->buttonIndex[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/func_80AFCDC8.s") + for (; i < ARRAY_COUNT(this->buttonIndex); i++) { + this->buttonIndex[i] = OCARINA_BTN_INVALID; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Update.s") +void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gakufu/EnGakufu_Draw.s") + this->songIndex = OCARINA_SONG_TERMINA_WALL; + EnGakufu_ProcessNotes(this); + Actor_SetScale(&this->actor, 1.0f); + + if (GAKUFU_GET_TYPE(&this->actor) == GAKUFU_MILK_BAR) { + this->actor.draw = NULL; + this->actionFunc = EnGakufu_WaitForTimer; + return; + } + + this->actor.flags &= ~ACTOR_FLAG_2000000; + + if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } else { + gSaveContext.eventInf[3] &= (u8)~2; + } + + this->actionFunc = EnGakufu_WaitForSong; + gSaveContext.eventInf[3] &= (u8)~4; +} + +void EnGakufu_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + if (GAKUFU_GET_TYPE(&this->actor) != GAKUFU_MILK_BAR) { + gSaveContext.eventInf[3] &= (u8)~2; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Draws the notes on the back of the stage + * until the timer runs out + */ +void EnGakufu_DisplayOnTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + this->actor.draw = EnGakufu_Draw; + this->actor.home.rot.x--; + } else { + this->actor.draw = NULL; + this->actor.home.rot.x = 0; + this->actionFunc = EnGakufu_WaitForTimer; + } +} + +/** + * Special behaviour for the Milk Bar: + * this->actor.home.rot.x acts as a timer. Waits for this timer to be set, + * then rerolls the notes and start displaying the notes + */ +void EnGakufu_WaitForTimer(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x > 0) { + EnGakufu_ProcessNotes(this); + this->actionFunc = EnGakufu_DisplayOnTimer; + } +} + +void EnGakufu_DoNothing(EnGakufu* this, GlobalContext* globalCtx) { +} + +s32 EnGakufu_IsPlayerInRange(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 600.0f) { + return true; + } else { + return false; + } +} + +/** + * Reward the player with three item drops depending on the time of day + */ +void EnGakufu_GiveReward(EnGakufu* this, GlobalContext* globalCtx) { + s32 hour; + s32 i; + + play_sound(NA_SE_SY_CORRECT_CHIME); + + hour = gSaveContext.save.time * (24.0f / 0x10000); + for (i = 0; i < 3; i++) { + Item_DropCollectible(globalCtx, &sRewardDropsSpawnTerminaFieldPos, sRewardDrops[i + sRewardDropsIndex[hour]]); + } + + this->actionFunc = EnGakufu_DoNothing; +} + +void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx) { + if (this->actor.cutscene == -1) { + EnGakufu_GiveReward(this, globalCtx); + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + EnGakufu_GiveReward(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * Waits for the notes on the wall to be played and updates the corresponding flags + * (gSaveContext.eventInf[3] & 2) is checking if Player is within range of the wall + * (gSaveContext.eventInf[3] & 4) is checking if Player has played the notes of the wall + */ +void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 2) { + if (gSaveContext.eventInf[3] & 4) { + gSaveContext.eventInf[3] &= (u8)~2; + gSaveContext.eventInf[3] &= (u8)~4; + + this->actionFunc = EnGakufu_PlayRewardCutscene; + EnGakufu_PlayRewardCutscene(this, globalCtx); + this->actor.draw = NULL; + } else if (!EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] &= (u8)~2; + } + } else if (EnGakufu_IsPlayerInRange(this, globalCtx)) { + gSaveContext.eventInf[3] |= 2; + } +} + +void EnGakufu_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGakufu* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 i; + s32 pad; + EnGakufu* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->interfaceCtx.parameterSegment); + + for (i = 0; (i < ARRAY_COUNT(this->buttonIndex)) && (this->buttonIndex[i] != OCARINA_BTN_INVALID); i++) { + Matrix_StatePush(); + Matrix_InsertTranslation(30 * i - 105, sOcarinaBtnWallYOffsets[this->buttonIndex[i]] * 7.5f, 1.0f, + MTXMODE_APPLY); + Matrix_Scale(0.6f, 0.6f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); + gDPLoadTextureBlock(POLY_XLU_DISP++, sOcarinaBtnWallTextures[this->buttonIndex[i]], G_IM_FMT_IA, G_IM_SIZ_8b, + 16, 16, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 4, G_TX_NOLOD, + G_TX_NOLOD); + + if (this->buttonIndex[i] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 150, 255, 200); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 50, 200); + } + + gSPDisplayList(POLY_XLU_DISP++, gGakufuButtonIndexDL); + + Matrix_StatePop(); + } + + gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h index b4bf8643c..9ba96a724 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.h @@ -7,10 +7,18 @@ struct EnGakufu; typedef void (*EnGakufuActionFunc)(struct EnGakufu*, GlobalContext*); +#define GAKUFU_GET_TYPE(thisx) ((thisx)->params & 0xF) + +typedef enum { + /* 0x00 */ GAKUFU_TERMINA_FIELD, + /* 0x01 */ GAKUFU_MILK_BAR +} GakufuType; + typedef struct EnGakufu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC]; - /* 0x0150 */ EnGakufuActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ s32 songIndex; + /* 0x148 */ u8 buttonIndex[8]; + /* 0x150 */ EnGakufuActionFunc actionFunc; } EnGakufu; // size = 0x154 extern const ActorInit En_Gakufu_InitVars; 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 a27c5bdc4..16547c112 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -6,7 +6,7 @@ #include "z_en_gamelupy.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnGamelupy*)thisx) 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 83fed5e23..74e573805 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -7,7 +7,7 @@ #include "z_en_gb2.h" #include "objects/object_ps/object_ps.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnGb2*)thisx) @@ -378,7 +378,7 @@ void func_80B0FEBC(EnGb2* this, GlobalContext* globalCtx) { } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B0FFA8; } else if ((this->actor.xzDistToPlayer < 300.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -389,7 +389,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -400,10 +400,10 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B0FEBC; } else { this->unk_26E = func_80B0F7FC(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26E == 0x14D5) { switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -411,11 +411,11 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } else { func_8019F208(); this->unk_26E = 0x14D8; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } break; @@ -423,7 +423,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14D6; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } else if (this->unk_26E == 0x14DA) { @@ -441,7 +441,7 @@ void func_80B0FFA8(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14DB; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } @@ -538,11 +538,11 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { void func_80B10584(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); - this->actor.flags &= ~0x10000; + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_80B10634; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); } } @@ -551,7 +551,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -569,17 +569,17 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { } } else { this->unk_26E = func_80B0F8F8(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } - } else if ((temp_v0 == 4) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_288) { play_sound(NA_SE_SY_ERROR); this->unk_26E = 0x14D7; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } else { func_8019F208(); Rupees_ChangeBy(-this->unk_288); @@ -594,7 +594,7 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { func_8019F230(); this->unk_26E = 0x14E3; this->unk_26C |= 2; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); break; } } @@ -638,7 +638,7 @@ void func_80B10924(EnGb2* this, GlobalContext* globalCtx) { void func_80B109DC(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B10634; } else { func_800B85E0(&this->actor, globalCtx, 300.0f, -1); @@ -668,7 +668,7 @@ void func_80B10A48(EnGb2* this, GlobalContext* globalCtx) { } else { this->actor.draw = NULL; this->unk_26C |= 0x100; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B111AC; } break; @@ -692,7 +692,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { if ((this->unk_26E == 0x14EE) || (this->unk_26E == 0x14F4)) { this->unk_26C |= 2; } - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->unk_290 = 1; this->unk_26C &= ~0x40; this->actionFunc = func_80B10DAC; @@ -703,8 +703,8 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { } else { this->unk_26C &= ~0x40; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_26C & 0x20)) { - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); if (this->unk_26E == 0x14EB) { gSaveContext.save.weekEventReg[80] |= 0x40; } else if (this->unk_26E == 0x14EF) { @@ -716,7 +716,7 @@ void func_80B10B5C(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { if (!(this->unk_26C & 0x80)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->unk_26C |= 0x20; func_800B8614(&this->actor, globalCtx, 300.0f); } @@ -746,7 +746,7 @@ void func_80B10DAC(EnGb2* this, GlobalContext* globalCtx) { } void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { this->unk_26C &= ~2; globalCtx->msgCtx.msgMode = 0x43; @@ -766,7 +766,7 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { s32 temp; this->unk_26E = func_80B0FB24(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); temp = this->unk_26E; if ((temp == 0x14E7) || (temp == 0x14E9) || (temp == 0x14EC) || (temp == 0x14F0)) { ActorCutscene_Stop(this->unk_282[this->unk_290]); @@ -780,17 +780,17 @@ void func_80B10E98(EnGb2* this, GlobalContext* globalCtx) { void func_80B11048(EnGb2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, this->unk_26E, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); this->actionFunc = func_80B10DAC; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 200.0f); } } void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_26C & 2) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -798,7 +798,7 @@ void func_80B110F8(EnGb2* this, GlobalContext* globalCtx) { this->actionFunc = func_80B10A48; } else { this->unk_26E = func_80B0F97C(this); - func_801518B0(globalCtx, this->unk_26E, &this->actor); + Message_StartTextbox(globalCtx, this->unk_26E, &this->actor); } } } @@ -844,7 +844,7 @@ void func_80B11268(EnGb2* this, GlobalContext* globalCtx) { Flags_GetClear(globalCtx, 5)) { this->unk_28A = 0xFF; this->unk_26C &= ~0x100; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnGb2_Draw; this->unk_26E = 0x14F9; this->actionFunc = func_80B11048; @@ -898,8 +898,8 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { } this->unk_28A = 255; - this->actor.flags |= 0x10; - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; if (gSaveContext.eventInf[4] & 0x40) { func_80B0F728(this, globalCtx); @@ -943,7 +943,7 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[76] & 0x80) { this->actor.draw = NULL; this->unk_26C |= 0x100; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B111AC; } else { this->unk_28A = 255; 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 2f3209e97..935eacb8c 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -6,7 +6,7 @@ #include "z_en_ge1.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGe1*)thisx) 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 d511788ab..b8522c2c6 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -6,7 +6,7 @@ #include "z_en_ge2.h" -#define FLAGS 0x80000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80000000) #define THIS ((EnGe2*)thisx) diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c index 7c0bcd71f..593c57a5a 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -6,7 +6,7 @@ #include "z_en_ge3.h" -#define FLAGS 0x80000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnGe3*)thisx) 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 f90b0f2c4..d022058dd 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -11,7 +11,7 @@ #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGeg*)thisx) @@ -125,18 +125,28 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, -4 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, - { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, - { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, 0 }, - { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_007764, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_014CE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; u16 func_80BB16D0(EnGeg* this) { @@ -368,7 +378,7 @@ void func_80BB1FCC(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2020(EnGeg* this, GlobalContext* globalCtx) { gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[this->unk_248].segment); - func_8013BC6C(&this->skelAnime, sAnimations, this->unk_4AC); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->unk_4AC); } s32 func_80BB2088(EnGeg* this, GlobalContext* globalCtx) { @@ -432,12 +442,12 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { this->unk_49A = this->unk_49C[2]; this->unk_230 &= ~4; } - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { this->unk_230 |= 4; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); } } else { @@ -445,7 +455,7 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[35] & 0x40) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) && (this->unk_230 & 8)) { this->unk_496 = 0xD62; - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->unk_230 &= ~8; this->actionFunc = func_80BB27D4; } else if ((this->actor.xzDistToPlayer < 300.0f) && this->actor.isTargeted) { @@ -456,12 +466,12 @@ void func_80BB221C(EnGeg* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[35] |= 0x40; this->unk_496 = 0xD5E; this->unk_49A = this->unk_49C[0]; - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB2520; this->unk_230 &= ~8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 300.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 300.0f); this->unk_230 |= 8; } @@ -532,7 +542,7 @@ void func_80BB2520(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD5E: this->unk_49A = this->unk_49C[1]; @@ -549,12 +559,12 @@ void func_80BB26EC(EnGeg* this, GlobalContext* globalCtx) { } this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); } } void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { switch (this->unk_496) { case 0xD63: globalCtx->msgCtx.msgMode = 0x43; @@ -589,7 +599,7 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { default: this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); break; } } @@ -598,14 +608,14 @@ void func_80BB27D4(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); if (this->unk_4AC == 19) { if (curFrame == lastFrame) { this->unk_4AC = 6; func_80BB2020(this, globalCtx); } - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD67) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -619,7 +629,7 @@ void func_80BB2944(EnGeg* this, GlobalContext* globalCtx) { } void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_496 == 0xD65) { ActorCutscene_Stop(this->unk_498); this->unk_230 &= ~0x10; @@ -629,7 +639,7 @@ void func_80BB2A54(EnGeg* this, GlobalContext* globalCtx) { this->actionFunc = func_80BB347C; } else { this->unk_496 = func_80BB16D0(this); - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); } } } @@ -694,7 +704,7 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { void func_80BB2E00(EnGeg* this, GlobalContext* globalCtx) { s16 sp2E = this->skelAnime.curFrame; - s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animationSeg); + s16 sp2C = Animation_GetLastFrame(sAnimations[this->unk_4AC].animation); if (this->unk_4AC == 2) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); @@ -761,11 +771,11 @@ void func_80BB30B4(EnGeg* this, GlobalContext* globalCtx) { } else { this->unk_496 = 0xD6E; } - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->actor.xzDistToPlayer < 150.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 150.0f); } } @@ -799,7 +809,7 @@ void func_80BB31B8(EnGeg* this, GlobalContext* globalCtx) { void func_80BB32AC(EnGeg* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_496, &this->actor); + Message_StartTextbox(globalCtx, this->unk_496, &this->actor); this->actionFunc = func_80BB27D4; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); @@ -894,7 +904,7 @@ void EnGeg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BB1FCC(this, globalCtx); func_80BB2088(this, globalCtx); func_80BB1C8C(this); - func_8013D9C8(globalCtx, &this->unk_238, &this->unk_232, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_238, this->unk_232, ARRAY_COUNT(this->unk_238)); func_80BB1D04(this); func_80BB178C(this, globalCtx); } 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 c846f447b..f5e9ad34d 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.h +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.h @@ -14,10 +14,8 @@ typedef struct EnGeg { /* 0x18C */ ColliderCylinder colliderCylinder; /* 0x1D8 */ ColliderSphere colliderSphere; /* 0x230 */ u16 unk_230; - /* 0x232 */ s16 unk_232; - /* 0x234 */ UNK_TYPE1 unk234[4]; - /* 0x238 */ s16 unk_238; - /* 0x23A */ UNK_TYPE1 unk23A[0x4]; + /* 0x232 */ s16 unk_232[3]; + /* 0x238 */ s16 unk_238[3]; /* 0x23E */ s16 unk_23E; /* 0x240 */ s16 unk_240; /* 0x242 */ s16 unk_242; 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 4eb259e50..3d80cc847 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -5,8 +5,10 @@ */ #include "z_en_gg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_gg/object_gg.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnGg*)thisx) @@ -15,7 +17,15 @@ void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGg_Update(Actor* thisx, GlobalContext* globalCtx); void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B352A4(EnGg* this, GlobalContext* globalCtx); +void func_80B35450(EnGg* this, GlobalContext* globalCtx); +void func_80B3556C(EnGg* this, GlobalContext* globalCtx); +u16 func_80B357F0(EnGg* this); +void func_80B358D8(EnGg* this, GlobalContext* globalCtx); +void func_80B359DC(EnGg* this, GlobalContext* globalCtx); +void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3); +void func_80B364D4(EnGgStruct* ptr, GlobalContext* globalCtx); + const ActorInit En_Gg_InitVars = { ACTOR_EN_GG, ACTORCAT_NPC, @@ -28,18 +38,29 @@ const ActorInit En_Gg_InitVars = { (ActorFunc)EnGg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B36C00 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 24, 72, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B36C2C = { 0, 24, 72, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 24, 72, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B36C38 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,62 +95,719 @@ static DamageTable D_80B36C38 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfo sAnimations[] = { + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, 2, -10.0f }, { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +}; -extern ColliderCylinderInit D_80B36C00; -extern CollisionCheckInfoInit2 D_80B36C2C; -extern DamageTable D_80B36C38; +void func_80B34F70(EnGg* this) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + 80.0f; + this->actor.focus.pos.z = this->actor.world.pos.z; -extern UNK_TYPE D_0600F578; + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B34F70.s") +s32 func_80B34FB4(EnGg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 pitch; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B34FB4.s") + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp34 = this->actor.world.pos; + sp34.y += 70.0f; + pitch = Math_Vec3f_Pitch(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35108.s") + if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.save.weekEventReg[19] & 0x80))) { + Math_SmoothStepToS(&this->unk_2E8, pitch, 4, 0x2AA8, 1); + } else { + Math_SmoothStepToS(&this->unk_2E8, 0, 4, 0x2AA8, 1); + } + this->unk_2E8 = CLAMP(this->unk_2E8, 0, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B351A4.s") +void func_80B35108(EnGg* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35250.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B352A4.s") +void func_80B351A4(EnGg* this) { + if ((this->unk_2E6 == 2) || (this->unk_2E6 == 3)) { + this->unk_2E2 = 3; + } else { + s16 temp = this->unk_2E4 - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35450.s") + if (temp >= 3) { + this->unk_2E2 = 0; + this->unk_2E4 = temp; + } else if (temp == 0) { + this->unk_2E2 = 2; + this->unk_2E4 = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2E2 = 1; + this->unk_2E4 = temp; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3556C.s") +void func_80B35250(EnGg* this) { + this->unk_2E4 = 20; + this->unk_2E2 = 0; + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B35450; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35634.s") +void func_80B352A4(EnGg* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E6].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B357F0.s") + if (sp26 == lastFrame) { + switch (this->actor.textId) { + case 0xCE5: + this->unk_2E6 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3584C.s") + case 0xCE6: + case 0xCEC: + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B358D8.s") + case 0xCE8: + this->unk_2E6 = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35968.s") + case 0xCE9: + this->unk_2E6 = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B359DC.s") + case 0xCED: + case 0xCEE: + this->unk_2E6 = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35B24.s") + default: + this->unk_2E6 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + break; + } + gSaveContext.save.weekEventReg[19] |= 0x80; + this->actionFunc = func_80B3556C; + } else if ((this->unk_2E6 == 0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { + if (sp26 < (lastFrame - 1)) { + this->skelAnime.playSpeed = 2.0f; + } else { + this->unk_2E6 = 4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35B44.s") +void func_80B35450(EnGg* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.weekEventReg[91] & 0x10) && (globalCtx->csCtx.state == 0)) { + func_80B359DC(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B35C84.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + func_800B90F4(globalCtx); + } + this->unk_308 = 1; + this->actionFunc = func_80B352A4; + } else if ((this->actor.xzDistToPlayer < 200.0f) && (this->actor.xzDistToPlayer > 50.0f)) { + if (gSaveContext.save.weekEventReg[19] & 0x80) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCEE; + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCE5; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B3610C.s") +void func_80B3556C(EnGg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_2E6 == 4) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_308 = 0; + this->actor.flags &= ~ACTOR_FLAG_80; + func_80B35250(this); + } else { + this->actor.textId = func_80B357F0(this); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->actionFunc = func_80B352A4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B363E8.s") +void func_80B35634(EnGg* this, GlobalContext* globalCtx) { + s32 pad; + s32 actionIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B364D4.s") + if (Cutscene_CheckActorAction(globalCtx, 119)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 119); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Init.s") + if (this->unk_2DB != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_2DB = globalCtx->csCtx.actorActions[actionIndex]->action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Destroy.s") + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_2DA = 0; + this->unk_2E6 = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Update.s") + case 2: + this->unk_2DA = 9; + this->unk_2E6 = 9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B368B0.s") + case 3: + this->unk_2DA = 10; + this->unk_2E6 = 10; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/func_80B368F0.s") + case 4: + do { + this->unk_344.unk_30 = this->unk_2DA = 11; + } while (0); + this->unk_2E6 = 11; + func_80B364D4(&this->unk_344, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg/EnGg_Draw.s") + case 5: + do { + this->unk_344.unk_30 = this->unk_2DA = 12; + } while (0); + this->unk_2E6 = 12; + break; + + case 6: + do { + this->unk_344.unk_30 = this->unk_2DA = 13; + } while (0); + this->unk_2E6 = 13; + break; + + case 7: + do { + this->unk_344.unk_30 = this->unk_2DA = 14; + } while (0); + this->unk_2E6 = 14; + func_80B364D4(&this->unk_344, globalCtx); + break; + + case 8: + Actor_MarkForDeath(&this->actor); + return; + + default: + this->unk_2DA = 0; + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2DA); + } + + if (this->unk_2DA == 14) { + func_80B358D8(this, globalCtx); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + this->actor.shape.yOffset = 0.0f; + } else { + this->unk_2DB = 99; + } +} + +u16 func_80B357F0(EnGg* this) { + switch (this->actor.textId) { + case 0xCE5: + return 0xCE6; + case 0xCE6: + return 0xCE8; + case 0xCE8: + return 0xCE9; + case 0xCE9: + return 0xCEC; + case 0xCEC: + return 0xCED; + } + return 0; +} + +void func_80B3584C(EnGg* this) { + this->unk_30A += 0x72C; + this->actor.shape.yOffset = Math_SinS(this->unk_30A) * 100.0f; + this->actor.shape.shadowScale = 30.0f - (Math_SinS(this->unk_30A) * 5.0f); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B358D8(EnGg* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2DA].animation); + + if ((this->unk_2E6 == 14) && (sp1E == lastFrame)) { + this->unk_2E6 = 15; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + } +} + +void func_80B35968(EnGg* this, GlobalContext* globalCtx) { + if (this->unk_344.unk_34 != NULL) { + this->unk_344.unk_34(&this->unk_344, globalCtx); + } else { + if ((this->unk_2DA == 11) || (this->unk_2DA == 14)) { + this->unk_344.unk_30 = this->unk_2DA; + } + func_80B363E8(&this->unk_344, globalCtx, &this->unk_320, &this->unk_32C, &this->unk_338); + } +} + +void func_80B359DC(EnGg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.xzDistToPlayer < 200.0f) { + if (this->unk_306 == 0) { + if (player->stateFlags2 & 0x8000000) { + this->unk_306 = 1; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (!(player->stateFlags2 & 0x8000000)) { + this->unk_306 = 0; + } + + if ((player->transformation == PLAYER_FORM_HUMAN) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 7)) { + if (!(gSaveContext.save.weekEventReg[19] & 0x80)) { + gSaveContext.save.weekEventReg[19] |= 0x80; + } + this->unk_307 = true; + } + + if (ActorCutscene_GetCanPlayNext(this->unk_2DC)) { + ActorCutscene_Start(this->unk_2DC, &this->actor); + this->unk_307 = false; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + + if (this->unk_307) { + ActorCutscene_SetIntentToPlay(this->unk_2DC); + } + } + } else { + this->unk_307 = false; + } +} + +void func_80B35B24(EnGgStruct* ptr, GlobalContext* globalCtx) { + ptr->unk_34 = NULL; + ptr->unk_38 = NULL; + ptr->unk_3C = 0; + ptr->unk_40 = 0; + ptr->unk_44 = 0; +} + +void func_80B35B44(EnGgStruct* ptr, GlobalContext* globalCtx) { + if (ptr->unk_30 == 0xE) { + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_48 = 1; + ptr->unk_40 = 0; + } + + if (ptr->unk_40 != 0x46) { + if (ptr->unk_48 != 0) { + ptr->unk_44 = 0x37; + } else { + ptr->unk_44 = ptr->unk_40 - 15; + if (ptr->unk_44 < 0) { + ptr->unk_44 = 0; + } + } + } else { + ptr->unk_44++; + if (ptr->unk_44 > 0x37) { + ptr->unk_44 = 0x37; + } + } + } else if ((ptr->unk_30 == 11) || (ptr->unk_30 == 12)) { + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_48 = 1; + ptr->unk_40 = 0; + } + } else if (ptr->unk_30 == 0xD) { + ptr->unk_48 = 0; + ptr->unk_40++; + if (ptr->unk_40 > 0x46) { + ptr->unk_40 = 0x46; + } + + if (ptr->unk_40 != 0x46) { + ptr->unk_44 = ptr->unk_40 - 15; + if (ptr->unk_44 < 0) { + ptr->unk_44 = 0; + } + } else { + ptr->unk_44++; + if (ptr->unk_44 > 0x37) { + func_80B364D4(ptr, globalCtx); + } + } + } +} + +void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { + s32 sp74; + s32 phi_s7; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f20; + s32 i; + s32 temp = 10; + + if (ptr->unk_48 != 0) { + sp74 = ptr->unk_40 % temp; + ptr->unk_40 = sp74; + phi_s7 = 0x46; + } else if (ptr->unk_30 == 0xD) { + sp74 = ptr->unk_40; + phi_s7 = 0x46; + } else { + phi_s7 = ptr->unk_40 - ptr->unk_44; + sp74 = ptr->unk_40 % temp; + } + + if (phi_s7 <= 0) { + return; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + for (i = sp74; i < phi_s7; i += temp) { + temp_f20 = i * 0.14f; + temp_f22 = ptr->unk_00.x + (ptr->unk_18.x * temp_f20) + (0.5f * ptr->unk_24.x * temp_f20 * temp_f20); + temp_f24 = ptr->unk_00.y - Math_SinS((i * 0x27FFB) / 70); + temp_f26 = ptr->unk_00.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); + temp_f20 = Rand_ZeroOne() * 0.003f; + + if (1) {} + + Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_StatePop(); + + Matrix_StatePush(); + + for (i = sp74; i < phi_s7; i += temp) { + temp_f20 = i * 0.14f; + temp_f22 = ptr->unk_0C.x + ((ptr->unk_18.x * temp_f20) + (0.5f * ptr->unk_24.x * temp_f20 * temp_f20)); + temp_f24 = ptr->unk_0C.y - Math_SinS((i * 0x27FFB) / 70); + temp_f26 = ptr->unk_0C.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); + temp_f20 = Rand_ZeroOne() * 0.003f; + + Matrix_InsertTranslation(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_StatePop(); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { + f32 temp_f20; + f32 temp_f24; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + s32 phi_s4; + f32 phi_f22; + s32 i; + + if (ptr->unk_48 != 0) { + phi_s4 = 0x46; + } else { + phi_s4 = ptr->unk_40; + } + + if (phi_s4 > 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + for (i = 0; i < phi_s4; i++) { + if (ptr->unk_48 != 0) { + phi_f22 = phi_s4 / 70.0f; + } else { + phi_f22 = i / 70.0f; + } + temp_f24 = ptr->unk_0C.x + (ptr->unk_18.x * i) + (0.5f * ptr->unk_24.x * i * i); + temp_f26 = ptr->unk_0C.y + (ptr->unk_18.y * i) + (0.5f * ptr->unk_24.y * i * i); + temp_f28 = ptr->unk_0C.z + (ptr->unk_18.z * i) + (0.5f * ptr->unk_24.z * i * i); + temp_f20 = Rand_ZeroOne() * 0.003f; + + Matrix_InsertTranslation((Rand_Centered() * (100.0f * phi_f22)) + temp_f24, temp_f26, + ((30.0f * phi_f22) * Rand_Centered()) + temp_f28, MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + + Matrix_StatePop(); + + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80B363E8(EnGgStruct* ptr, GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { + ptr->unk_34 = func_80B35B44; + ptr->unk_00 = *arg1; + ptr->unk_0C = *arg1; + ptr->unk_18 = *arg2; + ptr->unk_24 = *arg3; + ptr->unk_48 = 0; + + ptr->unk_00.x += -4.0f; + ptr->unk_0C.x += 4.0f; + + if ((ptr->unk_30 == 11) || (ptr->unk_30 == 12) || (ptr->unk_30 == 13)) { + ptr->unk_38 = func_80B35C84; + } else if (ptr->unk_30 == 14) { + ptr->unk_38 = func_80B3610C; + } +} + +void func_80B364D4(EnGgStruct* ptr, GlobalContext* globalCtx) { + ptr->unk_34 = NULL; + ptr->unk_38 = NULL; + func_80B35B24(ptr, globalCtx); +} + +void EnGg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGg* this = THIS; + + if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + this->actor.bgCheckFlags |= 0x400; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + this->morphTable, 20); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + this->actor.flags &= ~ACTOR_FLAG_80; + this->unk_310 = this->actor.home.pos.y; + this->unk_2DC = this->actor.cutscene; + this->actor.flags |= ACTOR_FLAG_2000000; + this->unk_308 = 0; + this->unk_309 = 0; + this->unk_304 = 0; + this->unk_30A = 0; + this->actor.flags |= ACTOR_FLAG_10; + func_80B35B24(&this->unk_344, globalCtx); + func_80B35250(this); +} + +void EnGg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGg* this = THIS; + + if (globalCtx->actorCtx.unk4 == 100) { + this->actor.flags |= ACTOR_FLAG_80; + this->actor.flags |= ACTOR_FLAG_1; + } else { + this->actor.flags &= ~ACTOR_FLAG_80; + this->actor.flags &= ~ACTOR_FLAG_1; + } + + if (gSaveContext.save.weekEventReg[19] & 0x80) { + if (globalCtx->csCtx.state == 0) { + this->actor.flags |= ACTOR_FLAG_1; + } else { + this->actor.flags &= ~ACTOR_FLAG_1; + } + } + + if ((globalCtx->csCtx.state == 0) && + ((this->unk_2DA != 14) && (this->unk_2DA != 11) && (this->unk_2DA != 12) && (this->unk_2DA != 13))) { + func_80B364D4(&this->unk_344, globalCtx); + } + + if (((this->unk_2DA == 14) || (this->unk_2DA == 11) || (this->unk_2DA == 12) || (this->unk_2DA == 13)) && + (this->unk_309 == 1)) { + func_80B35968(this, globalCtx); + } + + if (!(gSaveContext.save.weekEventReg[91] & 0x10) && + ((gSaveContext.save.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || + (this->unk_308 == 1))) { + gSaveContext.save.weekEventReg[91] |= 0x10; + } + + this->actionFunc(this, globalCtx); + + func_80B34F70(this); + func_80B35108(this, globalCtx); + func_80B34FB4(this, globalCtx); + Actor_MoveWithoutGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + if (globalCtx->csCtx.state == 0) { + func_80B3584C(this); + } else { + this->unk_2E8 = 0; + } + + func_80B35634(this, globalCtx); + func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + func_80B351A4(this); +} + +s32 EnGg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGg* this = THIS; + + if (limbIndex == 2) { + Matrix_InsertZRotation_s(this->unk_2E8, MTXMODE_APPLY); + } + return false; +} + +void EnGg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + static Vec3f D_80B36DF0 = { 1800.0f, 300.0f, 200.0f }; + EnGg* this = THIS; + Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; + + if (this->unk_2DA == 14) { + sp30.y = 3.0f; + sp30.z = -1.0f; + sp24.y = -0.07f; + this->unk_309 = 1; + } else if ((this->unk_2DA == 11) || (this->unk_2DA == 12) || (this->unk_2DA == 13)) { + sp30.x = 3.0f; + sp24.x = 0.5f; + this->unk_309 = 1; + } else { + this->unk_309 = 0; + } + + if (limbIndex == 4) { + Matrix_MultiplyVector3fByState(&D_80B36DF0, &this->unk_320); + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp30, &this->unk_32C); + Matrix_MultiplyVector3fByState(&sp24, &this->unk_338); + Matrix_StatePop(); + } +} + +TexturePtr D_80B36DFC[] = { + object_gg_Tex_009260, + object_gg_Tex_009660, + object_gg_Tex_009A60, + object_gg_Tex_009E60, +}; + +void EnGg_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_344.unk_38 != 0) { + this->unk_344.unk_38(&this->unk_344, globalCtx); + } + + if (gSaveContext.save.weekEventReg[19] & 0x80) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); + + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, 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)) { + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B36DFC[this->unk_2E2])); + + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGg_OverrideLimbDraw, EnGg_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + } + func_8012C2DC(globalCtx->state.gfxCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 f96a59548..eeb83cbbd 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.h +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.h @@ -4,14 +4,57 @@ #include "global.h" struct EnGg; +struct EnGgStruct; typedef void (*EnGgActionFunc)(struct EnGg*, GlobalContext*); +typedef void (*EnGgUnkFunc)(struct EnGgStruct*, GlobalContext*); + +typedef struct EnGgStruct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ u8 unk_30; + /* 0x34 */ EnGgUnkFunc unk_34; + /* 0x38 */ EnGgUnkFunc unk_38; + /* 0x3C */ s32 unk_3C; + /* 0x40 */ s32 unk_40; + /* 0x44 */ s32 unk_44; + /* 0x48 */ u8 unk_48; +} EnGgStruct; // size == 0x4C typedef struct EnGg { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGgActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x1B8]; + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ Vec3s jointTable[20]; + /* 0x025C */ Vec3s morphTable[20]; + /* 0x02D4 */ UNK_TYPE1 unk_2D4[0x6]; + /* 0x02DA */ u8 unk_2DA; + /* 0x02DB */ u8 unk_2DB; + /* 0x02DC */ s16 unk_2DC; + /* 0x02DE */ UNK_TYPE1 unk2DE[4]; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ s16 unk_2E6; + /* 0x02E8 */ s16 unk_2E8; + /* 0x02EA */ UNK_TYPE1 unk2EA[0x1A]; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ u8 unk_306; + /* 0x0307 */ u8 unk_307; + /* 0x0308 */ u8 unk_308; + /* 0x0309 */ u8 unk_309; + /* 0x030A */ s16 unk_30A; + /* 0x030C */ UNK_TYPE1 unk30C[4]; + /* 0x0310 */ f32 unk_310; + /* 0x0314 */ UNK_TYPE1 unk314[0xC]; + /* 0x0320 */ Vec3f unk_320; + /* 0x032C */ Vec3f unk_32C; + /* 0x0338 */ Vec3f unk_338; + /* 0x0344 */ EnGgStruct unk_344; } EnGg; // size = 0x390 extern const ActorInit En_Gg_InitVars; 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 e415165ac..ebe127fcf 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -5,8 +5,9 @@ */ #include "z_en_gg2.h" +#include "objects/object_gg/object_gg.h" -#define FLAGS 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnGg2*)thisx) @@ -15,7 +16,17 @@ void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx); void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx); +void func_80B3AFB0(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B120(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B294(EnGg2* this, GlobalContext* globalCtx); +void func_80B3B5D4(EnGg2* this, GlobalContext* globalCtx); +s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_); +f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3); + const ActorInit En_Gg2_InitVars = { ACTOR_EN_GG2, ACTORCAT_NPC, @@ -28,48 +39,456 @@ const ActorInit En_Gg2_InitVars = { (ActorFunc)EnGg2_Draw, }; -#endif +AnimationInfo D_80B3BF00[] = { + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, 2, -10.0f }, { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, 2, -10.0f }, + { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +}; -extern UNK_TYPE D_0600F578; +Color_RGBA8 D_80B3C080 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80B3C084 = { 255, 150, 0, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AC50.s") +Vec3f D_80B3C088 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B3C094 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B3C0A0 = { 1000.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AC94.s") +TexturePtr D_80B3C0AC[] = { + object_gg_Tex_009260, + object_gg_Tex_009660, + object_gg_Tex_009A60, + object_gg_Tex_009E60, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3ADD8.s") +void func_80B3AC50(EnGg2* this) { + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + 80.0f; + this->actor.focus.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AE60.s") + this->actor.focus.rot.x = this->actor.world.rot.x; + this->actor.focus.rot.y = this->actor.world.rot.y; + this->actor.focus.rot.z = this->actor.world.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3AFB0.s") +s32 func_80B3AC94(EnGg2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + s16 pitch; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B05C.s") + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B0A0.s") + sp34 = this->actor.world.pos; + sp34.y += 70.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B120.s") + pitch = Math_Vec3f_Pitch(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B21C.s") + if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + Math_SmoothStepToS(&this->unk_2F4, pitch, 4, 0x2AA8, 1); + } else { + Math_SmoothStepToS(&this->unk_2F4, 0, 4, 0x2AA8, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B294.s") + this->unk_2F4 = CLAMP(this->unk_2F4, 0, 0x1C70); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B4B0.s") +void func_80B3ADD8(EnGg2* this) { + s16 temp_v0 = this->unk_2EC - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B5D4.s") + if (temp_v0 >= 3) { + this->unk_2EA = 0; + this->unk_2EC = temp_v0; + } else if (temp_v0 == 0) { + this->unk_2EA = 2; + this->unk_2EC = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2EA = 1; + this->unk_2EC = temp_v0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B648.s") +void func_80B3AE60(EnGg2* this, GlobalContext* globalCtx) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(D_80B3BF00[this->unk_2EE].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B7E4.s") + if (curFrame == lastFrame) { + switch (this->unk_2EE) { + case 0: + this->unk_2EE = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 1); + this->actionFunc = func_80B3B0A0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3B8A4.s") + case 1: + case 8: + this->unk_2EE = 5; + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + this->actionFunc = func_80B3B120; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Init.s") + case 5: + this->unk_2EE = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B21C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Destroy.s") + case 6: + this->unk_2EE = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + this->actionFunc = func_80B3B294; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Update.s") + default: + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3AFB0; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3BD44.s") +void func_80B3AFB0(EnGg2* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + 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)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xCE4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/func_80B3BDC0.s") +void func_80B3B05C(EnGg2* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80)) { + this->actionFunc = func_80B3B5D4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gg2/EnGg2_Draw.s") +void func_80B3B0A0(EnGg2* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->unk_2F0 = 0; + this->actionFunc = func_80B3B5D4; + } +} + +void func_80B3B120(EnGg2* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->unk_1D8 != NULL) { + func_80B3B7E4(this->unk_1D8, this->unk_1DC, &this->actor.world.pos, &sp30); + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp30.x, 4, 0x3E8, 1); + this->actor.world.rot.x = -this->actor.shape.rot.x; + 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; + } else { + this->unk_1DC++; + } + } + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); + } +} + +void func_80B3B21C(EnGg2* this, GlobalContext* globalCtx) { + 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->actionFunc = func_80B3B5D4; + } +} + +void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { + Vec3s sp30; + + if (this->unk_2F1 == 0) { + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; + } + + if (this->unk_1D8 != NULL) { + func_80B3B7E4(this->unk_1D8, this->unk_1DC, &this->actor.world.pos, &sp30); + Math_SmoothStepToS(&this->actor.world.rot.y, sp30.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp30.x, 4, 0x3E8, 1); + this->actor.world.rot.x = -this->actor.shape.rot.x; + + if (func_80B3B648(this, this->unk_1D8, this->unk_1DC)) { + if (this->unk_1DC < (this->unk_1D8->count - 1)) { + this->unk_1DC++; + } else { + this->unk_2F1 = 1; + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.save.weekEventReg[20] |= 4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] |= 8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] |= 0x10; + } + } + } + } + } + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.2f, 1.0f); +} + +void func_80B3B4B0(EnGg2* this, GlobalContext* globalCtx) { + Vec3f sp64; + Color_RGBA8 sp60 = D_80B3C080; + Color_RGBA8 sp5C = D_80B3C084; + s32 i; + + for (i = 0; i < 5; i++) { + sp64.x = (Rand_Centered() * 50.0f) + this->unk_304.x; + sp64.y = this->unk_304.y; + sp64.z = (Rand_Centered() * 50.0f) + this->unk_304.z; + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp64, &D_80B3C088, &D_80B3C094, &sp60, &sp5C, 3000, 40); + } +} + +void func_80B3B5D4(EnGg2* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_2E4)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2E4, &this->actor); + this->actionFunc = func_80B3AE60; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_2E4); + } +} + +s32 func_80B3B648(EnGg2* this, Path* path, s32 arg2_) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 arg2 = arg2_; + s32 ret = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &points[arg2]); + + if (arg2 == 0) { + phi_f12 = points[1].x - points[0].x; + phi_f14 = points[1].z - points[0].z; + } else if ((sp58 - 1) == arg2) { + phi_f12 = points[sp58 - 1].x - points[sp58 - 2].x; + phi_f14 = points[sp58 - 1].z - points[sp58 - 2].z; + } else { + phi_f12 = points[arg2 + 1].x - points[arg2 - 1].x; + 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); + + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + ret = true; + } + return ret; +} + +f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + Vec3s* points; + Vec3f sp20; + + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[arg1]; + sp20.x = points->x; + sp20.y = points->y; + sp20.z = points->z; + } + + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} + +void func_80B3B8A4(EnGg2* this) { + f32 sp1C; + + if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { + this->unk_2F2 += 0x62C; + sp1C = 1100.0f; + } else { + this->unk_2F2 += 0x7BC; + sp1C = 950.0f; + } + + this->actor.shape.yOffset = Math_SinS(this->unk_2F2) * sp1C; + this->actor.shape.shadowScale = 30.0f - (Math_SinS(this->unk_2F2) * 5.0f); + this->unk_2F6 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +} + +void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnGg2* this = THIS; + + if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (gSaveContext.save.weekEventReg[91] & 0x10) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + this->actor.bgCheckFlags |= 0x400; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + this->morphTable, 20); + this->unk_1D8 = SubS_GetPathByIndex(globalCtx, ENGG2_GET_FC00(&this->actor), 0x3F); + this->actor.flags &= ~ACTOR_FLAG_80; + 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->unk_2EC = 20; + this->unk_2EA = 0; + + if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + this->unk_2EE = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3AFB0; + } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { + if ((gSaveContext.save.weekEventReg[20] & 4) && !(gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + this->unk_2EE = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B05C; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { + if (!(gSaveContext.save.weekEventReg[20] & 4) && (gSaveContext.save.weekEventReg[20] & 8) && + !(gSaveContext.save.weekEventReg[20] & 0x10)) { + gSaveContext.save.weekEventReg[20] &= (u8)~8; + this->unk_2EE = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->actionFunc = func_80B3B05C; + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + gSaveContext.save.weekEventReg[20] &= (u8)~4; + gSaveContext.save.weekEventReg[20] &= (u8)~8; + gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + Actor_MarkForDeath(&this->actor); + } +} + +void EnGg2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnGg2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGg2* this = THIS; + + if (globalCtx->actorCtx.unk4 == 100) { + this->actor.flags |= ACTOR_FLAG_80; + 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_1; + } + + this->actionFunc(this, globalCtx); + + func_80B3AC50(this); + func_80B3AC94(this, globalCtx); + Actor_MoveWithoutGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + func_80B3B8A4(this); + func_800E9250(globalCtx, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); + + if ((this->unk_2EE == 5) || (this->unk_2EE == 7)) { + func_800B9010(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); + if ((globalCtx->actorCtx.unk4 == 100) && ((globalCtx->state.frames % 4) == 0)) { + func_80B3B4B0(this, globalCtx); + } + } + + func_80B3ADD8(this); +} + +s32 func_80B3BD44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnGg2* this = THIS; + + if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { + if (limbIndex == 1) { + Matrix_RotateY(this->unk_2F6, MTXMODE_APPLY); + } + + if (limbIndex == 2) { + Matrix_InsertZRotation_s(this->unk_2F4, MTXMODE_APPLY); + } + } + return false; +} + +void func_80B3BDC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnGg2* this = THIS; + + if (limbIndex == 4) { + Matrix_MultiplyVector3fByState(&D_80B3C0A0, &this->unk_304); + } +} + +void EnGg2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGg2* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_2F0 == 1)) { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B3C0AC[this->unk_2EA])); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80B3BD44, func_80B3BDC0, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 dc4684272..0fea44822 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -7,11 +7,32 @@ struct EnGg2; typedef void (*EnGg2ActionFunc)(struct EnGg2*, GlobalContext*); +#define ENGG2_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnGg2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ UNK_TYPE1 unk144[0x4C]; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGg2ActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x138]; + /* 0x01D8 */ Path* unk_1D8; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Vec3s unk_1E0; + /* 0x01E6 */ Vec3s unk_1E6; + /* 0x01EC */ Vec3s jointTable[20]; + /* 0x0264 */ Vec3s morphTable[20]; + /* 0x02DC */ UNK_TYPE1 unk2DC[0x8]; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E6 */ UNK_TYPE1 unk2E6[4]; + /* 0x02EA */ s16 unk_2EA; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ u8 unk_2F0; + /* 0x02F1 */ u8 unk_2F1; + /* 0x02F2 */ s16 unk_2F2; + /* 0x02F4 */ s16 unk_2F4; + /* 0x02F6 */ s16 unk_2F6; + /* 0x02F8 */ UNK_TYPE1 unk2F8[0xC]; + /* 0x0304 */ Vec3f unk_304; } EnGg2; // size = 0x310 extern const ActorInit En_Gg2_InitVars; 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 4818d1f3a..90d945e2a 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -5,9 +5,8 @@ */ #include "z_en_giant.h" -#include "objects/object_giant/object_giant.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnGiant*)thisx) @@ -20,6 +19,59 @@ void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globa void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* globalCtx); void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx); +#define GIANT_TYPE_IS_NOT_TERMINA_FIELD(type) (type > GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_TERMINA_FIELD(type) (type <= GIANT_TYPE_OCEAN_TERMINA_FIELD) +#define GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type) \ + (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS) +#define GIANT_TYPE_IS_CHAMBER_OR_ENDING(type) \ + (type >= GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING && type <= GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING) +#define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) \ + (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) + +/** + * These values are used to index into sAnimations to pick the appropriate animation. + */ +typedef enum { + /* 0 */ GIANT_ANIMATION_LOOK_UP_START, + /* 1 */ GIANT_ANIMATION_LOOK_UP_LOOP, + /* 2 */ GIANT_ANIMATION_FALLING_OVER, + /* 3 */ GIANT_ANIMATION_RAISED_ARMS_START, + /* 4 */ GIANT_ANIMATION_RAISED_ARMS_LOOP, + /* 5 */ GIANT_ANIMATION_STRUGGLE_START, + /* 6 */ GIANT_ANIMATION_STRUGGLE_LOOP, + /* 7 */ GIANT_ANIMATION_IDLE_LOOP, + /* 8 */ GIANT_ANIMATION_WALKING_LOOP, + /* 9 */ GIANT_ANIMATION_BIG_CALL_START, + /* 10 */ GIANT_ANIMATION_BIG_CALL_LOOP, + /* 11 */ GIANT_ANIMATION_BIG_CALL_END, + /* 12 */ GIANT_ANIMATION_SMALL_CALL_START, + /* 13 */ GIANT_ANIMATION_SMALL_CALL_LOOP, + /* 14 */ GIANT_ANIMATION_SMALL_CALL_END, + /* 15 */ GIANT_ANIMATION_MAX +} GiantAnimationIndex; + +/** + * Used as values for csAction. 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; + const ActorInit En_Giant_InitVars = { ACTOR_EN_GIANT, ACTORCAT_NPC, @@ -113,28 +165,29 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { case GIANT_TYPE_CANYON_TERMINA_FIELD: case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: - this->actorActionCommand = 0x1C6; + this->actorActionCommand = 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 = 0x1C7; + this->actorActionCommand = 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 = 0x1C8; + this->actorActionCommand = 456; break; default: - this->actorActionCommand = 0x1C5; + this->actorActionCommand = 453; break; } if (GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type)) { - if (!(gSaveContext.save.weekEventReg[0x19] & 2)) { + if (!(gSaveContext.save.weekEventReg[25] & 2)) { Actor_MarkForDeath(&this->actor); return; } + this->actorActionCommand = 0x1C5; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; @@ -336,20 +389,23 @@ void EnGiant_PlaySound(EnGiant* this) { } void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { - CsCmdActorAction* actorAction = globalCtx->csCtx.npcActions[actionIndex]; - f32 startPosY = actorAction->unk0C.y; + CsCmdActorAction* actorAction = globalCtx->csCtx.actorActions[actionIndex]; + f32 startPosY = actorAction->startPos.y; s32 pad[2]; - f32 endPosY = actorAction->unk18.y; - f32 scale = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); + f32 endPosY = actorAction->endPos.y; + f32 scale = Environment_LerpWeight(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames); this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, this->actorActionCommand)) { - EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + EnGiant_UpdatePosition(this, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); + if (this->csAction != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + this->csAction = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] + ->action; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -369,10 +425,14 @@ void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* global void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { this->actor.draw = EnGiant_Draw; - if (func_800EE29C(globalCtx, this->actorActionCommand)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)); + if (this->csAction != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)]->action) { + this->csAction = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand)] + ->action; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); 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 e28aa2a32..c8d45ad39 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -2,13 +2,9 @@ #define Z_EN_GIANT_H #include "global.h" +#include "objects/object_giant/object_giant.h" #define GIANT_TYPE(thisx) ((thisx)->params & 0xF) -#define GIANT_TYPE_IS_NOT_TERMINA_FIELD(type) (type > GIANT_TYPE_OCEAN_TERMINA_FIELD) -#define GIANT_TYPE_IS_TERMINA_FIELD(type) (type <= GIANT_TYPE_OCEAN_TERMINA_FIELD) -#define GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_SUCCESS && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS) -#define GIANT_TYPE_IS_CHAMBER_OR_ENDING(type) (type >= GIANT_TYPE_MOUNTAIN_GIANTS_CHAMBER_AND_ENDING && type <= GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING) -#define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) /** * The giants are divided into types based on where in the game they appear. @@ -42,70 +38,6 @@ typedef enum { /* 15 */ GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE, } GiantType; -/** - * These values are used to index into sAnimationTable to pick the appropriate animation. - */ -typedef enum { - /* 0 */ GIANT_ANIMATION_LOOK_UP_START, - /* 1 */ GIANT_ANIMATION_LOOK_UP_LOOP, - /* 2 */ GIANT_ANIMATION_FALLING_OVER, - /* 3 */ GIANT_ANIMATION_RAISED_ARMS_START, - /* 4 */ GIANT_ANIMATION_RAISED_ARMS_LOOP, - /* 5 */ GIANT_ANIMATION_STRUGGLE_START, - /* 6 */ GIANT_ANIMATION_STRUGGLE_LOOP, - /* 7 */ GIANT_ANIMATION_IDLE_LOOP, - /* 8 */ GIANT_ANIMATION_WALKING_LOOP, - /* 9 */ GIANT_ANIMATION_BIG_CALL_START, - /* 10 */ GIANT_ANIMATION_BIG_CALL_LOOP, - /* 11 */ GIANT_ANIMATION_BIG_CALL_END, - /* 12 */ GIANT_ANIMATION_SMALL_CALL_START, - /* 13 */ GIANT_ANIMATION_SMALL_CALL_LOOP, - /* 14 */ GIANT_ANIMATION_SMALL_CALL_END, - /* 15 */ GIANT_ANIMATION_MAX -} GiantAnimationIndex; - -/** - * Used as values for csAction. 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; - -typedef enum { - /* 0 */ GIANT_LIMB_NONE, - /* 1 */ GIANT_LIMB_HEAD, - /* 2 */ GIANT_LIMB_LEFT_THIGH, - /* 3 */ GIANT_LIMB_LEFT_LOWER_LEG, - /* 4 */ GIANT_LIMB_LEFT_FOOT, - /* 5 */ GIANT_LIMB_RIGHT_THIGH, - /* 6 */ GIANT_LIMB_RIGHT_LOWER_LEG, - /* 7 */ GIANT_LIMB_RIGHT_FOOT, - /* 8 */ GIANT_LIMB_LEFT_SHOULDER, - /* 9 */ GIANT_LIMB_LEFT_UPPER_ARM, - /* 10 */ GIANT_LIMB_LEFT_FOREARM, - /* 11 */ GIANT_LIMB_LEFT_HAND, - /* 12 */ GIANT_LIMB_RIGHT_SHOULDER, - /* 13 */ GIANT_LIMB_RIGHT_UPPER_ARM, - /* 14 */ GIANT_LIMB_RIGHT_FOREARM, - /* 15 */ GIANT_LIMB_RIGHT_HAND, - /* 16 */ GIANT_LIMB_MAX, -} EnGiantLimbs; - struct EnGiant; typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); 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 442336904..f5d07fcf5 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 @@ -7,7 +7,7 @@ #include "z_en_ginko_man.h" #include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGinkoMan*)thisx) @@ -42,12 +42,12 @@ const ActorInit En_Ginko_Man_InitVars = { (ActorFunc)EnGinkoMan_Draw, }; -ActorAnimationEntry animations[] = { - { &object_boj_Anim_0008C0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_boj_Anim_0043F0, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_boj_Anim_004F40, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_boj_Anim_000AC4, 1.0f, 0.0f, 0.0f, 0, -4.0f }, // looking around for customers - { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, +static AnimationInfo sAnimations[] = { + { &object_boj_Anim_0008C0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_boj_Anim_0043F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_boj_Anim_004F40, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_boj_Anim_000AC4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // looking around for customers + { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, }; void EnGinkoMan_Init(Actor* thisx, GlobalContext* globalCtx) { @@ -71,8 +71,8 @@ void EnGinkoMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnGinkoMan_SetupIdle(EnGinkoMan* this) { - this->actor.flags |= 1; // targetable - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + this->actor.flags |= ACTOR_FLAG_1; // targetable + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); this->actionFunc = EnGinkoMan_Idle; } @@ -82,16 +82,16 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SwitchAnimation(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x44C, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x44C, &this->actor); this->curTextId = 0x44C; // would you like to make an account } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == 1)) { - func_801518B0(globalCtx, 0x467, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { + Message_StartTextbox(globalCtx, 0x467, &this->actor); this->curTextId = 0x467; // "What's this? You need somethin' on a day like this? } else { - func_801518B0(globalCtx, 0x466, &this->actor); + Message_StartTextbox(globalCtx, 0x466, &this->actor); this->curTextId = 0x466; // What's this? You need somethin'? } } @@ -103,29 +103,29 @@ void EnGinkoMan_Idle(EnGinkoMan* this, GlobalContext* globalCtx) { // action func: non-input dialogue void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } switch (this->curTextId) { case 0x44C: // "Hey there, little guy! Won't you deposit some Rupees? (first dialogue) - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if (gSaveContext.save.weekEventReg[10] & 8) { - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" } else { - func_801518B0(globalCtx, 0x44D, &this->actor); + Message_StartTextbox(globalCtx, 0x44D, &this->actor); this->curTextId = 0x44D; // "For example, if you deposit 200 Rupees, you'll get an item that holds a lot of Rupees." } break; case 0x44D: // "For example, if you deposit 200 Rupees, you'll get an item that holds a lot of Rupees." - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); this->curTextId = 0x44E; //" ...So, what'll it be? Deposit Rupees Don't deposit Rupees" break; case 0x44F: // "...So, what'll it be? Deposit Rupees Don't deposit Rupees" - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x450, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x450, &this->actor); this->curTextId = 0x450; // "How much? How much? [rupee prompt] break; @@ -135,55 +135,55 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->isNewAccount == true) { this->isNewAccount = false; if (this->curTextId != 0x453) { // "That's it? That ain't nothing at all, big spender! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); } - func_801518B0(globalCtx, 0x461, &this->actor); + Message_StartTextbox(globalCtx, 0x461, &this->actor); this->curTextId = 0x461; // So, little guy, what's your name? } else { if (this->curTextId == 0x453) { // "That's it? That ain't nothing at all, big spender! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); } globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x456: // "Is that so? Think about it, little guy!" case 0x459: // "Heyyy! You don't have that much! - func_801518B0(globalCtx, 0x44E, &this->actor); + Message_StartTextbox(globalCtx, 0x44E, &this->actor); 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) && !(gSaveContext.save.weekEventReg[59] & 0x40)) { gSaveContext.save.weekEventReg[59] |= 0x40; - func_801518B0(globalCtx, 0x45B, &this->actor); + Message_StartTextbox(globalCtx, 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) && !(gSaveContext.save.weekEventReg[59] & 0x80)) { gSaveContext.save.weekEventReg[59] |= 0x80; - func_801518B0(globalCtx, 0x45C, &this->actor); + Message_StartTextbox(globalCtx, 0x45C, &this->actor); this->curTextId = 0x45C; // "What's this? You've already saved up 1000 Rupees!?! } else if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { if ((this->previousBankValue < 5000) && !(gSaveContext.save.weekEventReg[60] & 1)) { gSaveContext.save.weekEventReg[60] |= 1; - func_801518B0(globalCtx, 0x45D, &this->actor); + Message_StartTextbox(globalCtx, 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)) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x45E, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x45E, &this->actor); this->curTextId = 0x45E; // "...Hang on there, little guy. I can't take any more deposits. Sorry..." } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x460, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x460, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x460, &this->actor); this->curTextId = 0x460; // "Come back and deposit some after you save up a bunch!" } break; @@ -196,15 +196,15 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_BankAward(this, globalCtx); break; case 0x461: // So, little guy, what's your name? - func_801518B0(globalCtx, 0x462, &this->actor); + Message_StartTextbox(globalCtx, 0x462, &this->actor); this->curTextId = 0x462; // Hmm... Link is it? break; case 0x462: // Hmm.. Link is it? - func_801518B0(globalCtx, 0x463, &this->actor); + Message_StartTextbox(globalCtx, 0x463, &this->actor); this->curTextId = 0x463; // Got it... I won't forget your deposits. Let me stamp you break; case 0x463: // Got it... I won't forget your deposits. Let me stamp you - func_801518B0(globalCtx, 0x464, &this->actor); + Message_StartTextbox(globalCtx, 0x464, &this->actor); this->curTextId = 0x464; // Hey, relax! It doesn't leave any marks break; case 0x464: // Hey, relax! It doesn't leave any marks @@ -212,14 +212,14 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_SetupStamp(this); // stamp player break; case 0x465: // "There! Now I'll know you when I see you!" - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" break; case 0x466: // What's this? You need somethin'? case 0x467: // "What's this? You need somethin' on a day like this? You haven't evacuated yet? - func_801518B0(globalCtx, 0x468, &this->actor); + Message_StartTextbox(globalCtx, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x469: // "Excuse me, but let me take a look at you..." @@ -230,38 +230,38 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { case 0x47E: // "Your deposits total [rupees]." if (this->choiceDepositWithdrawl == GINKOMAN_CHOICE_DEPOSIT) { if ((u32)(gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { - func_801518B0(globalCtx, 0x45F, &this->actor); + Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // "Excuuuse me! But I can't take anymore deposits! } else if (gSaveContext.save.playerData.rupees == 0) { - func_801518B0(globalCtx, 0x458, &this->actor); + Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // "Hmm...You play mean jokes, little guy! You haven't even got a single Rupee! } else { - func_801518B0(globalCtx, 0x479, &this->actor); + Message_StartTextbox(globalCtx, 0x479, &this->actor); this->curTextId = 0x479; // "Well, are you gonna make a deposit?" } - } else if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == 1)) { - func_801518B0(globalCtx, 0x46D, &this->actor); + } else if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { + Message_StartTextbox(globalCtx, 0x46D, &this->actor); // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just rumors!" this->curTextId = 0x46D; } else { // GINKOMAN_CHOICE_WITHDRAWL - func_801518B0(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(globalCtx, 0x46B, &this->actor); this->curTextId = 0x46B; // "So..." } this->choiceDepositWithdrawl = GINKOMAN_CHOICE_RESET; break; case 0x46B: // So... - func_801518B0(globalCtx, 0x46E, &this->actor); + Message_StartTextbox(globalCtx, 0x46E, &this->actor); this->curTextId = 0x46E; // "How much do you want? [rupee prompt] break; case 0x46D: // "Look, little guy, if it's 'cause of the bad rumors going around, forget it! They're just // rumors!" - func_801518B0(globalCtx, 0x46B, &this->actor); + Message_StartTextbox(globalCtx, 0x46B, &this->actor); this->curTextId = 0x46B; // So... break; case 0x470: // "Is that so? Come back and deposit some after saving up a bunch!" - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->isStampChecked = false; EnGinkoMan_SetupIdle(this); // change to waiting for approach @@ -269,11 +269,11 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { break; case 0x476: // "...You haven't deposited that many Rupees, so that much isn't available for withdrawal. Do the // math! - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); case 0x475: // "What's this? Look, little guy, you can't hold this many rupees! You got that?" case 0x47C: // "Is that so? Think it over, little guy! So what are you gonna do?" case 0x47D: // duplicate of 48 - func_801518B0(globalCtx, 0x468, &this->actor); + Message_StartTextbox(globalCtx, 0x468, &this->actor); this->curTextId = 0x468; // " Deposit Rupees Withdraw Rupees Nothing really" break; case 0x472: // "What's this? It's a waste to take out such a tiny bit! ...But if you say so!" @@ -281,22 +281,22 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { 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) { - func_801518B0(globalCtx, 0x478, &this->actor); + Message_StartTextbox(globalCtx, 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 { globalCtx->msgCtx.bankRupees = gSaveContext.save.bankRupees & 0xFFFF; - func_801518B0(globalCtx, 0x45A, &this->actor); + Message_StartTextbox(globalCtx, 0x45A, &this->actor); this->curTextId = 0x45A; // "All right, little guy, now I've got a total of [rupees] from you!" } break; case 0x477: // "...You know, at this time of day there's a 4 Rupee service charge on withdrawals!" - func_801518B0(globalCtx, 0x471, &this->actor); + Message_StartTextbox(globalCtx, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n" this->serviceFee = globalCtx->msgCtx.unk1206C; break; case 0x479: // Well, are you gonna make a deposit? - func_801518B0(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! So..." break; } @@ -304,7 +304,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, GlobalContext* globalCtx) { // actionfunc: wait for player dialogue input void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } @@ -313,22 +313,22 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if ((gSaveContext.save.bankRupees & 0xFFFF) >= 5000) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x45F, &this->actor); + Message_StartTextbox(globalCtx, 0x45F, &this->actor); this->curTextId = 0x45F; // bank full, cannot accept more } else { if (gSaveContext.save.playerData.rupees > 0) { func_8019F208(); - func_801518B0(globalCtx, 0x44F, &this->actor); + Message_StartTextbox(globalCtx, 0x44F, &this->actor); this->curTextId = 0x44F; // "All right! so..." } else { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x458, &this->actor); + Message_StartTextbox(globalCtx, 0x458, &this->actor); this->curTextId = 0x458; // you haven't even gotten a single rup } } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - func_801518B0(globalCtx, 0x451, &this->actor); + Message_StartTextbox(globalCtx, 0x451, &this->actor); this->curTextId = 0x451; // dont say that, come on, trust me! } break; @@ -336,20 +336,20 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_YES) { if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.bankRupeesSelected) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x459, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x459, &this->actor); this->curTextId = 0x459; // HEY you dont have that much } else { func_8019F208(); if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - func_801518B0(globalCtx, 0x455, &this->actor); + Message_StartTextbox(globalCtx, 0x455, &this->actor); this->curTextId = 0x455; // You're really going to be give me that much? Rich little guy! } else if (globalCtx->msgCtx.bankRupeesSelected >= 10) { - func_801518B0(globalCtx, 0x454, &this->actor); + Message_StartTextbox(globalCtx, 0x454, &this->actor); this->curTextId = 0x454; // Seriously? that's a lot. A lot! } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x453, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x453, &this->actor); this->curTextId = 0x453; // That's it? That aint nothing at all } @@ -365,12 +365,12 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } } else { // GINKOMAN_CHOICE_NO func_8019F230(); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); if ((gSaveContext.save.bankRupees & 0xFFFF) == 0) { - func_801518B0(globalCtx, 0x456, &this->actor); + Message_StartTextbox(globalCtx, 0x456, &this->actor); this->curTextId = 0x456; // Is that so? think about it } else { - func_801518B0(globalCtx, 0x47D, &this->actor); + Message_StartTextbox(globalCtx, 0x47D, &this->actor); this->curTextId = 0x47D; // is that so? think it over } } @@ -378,17 +378,17 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) case 0x468: // Deposit OR withdrawl OR cancel screen if (globalCtx->msgCtx.choiceIndex == GINKOMAN_CHOICE_CANCEL) { func_8019F230(); - func_801518B0(globalCtx, 0x470, &this->actor); + Message_StartTextbox(globalCtx, 0x470, &this->actor); this->curTextId = 0x470; // "Is that so? Come back and deposit some after saving up a bunch!" } else { func_8019F208(); this->choiceDepositWithdrawl = globalCtx->msgCtx.choiceIndex; if (!this->isStampChecked) { this->isStampChecked = true; - func_801518B0(globalCtx, 0x469, &this->actor); + Message_StartTextbox(globalCtx, 0x469, &this->actor); this->curTextId = 0x469; // "Excuse me, but let me take a look at you..." } else { - func_801518B0(globalCtx, 0x47E, &this->actor); + Message_StartTextbox(globalCtx, 0x47E, &this->actor); this->curTextId = 0x47E; // "Your deposits total [rupees]." } } @@ -398,25 +398,25 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) if ((s32)((gSaveContext.save.bankRupees & 0xFFFF)) < ((s32)(globalCtx->msgCtx.bankRupeesSelected + this->serviceFee))) { play_sound(NA_SE_SY_ERROR); - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_FLOORSMACKING); - func_801518B0(globalCtx, 0x476, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_FLOORSMACKING); + Message_StartTextbox(globalCtx, 0x476, &this->actor); this->curTextId = 0x476; // you dont have enough deposited to withdrawl } else if (CUR_CAPACITY(UPG_WALLET) < (globalCtx->msgCtx.bankRupeesSelected + gSaveContext.save.playerData.rupees)) { // check if wallet is big enough play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0x475, &this->actor); + Message_StartTextbox(globalCtx, 0x475, &this->actor); this->curTextId = 0x475; // You can't hold that many in your wallet } else { func_8019F208(); if (globalCtx->msgCtx.bankRupeesSelected >= 100) { - func_801518B0(globalCtx, 0x474, &this->actor); + Message_StartTextbox(globalCtx, 0x474, &this->actor); this->curTextId = 0x474; // Aw, you're taking out all that? } else if (globalCtx->msgCtx.bankRupeesSelected >= 10) { - func_801518B0(globalCtx, 0x473, &this->actor); + Message_StartTextbox(globalCtx, 0x473, &this->actor); this->curTextId = 0x473; // use it wisely } else { - func_801518B0(globalCtx, 0x472, &this->actor); + Message_StartTextbox(globalCtx, 0x472, &this->actor); this->curTextId = 0x472; // It's a waste to take out such a tiny bit } @@ -429,7 +429,7 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } } else { func_8019F230(); - func_801518B0(globalCtx, 0x47C, &this->actor); + Message_StartTextbox(globalCtx, 0x47C, &this->actor); this->curTextId = 0x47C; // "Is that so? Think it over, little guy! So what are you gonna do?" } break; @@ -437,27 +437,27 @@ void EnGinkoMan_WaitForDialogueInput(EnGinkoMan* this, GlobalContext* globalCtx) } void EnGinkoMan_WaitForRupeeCount(EnGinkoMan* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->curTextId) { case 0x450: // "How much? How much?" [rupee prompt] Set the amount with [Control Stick] and if (globalCtx->msgCtx.bankRupeesSelected == 0) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x457, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x457, &this->actor); this->curTextId = 0x457; // Zero Rupees? Cruel joke! } else { - func_801518B0(globalCtx, 0x452, &this->actor); + Message_StartTextbox(globalCtx, 0x452, &this->actor); this->curTextId = 0x452; // Really? are you really depositing [x]? Y/n } break; case 0x46E: // "How much do you want?" [rupee prompt] Set the amount with [Control Stick] if (globalCtx->msgCtx.bankRupeesSelected == 0) { - func_801518B0(globalCtx, 0x46F, &this->actor); + Message_StartTextbox(globalCtx, 0x46F, &this->actor); this->curTextId = 0x46F; // "Zero Rupees?!? That's a cruel joke!" - } else if (gSaveContext.save.isNight == 1) { - func_801518B0(globalCtx, 0x477, &this->actor); + } else if (gSaveContext.save.isNight == true) { + Message_StartTextbox(globalCtx, 0x477, &this->actor); this->curTextId = 0x477; // "...You know, at this time of day there's a 4 Rupee service charge... } else { - func_801518B0(globalCtx, 0x471, &this->actor); + Message_StartTextbox(globalCtx, 0x471, &this->actor); this->curTextId = 0x471; // "Are you really withdrawing [rupees selected]? Y/n this->serviceFee = 0; } @@ -482,7 +482,7 @@ void EnGinkoMan_Dialogue(EnGinkoMan* this, GlobalContext* globalCtx) { EnGinkoMan_DepositDialogue(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->isStampChecked = false; EnGinkoMan_SetupIdle(this); } @@ -532,22 +532,22 @@ void EnGinkoMan_SetupBankAward2(EnGinkoMan* this) { // separate function to handle bank rewards... called while the player is receiving the award void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.save.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { // "What's this? You've already saved up 200 Rupees!?! Well, little guy, here's your special gift. Take // it!" gSaveContext.save.weekEventReg[10] |= 8; - func_801518B0(globalCtx, 0x47A, &this->actor); + Message_StartTextbox(globalCtx, 0x47A, &this->actor); this->curTextId = 0x47A; // Message after receiving reward for depositing 200 rupees. } else { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x47B, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x47B, &this->actor); this->curTextId = 0x47B; // Message after receiving reward for depositing 1000 rupees. } EnGinkoMan_SetupDialogue(this); } else if (this->curTextId == 0x45D) { // saved up 5000 rupees for HP - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { if (!(gSaveContext.save.weekEventReg[59] & 8)) { gSaveContext.save.weekEventReg[59] |= 8; } @@ -559,7 +559,7 @@ void EnGinkoMan_BankAward2(EnGinkoMan* this, GlobalContext* globalCtx) { } void EnGinkoMan_SetupStamp(EnGinkoMan* this) { - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_REACHING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_REACHING); this->actionFunc = EnGinkoMan_Stamp; } @@ -572,18 +572,18 @@ void EnGinkoMan_Stamp(EnGinkoMan* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->curTextId) { case 0x464: // "Hey, relax! It doesn't leave any marks, and it's not gonna hurt." - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); - func_801518B0(globalCtx, 0x465, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); + Message_StartTextbox(globalCtx, 0x465, &this->actor); this->curTextId = 0x465; // "There! Now I'll know you when I see you!" break; case 0x469: // "Excuse me, but let me take a look at you..." - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_SITTING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_SITTING); globalCtx->msgCtx.bankRupees = (gSaveContext.save.bankRupees & 0xFFFF); - if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == 1)) { - func_801518B0(globalCtx, 0x46C, &this->actor); + if ((CURRENT_DAY == 3) && (gSaveContext.save.isNight == true)) { + Message_StartTextbox(globalCtx, 0x46C, &this->actor); this->curTextId = 0x46C; // "Ah, yes...[Link], right? } else { - func_801518B0(globalCtx, 0x46A, &this->actor); + Message_StartTextbox(globalCtx, 0x46A, &this->actor); this->curTextId = 0x46A; // "Ah, yes...[Link]. } break; @@ -598,12 +598,12 @@ void EnGinkoMan_SwitchAnimation(EnGinkoMan* this, GlobalContext* globalCtx) { if (this->animTimer == 0) { if (this->skelAnime.animation != &object_boj_Anim_004A7C) { this->animTimer = 40; - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_ADVERTISING); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_ADVERTISING); } } } else if ((this->animTimer == 0) && (this->skelAnime.animation != &object_boj_Anim_000AC4)) { this->animTimer = 40; - Actor_ChangeAnimation(&this->skelAnime, animations, GINKO_AMAZED); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, GINKO_AMAZED); } DECR(this->animTimer); diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c index 04f9a54aa..7a9529c2e 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -6,7 +6,7 @@ #include "z_en_girla.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGirlA*)thisx) @@ -159,8 +159,8 @@ void EnGirlA_SetupAction(EnGirlA* this, EnGirlAActionFunc action) { void EnGirlA_InitObjIndex(EnGirlA* this, GlobalContext* globalCtx) { s16 params = this->actor.params; - //! @bug: Condition is impossible - if (params >= 43 && params < 0) { + //! @bug: Condition is impossible, && should be an || + if (params >= SI_MAX && params < SI_POTION_RED_1) { Actor_MarkForDeath(&this->actor); return; } @@ -221,7 +221,7 @@ s32 EnGirlA_CanBuyPotionBlue(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyArrows(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_QUIVER) == 0) { + if (GET_CUR_UPG_VALUE(UPG_QUIVER) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW_2; } if (AMMO(ITEM_BOW) >= CUR_CAPACITY(UPG_QUIVER)) { @@ -234,7 +234,7 @@ s32 EnGirlA_CanBuyArrows(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_CAPACITY(UPG_NUTS) != 0 && AMMO(ITEM_NUT) >= CUR_CAPACITY(UPG_NUTS)) { + if (CUR_CAPACITY(UPG_NUTS) != 0 && CUR_CAPACITY(UPG_NUTS) <= AMMO(ITEM_NUT)) { return CANBUY_RESULT_NO_ROOM; } if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { @@ -247,7 +247,7 @@ s32 EnGirlA_CanBuyNuts(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyShieldHero(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { @@ -277,7 +277,7 @@ s32 EnGirlA_CanBuyMaskAllNight(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyBombBagCuriosityShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { @@ -287,10 +287,10 @@ s32 EnGirlA_CanBuyBombBagCuriosityShop(GlobalContext* globalCtx, EnGirlA* this) } s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 1) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 1) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) >= 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) >= 2) { return CANBUY_RESULT_HAVE_BETTER; } if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { @@ -300,10 +300,10 @@ s32 EnGirlA_CanBuyBombBag20BombShop(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 2) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 2) { return CANBUY_RESULT_ALREADY_HAVE; } - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 3) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 3) { return CANBUY_RESULT_HAVE_BETTER; } if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { @@ -313,7 +313,7 @@ s32 EnGirlA_CanBuyBombBag30BombShop(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMBCHU) >= CUR_CAPACITY(UPG_BOMB_BAG)) { @@ -329,7 +329,7 @@ s32 EnGirlA_CanBuyBombchus(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyBombs(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_UPG_VALUE_VOID(UPG_BOMB_BAG) == 0) { + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { return CANBUY_RESULT_CANNOT_GET_NOW; } if (AMMO(ITEM_BOMB) >= CUR_CAPACITY(UPG_BOMB_BAG)) { @@ -356,7 +356,7 @@ s32 EnGirlA_CanBuySword(GlobalContext* globalCtx, EnGirlA* this) { } s32 EnGirlA_CanBuyShieldMirror(GlobalContext* globalCtx, EnGirlA* this) { - if (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) != 0) { + if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) { return CANBUY_RESULT_NO_ROOM; } if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { @@ -377,24 +377,24 @@ s32 EnGirlA_CanBuyFairy(GlobalContext* globalCtx, EnGirlA* this) { void EnGirlA_BuyBottleItem(GlobalContext* globalCtx, EnGirlA* this) { switch (this->actor.params) { - case 0: - case 10: - case 18: - case 29: - case 32: - case 35: + case SI_POTION_RED_1: + case SI_POTION_RED_2: + case SI_POTION_RED_3: + case SI_POTION_RED_4: + case SI_POTION_RED_5: + case SI_POTION_RED_6: Item_Give(globalCtx, ITEM_POTION_RED); break; - case 1: - case 5: - case 14: + case SI_POTION_GREEN_1: + case SI_POTION_GREEN_2: + case SI_POTION_GREEN_3: Item_Give(globalCtx, ITEM_POTION_GREEN); break; - case 2: + case SI_POTION_BLUE: Item_Give(globalCtx, ITEM_POTION_BLUE); break; - case 3: - case 11: + case SI_FAIRY_1: + case SI_FAIRY_2: Item_Give(globalCtx, ITEM_FAIRY); break; } @@ -538,7 +538,7 @@ void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { ShopItemEntry* shopItem = &sShopItemEntries[params]; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; this->actor.textId = shopItem->descriptionTextId; this->choiceTextId = shopItem->choiceTextId; @@ -558,7 +558,7 @@ void EnGirlA_InitalUpdate(EnGirlA* this, GlobalContext* globalCtx) { this->itemParams = shopItem->params; this->drawFunc = shopItem->drawFunc; this->getItemDrawId = shopItem->getItemDrawId; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.25f); this->actor.shape.yOffset = 24.0f; this->actor.shape.shadowScale = 4.0f; diff --git a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h index 5e3d1b136..a3d8e0206 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.h +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.h @@ -25,7 +25,7 @@ typedef struct ShopItemEntry { typedef struct EnGirlA { /* 0x000 */ Actor actor; - /* 0x144 */ char unk144[0x44]; + /* 0x144 */ UNK_TYPE1 unk144[0x44]; /* 0x188 */ EnGirlAActionFunc actionFunc; /* 0x18C */ s8 objIndex; /* 0x190 */ EnGirlAActionFunc mainActionFunc; @@ -104,6 +104,7 @@ typedef enum { /* 40 */ SI_SWORD_GILDED, /* 41 */ SI_SHIELD_HERO_4, /* 42 */ SI_SHIELD_MIRROR, + /* 43 */ SI_MAX } EnGirlAShopItemId; extern const ActorInit En_GirlA_InitVars; @@ -122,7 +123,7 @@ typedef struct { /* 0x28 */ f32 arrowTexX; /* 0x2C */ f32 arrowTexY; /* 0x30 */ f32 texZ; // Used for both stickTexZ and arrowTexZ - /* 0x34 */ s32 isEnabled; + /* 0x34 */ u32 isEnabled; } StickDirectionPrompt; // size = 0x38 typedef struct ShopItem { 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 acc972053..22c34cf72 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -5,8 +5,9 @@ */ #include "z_en_gk.h" +#include "objects/object_gk/object_gk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnGk*)thisx) @@ -15,7 +16,23 @@ void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGk_Update(Actor* thisx, GlobalContext* globalCtx); void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B51698(EnGk* this, GlobalContext* globalCtx); +void func_80B51760(EnGk* this, GlobalContext* globalCtx); +void func_80B51970(EnGk* this, GlobalContext* globalCtx); +void func_80B51B40(EnGk* this, GlobalContext* globalCtx); +void func_80B51D9C(EnGk* this, GlobalContext* globalCtx); +void func_80B51EA4(EnGk* this, GlobalContext* globalCtx); +void func_80B51FD0(EnGk* this, GlobalContext* globalCtx); +void func_80B5202C(EnGk* this, GlobalContext* globalCtx); +void func_80B5216C(EnGk* this, GlobalContext* globalCtx); +void func_80B521E8(EnGk* this, GlobalContext* globalCtx); +void func_80B5227C(EnGk* this, GlobalContext* globalCtx); +void func_80B52340(EnGk* this, GlobalContext* globalCtx); +void func_80B52430(EnGk* this, GlobalContext* globalCtx); +void func_80B5253C(EnGk* this, GlobalContext* globalCtx); +void func_80B525E0(EnGk* this, GlobalContext* globalCtx); +void func_80B52654(EnGk* this, GlobalContext* globalCtx); + const ActorInit En_Gk_InitVars = { ACTOR_EN_GK, ACTORCAT_NPC, @@ -28,18 +45,29 @@ const ActorInit En_Gk_InitVars = { (ActorFunc)EnGk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B53210 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 24, 32, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B5323C = { 0, 24, 32, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 24, 32, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B53248 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,89 +102,1184 @@ static DamageTable D_80B53248 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfo sAnimations[] = { + { &object_gk_Anim_00787C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_007DC4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_0092C0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_005EDC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gk_Anim_009638, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_008774, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_gk_Anim_00AE34, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_00BD90, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_00C308, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_009858, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_009D88, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_00A21C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_gk_Anim_00AAEC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +}; -extern ColliderCylinderInit D_80B53210; -extern CollisionCheckInfoInit2 D_80B5323C; -extern DamageTable D_80B53248; +Color_RGBA8 D_80B533A0 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80B533A4 = { 50, 150, 150, 0 }; -extern UNK_TYPE D_06006688; -extern UNK_TYPE D_0600787C; +u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50410.s") + if (globalCtx->sceneNum == SCENE_17SETUGEN2) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[40] & 0x80)) { + switch (this->unk_31C) { + case 0xE7A: + return 0xE7B; + case 0xE7B: + return 0xE7C; + case 0xE7C: + return 0xE7D; + case 0xE7D: + return 0xE7E; + case 0xE7E: + return 0xE7F; + case 0xE7F: + gSaveContext.save.weekEventReg[40] |= 0x80; + this->unk_1E4 |= 1; + return 0xE80; + default: + return 0xE7A; + } + } else { + this->unk_1E4 |= 1; + return 0xE81; + } + } else if (!(gSaveContext.save.weekEventReg[41] & 1)) { + switch (this->unk_31C) { + case 0xE82: + return 0xE83; + case 0xE83: + return 0xE7D; + case 0xE7D: + return 0xE7E; + case 0xE7E: + return 0xE7F; + case 0xE7F: + gSaveContext.save.weekEventReg[41] |= 1; + this->unk_1E4 |= 1; + return 0xE80; + default: + return 0xE82; + } + } else { + this->unk_1E4 |= 1; + return 0xE81; + } + } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!(gSaveContext.save.weekEventReg[41] & 4)) { + if (this->unk_31C == 0xE88) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Inventory_HasEmptyBottle()) { + return 0xE89; + } + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 |= 1; + return 0xE94; + } + return 0xE88; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50710.s") + if ((this->unk_31C == 0xE8D) || (this->unk_31C == 0xE98)) { + if (!(gSaveContext.save.weekEventReg[41] & 8) || Inventory_HasEmptyBottle()) { + return 0xE89; + } + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 |= 1; + return 0xE94; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B507A0.s") + if (this->unk_1E4 & 0x10) { + return 0xE8D; + } + return 0xE98; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50854.s") + if (!(gSaveContext.save.weekEventReg[41] & 2)) { + switch (this->unk_31C) { + case 0xE85: + return 0xE86; + case 0xE86: + gSaveContext.save.weekEventReg[41] |= 2; + this->unk_1E4 |= 1; + return 0xE87; + default: + return 0xE85; + } + } else { + this->unk_1E4 |= 1; + return 0xE87; + } + } else { + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50954.s") +u16 func_80B50710(EnGk* this) { + switch (this->unk_31C) { + case 0xE8E: + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 &= ~0x10; + this->unk_1E4 |= 1; + return 0xE8F; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B509A8.s") + case 0xE8A: + return 0xE8B; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50B38.s") + case 0xE8B: + gSaveContext.save.weekEventReg[41] |= 4; + this->unk_1E4 |= 0x10; + this->unk_1E4 |= 1; + return 0xE8C; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50C78.s") +void func_80B507A0(EnGk* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50E14.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B50ED4.s") +s32 func_80B50854(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5100C.s") + if (!(this->unk_1E4 & 0x40)) { + if (player->stateFlags2 & 0x8000000) { + this->unk_1E4 |= 0x40; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } else if (!(player->stateFlags2 & 0x8000000)) { + this->unk_1E4 &= ~0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5123C.s") + if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 1)) { + Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + this->unk_2E4 = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80B521E8; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51308.s") +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); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51398.s") +void func_80B509A8(EnGk* this, GlobalContext* globalCtx) { + Vec3f sp4C; + s16 phi_s1 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51410.s") + this->unk_300.x += 2.0f * Rand_Centered(); + this->unk_300.y += Rand_ZeroOne(); + this->unk_300.z += 2.0f * Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51510.s") + this->unk_30C.x += 2.0f * Rand_Centered(); + this->unk_30C.y += Rand_ZeroOne(); + this->unk_30C.z += 2.0f * Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51698.s") + if (this->unk_2E4 == 0) { + sp4C.x = 0.0f; + sp4C.z = 0.0f; + sp4C.y = -1.2f; + phi_s1 = 25; + } else if ((this->unk_2E4 == 2) || (this->unk_2E4 == 9) || (this->unk_2E4 == 10) || (this->unk_2E4 == 11)) { + sp4C.x = 0.0f; + sp4C.z = 0.0f; + sp4C.y = -0.5f; + phi_s1 = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51760.s") + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2E8, &this->unk_300, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, 0); + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2F4, &this->unk_30C, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51970.s") +void func_80B50B38(EnGk* this, GlobalContext* globalCtx) { + s16 i; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51B40.s") + switch (this->unk_2E4) { + case 0: + this->unk_2E0 = 3; + for (i = 0; i < 2; i++) { + func_80B509A8(this, globalCtx); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51D9C.s") + case 2: + this->unk_2E0 = 3; + func_80B509A8(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51EA4.s") + case 1: + case 3: + case 12: + this->unk_2E0 = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B51FD0.s") + case 9: + case 10: + case 11: + this->unk_2E0 = 3; + func_80B509A8(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5202C.s") + default: + temp = this->unk_2E2; + temp--; + if (temp >= 3) { + this->unk_2E0 = 0; + this->unk_2E2 = temp; + } else if (temp == 0) { + this->unk_2E0 = 2; + this->unk_2E2 = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->unk_2E0 = 1; + this->unk_2E2 = temp; + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5216C.s") +s32 func_80B50C78(EnGk* this, Path* path, s32 arg2_) { + Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 arg2 = arg2_; + s32 ret = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B521E8.s") + Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); + if (arg2 == 0) { + phi_f12 = sp5C[1].x - sp5C[0].x; + phi_f14 = sp5C[1].z - sp5C[0].z; + } else if ((sp58 - 1) == arg2) { + phi_f12 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; + phi_f14 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; + } else { + phi_f12 = sp5C[arg2 + 1].x - sp5C[arg2 - 1].x; + phi_f14 = sp5C[arg2 + 1].z - sp5C[arg2 - 1].z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5227C.s") + func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52340.s") + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52430.s") +f32 func_80B50E14(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + Vec3s* points; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B5253C.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[arg1]; + sp20.x = points[0].x; + sp20.y = points[0].y; + sp20.z = points[0].z; + } + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + return sp20.y - arg2->y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B525E0.s") +s32 func_80B50ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5) { + Vec3f sp7C; + Vec3f sp70 = gZeroVec3f; + Vec3s sp68; + MtxF sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52654.s") + Matrix_MultiplyVector3fByState(&sp70, &sp7C); + Matrix_CopyCurrentState(&sp28); + func_8018219C(&sp28, &sp68, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Init.s") + *arg2 = sp7C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Destroy.s") + if (!arg4 && !arg5) { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Update.s") + if (arg5) { + sp68.z = arg0; + sp68.y = arg1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52AD4.s") + Math_SmoothStepToS(&arg3->x, sp68.x, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&arg3->y, sp68.y, 3, 0x2AA8, 0xB6); + Math_SmoothStepToS(&arg3->z, sp68.z, 3, 0x2AA8, 0xB6); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52AF0.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/func_80B52D8C.s") +s32 func_80B5100C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Gk/EnGk_Draw.s") + Math_SmoothStepToS(&this->unk_320, (this->actor.yawTowardsPlayer - this->unk_324) - this->actor.shape.rot.y, 4, + 0x2AA8, 1); + this->unk_320 = CLAMP(this->unk_320, -0x1FFE, 0x1FFE); + + Math_SmoothStepToS(&this->unk_324, (this->actor.yawTowardsPlayer - this->unk_320) - this->actor.shape.rot.y, 4, + 0x2AA8, 1); + this->unk_324 = CLAMP(this->unk_324, -0x1C70, 0x1C70); + + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + + sp34 = this->actor.world.pos; + sp34.y += 70.0f; + + Math_SmoothStepToS(&this->unk_31E, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_322, 4, 0x2AA8, 1); + this->unk_31E = CLAMP(this->unk_31E, -0x1C70, 0x1C70); + + Math_SmoothStepToS(&this->unk_322, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_31E, 4, 0x2AA8, 1); + this->unk_322 = CLAMP(this->unk_322, -0x1C70, 0x1C70); + return true; +} + +s32 func_80B5123C(EnGk* this, GlobalContext* globalCtx) { + s16 temp_v0; + s16 phi_v1; + + if (DECR(this->unk_34E) != 0) { + this->unk_31E = 0; + this->unk_320 = 0; + this->unk_1E4 &= ~8; + this->unk_322 = 0; + this->unk_324 = 0; + return true; + } + + if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8)) { + this->unk_1E4 |= 8; + func_80B5100C(this, globalCtx); + } else { + if (this->unk_1E4 & 8) { + this->unk_34E = 20; + } + this->unk_1E4 &= ~8; + this->unk_31E = 0; + this->unk_320 = 0; + this->unk_322 = 0; + this->unk_324 = 0; + } + return true; +} + +void func_80B51308(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_31A].animation); + + if ((this->unk_2E4 == 7) && (sp1E == lastFrame)) { + this->unk_2E4 = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); + } +} + +void func_80B51398(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[9].animation); + + if ((this->unk_2E4 == 9) && (sp1E == lastFrame)) { + this->unk_2E4 = 10; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + } +} + +void func_80B51410(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.xzDistToPlayer < 100.0f) { + if ((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && + (globalCtx->msgCtx.unk1202E == 0xE)) { + 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); + this->unk_1E4 &= ~0x20; + return; + } + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + + if (this->unk_1E4 & 0x20) { + ActorCutscene_SetIntentToPlay(this->unk_318); + } + } else { + this->unk_1E4 &= ~0x20; + } +} + +void func_80B51510(EnGk* this, GlobalContext* globalCtx) { + s32 pad; + s32 actionIndex; + + if (this) {} + + if (Cutscene_CheckActorAction(globalCtx, 479)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 479); + + if (globalCtx->csCtx.actorActions[actionIndex]->action != this->unk_31B) { + this->unk_31B = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_31A = 0; + this->unk_2E4 = 0; + break; + + case 2: + this->unk_31A = 2; + this->unk_2E4 = 2; + break; + + case 3: + this->unk_31A = 7; + this->unk_2E4 = 7; + break; + + case 4: + this->unk_31A = 3; + this->unk_2E4 = 3; + break; + + case 5: + this->unk_31A = 1; + this->unk_2E4 = 1; + this->unk_1E4 |= 0x80; + this->actionFunc = func_80B5227C; + break; + + case 6: + this->unk_31A = 12; + this->unk_2E4 = 12; + break; + + case 7: + Flags_SetSwitch(globalCtx, ENGK_GET_3F00(&this->actor)); + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_31A); + } + + if (this->unk_31A == 7) { + func_80B51308(this, globalCtx); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + this->actor.shape.yOffset = 0.0f; + } else { + this->unk_31B = 0x63; + } +} + +void func_80B51698(EnGk* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if (sp26 == lastFrame) { + switch (this->unk_2E4) { + case 0: + this->unk_2E4 = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80B5216C; + break; + + case 2: + this->unk_2E4 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B5202C; + break; + } + } +} + +void func_80B51760(EnGk* this, GlobalContext* globalCtx) { + s16 sp2E = this->skelAnime.curFrame; + s16 lastFrame; + + if (this->unk_2E4 == 11) { + lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + if (sp2E == lastFrame) { + this->unk_2E4 = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + } + } else if (this->unk_2E4 == 10) { + lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + if (sp2E == lastFrame) { + this->unk_2E4 = 11; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_2E4); + } + } else { + if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { + gSaveContext.save.weekEventReg[40] |= 0x40; + this->actionFunc = func_80B51D9C; + return; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1E4 |= 4; + this->unk_31C = func_80B50410(this, globalCtx); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51970; + if (this->unk_31C == 0xE81) { + this->unk_2E4 = 0; + this->unk_1E4 |= 2; + } + } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && + (gSaveContext.save.entranceIndex != 0xD010)) { + func_800B863C(&this->actor, globalCtx); + } + + if (this->unk_1E4 & 4) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + } +} + +void func_80B51970(EnGk* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (((temp_v0 == 6) || (temp_v0 == 5)) && Message_ShouldAdvance(globalCtx)) { + 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); + this->actionFunc = func_80B51D9C; + return; + } + + if (this->unk_1E4 & 1) { + this->unk_1E4 &= ~1; + this->unk_1E4 &= ~4; + if (this->unk_2E4 == 10) { + this->unk_1E4 &= ~2; + } + this->actionFunc = func_80B51760; + return; + } + + this->unk_31C = func_80B50410(this, globalCtx); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + if (this->unk_31C == 0xE80) { + this->unk_1E4 |= 2; + } else if (this->unk_31C == 0xE89) { + this->actionFunc = func_80B51B40; + } + } + + if (this->unk_1E4 & 2) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + if (this->unk_2E4 != 10) { + if (this->unk_2E4 != 9) { + this->unk_2E4 = 9; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + } else { + func_80B51398(this, globalCtx); + } + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (this->unk_2E4 == 6) { + func_80B50954(this); + } +} + +void func_80B51B40(EnGk* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if (temp_v0 == 6) { + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_1E4 & 1) { + this->unk_1E4 &= ~1; + this->unk_1E4 &= ~4; + + if (this->unk_2E4 == 10) { + this->unk_1E4 &= ~2; + } + + if (this->unk_31C == 0xE8F) { + globalCtx->nextEntranceIndex = 0xD010; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + Interface_AddMagic(globalCtx, ((void)0, gSaveContext.unk_3F30) + + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + } else { + this->actionFunc = func_80B51760; + } + return; + } + + this->unk_31C = func_80B50710(this); + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + if (this->unk_31C == 0xE8C) { + this->unk_1E4 |= 2; + } + } + } else if ((temp_v0 == 4) && (Message_ShouldAdvance(globalCtx) != 0)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + this->unk_31C = 0xE8E; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + break; + + case 1: + func_8019F230(); + this->unk_31C = 0xE8A; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + break; + } + } + + if (this->unk_1E4 & 2) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + if (this->unk_2E4 != 10) { + if (this->unk_2E4 != 9) { + this->unk_2E4 = 9; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); + } else { + func_80B51398(this, globalCtx); + } + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B51D9C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->unk_318)) { + ActorCutscene_StartAndSetFlag(this->unk_318, &this->actor); + if (this->unk_1E4 & 4) { + this->unk_1E4 &= ~4; + this->unk_2E4 = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + this->actionFunc = func_80B51EA4; + } else { + this->unk_1E4 |= 4; + if (player->transformation == PLAYER_FORM_GORON) { + this->unk_31C = 0xE84; + } else { + this->unk_31C = 0xE99; + } + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51970; + } + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->unk_318); + } + func_80B50954(this); +} + +void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { + Vec3s sp38; + s16 sp36; + + if (this->path != NULL) { + func_80B50E14(this->path, this->unk_1EC, &this->actor.world.pos, &sp38); + Math_SmoothStepToS(&this->actor.world.rot.y, sp38.y, 5, 0x1000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + 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); + Actor_MarkForDeath(&this->actor); + } else { + this->unk_1EC++; + } + } + + if (this->actor.bgCheckFlags & 8) { + sp38.y = this->actor.wallYaw; + } + + if (ABS_ALT(sp36) < 0x2AAA) { + Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.2f, 0.5f); + } + Actor_MoveWithGravity(&this->actor); + } + func_80B50954(this); +} + +void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { + if (this->unk_1E4 & 2) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + } else { + this->unk_1E4 |= 2; + } + } +} + +void func_80B5202C(EnGk* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->csCtx.state == 0) { + func_80B51410(this, globalCtx); + } + + if (!func_80B50854(this, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + gSaveContext.save.weekEventReg[24] |= 0x80; + this->actionFunc = func_80B51698; + } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + if (player->transformation == PLAYER_FORM_GORON) { + this->actor.textId = 0xE74; + } else { + this->actor.textId = 0xE76; + } + } + + if (this->unk_1E4 & 2) { + if ((globalCtx->msgCtx.ocarinaMode != 1) && (globalCtx->msgCtx.ocarinaMode != 3) && + (globalCtx->csCtx.state == 0)) { + func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); + } + } else { + this->unk_1E4 |= 2; + } + } +} + +void func_80B5216C(EnGk* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80B51698; + } +} + +void func_80B521E8(EnGk* this, GlobalContext* globalCtx) { + s16 sp1E = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if (sp1E == lastFrame) { + this->unk_2E4 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80B5227C; + } +} + +void func_80B5227C(EnGk* this, GlobalContext* globalCtx) { + s16 sp26 = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_2E4].animation); + + if ((sp26 + 1) == lastFrame) { + func_800B14D4(globalCtx, 20.0f, &this->actor.home.pos); + this->unk_350 = 60; + if (!(this->unk_1E4 & 0x80)) { + gSaveContext.save.weekEventReg[22] |= 4; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); + this->unk_350 = 0x4000; + this->actionFunc = func_80B52654; + } +} + +void func_80B52340(EnGk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1E4 |= 4; + if (gSaveContext.eventInf[1] & 2) { + this->unk_31C = 0xE90; + this->actionFunc = func_80B52430; + } else { + this->unk_31C = 0xE93; + this->actionFunc = func_80B52430; + } + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8614(&this->actor, globalCtx, 100.0f); + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B52430(EnGk* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + switch (this->unk_31C) { + case 0xE93: + this->unk_31C = 0xE89; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B51B40; + return; + + case 0xE90: + this->unk_31C = 0xE91; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + return; + + case 0xE91: + this->actionFunc = func_80B5253C; + return; + + case 0xE92: + this->unk_1E4 &= ~4; + this->actionFunc = func_80B51760; + return; + } + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; +} + +void func_80B5253C(EnGk* this, GlobalContext* globalCtx) { + s32 sp24; + + if (gSaveContext.save.weekEventReg[41] & 8) { + sp24 = 0x93; + } else { + sp24 = 0x6A; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + if (sp24 == 0x6A) { + gSaveContext.save.weekEventReg[41] |= 8; + } + this->actionFunc = func_80B525E0; + } else { + Actor_PickUp(&this->actor, globalCtx, sp24, 300.0f, 300.0f); + } +} + +void func_80B525E0(EnGk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_31C = 0xE92; + Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + this->actionFunc = func_80B52430; + } else { + func_800B85E0(&this->actor, globalCtx, 400.0f, -1); + } +} + +void func_80B52654(EnGk* this, GlobalContext* globalCtx) { + this->unk_350 += 0x400; + if ((this->unk_1E4 & 0x80) && (globalCtx->csCtx.frames == 250)) { + gSaveContext.save.weekEventReg[22] |= 4; + } + + this->unk_354 = Math_SinS(this->unk_350) * 0.006f * 0.06f; + this->actor.scale.y = 0.006f - this->unk_354; + 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); + } +} + +void EnGk_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGk* this = THIS; + + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gk_Skel_0079C0, &object_gk_Anim_00787C, this->jointTable, + this->morphTable, 20); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->unk_2E2 = 20; + this->unk_2E0 = 0; + this->unk_1E4 = 0; + this->unk_354 = 0.006f; + Actor_SetScale(&this->actor, 0.006f); + this->actor.gravity = -1.0f; + + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + this->unk_2E4 = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + if (globalCtx->sceneNum == SCENE_17SETUGEN2) { + if (Flags_GetSwitch(globalCtx, ENGK_GET_3F00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + } else { + this->unk_318 = this->actor.cutscene; + this->path = SubS_GetPathByIndex(globalCtx, ENGK_GET_F0(&this->actor), 15); + this->actionFunc = func_80B51760; + } + } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { + if (gSaveContext.save.entranceIndex == 0xD010) { + this->actionFunc = func_80B51760; + } else if (gSaveContext.save.entranceIndex == 0xD020) { + this->actionFunc = func_80B52340; + } else { + this->actionFunc = func_80B51760; + } + } else { + Actor_MarkForDeath(&this->actor); + } + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (ENGK_GET_F(&this->actor) == ENGK_F_2) { + if (!(gSaveContext.save.weekEventReg[22] & 4)) { + this->actionFunc = func_80B51FD0; + this->actor.draw = NULL; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + Actor_MarkForDeath(&this->actor); + } + } else if (!(gSaveContext.save.weekEventReg[22] & 4)) { + this->unk_2E4 = 0; + this->unk_318 = this->actor.cutscene; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_2000000; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80B5202C; + } else { + this->actionFunc = func_80B52654; + } +} + +void EnGk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGk* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnGk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGk* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((ENGK_GET_F(&this->actor) == ENGK_F_1) || + ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !(gSaveContext.save.weekEventReg[22] & 4))) { + func_80B507A0(this, globalCtx); + SkelAnime_Update(&this->skelAnime); + func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + func_80B5123C(this, globalCtx); + } + func_80B50B38(this, globalCtx); + } + + if (ENGK_GET_F(&this->actor) == ENGK_F_0) { + func_80B51510(this, globalCtx); + } +} + +s32 EnGk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void EnGk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnGk* this = THIS; + Vec3f sp58 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; + Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp34 = { 1100.0f, -100.0f, 0.0f }; + Vec3f sp28 = { 1100.0f, -100.0f, 0.0f }; + f32 phi_f0; + + sp34.x = 1100.0f; + sp34.z = 500.0f; + + sp28.x = 1100.0f; + sp28.z = -500.0f; + + if (this->unk_2E4 == 0) { + sp34.y = -100.0f; + sp28.y = -100.0f; + + sp40.x = 2.0f; + sp40.y = 5.8f; + sp40.z = 0.0f; + + sp4C = sp40; + sp4C.x *= -1.0f; + } else if ((this->unk_2E4 == 2) || (this->unk_2E4 == 9) || (this->unk_2E4 == 10) || (this->unk_2E4 == 11)) { + sp34.y = 400.0f; + sp28.y = 400.0f; + + sp40.x = 1.0f; + sp40.y = 0.8f; + sp40.z = 0.0f; + + sp4C = sp40; + sp4C.x *= -1.0f; + } + + if (limbIndex == 17) { + if (ENGK_GET_F(&this->actor) == ENGK_F_1) { + phi_f0 = 100.0f; + } else { + phi_f0 = 50.0f; + } + + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.y = this->actor.world.pos.y + phi_f0; + this->actor.focus.pos.z = this->actor.world.pos.z; + + Matrix_MultiplyVector3fByState(&sp58, &this->actor.focus.pos); + Matrix_MultiplyVector3fByState(&sp34, &this->unk_2E8); + Matrix_MultiplyVector3fByState(&sp28, &this->unk_2F4); + + Matrix_StatePush(); + + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sp4C, &this->unk_30C); + Matrix_MultiplyVector3fByState(&sp40, &this->unk_300); + + Matrix_StatePop(); + } +} + +void EnGk_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnGk* this = THIS; + s32 phi_v0; + s32 phi_v1; + + switch (limbIndex) { + case 18: + if (this->unk_1E4 & 8) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_34E != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + func_80B50ED4(this->unk_31E + this->unk_322 + 0x4000, + this->unk_320 + this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_328, + &this->unk_334, phi_v0, phi_v1); + + Matrix_StatePop(); + + Matrix_InsertTranslation(this->unk_328.x, this->unk_328.y, this->unk_328.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_334.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_334.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_334.z, MTXMODE_APPLY); + + Matrix_StatePush(); + break; + + case 9: + if (this->unk_1E4 & 8) { + phi_v1 = true; + } else { + phi_v1 = false; + } + + if (this->unk_34E != 0) { + phi_v0 = true; + } else { + phi_v0 = false; + } + func_80B50ED4(this->unk_322 + 0x4000, this->unk_324 + this->actor.shape.rot.y + 0x4000, &this->unk_33C, + &this->unk_348, phi_v0, phi_v1); + + Matrix_StatePop(); + + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_348.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_348.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_348.z, MTXMODE_APPLY); + + Matrix_StatePush(); + break; + } +} + +TexturePtr D_80B533E4[] = { + object_gk_Tex_00F720, + object_gk_Tex_00FF20, + object_gk_Tex_010720, + object_gk_Tex_010F20, +}; + +void EnGk_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnGk* this = THIS; + Vec3f sp5C; + Vec3f sp50; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && (gSaveContext.save.weekEventReg[22] & 4)) { + Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006688); + gSPDisplayList(POLY_OPA_DISP++, object_gk_DL_006680); + + func_8012C2DC(globalCtx->state.gfxCtx); + + sp5C = this->actor.world.pos; + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + + func_800BC620(&sp5C, &sp50, 255, globalCtx); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B533E4[this->unk_2E0])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnGk_OverrideLimbDraw, EnGk_PostLimbDraw, + EnGk_TransformDraw, &this->actor); + + if (ENGK_GET_F(&this->actor) != ENGK_F_2) { + func_8012C2DC(globalCtx->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; + + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + } else { + sp5C = this->actor.world.pos; + sp50.x = 0.2f; + sp50.y = 0.2f; + sp50.z = 0.2f; + } + func_800BC620(&sp5C, &sp50, 255, globalCtx); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 88a71cb16..21863c66f 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.h +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.h @@ -7,11 +7,53 @@ struct EnGk; typedef void (*EnGkActionFunc)(struct EnGk*, GlobalContext*); +#define ENGK_GET_F(thisx) ((thisx)->params & 0xF) +#define ENGK_GET_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define ENGK_GET_3F00(thisx) (((thisx)->params & 0x3F00) >> 8) + +enum { + /* 0 */ ENGK_F_0, + /* 1 */ ENGK_F_1, + /* 2 */ ENGK_F_2, + /* 3 */ ENGK_F_3, + /* 4 */ ENGK_F_4, + /* 5 */ ENGK_F_5, +}; + typedef struct EnGk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnGkActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x180]; + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ u16 unk_1E4; + /* 0x01E8 */ Path* path; + /* 0x01EC */ s32 unk_1EC; + /* 0x01F0 */ Vec3s jointTable[20]; + /* 0x01F0 */ Vec3s morphTable[20]; + /* 0x02E0 */ s16 unk_2E0; + /* 0x02E2 */ s16 unk_2E2; + /* 0x02E4 */ s16 unk_2E4; + /* 0x02E8 */ Vec3f unk_2E8; + /* 0x02F4 */ Vec3f unk_2F4; + /* 0x0300 */ Vec3f unk_300; + /* 0x030C */ Vec3f unk_30C; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ u8 unk_31A; + /* 0x031B */ u8 unk_31B; + /* 0x031C */ u16 unk_31C; + /* 0x031E */ s16 unk_31E; + /* 0x0320 */ s16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0328 */ Vec3f unk_328; + /* 0x0334 */ Vec3s unk_334; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ Vec3s unk_348; + /* 0x034E */ s16 unk_34E; + /* 0x0350 */ s16 unk_350; + /* 0x0354 */ f32 unk_354; } EnGk; // size = 0x358 extern const ActorInit En_Gk_InitVars; 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 2e3d20e9e..107c9a656 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_in2/object_in2.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGm*)thisx) @@ -128,14 +128,20 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80951CC0[13] = { - { &object_in2_Anim_009CDC, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_009CDC, 1.0f, 0, -1, 0, -4 }, - { &object_in2_Anim_00A5E0, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_00A70C, 1.0f, 0, 1, 0, 0 }, - { &object_in2_Anim_008090, 1.0f, 0, -1, 0, 0 }, { &object_in2_Anim_00898C, 1.0f, 0, -1, 2, -4 }, - { &object_in2_Anim_009450, 1.0f, 0, -1, 2, -4 }, { &object_in2_Anim_00AD18, 1.0f, 0, -1, 0, 0 }, - { &object_in2_Anim_00AD18, 1.0f, 0, -1, 0, -4 }, { &object_in2_Anim_00B8B0, 1.0f, 0, -1, 2, 0 }, - { &object_in2_Anim_00BA80, 1.0f, 0, -1, 0, -4 }, { &object_in2_Anim_00C03C, 1.0f, 0, -1, 0, -4 }, - { &object_in2_Anim_00B990, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS D_80951CC0[] = { + { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00A5E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_00A70C, 1.0f, 0, 1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_008090, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_00898C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_in2_Anim_009450, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00B8B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_in2_Anim_00BA80, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00C03C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in2_Anim_00B990, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; Actor* func_8094DEE0(EnGm* this, GlobalContext* globalCtx, u8 arg2, s16 arg3) { @@ -230,7 +236,7 @@ s32 func_8094E054(EnGm* this, GlobalContext* globalCtx, s32 arg2) { if (phi_v1) { if (tmp >= 0) { this->unk_3E8 = arg2; - ret = func_8013BC6C(&this->skelAnime, D_80951CC0, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80951CC0, arg2); this->unk_3A8 = this->skelAnime.playSpeed; } } @@ -243,7 +249,7 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { if ((this->unk_260 != globalCtx->roomCtx.currRoom.num) && (globalCtx->roomCtx.unk31 == 0)) { this->unk_260 = globalCtx->roomCtx.currRoom.num; - this->unk_262 = func_8013D924(0x248, globalCtx); + this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, globalCtx); this->actor.draw = NULL; this->unk_3FC = 1; } @@ -252,7 +258,7 @@ s32 func_8094E0F8(EnGm* this, GlobalContext* globalCtx) { return false; } - if ((this->unk_262 < 0) || !func_8013D8DC(this->unk_262, globalCtx)) { + if ((this->unk_262 < 0) || !SubS_IsObjectLoaded(this->unk_262, globalCtx)) { ret = true; } else { this->actor.draw = EnGm_Draw; @@ -379,7 +385,7 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { ActorCutscene_Stop(sp2A); } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_3E0++; ret = true; @@ -387,7 +393,8 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { case 1: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_3E0++; ret = true; @@ -447,7 +454,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { case 4: case 6: camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - func_800E0308(camera, &this->actor); + Camera_SetTargetActor(camera, &this->actor); this->unk_3E0++; ret = true; } @@ -458,7 +465,7 @@ s32 func_8094E69C(EnGm* this, GlobalContext* globalCtx) { case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp4A)); - func_800E0308(camera, this->actor.child); + Camera_SetTargetActor(camera, this->actor.child); } this->unk_3E0++; ret = true; @@ -646,7 +653,7 @@ s32 func_8094EE84(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3A4 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_3A4, 0, 7); + SubS_UpdateFlags(&this->unk_3A4, 0, 7); this->unk_3E0 = 0; this->unk_3E4 = NULL; this->actor.child = this->unk_268; @@ -771,7 +778,7 @@ void func_8094F2E8(EnGm* this) { void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - s32 var = globalCtx->msgCtx.unk11F04; + s32 var = globalCtx->msgCtx.currentTextId; if ((&this->actor == player->targetActor) && ((var < 0xFF) || (var > 0x200)) && (sp28 == 3) && (this->unk_3F0 == 3)) { @@ -786,7 +793,7 @@ void func_8094F3D0(EnGm* this, GlobalContext* globalCtx) { this->unk_3AC = 0.0f; } Math_SmoothStepToF(&this->unk_3B0, this->unk_3AC, 0.8f, 40.0f, 10.0f); - Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, 1); + Matrix_InsertTranslation(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); this->unk_3F0 = sp28; } @@ -800,7 +807,7 @@ s32 func_8094F4EC(EnGm* this, GlobalContext* globalCtx) { s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 sp32 = globalCtx->msgCtx.unk11F04; + u16 sp32 = globalCtx->msgCtx.currentTextId; Actor* al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); Actor* toto = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); @@ -895,12 +902,12 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar actor = func_8094DEE0(this, globalCtx, arg3, arg4); if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); } if ((actor != NULL) && (actor->update != NULL)) { if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp48 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); this->actor.shape.shadowDraw = NULL; @@ -915,7 +922,7 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.save.time - 0x3FFC; u8 sp55 = ENGM_GET_FF(&this->actor); - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -923,15 +930,15 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - sp50 = func_8094DF90(globalCtx, arg2->unk0); + door = func_8094DF90(globalCtx, arg2->unk0); if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_234 != NULL) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp4C = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_278, &sp40); @@ -939,7 +946,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, sp50->actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_261 = -75; } else { this->unk_261 = 75; @@ -947,7 +954,7 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3B8 = arg2->unk8 - arg2->unk4; this->unk_3BA = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 7); @@ -967,7 +974,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->unk0]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -993,7 +1000,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_250 = (this->unk_254 / this->unk_24C) + 2; this->unk_3A4 &= ~0x8; this->unk_3A4 &= ~0x10; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 7); @@ -1010,7 +1017,7 @@ s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TAB)) { if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D90); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { func_8094E054(this, globalCtx, 9); @@ -1028,7 +1035,7 @@ s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { func_8094E054(this, globalCtx, 11); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; ret = true; @@ -1043,7 +1050,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && (al->update != NULL)) { func_8094E054(this, globalCtx, 11); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_268 = al; if (!(gSaveContext.save.weekEventReg[86] & 0x20)) { this->unk_3C8 = 2; @@ -1069,18 +1076,18 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); } if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp48 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D9C); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; @@ -1107,7 +1114,7 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DA8); Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DB4); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x2000 | 0x100); this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 12); @@ -1122,7 +1129,7 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80951DBC); Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DC8); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x800 | 0x100); this->unk_3A4 |= 0x200; func_8094E054(this, globalCtx, 4); @@ -1138,7 +1145,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3s_Copy(&this->actor.world.rot, &D_80951DDC); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); this->actor.targetMode = 6; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3A4 |= (0x1000 | 0x100); this->unk_3A4 |= 0x200; this->unk_3C8 = 3; @@ -1153,7 +1160,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { s32 phi_v1; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; this->unk_3A4 = 0; this->unk_3C8 = 0; @@ -1245,7 +1252,7 @@ s32 func_809503F8(EnGm* this, GlobalContext* globalCtx) { if (this->unk_3E8 == 9) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); func_8094E054(this, globalCtx, 0); } else { AnimationContext_SetMoveActor(globalCtx, &this->actor, &this->skelAnime, 1.0f); @@ -1277,7 +1284,7 @@ s32 func_80950490(EnGm* this, GlobalContext* globalCtx) { case 9: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; @@ -1344,24 +1351,24 @@ s32 func_80950690(EnGm* this, GlobalContext* globalCtx) { break; } - func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D2)); + SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); return false; } s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { - EnDoor* sp44; + EnDoor* door; Vec3f sp38; s32 pad; f32 temp_f0; - sp44 = func_8094DF90(globalCtx, this->unk_258); + door = func_8094DF90(globalCtx, this->unk_258); if (!func_8013AD6C(globalCtx) && (this->unk_3C4 != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { - sp44->unk_1A7 = this->unk_261; + door->unk_1A7 = this->unk_261; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } @@ -1494,11 +1501,11 @@ void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { if (!func_80133038(globalCtx, (void*)&D_80951820, &sp20) || ((this->unk_258 != sp20.unk0) && !func_80950280(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; sp20.unk0 = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk_258 = sp20.unk0; this->unk_268 = func_8094F074(this, globalCtx); @@ -1512,7 +1519,7 @@ void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { Actor* al; if (func_8010BF58(&this->actor, globalCtx, this->unk_264, this->unk_3E4, &this->unk_25C)) { - func_8013AED4(&this->unk_3A4, 3, 7); + SubS_UpdateFlags(&this->unk_3A4, 3, 7); al = func_8094DEE0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AL); if ((this->unk_258 == 2) && (al != NULL) && (al->update != NULL)) { this->unk_268 = al; @@ -1532,16 +1539,11 @@ void func_80950DB8(EnGm* this, GlobalContext* globalCtx) { Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } } - func_8013D9C8(globalCtx, this->unk_3D8, this->unk_3D2, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3D8, this->unk_3D2, ARRAY_COUNT(this->unk_3D8)); } void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { - s32 sp50[] = { - 0, - 0, - 3, - 2, - }; + s32 sp50[] = { 0, 0, 3, 2 }; Player* player = GET_PLAYER(globalCtx); s32 pad; Vec3f sp3C; @@ -1549,8 +1551,8 @@ void func_80950F2C(EnGm* this, GlobalContext* globalCtx) { s32 sp2C; s16 yaw; - if (func_800EE29C(globalCtx, 0x20E)) { - sp2C = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20E)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 526)) { + sp2C = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 526)]->action; if (this->unk_259 != (sp2C & 0xFF)) { if (sp2C == 3) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHAIR_ROLL); 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 8b6202543..57c8dc044 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -10,7 +10,7 @@ #include "objects/object_taisou/object_taisou.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGo*)thisx) @@ -186,20 +186,31 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, 0, -4 }, - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, 0 }, - { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, 0, -4 }, { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, 2, -4 }, - { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, 0, 0 }, { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_011D98, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_003E28, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_oF1d_map_Anim_0039D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_oF1d_map_Anim_003650, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_oF1d_map_Anim_0135E8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_taisou_Anim_004DD4, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_0016C8, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_00283C, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_007764, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_005EE0, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_002C48, 1.0f, 0, -1, 0, 0 }, - { &object_taisou_Anim_0031D8, 1.0f, 0, -1, 0, 0 }, { &object_taisou_Anim_005790, 1.0f, 0, -1, 0, 0 }, + { &object_taisou_Anim_004DD4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0016C8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_00283C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_007764, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005EE0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_002C48, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_0031D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_taisou_Anim_005790, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, 0, -4 }, - { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, 2, 0 }, { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, 0, -4 }, + { &object_hakugin_demo_Anim_001420, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_001A4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_hakugin_demo_Anim_002704, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_hakugin_demo_Anim_003378, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; EnGoStruct* func_80A10FD0(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4, f32 arg5, s32 arg6) { @@ -290,7 +301,7 @@ void func_80A1143C(EnGoStruct ptr[], Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg void func_80A115B4(EnGoStruct ptr[], GlobalContext* globalCtx) { static TexturePtr D_80A16644[] = { - &gDust8Tex, &gDust7Tex, &gDust6Tex, &gDust5Tex, &gDust4Tex, &gDust3Tex, &gDust2Tex, &gDust1Tex, + gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, }; static Color_RGBA8 D_80A16664[] = { { 255, 255, 255, 0 }, @@ -526,7 +537,7 @@ s32 func_80A1222C(EnGo* this, GlobalContext* globalCtx) { if (((player->transformation == PLAYER_FORM_GORON) && (globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 1) && (this->unk_3EC == 0) && (this->actor.xzDistToPlayer < 400.0f)) || (!(gSaveContext.save.weekEventReg[22] & 4) && (globalCtx->sceneNum == SCENE_16GORON_HOUSE) && - (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.unk_12 == 1))) { + (gSaveContext.sceneSetupIndex == 0) && (this->unk_3EC == 0) && (globalCtx->csCtx.currentCsIndex == 1))) { ret = true; } return ret; @@ -661,7 +672,7 @@ s32 func_80A12774(EnGo* this, GlobalContext* globalCtx) { this->unk_390 |= 0x20; } - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->unk_3C0 = 0; this->unk_3C4 = 0; this->unk_18C = this->actionFunc; @@ -699,20 +710,20 @@ s32 func_80A12868(EnGo* this, GlobalContext* globalCtx) { s32 func_80A12954(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (globalCtx->csCtx.state != 0) && (this->actor.draw != NULL) && (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_394 = 255; this->unk_3F0 = 1; this->unk_18C = this->actionFunc; } - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->actionFunc = func_80A14FC8; } else if (this->unk_3F0 != 0) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_394 = 255; this->unk_3F0 = 0; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->actionFunc = this->unk_18C; } @@ -768,7 +779,7 @@ s32 func_80A12B78(EnGo* this, GlobalContext* globalCtx) { s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { s8 objIdx = this->actor.objBankIndex; s8 objIdx2 = -1; - s32 ret = 0; + s32 ret = false; if ((arg2 >= 18) && (this->unk_289 >= 0)) { objIdx2 = this->unk_289; @@ -781,7 +792,7 @@ s32 func_80A12C48(EnGo* this, GlobalContext* globalCtx, s32 arg2) { if (objIdx2 >= 0) { gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx2].segment); this->unk_3DC = arg2; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg2); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg2); this->unk_398 = this->skelAnime.playSpeed; gSegments[6] = PHYSICAL_TO_VIRTUAL2(globalCtx->objectCtx.status[objIdx].segment); } @@ -810,7 +821,7 @@ void func_80A12DF4(EnGo* this, GlobalContext* globalCtx) { } s32 func_80A12E80(EnGo* this, GlobalContext* globalCtx) { - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; Player* player = GET_PLAYER(globalCtx); if (ENGO_GET_F(&this->actor) != ENGO_F_4) { @@ -930,20 +941,20 @@ void func_80A132C8(EnGo* this, GlobalContext* globalCtx) { s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); if ((fabsf(this->actor.playerHeightRel) > 20.0f) || (this->actor.xzDistToPlayer > 300.0f)) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || (gSaveContext.save.weekEventReg[21] & 4) || (gSaveContext.save.weekEventReg[21] & 8)) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); } } void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[21] & 8) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); } } @@ -1034,7 +1045,7 @@ s32 func_80A13564(EnGo* this, f32 arg1, f32 arg2, s32 arg3) { } void func_80A136B8(GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3) { - s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, MAIN_CAM), 3); + s16 sp26 = Quake_Add(Play_GetCamera(globalCtx, CAM_ID_MAIN), 3); Quake_SetCountdown(sp26, arg3); Quake_SetSpeed(sp26, arg1); @@ -1275,7 +1286,7 @@ void func_80A14018(EnGo* this, GlobalContext* globalCtx) { Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166B0, &sp2C); Math_Vec3f_Copy(&this->actor.world.pos, &sp2C); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, this->unk_3A4); this->unk_3EC = 0; this->unk_390 = 0; @@ -1290,7 +1301,7 @@ void func_80A14104(EnGo* this, GlobalContext* globalCtx) { func_80A12C48(this, globalCtx, D_80A166D4[ENGO_GET_70(&this->actor) % 2]); temp = Rand_ZeroOne() * this->skelAnime.endFrame; this->skelAnime.curFrame = temp; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, this->unk_3A4); this->unk_3EC = 0; this->unk_390 = 0; @@ -1320,8 +1331,8 @@ void func_80A1428C(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp30, &this->actor.world.pos); if (this->unk_284 != NULL) { - this->actor.flags &= ~0x2000000; - func_8013C8B8(this->unk_284, 0, &sp24); + this->actor.flags &= ~ACTOR_FLAG_2000000; + SubS_CopyPointFromPathCheckBounds(this->unk_284, 0, &sp24); temp = Math_Vec3f_Yaw(&sp30, &sp24); this->actor.shape.rot.y = temp; this->actor.world.rot.y = temp; @@ -1337,7 +1348,7 @@ void func_80A14324(EnGo* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_3EC = 0; this->unk_390 |= 0x40; this->unk_3BC = 0; @@ -1351,7 +1362,7 @@ void func_80A143A8(EnGo* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, this->unk_3A4); this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_3EC = 0; this->unk_390 |= 0x40; this->unk_390 |= 0x20; @@ -1382,7 +1393,7 @@ void func_80A1449C(EnGo* this, GlobalContext* globalCtx) { void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { if (gSaveContext.save.day >= 2) { - this->unk_284 = func_8013BEDC(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); + this->unk_284 = SubS_GetDayDependentPath(globalCtx, ENGO_GET_7F80(&this->actor), 0xFF, &this->unk_3E4); if (this->unk_284 != NULL) { this->unk_3E4 = 1; } @@ -1399,7 +1410,7 @@ void func_80A144F4(EnGo* this, GlobalContext* globalCtx) { void func_80A145AC(EnGo* this, GlobalContext* globalCtx) { if ((ENGO_GET_70(&this->actor) == ENGO_70_1) && (((globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneSetupIndex == 1) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || !(gSaveContext.save.weekEventReg[21] & 8))) { this->actor.child = func_80A13400(this, globalCtx); this->actor.child->child = &this->actor; @@ -1426,11 +1437,11 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { func_80A12C48(this, globalCtx, 0); this->unk_3A4 *= 5.0f; Actor_SetScale(&this->actor, this->unk_3A4); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.targetMode = 3; this->unk_390 = 0; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_390 |= 0x40; this->unk_390 |= 0x20; this->unk_3D8 = func_80A13E80; @@ -1438,10 +1449,14 @@ void func_80A146CC(EnGo* this, GlobalContext* globalCtx) { } void func_80A14798(EnGo* this, GlobalContext* globalCtx) { - s32 sp38[2] = { 0x0000003E, 0x00000F64 }; + EffectTireMarkInit sp38 = { + 0, + 62, + { 0, 0, 15, 100 }, + }; - if ((this->unk_288 < 0) || func_8013D8DC(this->unk_288, globalCtx) || (this->unk_289 < 0) || - func_8013D8DC(this->unk_289, globalCtx)) { + if ((this->unk_288 < 0) || SubS_IsObjectLoaded(this->unk_288, globalCtx) || (this->unk_289 < 0) || + SubS_IsObjectLoaded(this->unk_289, globalCtx)) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, this->morphTable, 18); @@ -1453,7 +1468,7 @@ void func_80A14798(EnGo* this, GlobalContext* globalCtx) { Collider_InitAndSetSphere(globalCtx, &this->colliderSphere, &this->actor, &sSphereInit); Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit2); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Effect_Add(globalCtx, &this->unk_3E8, 4, 0, 0, &sp38); + Effect_Add(globalCtx, &this->unk_3E8, EFFECT_TIRE_MARK, 0, 0, &sp38); this->actor.targetMode = 1; this->unk_3A4 = 0.01f; @@ -1500,7 +1515,7 @@ void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_CHEER - SFX_FLAG); } else if (ENGO_GET_F(&this->actor) != ENGO_F_8) { if (func_80A1222C(this, globalCtx)) { - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); this->unk_3EC = 1; this->actionFunc = func_80A14B30; } else if (ENGO_GET_F(&this->actor) == ENGO_F_4) { @@ -1515,9 +1530,9 @@ void func_80A149B0(EnGo* this, GlobalContext* globalCtx) { } } else if (ENGO_GET_F(&this->actor) == ENGO_F_1) { if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x3FFC) { - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } else { - func_8013AED4(&this->unk_390, 0, 7); + SubS_UpdateFlags(&this->unk_390, 0, 7); } } } @@ -1568,7 +1583,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { } this->unk_3AE += 0x400; this->actor.shape.yOffset = (this->actor.scale.y / this->unk_3A4) * 14.0f; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); } } else if ((this->actor.xzDistToPlayer >= 240.0f) || (this->actor.playerHeightRel >= 20.0f) || (this->unk_3EC != 0)) { @@ -1579,7 +1594,7 @@ void func_80A14B30(EnGo* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 0.0f; } - func_8013D9C8(globalCtx, &this->unk_3CE[0], &this->unk_3C8[0], 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); Math_ApproachS(&this->actor.shape.rot.y, sp26, 4, 0x2AA8); } @@ -1610,7 +1625,7 @@ void func_80A14EB0(EnGo* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->actor.cutscene); func_80A143A8(this, globalCtx); if ((ENGO_GET_F(&this->actor) == ENGO_F_4) && (ENGO_GET_70(&this->actor) == ENGO_70_1)) { - func_8013AED4(&this->unk_390, 4, 7); + SubS_UpdateFlags(&this->unk_390, 4, 7); func_80A143A8(sp24, globalCtx); sp24->actionFunc = func_80A149B0; } @@ -1622,24 +1637,24 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { s32 sp38[] = { 0, 2, 6, 20, 18, 5, 5, 15, }; - u16 sp36 = 0; + u16 actorActionCmd = 0; s32 sp30; - u32 sp2C; + s32 actionIndex; switch (ENGO_GET_70(&this->actor)) { case ENGO_70_0: - sp36 = 0x80; + actorActionCmd = 128; break; case ENGO_70_1: - sp36 = 0x81; + actorActionCmd = 129; break; } - if ((sp36 == 0x80) || (sp36 == 0x81)) { - if (func_800EE29C(globalCtx, sp36)) { - sp2C = func_800EE200(globalCtx, sp36); - sp30 = globalCtx->csCtx.npcActions[sp2C]->unk0; + if ((actorActionCmd == 128) || (actorActionCmd == 129)) { + if (Cutscene_CheckActorAction(globalCtx, actorActionCmd)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd); + sp30 = globalCtx->csCtx.actorActions[actionIndex]->action; if (this->unk_394 != (u8)sp30) { this->unk_394 = sp30; @@ -1688,7 +1703,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { break; } - if (sp36 == 0x80) { + if (actorActionCmd == 128) { switch (globalCtx->csCtx.frames) { case 55: case 100: @@ -1712,7 +1727,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_VOICE_EATFULL); break; } - } else if (sp36 == 0x81) { + } else if (actorActionCmd == 129) { switch (globalCtx->csCtx.frames) { case 360: case 390: @@ -1733,8 +1748,8 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { } } - func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); - func_800EDF24(&this->actor, globalCtx, sp2C); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); } } } @@ -1747,8 +1762,8 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { if ((this->unk_390 & 0x1000) && (this->actor.colChkInfo.damageEffect == 0xF)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SNOWBALL_BROKEN); - this->actor.flags &= ~0x10; - this->actor.flags |= 0x2000000; + 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; @@ -1770,7 +1785,7 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { } sp5C = Lib_SegmentedToVirtual(this->unk_284->points); - if (func_8013BD40(&this->actor, this->unk_284, this->unk_3E4)) { + if (SubS_HasReachedPoint(&this->actor, this->unk_284, this->unk_3E4)) { if (this->unk_3E4 >= (this->unk_284->count - 1)) { this->unk_3E4 = 0; } else { @@ -1853,7 +1868,7 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp34, &this->actor.world.pos); Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); } - func_8013D9C8(globalCtx, this->unk_3CE, this->unk_3C8, 3); + SubS_FillLimbRotTables(globalCtx, this->unk_3CE, this->unk_3C8, ARRAY_COUNT(this->unk_3CE)); return; } @@ -1865,7 +1880,7 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { } this->unk_390 &= ~0x8; - func_8013AED4(&this->unk_390, 3, 7); + SubS_UpdateFlags(&this->unk_390, 3, 7); this->unk_28C = 0; this->unk_390 |= 0x40; this->actionFunc = this->unk_18C; @@ -1874,8 +1889,8 @@ void func_80A157C4(EnGo* this, GlobalContext* globalCtx) { void EnGo_Init(Actor* thisx, GlobalContext* globalCtx) { EnGo* this = THIS; - this->unk_288 = func_8013D924(OBJECT_TAISOU, globalCtx); - this->unk_289 = func_8013D924(OBJECT_HAKUGIN_DEMO, globalCtx); + this->unk_288 = SubS_GetObjectIndex(OBJECT_TAISOU, globalCtx); + this->unk_289 = SubS_GetObjectIndex(OBJECT_HAKUGIN_DEMO, globalCtx); this->actionFunc = func_80A14798; } 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 8905b116c..dd8d95c23 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -8,7 +8,7 @@ #include "objects/object_goroiwa/object_goroiwa.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnGoroiwa*)thisx) @@ -474,7 +474,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { temp_f2 = temp_f14 - this->actor.world.pos.y; if (fabsf(temp_f2) < (fabsf(this->actor.velocity.y) + 0.01f)) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { sp48.x = this->actor.world.pos.x; sp48.y = temp_f14 + 10.0f; sp48.z = this->actor.world.pos.z; @@ -506,7 +506,7 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { if ((this->actor.world.pos.y + this->unk_1DC) <= sp40) { this->unk_1E5 |= 0x20; if (sp40 < (this->unk_1DC + sp78)) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { Vec3f sp34; sp34.x = this->actor.world.pos.x; @@ -528,10 +528,9 @@ s32 func_8093F6F8(EnGoroiwa* this, GlobalContext* globalCtx) { return false; } -#ifdef NON_MATCHING -// Stack void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { f32 temp; + f32 tmp2; f32 sp7C; Vec3f sp70; Vec3f sp64; @@ -541,7 +540,8 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { sp7C = this->unk_1C0; } else { temp = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); - this->unk_1C0 = temp / this->unk_1DC; + tmp2 = temp / this->unk_1DC; + this->unk_1C0 = tmp2; sp7C = this->unk_1C0; } @@ -567,9 +567,6 @@ void func_8093FAA4(EnGoroiwa* this, GlobalContext* globalCtx) { Matrix_CopyCurrentState(&sp24); func_8018219C(&sp24, &this->actor.shape.rot, MTXMODE_NEW); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/func_8093FAA4.s") -#endif void func_8093FC00(EnGoroiwa* this) { s32 params = ENGOROIWA_GET_300(&this->actor); @@ -672,7 +669,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { f32 temp_f20; s32 pad3; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { spEC = (this->actor.scale.x + 0.1f) * 0.5f; sp10C.x = this->actor.world.pos.x; sp10C.y = this->actor.world.pos.y + this->unk_1DC; @@ -724,8 +721,8 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&sp100, &sp10C, &sp100); EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, 0xEF, - phi_s1); + ((Rand_ZeroOne() * 150.0f) + 300.0f) * this->actor.scale.x, phi_s3, 0, 0x32, -1, + OBJECT_GOROIWA, phi_s1); if (this->unk_1E6 == 0) { sp100.x += ((Rand_ZeroOne() * 1200.0f) - 600.0f) * this->actor.scale.x; sp100.y += ((Rand_ZeroOne() * 1400.0f) - 600.0f) * this->actor.scale.y; @@ -807,7 +804,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB } EffectSsKakera_Spawn(globalCtx, &sp100, &spF4, &sp100, phi_fp, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, 0xEF, phi_s7); + ((Rand_ZeroOne() * 100.0f) + 170.0f) * arg5, spC8, 0, 0x36, -1, OBJECT_GOROIWA, phi_s7); for (j = 0; j < 2; j++) { spE8.x = (((Rand_ZeroOne() * 1000.0f) - 500.0f) * arg5) + sp100.x; @@ -882,7 +879,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } EffectSsKakera_Spawn(globalCtx, &spE8, &spDC, &spE8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, 0xEF, phi_s1); + ((Rand_ZeroOne() * 150.0f) + 250.0f) * arg5, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, phi_s1); spE8.x += ((Rand_ZeroOne() * 800.0f) - 400.0f) * arg5; spE8.y += ((Rand_ZeroOne() * 800.0f) - 250.0f) * arg5; @@ -901,7 +898,7 @@ void func_80940E38(EnGoroiwa* this, GlobalContext* globalCtx) { s16 sp46; s16 temp_a0; - if (this->actor.flags & 0x40) { + 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); if (Rand_ZeroOne() < sp5C) { @@ -992,7 +989,7 @@ void EnGoroiwa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = 200; func_8093EB58(this, globalCtx); - this->unk_1D0 = (Vec3s*)Lib_SegmentedToVirtual(sp2C->points); + this->unk_1D0 = Lib_SegmentedToVirtual(sp2C->points); func_8093EE18(this, globalCtx); func_8093EE64(this, this->actor.home.rot.y); @@ -1358,7 +1355,7 @@ void func_8094220C(EnGoroiwa* this, GlobalContext* globalCtx) { ptr->unk_18 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &ptr->unk_28, &spD0, &this->actor, &spC4); if (ptr->unk_10 <= 0.0f) { - Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, 0); + Matrix_InsertRotation(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&D_80942E6C, &spB8); temp_f20 = this->unk_1DC * 0.9f; @@ -1431,8 +1428,6 @@ void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING -// stack for params and colCtx void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGoroiwa* this = THIS; @@ -1442,6 +1437,8 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { Vec3f sp50; f32 sp4C; s32 sp48 = true; + u32 temp_v0_2; + CollisionPoly* tmp; if (!(player->stateFlags1 & (0x30000000 | 0x80 | 0x40))) { if (this->unk_1CC > 0) { @@ -1458,9 +1455,10 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_8093E91C(this); sp5C = true; - if (this->actor.flags & 0x40) { - if (this->actor.floorPoly != NULL) { - u32 temp_v0_2 = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if (this->actor.flags & ACTOR_FLAG_40) { + tmp = this->actor.floorPoly; + if (tmp != NULL) { + temp_v0_2 = func_800C99D4(&globalCtx->colCtx, tmp, this->actor.floorBgId); if ((temp_v0_2 == 14) || (temp_v0_2 == 15)) { if (!(this->unk_1E5 & 0x40)) { @@ -1517,7 +1515,7 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_8093FAA4(this, globalCtx); - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { s32 params = ENGOROIWA_GET_C000(&this->actor); func_8093E938(this); @@ -1549,9 +1547,6 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Goroiwa/EnGoroiwa_Update.s") -#endif void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { s32 pad; 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 1a877457f..e19d2fa37 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -6,7 +6,7 @@ #include "z_en_grasshopper.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnGrasshopper*)thisx) 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 dbaa59828..cfd252d07 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -8,7 +8,7 @@ #include "objects/object_gs/object_gs.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnGs*)thisx) @@ -156,7 +156,7 @@ void EnGs_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1F4 = this->unk_1FA; Math_Vec3f_Copy(&this->unk_1B0[0], &D_801C5DB0); Math_Vec3f_Copy(&this->unk_1B0[1], &D_801C5DB0); - func_8013E3B8(&this->actor, &this->unk_212, 2); + SubS_FillCutscenesList(&this->actor, this->unk_212, ARRAY_COUNT(this->unk_212)); func_801A5080(0); if (this->actor.params == ENGS_1) { Actor_SetScale(&this->actor, 0.15f); @@ -206,7 +206,7 @@ void func_80997DEC(EnGs* this, GlobalContext* globalCtx) { void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: - func_801518B0(globalCtx, this->unk_210, &this->actor); + Message_StartTextbox(globalCtx, this->unk_210, &this->actor); break; case 1: @@ -217,8 +217,8 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x20D0: func_80997D14(this, globalCtx); break; @@ -262,7 +262,7 @@ void func_80997E4C(EnGs* this, GlobalContext* globalCtx) { } void func_80997FF0(EnGs* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, globalCtx->unk_1879C[0], -1, 1)) { + if (SubS_StartActorCutscene(&this->actor, globalCtx->playerActorCsIds[0], -1, SUBS_CUTSCENE_NORMAL)) { func_80998040(this, globalCtx); } } @@ -339,7 +339,7 @@ void func_8099807C(EnGs* this, GlobalContext* globalCtx) { void func_80998300(EnGs* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { - ActorCutscene_Stop(globalCtx->unk_1879C[0]); + ActorCutscene_Stop(globalCtx->playerActorCsIds[0]); } } @@ -380,7 +380,7 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { EnGs* gossipStone; Vec3f sp38; - if (func_8013E2D4(&this->actor, this->unk_212, -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->unk_212[0], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { Player* player = GET_PLAYER(globalCtx); Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); @@ -388,8 +388,8 @@ void func_809985B8(EnGs* this, GlobalContext* globalCtx) { 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.unk_EC4 = ((u32)gSaveContext.save.unk_EC4 & ~(7 << (this->unk_198 * 3))) | + ((this->unk_194 & 7) << (this->unk_198 * 3)); gossipStone = NULL; do { @@ -446,7 +446,7 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { if ((this->unk_19C == 5) && (this->unk_194 != 0)) { s32 i; - ActorCutscene_Stop(this->unk_212); + ActorCutscene_Stop(this->unk_212[0]); phi_v0 = 1; for (i = 0; i < 4; i++) { @@ -533,10 +533,11 @@ s32 func_80998A48(EnGs* this, GlobalContext* globalCtx) { } else if (this->unk_19D == 1) { if (func_80998334(this, globalCtx, &this->unk_1DC, &this->unk_1E0, &this->unk_1D4, 0.8f, 0.007f, 0.001f, 7, 0) == 0.0f) { - if ((this->actor.params != ENGS_0) && !func_801690CC(globalCtx) && !Message_GetState(&globalCtx->msgCtx)) { + if ((this->actor.params != ENGS_0) && !Play_InCsMode(globalCtx) && + (Message_GetState(&globalCtx->msgCtx) == 0)) { this->unk_216 = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIVE_LUPY_COUNT); - func_801518B0(globalCtx, 0x20D2, NULL); + Message_StartTextbox(globalCtx, 0x20D2, NULL); } this->unk_19A &= ~1; sp3C = 0; @@ -1021,11 +1022,11 @@ void EnGs_Update(Actor* thisx, GlobalContext* globalCtx) { s16 sp2E; s16 sp2C; - if ((this->actor.flags & 0x40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { + if ((this->actor.flags & ACTOR_FLAG_40) || (this->unk_19A & 0x100) || (this->unk_19A & 0x200)) { func_80999BC8(&this->actor, globalCtx); Actor_GetScreenPos(globalCtx, &this->actor, &sp2E, &sp2C); - if ((this->actor.xyzDistToPlayerSq > SQ(400.0f)) || (sp2E < 0) || (sp2E > 320) || (sp2C < 0) || - (sp2C > 240)) { + 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, globalCtx, this->unk_21C, this->unk_21E); 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 8b10cb68d..c76a0c346 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.h +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.h @@ -49,8 +49,7 @@ typedef struct EnGs { /* 0x208 */ s32 unk_208; /* 0x20C */ s32 unk_20C; /* 0x210 */ u16 unk_210; - /* 0x212 */ s16 unk_212; - /* 0x214 */ UNK_TYPE1 unk214[2]; + /* 0x212 */ s16 unk_212[2]; /* 0x216 */ s16 unk_216; /* 0x218 */ s16 unk_218; /* 0x21A */ s16 unk_21A; 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 8f7fa4f4a..2434ca2cf 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 @@ -6,7 +6,7 @@ #include "z_en_guard_nuts.h" -#define FLAGS 0x80100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnGuardNuts*)thisx) @@ -15,7 +15,15 @@ void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index); +void EnGuardNuts_SetupWait(EnGuardNuts* this); +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx); +void func_80ABB540(EnGuardNuts* this); +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx); +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx); + const ActorInit En_Guard_Nuts_InitVars = { ACTOR_EN_GUARD_NUTS, ACTORCAT_NPC, @@ -28,42 +36,350 @@ const ActorInit En_Guard_Nuts_InitVars = { (ActorFunc)EnGuardNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ABBDF0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON | OCELEM_UNK3, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON | OCELEM_UNK3, + }, { 50, 50, 0, { 0, 0, 0 } }, }; -#endif +s32 sGuardCount = 0; -extern ColliderCylinderInit D_80ABBDF0; +s32 D_80ABBE20 = 0; -extern UNK_TYPE D_06002700; -extern UNK_TYPE D_06002A08; +static u16 sTextIDs[] = { 0x0824, 0x0825, 0x0826, 0x082D, 0x0827, 0x0828, 0x0829, 0x082A, 0x082B, 0x082C }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Init.s") +s16 D_80ABBE38[] = { 0x0000, 0x0000, 0x0002, 0x0001, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0002 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Destroy.s") +static AnimationHeader* sAnimations[] = { + &gDekuPalaceGuardWaitAnim, + &gDekuPalaceGuardWalkAnim, + &gDekuPalaceGuardDigAnim, + &gDekuPalaceGuardWalkAnim, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB210.s") +static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB29C.s") +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB2D4.s") +typedef enum { + /* 0 */ WAIT_HEAD_TILT_ANIM, + /* 1 */ WALK_ANIM, + /* 2 */ DIG_ANIM, + /* 3 */ WALK_ANIM_2, +} EnGuardNutsAnim; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB540.s") +typedef enum { + /* 0 */ GUARD_NUTS_WAIT_STATE, + /* 1 */ GUARD_NUTS_TALKING_STATE, + /* 3 */ GUARD_NUTS_BURROWED_STATE = 3, + /* 4 */ GUARD_NUTS_UNK_STATE +} EnGuardNutsState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB590.s") +void EnGuardNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB854.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardWaitAnim, this->jointTable, + this->morphTable, OBJECT_DNK_LIMB_MAX); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Actor_SetScale(&this->actor, 0.015f); + Math_Vec3f_Copy(&this->guardPos, &this->actor.world.pos); + this->guardNumber = sGuardCount; + sGuardCount++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB91C.s") + // If you have returned deku princess guards will init burrowed. + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + EnGuardNuts_SetupWait(this); + } else { + EnGuardNuts_Burrow(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABB990.s") +void EnGuardNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Update.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/func_80ABBC60.s") +/** + * @brief Changes the animation to the provided index. Updates animIndex and animFrameCount for the animation. + * + * @param this + * @param index the index of sAnimations to change to + */ +void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 index) { + this->animIndex = index; + this->animFrameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animFrameCount, + sAnimModes[this->animIndex], -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Guard_Nuts/EnGuardNuts_Draw.s") +void EnGuardNuts_SetupWait(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + this->state = GUARD_NUTS_WAIT_STATE; + this->actionFunc = EnGuardNuts_Wait; +} + +void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 phi_a1; + s16 yawDiff; + + SkelAnime_Update(&this->skelAnime); + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80ABB540(this); + return; + } + if (yawDiff > 0x6000) { + D_80ABBE20 = 2; + } + if (player->transformation == PLAYER_FORM_DEKU) { + // this is the palace of... + this->guardTextIndex = 0; + if ((gSaveContext.save.weekEventReg[17] & 4) && (!this->hasCompletedConversation)) { + // I told you not to enter!! + this->guardTextIndex = 7; + } else if (gSaveContext.save.weekEventReg[12] & 0x40) { + // come to see the monkey again? + this->guardTextIndex = 4; + } + } else { + // No place for an outsider + this->guardTextIndex = 3; + } + this->actor.textId = sTextIDs[this->guardTextIndex]; + phi_a1 = this->actor.world.rot.y; + if (D_80ABBE20 == 2) { + EnGuardNuts_Burrow(this, globalCtx); + return; + } + if (D_80ABBE20 == 1) { + if (this->animIndex != WALK_ANIM) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + } + phi_a1 = (this->actor.home.rot.y + 0x8000); + } + if (fabsf((f32)(this->actor.shape.rot.y - phi_a1)) < 100.0f) { + this->actor.shape.rot.y = phi_a1; + if ((D_80ABBE20 == 1) && (this->animIndex != WALK_ANIM_2)) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM_2); + } + } else { + Math_SmoothStepToS(&this->actor.shape.rot.y, phi_a1, 1, 0xBB8, 0); + } + if (this->targetHeadPos.x == 0) { + if (fabsf((f32)this->actor.world.rot.y - (f32)this->actor.yawTowardsPlayer) < 10000.0f) { + this->targetHeadPos.y = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + this->targetHeadPos.y = -this->targetHeadPos.y; + } + } + func_800B8614(&this->actor, globalCtx, 70.0f); +} + +void func_80ABB540(EnGuardNuts* this) { + EnGuardNuts_ChangeAnim(this, WALK_ANIM); + this->targetHeadPos.x = this->targetHeadPos.y = 0; + this->timer = 16; + this->state = GUARD_NUTS_TALKING_STATE; + this->actionFunc = func_80ABB590; +} + +void func_80ABB590(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yaw = this->actor.yawTowardsPlayer; + f32 curFrame; + + if (D_80ABBE20 == 1) { + yaw = (this->actor.home.rot.y + 0x8000); + } + if (fabsf((this->actor.shape.rot.y - yaw)) < 100.0f) { + this->actor.shape.rot.y = yaw; + curFrame = this->skelAnime.curFrame; + if ((curFrame < this->animFrameCount) || (this->guardTextIndex >= 7)) { + SkelAnime_Update(&this->skelAnime); + } + } else { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 0xBB8, 0); + } + if (Message_GetState(&globalCtx->msgCtx) == 5) { + this->targetHeadPos.y = 0; + this->targetHeadPos.x = 0; + if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { + EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + } + if (Message_ShouldAdvance(globalCtx) != 0) { + if (D_80ABBE38[this->guardTextIndex] != 1) { + if (D_80ABBE38[this->guardTextIndex] == 2) { + func_801477B4(globalCtx); + D_80ABBE20 = 2; + gSaveContext.save.weekEventReg[12] |= 0x40; + EnGuardNuts_Burrow(this, globalCtx); + } else { + this->guardTextIndex++; + Message_StartTextbox(globalCtx, sTextIDs[this->guardTextIndex], &this->actor); + if (D_80ABBE38[this->guardTextIndex] == 2) { + D_80ABBE20 = 1; + } + this->timer = 16; + } + } else if (this->guardTextIndex != 3) { + this->targetHeadPos.x = 0; + this->targetHeadPos.y = this->targetHeadPos.x; + func_801477B4(globalCtx); + this->state = GUARD_NUTS_UNK_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + } else { + func_801477B4(globalCtx); + EnGuardNuts_SetupWait(this); + } + } + } else if ((Message_GetState(&globalCtx->msgCtx) >= 3) && (D_80ABBE20 == 0)) { + if ((this->guardTextIndex == 0) || (this->guardTextIndex == 3) || (this->guardTextIndex >= 7)) { + if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.y ^= 0x2000; + } + } else if (this->timer == 0) { + this->timer = 2; + this->targetHeadPos.x ^= 0x2000; + } + } +} + +void EnGuardNuts_Burrow(EnGuardNuts* this, GlobalContext* globalCtx) { + Vec3f digPos; + + EnGuardNuts_ChangeAnim(this, DIG_ANIM); + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + this->targetHeadPos.y = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->targetHeadPos.x = this->targetHeadPos.y; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + this->actionFunc = EnGuardNuts_SetupUnburrow; +} + +void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + SkelAnime_Update(&this->skelAnime); + if (this->animFrameCount <= curFrame) { + this->state = GUARD_NUTS_BURROWED_STATE; + this->actionFunc = EnGuardNuts_Unburrow; + this->actor.world.rot.y = this->actor.home.rot.y; + this->actor.shape.rot.y = this->actor.home.rot.y; + } +} + +void EnGuardNuts_Unburrow(EnGuardNuts* this, GlobalContext* globalCtx) { + s16 yawDiff; + Vec3f digPos; + + // If you have returned Deku Princess, guards will not unburrow + if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); + if ((yawDiff < 0x4000) && ((D_80ABBE20 == 0) || (this->actor.xzDistToPlayer > 150.0f))) { + Math_Vec3f_Copy(&digPos, &this->actor.world.pos); + digPos.y = this->actor.floorHeight; + EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + D_80ABBE20 = 0; + if (this->guardTextIndex == 9) { + this->hasCompletedConversation = true; + } + this->actor.flags &= ~ACTOR_FLAG_8000000; + EnGuardNuts_SetupWait(this); + } + } +} + +void EnGuardNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + s32 pad; + + if (this->blinkTimer == 0) { + if (++(this->eyeState) >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + 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); + } + + this->actionFunc(this, globalCtx); + Actor_SetFocus(&this->actor, 40.0f); + Math_SmoothStepToS(&this->headRot.x, this->targetHeadPos.x, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRot.y, this->targetHeadPos.y, 1, 0xBB8, 0); + + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->timer != 0) { + this->timer--; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1D); + if ((this->state != GUARD_NUTS_BURROWED_STATE) && (this->state != GUARD_NUTS_UNK_STATE)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +s32 EnGuardNuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnGuardNuts* this = THIS; + + if (limbIndex == OBJECT_DNK_LIMB_HEAD) { + rot->x += this->headRot.x; + rot->y += this->headRot.y; + rot->z += this->headRot.z; + } + return false; +} + +void EnGuardNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnGuardNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnGuardNuts_OverrideLimbDraw, + NULL, &this->actor); + Matrix_InsertTranslation(this->guardPos.x, this->actor.floorHeight, this->guardPos.z, MTXMODE_NEW); + Matrix_Scale(0.015f, 0.015f, 0.015f, 1); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gDekuPalaceGuardFlower); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h index 13acc2237..59f885563 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h @@ -2,16 +2,31 @@ #define Z_EN_GUARD_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnGuardNuts; typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); typedef struct EnGuardNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; - /* 0x020C */ EnGuardNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; + /* 0x20C */ EnGuardNutsActionFunc actionFunc; + /* 0x210 */ s16 eyeState; + /* 0x212 */ s16 blinkTimer; + /* 0x214 */ s16 timer; + /* 0x218 */ s32 animIndex; + /* 0x21C */ s16 state; + /* 0x21E */ s16 guardNumber; // Unused - Number used to identify guard + /* 0x220 */ s32 guardTextIndex; + /* 0x224 */ u8 hasCompletedConversation; // Flag set when player has gone through all text. + /* 0x228 */ Vec3f guardPos; + /* 0x234 */ Vec3s headRot; + /* 0x23A */ Vec3s targetHeadPos; + /* 0x240 */ f32 animFrameCount; + /* 0x244 */ ColliderCylinder collider; } EnGuardNuts; // size = 0x290 extern const ActorInit En_Guard_Nuts_InitVars; 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 51bb967c0..8844062b8 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -7,7 +7,7 @@ #include "z_en_guruguru.h" #include "objects/object_fu/object_fu.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnGuruguru*)thisx) @@ -83,9 +83,9 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 0) { func_80BC6E10(this); } else if (this->actor.params == 2) { - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnGuruguru_DoNothing; } else { Actor_MarkForDeath(&this->actor); @@ -207,7 +207,7 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { } } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { func_801477B4(globalCtx); this->headZRotTarget = 0; if ((this->textIdIndex == 13) || (this->textIdIndex == 14)) { 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 1e4da23ea..108d62afd 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_boss_hakugin/object_boss_hakugin.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnHakurock*)thisx) 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 ce1f2a0f0..d7ec6103f 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -5,8 +5,9 @@ */ #include "z_en_hanabi.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnHanabi*)thisx) @@ -18,8 +19,8 @@ void func_80B23894(EnHanabi* this, GlobalContext* globalCtx); void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx); void func_80B23910(EnHanabi* this, GlobalContext* globalCtx); void func_80B23934(EnHanabi* this, GlobalContext* globalCtx); +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hanabi_InitVars = { ACTOR_EN_HANABI, ACTORCAT_ITEMACTION, @@ -32,38 +33,322 @@ const ActorInit En_Hanabi_InitVars = { (ActorFunc)NULL, }; -#endif +Vec3s D_80B23AA0[] = { + { 85, 14, 49 }, { 70, -70, 0 }, { 85, 14, -49 }, { 90, -32, 28 }, { 90, -32, -28 }, { 98, 16, 0 }, + { 70, 70, 0 }, { 84, 45, 26 }, { 84, 45, -26 }, { 50, -50, 70 }, { 73, -19, 64 }, { 65, -65, 38 }, + { 50, -50, -70 }, { 65, -65, -38 }, { 73, -19, -64 }, { 0, 0, -100 }, { 14, 85, -49 }, { 49, 8, -86 }, + { 8, 49, -86 }, { 57, 57, -57 }, { 45, 84, -26 }, { 27, -27, -92 }, { -50, 50, -70 }, { -27, 27, -92 }, + { -19, 73, -64 }, { -70, 70, 0 }, { 14, 85, 49 }, { -32, 90, -28 }, { -32, 90, 28 }, { 16, 98, 0 }, + { 45, 84, 26 }, { -65, 65, -38 }, { -50, 50, 70 }, { -65, 65, 38 }, { -19, 73, 64 }, { 0, 0, 100 }, + { 8, 49, 86 }, { 49, 8, 86 }, { 57, 57, 57 }, { -27, 27, 92 }, { 27, -27, 92 }, { -14, -85, -49 }, + { -14, -85, 49 }, { 32, -90, -28 }, { 32, -90, 28 }, { -16, -98, 0 }, { -70, -70, 0 }, { -45, -84, -26 }, + { -45, -84, 26 }, { 19, -73, -64 }, { 19, -73, 64 }, { -85, -14, -49 }, { -49, -8, -86 }, { -8, -49, -86 }, + { -57, -57, -57 }, { -84, -45, -26 }, { -73, 19, -64 }, { -85, -14, 49 }, { -90, 32, 28 }, { -90, 32, -28 }, + { -98, -16, 0 }, { -84, -45, 26 }, { -73, 19, 64 }, { -8, -49, 86 }, { -49, -8, 86 }, { -57, -57, 57 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C00.s") +u8 D_80B23C2C[] = { + 255, 255, 200, 255, 200, 255, 200, 255, 255, 255, 200, 200, 200, 255, 200, 200, 200, 255, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C2C.s") +u8 D_80B23C40[] = { + 200, 200, 0, 200, 0, 200, 0, 200, 200, 200, 0, 0, 0, 200, 0, 0, 200, 200, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22C80.s") +void func_80B22C00(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22E0C.s") + for (i = 0; i < 400; i++, arg0++) { + arg0->unk_00 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22F34.s") +void func_80B22C2C(EnHanabiStruct* arg0, s32 arg1) { + arg0->unk_01 = (s32)Rand_ZeroFloat(20.0f) + 60; + arg0->unk_02 = arg1; + arg0->unk_14.x = 0.7f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B22FA8.s") +s32 func_80B22C80(Vec3f* arg0, EnHanabiStruct* arg1, f32 arg2) { + Vec3s* phi_s1 = &D_80B23AA0[0]; + f32 temp_f22 = (Rand_ZeroFloat(0.2f) + 0.6f) * arg2; + s32 temp_s6 = (s32)Rand_ZeroFloat(6.0f) * 3; + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Init.s") + for (i = 0, j = 0; j < ARRAY_COUNT(D_80B23AA0) && i < 400; i++, arg1++) { + if (arg1->unk_00 <= 0) { + arg1->unk_00 = 1; + Math_Vec3f_Copy(&arg1->unk_08, arg0); + arg1->unk_20.x = phi_s1->x * temp_f22; + arg1->unk_20.y = (phi_s1->y * temp_f22) + 50.0f; + arg1->unk_20.z = phi_s1->z * temp_f22; + arg1->unk_04 = 1.5f * arg2; + func_80B22C2C(arg1, temp_s6); + phi_s1++; + j++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Destroy.s") + return temp_s6; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B234C8.s") +void func_80B22E0C(EnHanabiStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B235CC.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + arg0->unk_08.x += arg0->unk_20.x; + arg0->unk_08.y += arg0->unk_20.y; + arg0->unk_08.z += arg0->unk_20.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B236C8.s") + arg0->unk_20.x *= arg0->unk_14.x; + arg0->unk_20.z *= arg0->unk_14.x; + arg0->unk_20.y *= arg0->unk_14.x; + arg0->unk_20.y -= 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23894.s") + arg0->unk_20.x += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.y += randPlusMinusPoint5Scaled(0.8f); + arg0->unk_20.z += randPlusMinusPoint5Scaled(0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B238D4.s") + if (arg0->unk_01 > 0) { + arg0->unk_01--; + } else { + arg0->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23910.s") +s32 func_80B22F34(EnHanabiStruct* arg0) { + s32 count = 0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23934.s") + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + count++; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/EnHanabi_Update.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hanabi/func_80B23A38.s") +void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s32 i; + u8 sp53; + + OPEN_DISPS(gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + + sp53 = 0xFF; + if (sp53) {} + + for (i = 0; i < 400; i++, arg0++) { + if (arg0->unk_00 == 1) { + Matrix_InsertTranslation(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + if (arg0->unk_01 < 40) { + Matrix_Scale(arg0->unk_04 * 0.025f * arg0->unk_01, arg0->unk_04 * 0.025f * arg0->unk_01, 1.0f, + MTXMODE_APPLY); + } else { + Matrix_Scale(arg0->unk_04, arg0->unk_04, 1.0f, MTXMODE_APPLY); + } + Matrix_InsertZRotation_s(globalCtx->gameplayFrames * 4864, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (sp53 != arg0->unk_02) { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, D_80B23C40[arg0->unk_02], D_80B23C40[arg0->unk_02 + 1], + D_80B23C40[arg0->unk_02 + 2], 255); + + sp53 = arg0->unk_02; + } + + if (arg0->unk_01 < 6) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], arg0->unk_01 * 50); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, D_80B23C2C[arg0->unk_02], D_80B23C2C[arg0->unk_02 + 1], + D_80B23C2C[arg0->unk_02 + 2], 255); + } + + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + } + } + + CLOSE_DISPS(gfxCtx); +} + +void EnHanabi_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + if (1) {} + + Actor_SetScale(thisx, 1.0f); + this->actionFunc = func_80B23910; + this->unk_144 = 0; + func_80B22C00(this->unk_148); + + for (i = 0; i < ARRAY_COUNT(this->unk_4608); i++) { + Lights_PointNoGlowSetInfo(&this->unk_4608[i], thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 255, + 255, 255, -1); + this->unk_4634[i] = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->unk_4608[i]); + } + + if (ENHANABI_GET_1F(thisx) == ENHANABI_1F_1) { + this->actionFunc = func_80B23934; + this->actor.home.rot.x = 0x384; + } +} + +void EnHanabi_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHanabi* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4634); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->unk_4634[i]); + } +} + +void func_80B234C8(EnHanabi* this) { + s16 phi_v1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] > 0) { + this->unk_4640[i]--; + if (this->unk_4640[i] == 0) { + phi_v1 = -1; + } else { + if (this->unk_4640[i] >= 0xA) { + phi_v1 = 0x3E8; + } else { + phi_v1 = this->unk_4640[i] * 0x64; + } + + if (this->actor.home.rot.x >= 0x259) { + phi_v1 *= 2; + } + } + + Lights_PointSetColorAndRadius(&this->unk_4608[i], D_80B23C2C[this->unk_4648[i]], + D_80B23C2C[this->unk_4648[i] + 1], D_80B23C2C[this->unk_4648[i] + 2], phi_v1); + } + } +} + +void func_80B235CC(EnHanabi* this, Vec3f* arg1, s32 arg2) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_4640); i++) { + if (this->unk_4640[i] == 0) { + this->unk_4648[i] = arg2; + Lights_PointNoGlowSetInfo(&this->unk_4608[i], arg1->x, arg1->y, arg1->z, D_80B23C2C[arg2], + D_80B23C2C[arg2 + 1], D_80B23C2C[arg2 + 2], 0x3E8); + this->unk_4640[i] = 20; + break; + } + } +} + +void func_80B236C8(EnHanabi* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 sp30; + s32 pad; + s32 sp28; + + this->actor.draw = EnHanabi_Draw; + func_80B234C8(this); + if (this->actor.home.rot.x != 0) { + if (this->unk_144 > 0) { + this->unk_144--; + return; + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + + if (this->actor.home.rot.x != 0) { + sp30 = Rand_ZeroFloat(200.0f) + this->actor.home.rot.x; + } else { + sp30 = Rand_ZeroFloat(200.0f) + 300.0f; + } + + sp34.x += sp30 * Math_SinS(this->actor.home.rot.y); + sp34.y += randPlusMinusPoint5Scaled(300.0f); + sp34.z += sp30 * Math_CosS(this->actor.home.rot.y); + + if (this->actor.home.rot.x >= 0x259) { + sp28 = func_80B22C80(&sp34, this->unk_148, 2.0f); + } else { + sp28 = func_80B22C80(&sp34, this->unk_148, 1.0f); + } + + 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); + func_80B235CC(this, &sp34, sp28); + } +} + +void func_80B23894(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (func_80B22F34(this->unk_148) == 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B238D4(EnHanabi* this, GlobalContext* globalCtx) { + func_80B236C8(this, globalCtx); + if (this->actor.home.rot.x == 0) { + this->actionFunc = func_80B23894; + } +} + +void func_80B23910(EnHanabi* this, GlobalContext* globalCtx) { + if (this->actor.home.rot.x != 0) { + this->actionFunc = func_80B238D4; + } +} + +void func_80B23934(EnHanabi* this, GlobalContext* globalCtx) { + if ((gSaveContext.save.entranceIndex == 0x5410) && (gSaveContext.sceneSetupIndex == 7)) { + if (globalCtx->csCtx.frames > 1650) { + func_80B236C8(this, globalCtx); + func_800B8FE8(&this->actor, NA_SE_EV_FIREWORKS_LAUNCH - SFX_FLAG); + } + } + + if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 7) && + (globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 610)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_KYOJIN_GROAN); + } +} + +void EnHanabi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B22E0C(this->unk_148); +} + +void EnHanabi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHanabi* this = THIS; + + Matrix_StatePush(); + func_80B22FA8(this->unk_148, globalCtx); + Matrix_StatePop(); +} diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h index 78f198ed4..ed4963daf 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.h @@ -7,9 +7,28 @@ struct EnHanabi; typedef void (*EnHanabiActionFunc)(struct EnHanabi*, GlobalContext*); +#define ENHANABI_GET_1F(thisx) ((thisx)->params & 0x1F) + +#define ENHANABI_1F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; + /* 0x04 */ f32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; +} EnHanabiStruct; // size = 0x2C + typedef struct EnHanabi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4510]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ EnHanabiStruct unk_148[400]; + /* 0x4608 */ LightInfo unk_4608[3]; + /* 0x4634 */ LightNode* unk_4634[3]; + /* 0x4640 */ s16 unk_4640[3]; + /* 0x4648 */ s32 unk_4648[3]; /* 0x4654 */ EnHanabiActionFunc actionFunc; } EnHanabi; // size = 0x4658 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 229c1b65d..bb2fb002b 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -5,8 +5,9 @@ */ #include "z_en_heishi.h" +#include "objects/object_sdn/object_sdn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnHeishi*)thisx) @@ -15,9 +16,19 @@ void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx); void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BE9214(EnHeishi* this, GlobalContext* globalCtx); +void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex); +void EnHeishi_SetHeadRotation(EnHeishi* this); +void EnHeishi_SetupIdle(EnHeishi* this); +void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ HEISHI_ANIMATION_STAND_HAND_ON_HIP, + /* 1 */ HEISHI_ANIMATION_CHEER_WITH_SPEAR, + /* 2 */ HEISHI_ANIMATION_WAVE, + /* 3 */ HEISHI_ANIMATION_SIT_AND_REACH, + /* 4 */ HEISHI_ANIMATION_STAND_UP +} EnHeishiAnimationIndex; -#if 0 const ActorInit En_Heishi_InitVars = { ACTOR_EN_HEISHI, ACTORCAT_NPC, @@ -30,33 +41,153 @@ const ActorInit En_Heishi_InitVars = { (ActorFunc)EnHeishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE9450 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; -#endif +void EnHeishi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; -extern ColliderCylinderInit D_80BE9450; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSoldierSkeleton, &gSoldierWave, this->jointTable, + this->morphTable, HEISHI_LIMB_MAX); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->paramsCopy = this->actor.params; + this->yawTowardsPlayer = this->actor.world.rot.y; -extern UNK_TYPE D_06003BFC; + if (this->paramsCopy == 0) { + this->shouldSetHeadRotation = 1; + if (!(gSaveContext.save.weekEventReg[63] & 0x80) && + !((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } else { + this->colliderCylinder.dim.radius = 30; + this->colliderCylinder.dim.height = 60; + this->colliderCylinder.dim.yShift = 0; + if ((gSaveContext.save.weekEventReg[63] & 0x80) || + ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Init.s") + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; + Collider_InitAndSetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + this->actor.flags |= ACTOR_FLAG_8000000; + EnHeishi_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Destroy.s") +void EnHeishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE90BC.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9148.s") +void EnHeishi_ChangeAnimation(EnHeishi* this, s32 animIndex) { + static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, + }; + static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE91DC.s") + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/func_80BE9214.s") +void EnHeishi_SetHeadRotation(EnHeishi* this) { + s16 yawDiff = this->yawTowardsPlayer - this->actor.world.rot.y; + s32 absYawDiff = ABS_ALT(yawDiff); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Update.s") + this->headRotXTarget = 0; + if ((this->actor.xzDistToPlayer < 200.0f) && (absYawDiff < 0x4E20)) { + this->headRotXTarget = this->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_Heishi/func_80BE9380.s") +void EnHeishi_SetupIdle(EnHeishi* this) { + s8 animIndex = HEISHI_ANIMATION_STAND_HAND_ON_HIP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Heishi/EnHeishi_Draw.s") + EnHeishi_ChangeAnimation(this, animIndex); + this->unk278 = animIndex; + this->actionFunc = EnHeishi_Idle; +} + +void EnHeishi_Idle(EnHeishi* this, GlobalContext* globalCtx) { +} + +void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHeishi* this = THIS; + + SkelAnime_Update(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->paramsCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { + Actor_MarkForDeath(&this->actor); + } else { + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 29); + Actor_SetScale(&this->actor, 0.01f); + if (this->shouldSetHeadRotation) { + EnHeishi_SetHeadRotation(this); + } + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 3000, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 1000, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} + +s32 EnHeishi_OverrideLimbDraw(GlobalContext* globalctx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnHeishi* this = THIS; + + if (limbIndex == HEISHI_LIMB_HEAD) { + rot->x += this->headRotX; + rot->y += this->headRotY; + rot->z += this->headRotZ; + } + + return false; +} + +void EnHeishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHeishi_OverrideLimbDraw, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h index 8ceb74a00..de65bac72 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h @@ -7,13 +7,48 @@ struct EnHeishi; typedef void (*EnHeishiActionFunc)(struct EnHeishi*, GlobalContext*); +typedef enum { + /* 0 */ HEISHI_LIMB_NONE, + /* 1 */ HEISHI_LIMB_ROOT, + /* 2 */ HEISHI_LIMB_PELVIS, + /* 3 */ HEISHI_LIMB_LEFT_THIGH, + /* 4 */ HEISHI_LIMB_LEFT_CALF, + /* 5 */ HEISHI_LIMB_LEFT_FOOT, + /* 6 */ HEISHI_LIMB_RIGHT_THIGH, + /* 7 */ HEISHI_LIMB_RIGHT_CALF, + /* 8 */ HEISHI_LIMB_RIGHT_FOOT, + /* 9 */ HEISHI_LIMB_TORSO, + /* 10 */ HEISHI_LIMB_LEFT_SHOULDER, + /* 11 */ HEISHI_LIMB_LEFT_FOREARM, + /* 12 */ HEISHI_LIMB_LEFT_HAND, + /* 13 */ HEISHI_LIMB_RIGHT_SHOULDER, + /* 14 */ HEISHI_LIMB_RIGHT_FOREARM, + /* 15 */ HEISHI_LIMB_RIGHT_HAND_WITH_SPEAR, + /* 16 */ HEISHI_LIMB_HEAD, + /* 17 */ HEISHI_LIMB_MAX +} EnHeishiLimbs; + typedef struct EnHeishi { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x110]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[HEISHI_LIMB_MAX]; + /* 0x01EE */ Vec3s morphTable[HEISHI_LIMB_MAX]; /* 0x0254 */ EnHeishiActionFunc actionFunc; - /* 0x0258 */ char unk_258[0x78]; + /* 0x0258 */ s16 headRotY; + /* 0x025A */ s16 headRotX; + /* 0x025C */ s16 headRotZ; + /* 0x025E */ s16 headRotYTarget; + /* 0x0260 */ s16 headRotXTarget; + /* 0x0262 */ s16 headRotZTarget; + /* 0x0264 */ s32 animIndex; + /* 0x0268 */ s32 paramsCopy; + /* 0x026C */ s32 shouldSetHeadRotation; + /* 0x0270 */ s16 timer; + /* 0x0272 */ s16 yawTowardsPlayer; + /* 0x0274 */ f32 frameCount; + /* 0x0278 */ s16 unk278; // set and not used + /* 0x027C */ UNK_TYPE1 unk_27C[0x8]; + /* 0x0284 */ ColliderCylinder colliderCylinder; } EnHeishi; // size = 0x2D0 -extern const ActorInit En_Heishi_InitVars; - #endif // Z_EN_HEISHI_H 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 0728b832d..0bbef0b9e 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -7,7 +7,7 @@ #include "z_en_hg.h" #include "objects/object_harfgibud/object_harfgibud.h" -#define FLAGS 0x02100019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnHg*)thisx) @@ -102,15 +102,15 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, 0x80, }; -static ActorAnimationEntry sAnimations[] = { - { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static u32 D_80BD00C8 = false; @@ -126,7 +126,7 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - if ((gSaveContext.save.weekEventReg[0x4B] & 0x20) || (gSaveContext.save.weekEventReg[0x34] & 0x20)) { + if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { Actor_MarkForDeath(&this->actor); } this->actor.targetMode = 1; @@ -149,17 +149,17 @@ void EnHg_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BCF354(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF398; } void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health == 1) { if ((this->actor.xzDistToPlayer < 200.0f && this->actor.playerHeightRel < 40.0f) && - !func_800EE29C(globalCtx, 0x1E3)) { + !Cutscene_CheckActorAction(globalCtx, 0x1E3)) { func_80BCF468(this); } - if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.unk_12 == 0) && + if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 20 || globalCtx->csCtx.frames == 60)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_HALF_REDEAD_SURPRISE); } @@ -167,7 +167,7 @@ void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF468(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BCF4AC; } @@ -176,7 +176,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { s32 pad; this->actor.speedXZ = 1.6f; - if (!(player->stateFlags2 & 0x08000000) && !Message_GetState(&globalCtx->msgCtx)) { + if (!(player->stateFlags2 & 0x08000000) && Message_GetState(&globalCtx->msgCtx) == 0) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { Actor_MoveWithGravity(&this->actor); @@ -191,7 +191,7 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF5F0(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BCF634; } @@ -204,7 +204,7 @@ void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { } void func_80BCF68C(EnHg* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80BCF6D0; } @@ -217,7 +217,7 @@ void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { void func_80BCF710(EnHg* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x24F, &this->actor); + Message_StartTextbox(globalCtx, 0x24F, &this->actor); } else { func_800B8614(&this->actor, globalCtx, 80.0f); } @@ -228,7 +228,7 @@ void func_80BCF778(EnHg* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.health == 1) { if (this->actionFunc == func_80BCF4AC || this->actionFunc == func_80BCF6D0 || this->actionFunc == func_80BCF634) { - func_800B9010(&this->actor, 0x32B7); + func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); } } } @@ -271,24 +271,25 @@ void func_80BCF93C(EnHg* this) { } void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x1E4)) { - u32 actionIndex = func_800EE200(globalCtx, 0x1E4); - if (this->cutscenes[3] != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->cutscenes[3] = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 484)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 484); + + if (this->cutscenes[3] != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->cutscenes[3] = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->currentAnimation = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; case 2: this->cutscenes[2] = 0; this->currentAnimation = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 3: this->cutscenes[2] = 0; this->currentAnimation = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; case 4: this->cutscenes[2] = 0; @@ -296,14 +297,14 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { if ((this->unk218 == 1) || (this->unk218 == 3)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); break; case 5: this->currentAnimation = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 6: - gSaveContext.save.weekEventReg[0x4B] |= 0x20; + gSaveContext.save.weekEventReg[75] |= 0x20; Actor_MarkForDeath(&this->actor); break; } @@ -312,11 +313,11 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { switch (this->currentAnimation) { case 3: this->currentAnimation = 4; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 5: this->currentAnimation = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); break; } } @@ -336,7 +337,7 @@ void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { } break; } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return; } else if (globalCtx->csCtx.state == 0) { func_80BCF354(this); @@ -368,8 +369,8 @@ void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { } else { if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { - if (!(gSaveContext.save.weekEventReg[0x3D] & 2)) { - gSaveContext.save.weekEventReg[0x3D] |= 2; + if (!(gSaveContext.save.weekEventReg[61] & 2)) { + gSaveContext.save.weekEventReg[61] |= 2; this->unk218 = 0; } else { this->unk218 = 2; 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 0bc926ca1..2aa217846 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -7,7 +7,7 @@ #include "z_en_hgo.h" #include "objects/object_harfgibud/object_harfgibud.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHgo*)thisx) @@ -40,14 +40,14 @@ const ActorInit En_Hgo_InitVars = { (ActorFunc)EnHgo_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -109,7 +109,7 @@ void EnHgo_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80BD03EC(EnHgo* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80BD0410; } @@ -128,7 +128,7 @@ void func_80BD0434(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD049C(EnHgo* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD04E0; } @@ -137,29 +137,29 @@ void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (!(this->unk_310 & 4)) { this->unk_310 |= 4; - func_801518B0(globalCtx, 0x15A5, &this->actor); + Message_StartTextbox(globalCtx, 0x15A5, &this->actor); this->unk_314 = 0x15A5; // That mask is a gibdo } else { - func_801518B0(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; // can I research that mask } } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { if (!(this->unk_310 & 1)) { this->unk_310 |= 1; - func_801518B0(globalCtx, 0x158F, &this->actor); + Message_StartTextbox(globalCtx, 0x158F, &this->actor); this->unk_314 = 0x158F; // Isn't this a fairy } else { - func_801518B0(globalCtx, 0x1593, &this->actor); + Message_StartTextbox(globalCtx, 0x1593, &this->actor); this->unk_314 = 0x1593; // Never seen a fairy this lively } } else { if (!(this->unk_310 & 2)) { this->unk_310 |= 2; - func_801518B0(globalCtx, 0x1595, &this->actor); + Message_StartTextbox(globalCtx, 0x1595, &this->actor); this->unk_314 = 0x1595; // ghost radar is reacting } else { - func_801518B0(globalCtx, 0x1598, &this->actor); + Message_StartTextbox(globalCtx, 0x1598, &this->actor); this->unk_314 = 0x1598; // you seem to be similar to a ghost } } @@ -185,7 +185,7 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { func_80BD06FC(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD049C(this); } } @@ -194,47 +194,47 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, GlobalContext* globalCtx) { } void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_314) { case 0x158F: - func_801518B0(globalCtx, 0x1590, &this->actor); + Message_StartTextbox(globalCtx, 0x1590, &this->actor); this->unk_314 = 0x1590; break; case 0x1590: if (gSaveContext.save.weekEventReg[14] & 4) { - func_801518B0(globalCtx, 0x1591, &this->actor); + Message_StartTextbox(globalCtx, 0x1591, &this->actor); this->unk_314 = 0x1591; break; } - func_801518B0(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(globalCtx, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1591: - func_801518B0(globalCtx, 0x1592, &this->actor); + Message_StartTextbox(globalCtx, 0x1592, &this->actor); this->unk_314 = 0x1592; break; case 0x1593: - func_801518B0(globalCtx, 0x1594, &this->actor); + Message_StartTextbox(globalCtx, 0x1594, &this->actor); this->unk_314 = 0x1594; break; case 0x1595: - func_801518B0(globalCtx, 0x1596, &this->actor); + Message_StartTextbox(globalCtx, 0x1596, &this->actor); this->unk_314 = 0x1596; break; case 0x1596: - func_801518B0(globalCtx, 0x1597, &this->actor); + Message_StartTextbox(globalCtx, 0x1597, &this->actor); this->unk_314 = 0x1597; break; case 0x1598: - func_801518B0(globalCtx, 0x1599, &this->actor); + Message_StartTextbox(globalCtx, 0x1599, &this->actor); this->unk_314 = 0x1599; break; case 0x15A5: - func_801518B0(globalCtx, 0x15A6, &this->actor); + Message_StartTextbox(globalCtx, 0x15A6, &this->actor); this->unk_314 = 0x15A6; break; case 0x15A6: - func_801518B0(globalCtx, 0x15A7, &this->actor); + Message_StartTextbox(globalCtx, 0x15A7, &this->actor); this->unk_314 = 0x15A7; break; case 0x15A7: @@ -246,37 +246,37 @@ void func_80BD06FC(EnHgo* this, GlobalContext* globalCtx) { } s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E6)) { - actionIndex = func_800EE200(globalCtx, 0x1E6); - if (this->unk_316 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk_316 = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 486)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 486); + if (this->unk_316 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_316 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->unk_218 = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); break; case 2: this->actor.draw = EnHgo_Draw; this->unk_218 = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); break; case 3: this->unk_218 = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); break; case 4: this->unk_218 = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 5: this->unk_218 = 4; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); break; case 6: this->unk_218 = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -285,22 +285,22 @@ s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_312 == 0)) { this->unk_312 = 1; if ((gSaveContext.sceneSetupIndex == 0) && - ((globalCtx->csCtx.unk_12 == 2) || (globalCtx->csCtx.unk_12 == 4))) { + ((globalCtx->csCtx.currentCsIndex == 2) || (globalCtx->csCtx.currentCsIndex == 4))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); } } break; case 2: this->unk_218 = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); break; case 5: this->unk_218 = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } if ((globalCtx->csCtx.state == 0) && (((gSaveContext.save.weekEventReg[75]) & 0x20)) && 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 2dc819719..e1432c10a 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -5,8 +5,9 @@ */ #include "z_en_hidden_nuts.h" +#include "objects/object_hintnuts/object_hintnuts.h" -#define FLAGS 0x02000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) #define THIS ((EnHiddenNuts*)thisx) @@ -15,15 +16,20 @@ void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BDB268(EnHiddenNuts* this); void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB580(EnHiddenNuts* this); void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB788(EnHiddenNuts* this); void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDB930(EnHiddenNuts* this); void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx); +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx); void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hidden_Nuts_InitVars = { ACTOR_EN_HIDDEN_NUTS, ACTORCAT_PROP, @@ -36,51 +42,397 @@ const ActorInit En_Hidden_Nuts_InitVars = { (ActorFunc)EnHiddenNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDC0D0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 30, 20, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* D_80BDC0FC[] = { + &object_hintnuts_Anim_000168, &object_hintnuts_Anim_0024CC, &object_hintnuts_Anim_0026C4, + &object_hintnuts_Anim_002894, &object_hintnuts_Anim_002B90, &object_hintnuts_Anim_002F7C, + &object_hintnuts_Anim_003128, &object_hintnuts_Anim_0029BC, &object_hintnuts_Anim_0024CC, +}; -extern ColliderCylinderInit D_80BDC0D0; +u8 D_80BDC120[] = { + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, +}; -extern UNK_TYPE D_060024CC; +void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, &object_hintnuts_Anim_0024CC, + this->jointTable, this->morphTable, 10); + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Destroy.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB1B4.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB268.s") + this->unk_21E = ENHIDDENNUTS_GET_F80(&this->actor); + this->switchFlag = ENHIDDENNUTS_GET_SWITCHFLAG(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB2B8.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB580.s") + if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB59C.s") + if (this->unk_21E == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB788.s") + this->path = SubS_GetPathByIndex(globalCtx, this->unk_21E, 0x3F); + this->unk_226 = this->actor.cutscene; + func_801A5080(2); + func_80BDB268(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB7E8.s") +void EnHiddenNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB8F4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB930.s") +void func_80BDB1B4(EnHiddenNuts* this, s32 arg1) { + f32 sp34; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDB978.s") + this->unk_220 = arg1; + sp34 = 0.0f; + sp30 = -4.0f; + this->unk_22C = Animation_GetLastFrame(D_80BDC0FC[arg1]); + if (this->unk_220 == 1) { + sp34 = this->unk_22C; + sp30 = 0.0f; + } + Animation_Change(&this->skelAnime, D_80BDC0FC[this->unk_220], 1.0f, sp34, this->unk_22C, D_80BDC120[this->unk_220], + sp30); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBA28.s") +void func_80BDB268(EnHiddenNuts* this) { + this->actor.textId = 0x234; + this->unk_228 = 1600.0f; + this->actor.shape.yOffset = 1600.0f; + func_80BDB1B4(this, 1); + this->unk_21A = 0; + this->actionFunc = func_80BDB2B8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBB48.s") +void func_80BDB2B8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBE70.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/func_80BDBED4.s") + if (player->stateFlags2 & 0x8000000) { + if (this->unk_20A == 0) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + this->unk_20A = 1; + } + } else { + this->unk_20A = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Update.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + func_80BDB580(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hidden_Nuts/EnHiddenNuts_Draw.s") + if (this->unk_218 == 0) { + Vec3f sp94 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp88 = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp84 = { 255, 255, 255, 255 }; + Color_RGBA8 sp80 = { 150, 150, 150, 0 }; + Vec3f sp74; + + for (i = 0; i < 3; i++) { + sp94.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp74, &this->actor.world.pos); + + sp74.x += randPlusMinusPoint5Scaled(15.0f); + sp74.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp74, &sp94, &sp88, &sp84, &sp80, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if (!(this->actor.xzDistToPlayer > 120.0f)) { + if ((globalCtx->msgCtx.ocarinaMode == 3) && (globalCtx->msgCtx.unk1202E == 0)) { + globalCtx->msgCtx.ocarinaMode = 4; + func_80BDB788(this); + } else if (func_801A5100() == 2) { + func_80BDB788(this); + } else { + func_800B8614(&this->actor, globalCtx, BREG(13) + 100.0f); + } + } +} + +void func_80BDB580(EnHiddenNuts* this) { + this->unk_21A = 1; + this->actionFunc = func_80BDB59C; +} + +void func_80BDB59C(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 i; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); + + if (this->unk_218 == 0) { + Vec3f sp98 = { 0.0f, 0.0f, 0.0f }; + Vec3f sp8C = { 0.0f, 0.0f, 0.0f }; + Color_RGBA8 sp88 = { 255, 255, 255, 255 }; + Color_RGBA8 sp84 = { 150, 150, 150, 0 }; + Vec3f sp78; + + for (i = 0; i < 3; i++) { + sp98.y = Rand_ZeroFloat(1.0f) + 1.0f; + + Math_Vec3f_Copy(&sp78, &this->actor.world.pos); + + sp78.x += randPlusMinusPoint5Scaled(15.0f); + sp78.z += randPlusMinusPoint5Scaled(15.0f); + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp78, &sp98, &sp8C, &sp88, &sp84, Rand_S16Offset(120, 90), 30, + 1); + } + this->unk_218 = 30; + } + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + 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->unk_21A = 2; + this->actionFunc = func_80BDB7E8; +} + +void func_80BDB7E8(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp3C; + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + if (!ActorCutscene_GetCanPlayNext(this->unk_226)) { + ActorCutscene_SetIntentToPlay(this->unk_226); + return; + } + + ActorCutscene_StartAndSetUnkLinkFields(this->unk_226, &this->actor); + this->unk_228 = -1200.0f; + + Math_Vec3f_Copy(&sp3C, &this->actor.world.pos); + sp3C.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp3C, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + func_80BDB1B4(this, 7); + this->actionFunc = func_80BDB8F4; +} + +void func_80BDB8F4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_22C <= curFrame) { + func_80BDB930(this); + } +} + +void func_80BDB930(EnHiddenNuts* this) { + func_80BDB1B4(this, 3); + this->unk_21A = 3; + this->unk_228 = 500.0f; + this->actionFunc = func_80BDB978; +} + +void func_80BDB978(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + 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); + } + + if (this->unk_22C <= curFrame) { + this->unk_224++; + if (this->unk_224 >= 2) { + func_80BDBA28(this, globalCtx); + } + } +} + +void func_80BDBA28(EnHiddenNuts* this, GlobalContext* globalCtx) { + Vec3f sp44; + + func_80BDB1B4(this, 2); + this->unk_228 = 0.0f; + + Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + sp44.y = this->actor.floorHeight + 30.0f; + + EffectSsHahen_SpawnBurst(globalCtx, &sp44, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + + Actor_PlaySfxAtPos(&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_MarkForDeath(&this->actor); + } + + this->actor.speedXZ = 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); + this->unk_21A = 4; + this->actionFunc = func_80BDBB48; +} + +void func_80BDBB48(EnHiddenNuts* this, GlobalContext* globalCtx) { + s32 pad[3]; + f32 sp58 = this->skelAnime.curFrame; + WaterBox* sp54; + f32 sp50; + s16 sp4E = 0; + Vec3f sp40; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, + &sp54) && + (this->actor.world.pos.y < sp50)) { + this->actor.velocity.y = 0.0f; + Math_Vec3f_Copy(&sp40, &this->actor.world.pos); + sp40.y = sp50; + this->actor.gravity = 0.0f; + + if ((globalCtx->gameplayFrames % 8) == 0) { + EffectSsGRipple_Spawn(globalCtx, &sp40, 650, 3150, 0); + } + + 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); + 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); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C), 1, 0x1388, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x3E8, 0); + + if (this->unk_220 == 2) { + if (this->unk_22C <= sp58) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_80BDB1B4(this, 6); + } + } else { + Math_ApproachF(&this->actor.world.pos.x, this->unk_20C.x, 0.5f, + fabsf(Math_SinS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + Math_ApproachF(&this->actor.world.pos.z, this->unk_20C.z, 0.5f, + fabsf(Math_CosS(this->actor.world.rot.y) * (BREG(33) + 8.0f))); + + if ((sqrtf(SQ(this->actor.world.pos.x - this->unk_20C.x) + SQ(this->actor.world.pos.z - this->unk_20C.z)) < + 4.0f) && + (this->path != NULL)) { + this->unk_208++; + if (this->unk_208 >= this->path->count) { + func_80BDBE70(this, globalCtx); + } else if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { + Actor_MarkForDeath(&this->actor); + } + } + } +} + +void func_80BDBE70(EnHiddenNuts* this, GlobalContext* globalCtx) { + if (this->switchFlag >= 0) { + Flags_SetSwitch(globalCtx, this->switchFlag); + } + func_80BDB1B4(this, 8); + this->unk_21A = 5; + this->actionFunc = func_80BDBED4; +} + +void func_80BDBED4(EnHiddenNuts* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + Vec3f sp38; + + if (this->unk_22C <= curFrame) { + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + sp38.y = this->actor.floorHeight; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); + EffectSsHahen_SpawnBurst(globalCtx, &sp38, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHiddenNuts* this = THIS; + + if (this->unk_218 != 0) { + this->unk_218--; + } + + Actor_SetFocus(&this->actor, 20.0f); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + Math_ApproachF(&this->actor.shape.yOffset, this->unk_228, 0.5f, 200.0f); + + if (this->unk_21A >= 4) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 40.0f, 0x1D); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnHiddenNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHiddenNuts* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} 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 08dc574fe..baff911b6 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 @@ -7,11 +7,30 @@ struct EnHiddenNuts; typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, GlobalContext*); +#define ENHIDDENNUTS_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define ENHIDDENNUTS_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) + typedef struct EnHiddenNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[10]; + /* 0x01C4 */ Vec3s morphTable[10]; /* 0x0200 */ EnHiddenNutsActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x7C]; + /* 0x0204 */ Path* path; + /* 0x0208 */ s16 unk_208; + /* 0x020A */ u8 unk_20A; + /* 0x020C */ Vec3f unk_20C; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 switchFlag; + /* 0x021E */ s16 unk_21E; + /* 0x0220 */ s32 unk_220; + /* 0x0224 */ s16 unk_224; + /* 0x0226 */ s16 unk_226; + /* 0x0228 */ f32 unk_228; + /* 0x022C */ f32 unk_22C; + /* 0x0230 */ UNK_TYPE1 unk230[4]; + /* 0x0234 */ ColliderCylinder collider; } EnHiddenNuts; // size = 0x280 extern const ActorInit En_Hidden_Nuts_InitVars; 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 28225d2f6..51a408e6e 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 @@ -125,14 +125,20 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0f }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static InitChainEntry sInitChain[] = { @@ -156,7 +162,7 @@ void EnHintSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3DE = 0; this->unk_3E0 = 0; this->unk_3DC = 0; - this->unk_3E9 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; func_80C1FE0C(this); } @@ -174,7 +180,7 @@ void func_80C1FE20(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C1FE30(EnHintSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->actionFunc = func_80C1FE80; } @@ -193,7 +199,7 @@ void func_80C1FE80(EnHintSkb* this, GlobalContext* globalCtx) { void func_80C1FF30(EnHintSkb* this) { this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80C1FF88; } @@ -266,12 +272,12 @@ void func_80C2016C(EnHintSkb* this, GlobalContext* globalCtx) { void func_80C20274(EnHintSkb* this) { if (this->skelAnime.animation == &object_skb_Anim_00697C) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -308,7 +314,7 @@ void func_80C20334(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C20484(EnHintSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->unk_3E8 |= 4; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; @@ -334,13 +340,13 @@ void func_80C20540(EnHintSkb* this) { } void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -348,7 +354,7 @@ void func_80C20590(EnHintSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80C20484(this); } - } else if (this->unk_3E2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80C21468(this, globalCtx); } } @@ -361,13 +367,13 @@ void func_80C2066C(EnHintSkb* this) { } void func_80C2069C(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 == 0) { - this->unk_3E2 = 0; - this->unk_2D8 = 0.0f; - this->unk_2D4 = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -389,18 +395,18 @@ void func_80C2077C(EnHintSkb* this, GlobalContext* globalCtx) { this->unk_3E0 = 1; if (this->unk_3DC == 0) { this->unk_3DC = 1; - func_801518B0(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(globalCtx, 0x1147, &this->actor); this->unk_3E6 = 0x1147; if (this->skelAnime.animation == &object_skb_Anim_00697C) { globalCtx->msgCtx.msgMode = 0x44; this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); } } else { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); - func_801518B0(globalCtx, 0x1148, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + Message_StartTextbox(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; } func_80C208BC(this); @@ -432,7 +438,7 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C2075C(this); } break; @@ -456,9 +462,9 @@ void func_80C208D0(EnHintSkb* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &object_skb_Anim_003584) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_801518B0(globalCtx, 0x1147, &this->actor); + Message_StartTextbox(globalCtx, 0x1147, &this->actor); this->unk_3E6 = 0x1147; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } } @@ -473,67 +479,67 @@ void func_80C20A74(EnHintSkb* this, GlobalContext* globalCtx) { switch (params) { case 1: - func_801518B0(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(globalCtx, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; case 2: - func_801518B0(globalCtx, 0x114A, &this->actor); + Message_StartTextbox(globalCtx, 0x114A, &this->actor); this->unk_3E6 = 0x114A; break; case 3: - func_801518B0(globalCtx, 0x114B, &this->actor); + Message_StartTextbox(globalCtx, 0x114B, &this->actor); this->unk_3E6 = 0x114B; break; case 4: - func_801518B0(globalCtx, 0x114C, &this->actor); + Message_StartTextbox(globalCtx, 0x114C, &this->actor); this->unk_3E6 = 0x114C; break; case 5: - func_801518B0(globalCtx, 0x114D, &this->actor); + Message_StartTextbox(globalCtx, 0x114D, &this->actor); this->unk_3E6 = 0x114D; break; case 6: - func_801518B0(globalCtx, 0x114E, &this->actor); + Message_StartTextbox(globalCtx, 0x114E, &this->actor); this->unk_3E6 = 0x114E; break; default: - func_801518B0(globalCtx, 0x1149, &this->actor); + Message_StartTextbox(globalCtx, 0x1149, &this->actor); this->unk_3E6 = 0x1149; break; } } void func_80C20B88(EnHintSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); this->unk_3E8 |= 0x10; - func_801518B0(globalCtx, 0x1150, &this->actor); + Message_StartTextbox(globalCtx, 0x1150, &this->actor); this->unk_3E6 = 0x1150; } else { func_8019F230(); - func_801518B0(globalCtx, 0x1152, &this->actor); + Message_StartTextbox(globalCtx, 0x1152, &this->actor); this->unk_3E6 = 0x1152; } } } void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { - if (!func_80147624(globalCtx)) { + if (!Message_ShouldAdvance(globalCtx)) { return; } switch (this->unk_3E6) { case 0x1147: - func_801518B0(globalCtx, 0x1148, &this->actor); + Message_StartTextbox(globalCtx, 0x1148, &this->actor); this->unk_3E6 = 0x1148; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); break; case 0x1148: @@ -546,17 +552,17 @@ void func_80C20C24(EnHintSkb* this, GlobalContext* globalCtx) { case 0x114C: case 0x114D: case 0x114E: - func_801518B0(globalCtx, 0x114F, &this->actor); + Message_StartTextbox(globalCtx, 0x114F, &this->actor); this->unk_3E6 = 0x114F; break; case 0x1152: - func_801518B0(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(globalCtx, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; case 0x1150: - func_801518B0(globalCtx, 0x1151, &this->actor); + Message_StartTextbox(globalCtx, 0x1151, &this->actor); this->unk_3E6 = 0x1151; break; @@ -582,7 +588,7 @@ void func_80C20D64(EnHintSkb* this, GlobalContext* globalCtx) { this->actor.hintId = 255; this->actor.textId = 0; if (this->actionFunc == func_80C1FE80) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); } func_80C2075C(this); } @@ -630,10 +636,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 9: case 10: case 11: - if (this->unk_3E2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80C21468(this, globalCtx); } - this->unk_3E2 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -649,10 +655,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E9 = 30; - this->unk_3E2 = 40; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80C2011C(this); break; @@ -663,10 +669,10 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3E2 = 80; - this->unk_3E9 = 0; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.0f; + this->drawDmgEffTimer = 80; + 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); this->unk_3E8 |= 1; @@ -675,24 +681,24 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3E2 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3E2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E9 = 11; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80C20540(this); break; case 4: - this->unk_3E2 = 40; - this->unk_3E9 = 20; - this->unk_2D4 = 1.0f; - this->unk_2D8 = 0.5f; + this->drawDmgEffTimer = 40; + 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_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80C2066C(this); break; @@ -709,7 +715,7 @@ void func_80C20E90(EnHintSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80C20274(this); break; @@ -741,20 +747,20 @@ void func_80C21250(EnHintSkb* this, GlobalContext* globalCtx) { } void func_80C21320(EnHintSkb* this, GlobalContext* globalCtx) { - if (this->unk_3E2 > 0) { - this->unk_3E2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80C20590) { - if (this->unk_3E2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80C2069C) { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2D8, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2D4 = this->unk_3E2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2D8, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -776,21 +782,21 @@ void func_80C21468(EnHintSkb* this, GlobalContext* globalCtx) { s32 i; if (this->unk_3E8 & 2) { - phi_s4 = ARRAY_COUNT(this->unk_22C) - 1; + phi_s4 = ARRAY_COUNT(this->limbPos) - 1; } else { - phi_s4 = ARRAY_COUNT(this->unk_22C); + phi_s4 = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < phi_s4; i++) { - temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C[i]); + temp_s1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(temp_s1) * 3.0f; sp84.z = Math_CosS(temp_s1) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_22C[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80C21E4C, &D_80C21E44, &D_80C21E48, 30); } } @@ -873,15 +879,15 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3E2 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80C21E70, &this->unk_22C[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80C21E70, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -890,13 +896,13 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnHintSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnHintSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnHintSkb_OverrideLimbDraw, EnHintSkb_PostLimbDraw, &this->actor); - if (this->unk_3E2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_22C, this->unk_2DC, this->unk_2D8, 0.5f, this->unk_2D4, - this->unk_3E9); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3E8 & 4) { diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h index e399638b7..b67e56352 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h @@ -15,21 +15,21 @@ typedef struct EnHintSkb { /* 0x0164 */ ColliderJntSphElement colliderElement[2]; /* 0x01E4 */ SkelAnime skelAnime; /* 0x0228 */ EnHintSkbActionFunc actionFunc; - /* 0x022C */ Vec3f unk_22C[14]; - /* 0x02D4 */ f32 unk_2D4; - /* 0x02D8 */ f32 unk_2D8; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ Vec3f limbPos[14]; + /* 0x02D4 */ f32 drawDmgEffAlpha; + /* 0x02D8 */ f32 drawDmgEffScale; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphtable[20]; /* 0x03D0 */ UNK_TYPE1 unk3D0[0xC]; /* 0x03DC */ s16 unk_3DC; /* 0x03DE */ s16 unk_3DE; /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; + /* 0x03E2 */ s16 drawDmgEffTimer; /* 0x03E4 */ s16 unk_3E4; /* 0x03E6 */ u16 unk_3E6; /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 unk_3E9; + /* 0x03E9 */ u8 drawDmgEffType; } EnHintSkb; // size = 0x3EC extern const ActorInit En_Hint_Skb_InitVars; diff --git a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c index 3c7eac5ae..78cfa14a0 100644 --- a/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c +++ b/src/overlays/actors/ovl_En_Hit_Tag/z_en_hit_tag.c @@ -6,7 +6,7 @@ #include "z_en_hit_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHitTag*)thisx) 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 ff418b579..8d5816c16 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -39,7 +39,7 @@ #include "z_en_holl.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHoll*)thisx) diff --git a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c index 3edd916d2..aaea88252 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -6,7 +6,7 @@ #include "z_en_honotrap.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHonotrap*)thisx) 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 e03114ea8..0e8dcb868 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -5,8 +5,9 @@ */ #include "z_en_horse.h" +#include "objects/object_horse_link_child/object_horse_link_child.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHorse*)thisx) @@ -15,7 +16,116 @@ void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8087D540(Actor* thisx, GlobalContext* globalCtx); +void EnHorse_StartMountedIdleResetAnim(EnHorse* this); +void EnHorse_StartMountedIdle(EnHorse* this); +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_MountedIdleAnim(EnHorse* this); +void EnHorse_MountedIdleWhinney(EnHorse* this); +void EnHorse_StartTurning(EnHorse* this); +void EnHorse_StartWalkingFromIdle(EnHorse* this); +void EnHorse_StartWalkingInterruptable(EnHorse* this); +void EnHorse_StartWalking(EnHorse* this); +void EnHorse_StartTrotting(EnHorse* this); +void EnHorse_StartGallopingInterruptable(EnHorse* this); +void EnHorse_StartGalloping(EnHorse* this); +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartReversingInterruptable(EnHorse* this); +void EnHorse_StartReversing(EnHorse* this); +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitInactive(EnHorse* this); +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames); +void EnHorse_ResetIdleAnimation(EnHorse* this); +void EnHorse_StartIdleRidable(EnHorse* this); +void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames); +void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitIngoHorse(EnHorse* this); +void EnHorse_UpdateIngoHorseAnim(EnHorse* this); +void func_80881290(EnHorse* this, GlobalContext* globalCtx); +void func_8088159C(EnHorse* this, GlobalContext* globalCtx); +void func_80881634(EnHorse* this); +void func_8088168C(EnHorse* this); +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_InitHorsebackArchery(EnHorse* this); +void EnHorse_UpdateHbaAnim(EnHorse* this); +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883DE0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883EA0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F18(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80883F98(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884010(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808843B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808844E0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action); +void func_808846F0(EnHorse* this, GlobalContext* globalCtx); +void func_80884994(EnHorse* this); +void func_80884D04(EnHorse* this, GlobalContext* globalCtx); +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle); +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx); + +typedef struct { + s32 csAction; + s32 csFuncIdx; +} CsActionEntry; + +typedef struct { + s16 x; + s16 y; + s16 z; + s16 speed; + s16 angle; +} RaceWaypoint; + +typedef struct { + s32 numWaypoints; + RaceWaypoint* waypoints; +} RaceInfo; + +static AnimationHeader* sEponaAnimHeaders[] = { + &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468, &object_horse_link_child_Anim_005F64, + &object_horse_link_child_Anim_004DE8, &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, + &object_horse_link_child_Anim_002F98, &object_horse_link_child_Anim_0035B0, &object_horse_link_child_Anim_003D38, +}; + +static AnimationHeader* sHniAnimHeaders[] = { + &object_ha_Anim_00C850, &object_ha_Anim_00CE70, &object_ha_Anim_00B9C8, + &object_ha_Anim_00B00C, &object_ha_Anim_00D648, &object_ha_Anim_00A650, + &object_ha_Anim_009208, &object_ha_Anim_009858, &object_ha_Anim_00A05C, +}; + +static AnimationHeader** sAnimationHeaders[] = { + NULL, NULL, sEponaAnimHeaders, sHniAnimHeaders, sHniAnimHeaders, +}; + +static f32 sPlaybackSpeeds[] = { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f / 3.0f, 2.0f / 3.0f }; + +static SkeletonHeader* sSkeletonHeaders[] = { + NULL, NULL, &object_horse_link_child_Skel_00A480, NULL, NULL, +}; + const ActorInit En_Horse_InitVars = { ACTOR_EN_HORSE, ACTORCAT_BG, @@ -28,370 +138,4617 @@ const ActorInit En_Horse_InitVars = { (ActorFunc)EnHorse_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888F74 = { - { COLTYPE_NONE, AT_NONE | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000004, 0x00, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80888FA0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, - { 20, 70, 0, { 0, 0, 0 } }, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80888FCC[1] = { +static ColliderCylinderInit sCylinderInit1 = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00013820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_ON, }, + COLTYPE_NONE, + AT_NONE | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000004, 0x00, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { 20, 70, 0, { 0, 0, 0 } }, +}; + +static ColliderJntSphElementInit sJntSphElementsInit[] = { + { + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00013820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_ON, + }, { 13, { { 0, 0, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80888FF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1 | OC2_UNK1, COLSHAPE_JNTSPH, }, - 1, D_80888FCC, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1 | OC2_UNK1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80889000 = { 10, 35, 100, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 10, 35, 100, MASS_HEAVY }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80889010[] = { +static s32 sAnimSoundFrames[] = { + 0, + 16, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; +static u8 sResetNoInput[] = { + false, false, false, false, false, false, true, true, true, true, true, true, + true, true, true, false, false, false, false, false, false, false, false, false, +}; + +static s32 sIdleAnimIds[] = { + 1, 3, 0, 3, 1, 0, +}; + +static s16 sIngoAnimations[] = { 7, 6, 2, 2, 1, 1, 0, 0, 0, 0 }; + +static EnHorseCsFunc sCutsceneInitFuncs[] = { + NULL, + EnHorse_CsMoveInit, + EnHorse_CsJumpInit, + EnHorse_CsRearingInit, + EnHorse_WarpMoveInit, + EnHorse_CsWarpRearingInit, +}; + +static EnHorseCsFunc sCutsceneActionFuncs[] = { + NULL, EnHorse_CsMoveToPoint, EnHorse_CsJump, EnHorse_CsRearing, EnHorse_CsWarpMoveToPoint, EnHorse_CsWarpRearing, +}; + +static CsActionEntry sCsActionTable[] = { + { 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, +}; + +static RaceWaypoint sHbaWaypoints[] = { + { 3600, 1413, -5055, 11, 0x8001 }, { 3360, 1413, -5220, 5, 0xC000 }, { 3100, 1413, -4900, 5, 0x0000 }, + { 3600, 1413, -4100, 11, 0x0000 }, { 3600, 1413, 360, 11, 0x0000 }, +}; + +static RaceInfo sHbaInfo = { 5, sHbaWaypoints }; + +static EnHorseCsFunc D_808890F0[] = { + NULL, func_80883BEC, func_80883D64, func_80883E10, func_80883F18, func_80884010, + func_80884194, func_80884314, func_80884444, func_80884564, func_808846B4, +}; + +static EnHorseCsFunc D_8088911C[] = { + NULL, func_80883CB0, func_80883DE0, func_80883EA0, func_80883F98, func_808840C4, + func_8088424C, func_808843B4, func_808844E0, func_80884604, func_808846DC, +}; + +void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { + pos->x = waypoints[idx].x; + pos->y = waypoints[idx].y; + pos->z = waypoints[idx].z; +} + +void EnHorse_RotateToPoint(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, s16 turnAmount) { + func_800F415C(&this->actor, pos, turnAmount); +} + +void func_8087B7C0(EnHorse* this, GlobalContext* globalCtx, Path* path) { + s32 spA4; + Vec3s* spA0; + f32 phi_f12; + f32 phi_f14; + Vec3f sp8C; + Vec3f sp80; + f32 sp7C; + f32 sp78; + f32 sp74; + f32 sp70; + s32 i; + s32 sp68; + f32 sp64; + s32 sp60; + f32 temp_f0; + Vec3f sp50; + + spA4 = path->count; + spA0 = Lib_SegmentedToVirtual(path->points); + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + + if (this->curRaceWaypoint == 0) { + phi_f12 = spA0[1].x - spA0[0].x; + phi_f14 = spA0[1].z - spA0[0].z; + } else if ((this->curRaceWaypoint + 1) == path->count) { + phi_f12 = spA0[path->count - 1].x - spA0[path->count - 2].x; + phi_f14 = spA0[path->count - 1].z - spA0[path->count - 2].z; + } else { + phi_f12 = spA0[this->curRaceWaypoint + 1].x - spA0[this->curRaceWaypoint - 1].x; + phi_f14 = spA0[this->curRaceWaypoint + 1].z - spA0[this->curRaceWaypoint - 1].z; + } + + func_8017B7F8(&sp8C, Math_Atan2S(phi_f12, phi_f14), &sp7C, &sp78, &sp74); + + if (((this->actor.world.pos.x * sp7C) + (sp78 * this->actor.world.pos.z) + sp74) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= spA4) { + this->curRaceWaypoint = spA4 - 1; + } + Math_Vec3s_ToVec3f(&sp8C, &spA0[this->curRaceWaypoint]); + } + + if (this->curRaceWaypoint == 0) { + Math_Vec3s_ToVec3f(&sp80, &spA0[1]); + } else { + Math_Vec3s_ToVec3f(&sp80, &spA0[this->curRaceWaypoint - 1]); + } + + 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)) { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0xC80); + if (this->unk_1EC & 4) { + this->unk_1EC &= ~4; + } + } else { + EnHorse_RotateToPoint(this, globalCtx, &sp8C, 0x320); + if (sp70 < SQ(100.0f)) { + if ((this->actor.xzDistToPlayer < 100.0f) || + (this->colliderJntSph.elements[0].info.ocElemFlags & OCELEM_HIT)) { + s32 pad; + + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y -= 0x1E0; + } else { + this->actor.world.rot.y += 0x1E0; + } + } else if (this->actor.xzDistToPlayer < 300.0f) { + if (Math_SinS(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0.0f) { + this->actor.world.rot.y += 0x1E0; + } else { + this->actor.world.rot.y -= 0x1E0; + } + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + } + + sp68 = this->curRaceWaypoint - 3; + if (sp68 < 0) { + sp68 = 0; + } + + sp64 = 1.0e+38; + sp60 = sp68 + 5; + if (path->count < sp60) { + sp60 = path->count; + } + + for (i = sp68; i < sp60; i++) { + Math_Vec3s_ToVec3f(&sp50, &spA0[i]); + temp_f0 = Math3D_Distance(&this->actor.world.pos, &sp50); + if (temp_f0 < sp64) { + sp64 = temp_f0; + sp68 = i; + } + } + + this->unk_398 = spA0[this->curRaceWaypoint].y * 0.01f; + if ((this->unk_1EC & 0x100) && !(this->stateFlags & ENHORSE_JUMPING) && + ((this->colliderCylinder1.base.acFlags & AC_HIT) || (this->colliderCylinder2.base.acFlags & AC_HIT) || + (this->unk_58C > 0))) { + if (this->unk_58C == 0) { + this->unk_590 = 0x1F4; + this->unk_58C = 0x2B; + } + this->unk_58C--; + if (this->actor.speedXZ > 5.0f) { + this->actor.speedXZ -= 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); + } + } + this->unk_590--; + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 1.0f; + } else { + this->actor.speedXZ -= 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; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + return; + } + + sp4A = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->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; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else if (sp68 >= this->curRaceWaypoint) { + if (this->actor.speedXZ < this->unk_398) { + this->actor.speedXZ += 0.5f; + } else { + this->actor.speedXZ -= 0.5f; + } + this->unk_394 |= 1; + } else if ((sp68 + 1) == this->curRaceWaypoint) { + s16 sp48 = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->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; + } else { + this->actor.speedXZ -= 0.25f; + } + this->unk_394 |= 1; + } else { + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } + } else { + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ += 0.4f; + } else { + this->actor.speedXZ -= 0.2f; + } + this->unk_394 &= ~1; + } +} + +void EnHorse_PlayWalkingSound(EnHorse* this) { + if (sAnimSoundFrames[this->soundTimer] < this->curFrame) { + if ((this->soundTimer == 0) && (sAnimSoundFrames[1] < this->curFrame)) { + return; + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_WALK); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_WALK); + } + + this->soundTimer++; + if (this->soundTimer > 1) { + this->soundTimer = 0; + } + } +} + +void func_8087C178(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +void func_8087C1C0(EnHorse* this) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } +} + +f32 EnHorse_SlopeSpeedMultiplier(EnHorse* this, GlobalContext* globalCtx) { + f32 multiplier = 1.0f; + + if ((Math_CosS(this->actor.shape.rot.x) < 0.939262f) && (Math_SinS(this->actor.shape.rot.x) < 0.0f)) { + multiplier = 0.7f; + } + return multiplier; +} + +void func_8087C288(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); +} + +s32 func_8087C2B8(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2, f32 arg3) { + f32 phi_f14; + + if ((arg2->z > 0.0f) && (arg2->z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale))) { + if (arg3 < 1.0f) { + phi_f14 = 1.0f; + } else { + phi_f14 = 1.0f / arg3; + } + + if (((fabsf(arg2->x) * phi_f14) < 1.0f) && (((arg2->y + this->actor.uncullZoneDownward) * phi_f14) > -1.0f) && + (((arg2->y - this->actor.uncullZoneScale) * phi_f14) < 1.0f)) { + return true; + } + } + return false; +} + +s32 func_8087C38C(GlobalContext* globalCtx, EnHorse* this, Vec3f* arg2) { + Vec3f sp24; + f32 sp20; + f32 eyeDist; + + func_8087C288(globalCtx, arg2, &sp24, &sp20); + + if (fabsf(sp20) < 0.008f) { + return false; + } + + eyeDist = Math3D_Distance(arg2, &globalCtx->view.eye); + + return func_8087C2B8(globalCtx, this, &sp24, sp20) || (eyeDist < 100.0f); +} + +void EnHorse_IdleAnimSounds(EnHorse* this, GlobalContext* globalCtx) { + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && + (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI)) || + ((this->curFrame > 25.0f) && (this->type == HORSE_2))) && + !(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } else if ((this->animationIdx == 3) && (this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } +} + +s32 EnHorse_Spawn(EnHorse* this, GlobalContext* globalCtx) { + s32 i; + f32 dist; + Path* path; + s32 spawn = false; + f32 minDist = 1.0e+38; + Player* player = GET_PLAYER(globalCtx); + Vec3f spawnPos; + s32 pathIdx = func_800F3940(globalCtx); + s32 pathCount; + Vec3s* pathPoints; + + if (pathIdx == -1) { + return false; + } + + path = &globalCtx->setupPathList[pathIdx]; + pathCount = path->count; + pathPoints = Lib_SegmentedToVirtual(path->points); + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if ((minDist < dist) || func_8087C38C(globalCtx, this, &spawnPos)) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + 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(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + if (spawn == true) { + return true; + } + + for (i = 0; i < pathCount; i++) { + spawnPos.x = pathPoints[i].x; + spawnPos.y = pathPoints[i].y; + spawnPos.z = pathPoints[i].z; + dist = Math3D_Distance(&player->actor.world.pos, &spawnPos); + + if (minDist < dist) { + continue; + } + + minDist = dist; + this->actor.world.pos.x = spawnPos.x; + this->actor.world.pos.y = spawnPos.y; + 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(globalCtx)->actor); + spawn = true; + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->actor.world.pos, &this->actor.projectedPos, + &this->actor.projectedW); + } + + return spawn; +} + +void EnHorse_ResetCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->cutsceneAction = -1; + this->cutsceneFlags = 0; +} + +void EnHorse_ResetRace(EnHorse* this, GlobalContext* globalCtx) { + this->inRace = false; +} + +s32 EnHorse_PlayerCanMove(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 1) || (func_800B7128(GET_PLAYER(globalCtx)) == true) || + (player->stateFlags1 & 0x100000) || + (((this->stateFlags & ENHORSE_FLAG_19) || (this->stateFlags & ENHORSE_FLAG_29)) && !this->inRace) || + (this->action == 19) || (player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20) || (player->csMode != 0)) { + return false; + } + return true; +} + +void EnHorse_ResetHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + this->unk_39C = 0; + this->hbaStarted = 0; + this->hbaFlags = 0; +} + +void EnHorse_ClearDustFlags(u16* dustFlags) { + *dustFlags = 0; +} + +void func_8087C9F8(EnHorse* this) { +} + +void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { +} + +#ifdef NON_MATCHING +void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnHorse* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + EnHorse_ClearDustFlags(&this->dustFlags); + D_801BDAA4 = 0; + Skin_Setup(&this->skin); + this->riderPos = this->actor.world.pos; + this->unk_52C = 0; + this->noInputTimer = 0; + this->riderPos.y += 70.0f; + this->noInputTimerMax = 0; + this->unk_1EC = 0; + this->unk_58C = 0; + this->unk_590 = 0; + this->unk_3E8 = 0.0f; + this->unk_528 = 100.0f; + + if (ENHORSE_GET_8000(&this->actor)) { + this->type = HORSE_4; + this->unk_528 = 80.0f; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + this->actor.update = func_8087D540; + } else if (ENHORSE_GET_4000(&this->actor)) { + this->type = HORSE_2; + this->unk_528 = 64.8f; + this->boostSpeed = 15; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD)) < 0) { + this->actor.objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); + Actor_SetObjectDependency(globalCtx, &this->actor); + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->unk_1EC |= 0x200; + } else { + this->actor.update = func_8087D540; + } + } else if (ENHORSE_GET_2000(&this->actor)) { + this->type = HORSE_3; + this->boostSpeed = 12; + if ((this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_HA)) < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + this->unk_1EC |= 1; + this->actor.update = func_8087D540; + } else { + this->type = HORSE_EPONA; + this->boostSpeed = 15; + Actor_MarkForDeath(&this->actor); + } + + this->actor.params &= ~0xE000; + if (this->actor.params == 0x1FFF) { + this->actor.params = ENHORSE_1; + } + + if (this->actor.params == ENHORSE_3) { + this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else if (this->actor.params == ENHORSE_8) { + this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; + if (CHECK_QUEST_ITEM(14)) { + this->stateFlags &= ~ENHORSE_CANT_JUMP; + this->stateFlags |= ENHORSE_FLAG_26; + } + } else if (this->actor.params == ENHORSE_13) { + this->stateFlags = ENHORSE_FLAG_29; + this->unk_1EC |= 0x10; + } else if (this->actor.params == ENHORSE_4) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_5) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_15) { + this->stateFlags = ENHORSE_UNRIDEABLE | ENHORSE_FLAG_7; + } else if (this->actor.params == ENHORSE_17) { + this->stateFlags = 0; + this->unk_1EC |= 8; + } else if (this->actor.params == ENHORSE_18) { + this->stateFlags = ENHORSE_FLAG_29 | ENHORSE_CANT_JUMP; + this->actor.flags |= ACTOR_FLAG_80000000; + } else if (this->actor.params == ENHORSE_1) { + this->stateFlags = ENHORSE_FLAG_7; + } else if ((this->actor.params == ENHORSE_19) || (this->actor.params == ENHORSE_20)) { + this->stateFlags = ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; + } else { + this->stateFlags = 0; + } + + if (((globalCtx->sceneNum == SCENE_KOEPONARACE) && ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 1)) || + ((gSaveContext.save.entranceIndex == 0x6400) && Cutscene_GetSceneSetupIndex(globalCtx))) { + this->stateFlags |= ENHORSE_FLAG_25; + } + + this->actor.gravity = -3.5f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawHorse, 20.0f); + this->action = ENHORSE_ACT_IDLE; + this->actor.speedXZ = 0.0f; + + if (this->type == HORSE_2) { + sJntSphInit.elements[0].dim.limb = 13; + } else if ((this->type == HORSE_3) || (this->type == HORSE_4)) { + sJntSphInit.elements[0].dim.limb = 10; + } + + Collider_InitCylinder(globalCtx, &this->colliderCylinder1); + Collider_SetCylinder(globalCtx, &this->colliderCylinder1, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->colliderCylinder2); + Collider_SetCylinder(globalCtx, &this->colliderCylinder2, &this->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, this->colliderJntSphElements); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.radius = this->colliderCylinder1.dim.radius * 0.8f; + this->colliderCylinder2.dim.radius = this->colliderCylinder2.dim.radius * 0.8f; + this->colliderJntSph.elements[0].dim.modelSphere.radius *= 0.6f; + } else if (this->type == HORSE_4) { + this->colliderCylinder1.dim.radius = 50; + } + + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + this->actor.focus.pos = this->actor.world.pos; + this->playerControlled = false; + this->actor.focus.pos.y += 70.0f; + + if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (this->actor.update == EnHorse_Update)) { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + + this->animationIdx = 0; + this->numBoosts = 6; + this->boostRegenTime = 0; + this->postDrawFunc = NULL; + this->blinkTimer = 0; + + EnHorse_ResetCutscene(this, globalCtx); + EnHorse_ResetRace(this, globalCtx); + EnHorse_ResetHorsebackArchery(this, globalCtx); + + if (this->actor.params == ENHORSE_2) { + this->unk_53C = 0; + EnHorse_InitInactive(this); + } else if (this->actor.params == ENHORSE_3) { + EnHorse_InitIngoHorse(this); + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, 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, 1, 1); + this->unk_398 = 14.34f; + } else if (this->actor.params == ENHORSE_4) { + func_80881634(this); + this->unk_398 = 14.34f; + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, 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, 1, 1); + this->unk_1EC |= 0x100; + } else if (this->actor.params == ENHORSE_5) { + func_80881634(this); + this->unk_398 = 14.525f; + this->rider = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, 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, 1, 2); + this->unk_1EC |= 0x100; + } else if (this->actor.params == ENHORSE_9) { + EnHorse_InitCutscene(this, globalCtx); + } else if (this->actor.params == ENHORSE_10) { + EnHorse_InitHorsebackArchery(this); + Interface_InitMinigame(globalCtx); + } else if (this->actor.params == ENHORSE_14) { + func_808846F0(this, globalCtx); + if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { + Actor_MarkForDeath(&this->actor); + } + } else if (this->actor.params == ENHORSE_16) { + func_8087C9F8(this); + } else if (this->actor.params == ENHORSE_15) { + EnHorse_ResetIdleAnimation(this); + } else if (this->actor.params == ENHORSE_18) { + func_80884994(this); + } else if (this->actor.params == ENHORSE_19) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, 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, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x4); + } else if (this->actor.params == ENHORSE_20) { + EnIn* in; + + func_80884D04(this, globalCtx); + in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, 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, 1, 1); + this->rider = in; + in->unk4AC |= (0x20 | 0x8 | 0x4); + } else { + EnHorse_StartIdleRidable(this); + } + + this->actor.shape.rot.z = 0; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.home.rot.z = this->actor.shape.rot.z; + this->unk_3EC = this->actor.world.rot.y; + this->unk_538 = 0; + + if (this->unk_1EC & 0x100) { + this->colliderCylinder1.base.colType = COLTYPE_HIT3; + this->colliderCylinder1.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder1.info.bumperFlags |= BUMP_ON; + this->colliderCylinder1.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + this->colliderCylinder2.base.colType = COLTYPE_HIT3; + this->colliderCylinder2.base.acFlags |= (AC_TYPE_PLAYER | AC_ON); + this->colliderCylinder2.info.bumperFlags |= BUMP_ON; + this->colliderCylinder2.info.bumper.dmgFlags = 0x10000 | 0x2000 | 0x1000 | 0x800 | 0x20; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") #endif -extern ColliderCylinderInit D_80888F74; -extern ColliderCylinderInit D_80888FA0; -extern ColliderJntSphElementInit D_80888FCC[1]; -extern ColliderJntSphInit D_80888FF0; -extern CollisionCheckInfoInit D_80889000; -extern InitChainEntry D_80889010[]; - -extern UNK_TYPE D_06008C68; -extern UNK_TYPE D_0600A8DC; -extern UNK_TYPE D_0600AD08; -extern UNK_TYPE D_0600B3E0; -extern UNK_TYPE D_0600BDE0; -extern UNK_TYPE D_0600D178; -extern UNK_TYPE D_0600D4E8; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B730.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087B7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C0AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C178.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C1C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C208.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C2B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C38C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C43C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C8E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087C9F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087CA04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D540.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D70C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D75C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D814.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087D988.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DDEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DE28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087DF64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E0A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E18C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E2A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E350.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E5D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E684.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E6D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E92C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087E9D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EA1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EB78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EC78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087ED10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087EEC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F1FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F39C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F5B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F658.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087F9C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FB14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FD94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FDB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8087FF14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808801F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808802D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808804CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880500.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880534.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808806DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880844.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880978.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880DA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80880E00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881128.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088126C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881290.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881398.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088159C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881634.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088168C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808819D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881BDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881C54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881DC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80881F48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808821C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808822CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088247C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808826B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808829F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882B9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882D8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80882DC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883104.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883308.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883B70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883BEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883CB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883D64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883DE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883E10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80883F98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808840C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088424C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884314.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808843B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884444.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808844E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884564.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884604.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808846F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884718.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884868.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808848C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884994.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884A40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884D04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80884E0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885060.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808850DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885220.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808853E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_8088598C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885AF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885B4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885C90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80885DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886C00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886DC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80886FA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808870A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_808871A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887270.s") - +void func_8087D540(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { + this->actor.objBankIndex = this->bankIndex; + Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.update = EnHorse_Update; + if (this->unk_1EC & 1) { + if (this->type == HORSE_3) { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_008C68, NULL, this->jointTable, + this->morphTable, OBJECT_HA_1_LIMB_MAX); + } else { + SkelAnime_InitFlex(globalCtx, &this->skin.skelAnime, &object_ha_Skel_0150D8, NULL, this->jointTable, + this->morphTable, OBJECT_HA_2_LIMB_MAX); + } + } else { + Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + } + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } +} + +void EnHorse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (this->stateFlags & ENHORSE_DRAW) { + Audio_StopSfxByPos(&this->unk_218); + } + Skin_Free(&globalCtx->state, &this->skin); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder1); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder2); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} + +void EnHorse_RotateToPlayer(EnHorse* this, GlobalContext* globalCtx) { + EnHorse_RotateToPoint(this, globalCtx, &GET_PLAYER(globalCtx)->actor.world.pos, 0x320); + if (this->stateFlags & ENHORSE_OBSTACLE) { + this->actor.world.rot.y += 1600; + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_Freeze(EnHorse* this, GlobalContext* globalCtx) { + if ((this->action != ENHORSE_ACT_HBA) && (this->action != ENHORSE_ACT_21) && + (this->action != ENHORSE_ACT_FLEE_PLAYER)) { + if (sResetNoInput[this->actor.params] && (this->actor.params != ENHORSE_6)) { + Player* player = GET_PLAYER(globalCtx); + + this->noInputTimerMax = 0; + this->noInputTimer = 0; + player->actor.world.pos = this->actor.world.pos; + player->actor.world.pos.y += 70.0f; + } + this->prevAction = this->action; + this->action = ENHORSE_ACT_FROZEN; + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->animationIdx = ENHORSE_ANIM_IDLE; + } +} + +void EnHorse_Frozen(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->noInputTimer--; + if (this->noInputTimer < 0) { + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + if (this->playerControlled == true) { + this->stateFlags &= ~ENHORSE_FLAG_7; + if (this->actor.params == ENHORSE_6) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (this->actor.params == ENHORSE_11) { + this->actor.params = ENHORSE_7; + if (globalCtx->csCtx.state != 0) { + EnHorse_StartMountedIdle(this); + } else { + this->actor.speedXZ = 8.0f; + EnHorse_StartGalloping(this); + } + } else if (this->prevAction == ENHORSE_ACT_IDLE) { + EnHorse_StartMountedIdle(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->actor.params != ENHORSE_0) { + this->actor.params = ENHORSE_0; + } + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_TURN) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else if (this->prevAction == ENHORSE_ACT_MOUNTED_WALK) { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } else { + EnHorse_ChangeIdleAnimation(this, 0, 0.0f); + } + } +} + +void EnHorse_UpdateSpeed(EnHorse* this, GlobalContext* globalCtx, f32 brakeDecel, f32 brakeAngle, f32 minStickMag, + f32 decel, f32 baseSpeed, s16 turnSpeed) { + f32 phi_f0; + f32 stickMag; + s16 stickAngle; + s16 turn; + f32 temp_f12; + + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ -= decel; + } else if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + return; + } + + baseSpeed *= EnHorse_SlopeSpeedMultiplier(this, globalCtx); + 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); + 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; + } + return; + } + + if (this->stateFlags & ENHORSE_BOOST) { + if ((16 - this->boostTimer) > 0) { + this->actor.speedXZ = + (((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) - this->actor.speedXZ) / + (16.0f - this->boostTimer)) + + this->actor.speedXZ; + } else { + this->actor.speedXZ = EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed; + } + + if ((EnHorse_SlopeSpeedMultiplier(this, globalCtx) * this->boostSpeed) <= this->actor.speedXZ) { + 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; + this->stateFlags &= ~ENHORSE_BOOST_DECEL; + } + } else { + if (this->actor.speedXZ <= (baseSpeed * (1.0f / 54.0f) * stickMag)) { + phi_f0 = 1.0f; + } else { + phi_f0 = -1.0f; + } + + this->actor.speedXZ += phi_f0 * 50.0f * 0.01f; + + if (this->actor.speedXZ > baseSpeed) { + this->actor.speedXZ -= decel; + if (this->actor.speedXZ < baseSpeed) { + this->actor.speedXZ = 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)))); + this->actor.world.rot.y += turn; + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void EnHorse_StartMountedIdleResetAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartMountedIdle(this); + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; +} + +void EnHorse_StartMountedIdle(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_TURN; + this->animationIdx = ENHORSE_ANIM_IDLE; + + if (((this->curFrame > 35.0f) && (this->type == HORSE_EPONA)) || + ((this->curFrame > 28.0f) && (this->type == HORSE_HNI))) { + if (!(this->stateFlags & ENHORSE_SANDDUST_SOUND)) { + this->stateFlags |= ENHORSE_SANDDUST_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedIdle(EnHorse* this, GlobalContext* globalCtx) { + f32 mag; + s16 angle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &mag, &angle); + if (mag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(angle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(angle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_MountedIdleAnim(this); + } +} + +void EnHorse_MountedIdleAnim(EnHorse* this) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_MountedIdleWhinney(this); +} + +void EnHorse_MountedIdleWhinney(EnHorse* this) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_WALK; + this->animationIdx = ENHORSE_ANIM_WHINNEY; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][1]), ANIMMODE_ONCE, -3.0f); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } +} + +void EnHorse_MountedIdleWhinneying(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle = 0; + + this->actor.speedXZ = 0.0f; + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartWalkingFromIdle(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + EnHorse_StartMountedIdleResetAnim(this); + } +} + +void EnHorse_StartTurning(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_TROT; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTurn(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 clampedYaw; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + EnHorse_PlayWalkingSound(this); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (stickMag > 10.0f) { + if (!EnHorse_PlayerCanMove(this, globalCtx)) { + EnHorse_StartMountedIdleResetAnim(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else if (Math_CosS(stickAngle) <= 0.7071f) { + clampedYaw = CLAMP(stickAngle, -1600.0f, 1600.0f); + this->actor.world.rot.y += clampedYaw; + this->actor.shape.rot.y = this->actor.world.rot.y; + } else { + EnHorse_StartWalkingInterruptable(this); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (Math_CosS(stickAngle) <= 0.7071f) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else if (this->unk_3EC != this->actor.world.rot.y) { + EnHorse_StartTurning(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartWalkingFromIdle(EnHorse* this) { + EnHorse_StartWalkingInterruptable(this); + if (!(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + this->stateFlags |= ENHORSE_FLAG_9; + this->waitTimer = 8; + } else { + this->waitTimer = 0; + } +} + +void EnHorse_StartWalkingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartWalking(this); +} + +void EnHorse_StartWalking(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][4]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedWalkingReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_GALLOP; + this->soundTimer = 0; + this->animationIdx = ENHORSE_ANIM_WALK; + this->waitTimer = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedWalk(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 3.0f, 0x320); + } else { + this->actor.speedXZ = 3.0f; + } + + if (this->actor.speedXZ == 0.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if (this->actor.speedXZ > 3.0f) { + this->stateFlags &= ~ENHORSE_FLAG_9; + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + 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) { + EnHorse_StartTrotting(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else if ((stickMag < 10.0f) || (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartMountedIdleResetAnim(this); + this->noInputTimer = 0; + this->noInputTimerMax = 0; + } else { + EnHorse_MountedWalkingReset(this); + } + } + } else { + this->waitTimer--; + this->actor.speedXZ = 0.0f; + } +} + +void EnHorse_StartTrotting(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedTrotReset(EnHorse* this) { + this->action = ENHORSE_ACT_MOUNTED_REARING; + this->animationIdx = ENHORSE_ANIM_TROT; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_MountedTrot(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 6.0f, 800); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C178(this); + func_8013ECE0(0.0f, 60, 8, 255); + if (this->actor.speedXZ >= 6.0f) { + EnHorse_StartGallopingInterruptable(this); + } else if (this->actor.speedXZ < 3.0f) { + EnHorse_StartWalkingInterruptable(this); + } else { + EnHorse_MountedTrotReset(this); + } + } +} + +void EnHorse_StartGallopingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartGalloping(this); +} + +void EnHorse_StartGalloping(EnHorse* this) { + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedGallopReset(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->unk_230 = 0; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); +} + +void EnHorse_JumpLanding(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_STOPPING; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void EnHorse_MountedGallop(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (this->noInputTimer <= 0) { + EnHorse_UpdateSpeed(this, globalCtx, 0.3f, -0.5f, 10.0f, 0.06f, 8.0f, 800); + } else if (this->noInputTimer > 0) { + this->noInputTimer--; + this->actor.speedXZ = 8.0f; + } + + if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((stickMag >= 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + EnHorse_StartBraking(this, globalCtx); + } else if (this->actor.speedXZ < 6.0f) { + EnHorse_StartTrotting(this); + } else { + EnHorse_MountedGallopReset(this); + } + } else { + EnHorse_MountedGallopReset(this); + } + } +} + +void EnHorse_StartRearing(EnHorse* this) { + this->action = ENHORSE_ACT_REVERSE; + this->animationIdx = ENHORSE_ANIM_REARING; + + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + func_8013ECE0(0.0f, 180, 20, 100); + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_MountedRearing(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + func_8013ECE0(0.0f, 180, 20, 100); + } + } + + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + EnHorse_StartReversing(this); + } else if (this->stateFlags & ENHORSE_FORCE_WALKING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + this->stateFlags &= ~ENHORSE_FORCE_WALKING; + EnHorse_StartWalking(this); + } else if (Math_CosS(stickAngle) <= -0.5f) { + EnHorse_StartReversingInterruptable(this); + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartBraking(EnHorse* this, GlobalContext* globalCtx) { + this->action = ENHORSE_ACT_LOW_JUMP; + this->animationIdx = ENHORSE_ANIM_STOPPING; + if (sAnimationHeaders[this->type][this->animationIdx] == NULL) { + if (Rand_ZeroOne() > 0.5f) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } + EnHorse_StartMountedIdleResetAnim(this); + } + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_SLIP); + } + + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->stateFlags |= ENHORSE_STOPPING_NEIGH_SOUND; + this->stateFlags &= ~ENHORSE_BOOST; +} + +void EnHorse_Stopping(EnHorse* this, GlobalContext* globalCtx) { + if (this->actor.speedXZ > 0.0f) { + this->actor.speedXZ -= 0.6f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if ((this->stateFlags & ENHORSE_STOPPING_NEIGH_SOUND) && (this->skin.skelAnime.curFrame > 29.0f)) { + this->actor.speedXZ = 0.0f; + if ((Rand_ZeroOne() > 0.5f) && + ((gSaveContext.save.entranceIndex != 0x6400) || !Cutscene_GetSceneSetupIndex(globalCtx))) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags &= ~ENHORSE_STOPPING_NEIGH_SOUND; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } + + 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; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->stateFlags & ENHORSE_FORCE_REVERSING) { + this->noInputTimer = 100; + this->noInputTimerMax = 100; + EnHorse_StartReversing(this); + this->stateFlags &= ~ENHORSE_FORCE_REVERSING; + } else { + EnHorse_StartMountedIdleResetAnim(this); + } + } +} + +void EnHorse_StartReversingInterruptable(EnHorse* this) { + this->noInputTimer = 0; + this->noInputTimerMax = 0; + EnHorse_StartReversing(this); +} + +void EnHorse_StartReversing(EnHorse* this) { + this->action = ENHORSE_ACT_HIGH_JUMP; + this->animationIdx = ENHORSE_ANIM_WALK; + this->soundTimer = 0; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, -3.0f); +} + +void EnHorse_Reverse(EnHorse* this, GlobalContext* globalCtx) { + f32 stickMag; + s16 stickAngle; + s16 turnAmount; + Player* player = GET_PLAYER(globalCtx); + + EnHorse_PlayWalkingSound(this); + EnHorse_StickDirection(&this->curStick, &stickMag, &stickAngle); + if (EnHorse_PlayerCanMove(this, globalCtx) == true) { + if ((this->noInputTimerMax == 0) || + ((this->noInputTimer > 0) && (this->noInputTimer < (this->noInputTimerMax - 20)))) { + if ((stickMag < 10.0f) && (this->noInputTimer <= 0)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 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; + return; + } + } else if (stickMag < 10.0f) { + stickAngle = -0x7FFF; + } + } else if ((player->actor.flags & ACTOR_FLAG_100) || (globalCtx->csCtx.state != 0) || + (ActorCutscene_GetCurrentIndex() != -1) || (player->stateFlags1 & 0x20)) { + EnHorse_StartMountedIdleResetAnim(this); + this->actor.speedXZ = 0.0f; + return; + } else { + stickAngle = -0x7FFF; + } + + this->actor.speedXZ = -2.0f; + turnAmount = -0x8000 - stickAngle; + turnAmount = CLAMP(turnAmount, -2400.0f, 2400.0f); + this->actor.world.rot.y += turnAmount; + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->noInputTimer > 0) { + this->noInputTimer--; + if (this->noInputTimer <= 0) { + this->noInputTimerMax = 0; + } + } + + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.5f * 1.5f; + + if (SkelAnime_Update(&this->skin.skelAnime) && (this->noInputTimer <= 0) && + (EnHorse_PlayerCanMove(this, globalCtx) == true)) { + if ((stickMag > 10.0f) && (Math_CosS(stickAngle) <= -0.5f)) { + this->noInputTimerMax = 0; + EnHorse_StartReversingInterruptable(this); + } else if (stickMag < 10.0f) { + this->noInputTimerMax = 0; + EnHorse_StartMountedIdleResetAnim(this); + } else { + EnHorse_StartReversing(this); + } + } +} + +void EnHorse_LowJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartLowJump(this, globalCtx); +} + +void EnHorse_StartLowJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_BRIDGE_JUMP; + this->animationIdx = ENHORSE_ANIM_LOW_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub1(EnHorse* this) { +} + +void EnHorse_LowJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 12.0f) { + this->actor.speedXZ = 12.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 17.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -6.0f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_HighJumpInit(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_StartHighJump(this, globalCtx); +} + +void EnHorse_StartHighJump(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_CS_UPDATE; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= ((y * 0.01f) * this->unk_528) * 0.01f; + + this->stateFlags |= ENHORSE_CALC_RIDER_POS; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_Stub2(EnHorse* this) { +} + +void EnHorse_HighJump(EnHorse* this, GlobalContext* globalCtx) { + Vec3f pad; + f32 temp_f0; + f32 curFrame; + Vec3s* jointTable; + + this->stateFlags |= ENHORSE_JUMPING; + + if (this->actor.speedXZ < 13.0f) { + this->actor.speedXZ = 13.0f; + } + + if (this->actor.floorHeight != BGCHECK_Y_MIN) { + CollisionPoly* colPoly; + s32 floorBgId; + Vec3f pos = this->actor.world.pos; + + pos.y = this->actor.floorHeight - 5.0f; + temp_f0 = + BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &colPoly, &floorBgId, &this->actor, &pos); + if ((this->actor.floorHeight - 120.0f) < temp_f0) { + this->actor.floorHeight = temp_f0; + this->actor.floorPoly = colPoly; + this->actor.floorBgId = floorBgId; + } + } + + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + temp_f0 = jointTable->y; + this->actor.world.pos.y = this->jumpStartY + (temp_f0 * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 23.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + EnHorse_JumpLanding(this, globalCtx); + } +} + +void EnHorse_InitInactive(EnHorse* this) { + this->colliderCylinder1.base.ocFlags1 &= ~OC1_ON; + this->colliderCylinder2.base.ocFlags1 &= ~OC1_ON; + this->colliderJntSph.base.ocFlags1 &= ~OC1_ON; + this->action = ENHORSE_ACT_INACTIVE; + this->animationIdx = ENHORSE_ANIM_WALK; + this->stateFlags |= ENHORSE_INACTIVE; + this->followTimer = 0; +} + +void EnHorse_Inactive(EnHorse* this, GlobalContext* globalCtx) { + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } + this->stateFlags &= ~ENHORSE_INACTIVE; + } + } + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + this->actor.params = ENHORSE_0; + this->colliderCylinder1.base.ocFlags1 |= OC1_ON; + this->colliderCylinder2.base.ocFlags1 |= OC1_ON; + this->colliderJntSph.base.ocFlags1 |= OC1_ON; + } +} + +void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_IDLE; + this->actor.speedXZ = 0.0f; + + if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNEY) && (anim != ENHORSE_ANIM_REARING)) { + anim = ENHORSE_ANIM_IDLE; + } + + if (sAnimationHeaders[this->type][anim] == NULL) { + anim = ENHORSE_ANIM_IDLE; + } + + if (anim != this->animationIdx) { + this->animationIdx = anim; + if (anim == ENHORSE_ANIM_IDLE) { + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } else if (this->animationIdx == ENHORSE_ANIM_REARING) { + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } +} + +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames) { + EnHorse_PlayIdleAnimation(this, anim, morphFrames, this->curFrame); +} + +void EnHorse_ResetIdleAnimation(EnHorse* this) { + this->animationIdx = ENHORSE_ANIM_WALK; + EnHorse_PlayIdleAnimation(this, this->animationIdx, 0.0f, 0.0f); +} + +void EnHorse_StartIdleRidable(EnHorse* this) { + EnHorse_ResetIdleAnimation(this); + this->stateFlags &= ~ENHORSE_UNRIDEABLE; +} + +void EnHorse_Idle(EnHorse* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + EnHorse_IdleAnimSounds(this, globalCtx); + + if ((D_801BDAA4 != 0) && (this->type == HORSE_2)) { + D_801BDAA4 = 0; + if (!func_8087C38C(globalCtx, this, &this->actor.world.pos)) { + if (EnHorse_Spawn(this, globalCtx)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_SetFollowAnimation(this, globalCtx); + } + } else { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + this->followTimer = 0; + EnHorse_StartMovingAnimation(this, 6, -3.0f, 0.0f); + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + s32 idleAnimIdx = 0; + + if (this->animationIdx != 0) { + if (this->animationIdx == 1) { + idleAnimIdx = 1; + } else if (this->animationIdx == 3) { + idleAnimIdx = 2; + } + } + // Play one of the two other idle animations + EnHorse_PlayIdleAnimation(this, sIdleAnimIds[((Rand_ZeroOne() > 0.5f) ? 0 : 1) + idleAnimIdx * 2], 0.0f, 0.0f); + } +} + +void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { + this->action = ENHORSE_ACT_FOLLOW_PLAYER; + this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + + if ((anim != ENHORSE_ANIM_TROT) && (anim != ENHORSE_ANIM_GALLOP) && (anim != ENHORSE_ANIM_WALK)) { + anim = ENHORSE_ANIM_WALK; + } + + if (anim != this->animationIdx) { + this->animationIdx = anim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + morphFrames); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, startFrames, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_SetFollowAnimation(EnHorse* this, GlobalContext* globalCtx) { + s32 anim = ENHORSE_ANIM_WALK; + f32 distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (!(distToPlayer <= 300.0f) && (distToPlayer <= 400.0f)) { + anim = ENHORSE_ANIM_TROT; + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + if (distToPlayer > 400.0f) { + anim = ENHORSE_ANIM_GALLOP; + } else if (distToPlayer < 300.0f) { + anim = ENHORSE_ANIM_WALK; + } else { + anim = ENHORSE_ANIM_TROT; + } + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + if (distToPlayer > 300.0f) { + anim = ENHORSE_ANIM_TROT; + } else { + anim = ENHORSE_ANIM_WALK; + } + } + + EnHorse_StartMovingAnimation(this, anim, -3.0f, 0.0f); +} + +void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { + f32 distToPlayer; + + D_801BDAA4 = 0; + distToPlayer = Actor_XZDistanceBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + if (((this->playerDir == PLAYER_DIR_BACK_R) || (this->playerDir == PLAYER_DIR_BACK_L)) && (distToPlayer > 300.0f) && + !(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + f32 angleDiff; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->stateFlags |= ENHORSE_TURNING_TO_PLAYER; + this->angleToPlayer = Actor_YawBetweenActors(&this->actor, &GET_PLAYER(globalCtx)->actor); + + angleDiff = (f32)this->angleToPlayer - this->actor.world.rot.y; + if (angleDiff > 0x7FFF) { + angleDiff -= 0x7FFF; + } else if (angleDiff < -0x7FFF) { + angleDiff += 0x7FFF; + } + + this->followPlayerTurnSpeed = + angleDiff / Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]); + + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->skin.skelAnime.playSpeed = 1.0f; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + } else if (this->stateFlags & ENHORSE_TURNING_TO_PLAYER) { + this->actor.world.rot.y += this->followPlayerTurnSpeed; + this->actor.shape.rot.y = this->actor.world.rot.y; + if ((this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } else { + EnHorse_RotateToPlayer(this, globalCtx); + } + + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + if (this->animationIdx == ENHORSE_ANIM_TROT) { + this->actor.speedXZ = 6.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + this->actor.speedXZ = 3.0f; + EnHorse_PlayWalkingSound(this); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + } else { + this->actor.speedXZ = 0.0f; + this->skin.skelAnime.playSpeed = 1.0f; + } + } + + if (!(this->stateFlags & ENHORSE_TURNING_TO_PLAYER)) { + this->followTimer++; + if (this->followTimer > 300) { + EnHorse_StartIdleRidable(this); + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; + + if (distToPlayer < 100.0f) { + EnHorse_StartIdleRidable(this); + } else { + EnHorse_SetFollowAnimation(this, globalCtx); + } + } +} + +void EnHorse_InitIngoHorse(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateIngoHorseAnim(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void EnHorse_SetIngoAnimation(s32 anim, f32 curFrame, s32 arg2, s16* animIdxOut) { + *animIdxOut = sIngoAnimations[anim]; + if (arg2 == 1) { + if (anim == 5) { + *animIdxOut = 4; + } else if (anim == 6) { + *animIdxOut = 3; + } + } +} + +void EnHorse_UpdateIngoHorseAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_INGO_RACE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_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->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateIngoRace(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == 5) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == 6) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateIngoHorseAnim(this); + } +} + +void func_8088126C(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + func_80881290(this, globalCtx); +} + +void func_80881290(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + + this->action = ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING; + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->jumpStartY = this->actor.world.pos.y; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void func_80881398(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + s32 animeUpdated; + f32 curFrame; + + this->stateFlags |= ENHORSE_JUMPING; + if (this->actor.speedXZ < 14.0f) { + this->actor.speedXZ = 14.0f; + } + + animeUpdated = SkelAnime_Update(&this->skin.skelAnime); + curFrame = this->skin.skelAnime.curFrame; + + if (curFrame > 23.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); + } + + if (animeUpdated || ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->stateFlags &= ~ENHORSE_FLAG_30; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + func_8088159C(this, globalCtx); + } +} + +void func_8088159C(EnHorse* this, GlobalContext* globalCtx) { + Vec3s* jointTable; + f32 y; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + this->postDrawFunc = NULL; +} + +void func_80881634(EnHorse* this) { + this->curRaceWaypoint = 0; + this->soundTimer = 0; + this->actor.speedXZ = 0.0f; + func_8088168C(this); + if (this->stateFlags & ENHORSE_DRAW) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_IT_INGO_HORSE_NEIGH); + } +} + +void func_8088168C(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + f32 finalAnimSpeed; + + this->action = ENHORSE_ACT_MOUNTED_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_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->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + } else { + animSpeed = 1.0f; + } + + finalAnimSpeed = sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f; + if (finalAnimSpeed < 1.0f) { + finalAnimSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], finalAnimSpeed, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_808819D8(EnHorse* this, GlobalContext* globalCtx) { + Path* path; + f32 animSpeed; + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + this->rider->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateIngoHorseAnim(this); + } + } + + if (this->actor.params == ENHORSE_4) { + path = &globalCtx->setupPathList[0]; + func_8087B7C0(this, globalCtx, path); + } else if (this->actor.params == ENHORSE_5) { + path = &globalCtx->setupPathList[1]; + func_8087B7C0(this, globalCtx, path); + } + + if (!this->inRace) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + func_8088168C(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + } else { + animSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = animSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + func_8088168C(this); + } + + if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 3) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } +} + +void EnHorse_CsMoveInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 1; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.2f * 1.5f); +} + +void EnHorse_CsMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsSetAnimHighJump(EnHorse* this, GlobalContext* globalCtx) { + this->skin.skelAnime.curFrame = 0.0f; + EnHorse_CsPlayHighJumpAnim(this, globalCtx); +} + +void EnHorse_CsPlayHighJumpAnim(EnHorse* this, GlobalContext* globalCtx) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + + this->animationIdx = ENHORSE_ANIM_HIGH_JUMP; + curFrame = this->skin.skelAnime.curFrame; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.5f, curFrame, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + this->postDrawFunc = NULL; + this->jumpStartY = this->actor.world.pos.y; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y -= y * 0.01f * this->unk_528 * 0.01f; + + this->stateFlags |= ENHORSE_ANIM_HIGH_JUMP; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_JUMP); + } + func_8013ECE0(0.0f, 170, 10, 10); +} + +void EnHorse_CsJumpInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_CsSetAnimHighJump(this, globalCtx); + this->cutsceneAction = 2; + this->cutsceneFlags &= ~1; +} + +void EnHorse_CsJump(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + f32 curFrame; + f32 y; + Vec3s* jointTable; + s32 pad[2]; + + if (this->cutsceneFlags & 1) { + EnHorse_CsMoveToPoint(this, globalCtx, action); + return; + } + + curFrame = this->skin.skelAnime.curFrame; + this->actor.speedXZ = 13.0f; + this->stateFlags |= ENHORSE_JUMPING; + + if (curFrame > 19.0f) { + this->actor.gravity = -3.5f; + if (this->actor.velocity.y == 0.0f) { + this->actor.velocity.y = -10.5f; + } + if (this->actor.world.pos.y < (this->actor.floorHeight + 90.0f)) { + this->skin.skelAnime.playSpeed = 1.5f; + } else { + this->skin.skelAnime.playSpeed = 0.0f; + } + } else { + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + + this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); + } + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((curFrame > 19.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + this->cutsceneFlags |= 1; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); + } + func_8013ECE0(0.0f, 255, 10, 80); + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = this->actor.floorHeight; + func_800B1598(globalCtx, 25.0f, &this->actor.world.pos); + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[6]); + + jointTable = this->skin.skelAnime.jointTable; + y = jointTable->y; + this->riderPos.y += y * 0.01f * this->unk_528 * 0.01f; + + this->postDrawFunc = NULL; + } +} + +void EnHorse_CsRearingInit(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 3; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_WarpMoveInit(EnHorse* this, GlobalContext* globalCtx, 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; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_GALLOP; + this->cutsceneAction = 4; + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); +} + +void EnHorse_CsWarpMoveToPoint(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Vec3f endPos; + s32 pad; + + endPos.x = action->endPos.x; + endPos.y = action->endPos.y; + endPos.z = action->endPos.z; + + if (Math3D_Distance(&endPos, &this->actor.world.pos) > 8.0f) { + EnHorse_RotateToPoint(this, globalCtx, &endPos, 0x320); + this->actor.speedXZ = 8.0f; + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + } else { + this->actor.world.pos = endPos; + this->actor.speedXZ = 0.0f; + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + func_8087C1C0(this); + func_8013ECE0(0.0f, 120, 8, 255); + Animation_PlayOnceSetSpeed(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + this->actor.speedXZ * 0.3f); + } +} + +void EnHorse_CsWarpRearingInit(EnHorse* this, GlobalContext* globalCtx, 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; + this->actor.prevPos = this->actor.world.pos; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->animationIdx = ENHORSE_ANIM_REARING; + this->cutsceneAction = 5; + this->cutsceneFlags &= ~4; + this->stateFlags &= ~ENHORSE_LAND2_SOUND; + + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void EnHorse_CsWarpRearing(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + this->actor.speedXZ = 0.0f; + if (this->curFrame > 25.0f) { + if (!(this->stateFlags & ENHORSE_LAND2_SOUND)) { + this->stateFlags |= ENHORSE_LAND2_SOUND; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); + } + } + } + + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + if (!(this->cutsceneFlags & 4)) { + this->cutsceneFlags |= 4; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_LOOP, + 0.0f); + } + } +} + +void EnHorse_InitCutscene(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_HBA; + this->cutsceneAction = 0; + this->actor.speedXZ = 0.0f; +} + +s32 EnHorse_GetCutsceneFunctionIndex(s32 csAction) { + s32 numActions = ARRAY_COUNT(sCsActionTable); // prevents unrolling + s32 i; + + for (i = 0; i < numActions; i++) { + if (csAction == sCsActionTable[i].csAction) { + return sCsActionTable[i].csFuncIdx; + } + + if (csAction < sCsActionTable[i].csAction) { + return 0; + } + } + return 0; +} + +void EnHorse_CutsceneUpdate(EnHorse* this, GlobalContext* globalCtx) { + s32 csFunctionIdx; + CsCmdActorAction* playerAction = globalCtx->csCtx.playerAction; + + if (globalCtx->csCtx.state == 3) { + this->playerControlled = true; + this->actor.params = ENHORSE_12; + this->action = ENHORSE_ACT_IDLE; + EnHorse_Freeze(this, globalCtx); + return; + } + + if (playerAction != NULL) { + csFunctionIdx = EnHorse_GetCutsceneFunctionIndex(playerAction->action); + 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.rot.y = playerAction->urot.y; + this->actor.shape.rot = this->actor.world.rot; + this->actor.prevPos = this->actor.world.pos; + } + this->cutsceneAction = csFunctionIdx; + sCutsceneInitFuncs[csFunctionIdx](this, globalCtx, playerAction); + } + sCutsceneActionFuncs[this->cutsceneAction](this, globalCtx, playerAction); + } + } +} + +s32 EnHorse_UpdateHbaRaceInfo(EnHorse* this, GlobalContext* globalCtx, RaceInfo* raceInfo) { + Vec3f pos; + f32 px; + f32 pz; + f32 d; + + EnHorse_RaceWaypointPos(raceInfo->waypoints, this->curRaceWaypoint, &pos); + func_8017B7F8(&pos, raceInfo->waypoints[this->curRaceWaypoint].angle, &px, &pz, &d); + + if ((this->curRaceWaypoint >= (raceInfo->numWaypoints - 1)) && + (Math3D_Distance(&pos, &this->actor.world.pos) < DREG(8))) { + this->hbaFlags |= 2; + } + + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + this->curRaceWaypoint++; + if (this->curRaceWaypoint >= raceInfo->numWaypoints) { + this->hbaFlags |= 1; + return true; + } + } + + if (!(this->hbaFlags & 1)) { + EnHorse_RotateToPoint(this, globalCtx, &pos, 0x640); + } + + 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; + } else { + this->actor.speedXZ -= 0.4f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + return false; +} + +void EnHorse_InitHorsebackArchery(EnHorse* this) { + this->hbaStarted = 0; + this->soundTimer = 0; + this->curRaceWaypoint = 0; + this->hbaTimer = 0; + this->actor.speedXZ = 0.0f; + EnHorse_UpdateHbaAnim(this); +} + +void EnHorse_UpdateHbaAnim(EnHorse* this) { + s32 animChanged = false; + f32 animSpeed; + + this->action = ENHORSE_ACT_FLEE_PLAYER; + if (this->actor.speedXZ == 0.0f) { + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_IDLE; + } else if (this->actor.speedXZ <= 3.0f) { + if (this->animationIdx != ENHORSE_ANIM_WALK) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_WALK; + } else if (this->actor.speedXZ <= 6.0f) { + if (this->animationIdx != ENHORSE_ANIM_TROT) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_TROT; + } else { + if (this->animationIdx != ENHORSE_ANIM_GALLOP) { + animChanged = true; + } + this->animationIdx = ENHORSE_ANIM_GALLOP; + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + animSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + animSpeed = this->actor.speedXZ * 0.25f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 60, 8, 255); + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + animSpeed = this->actor.speedXZ * 0.2f; + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_RUN); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + func_8013ECE0(0.0f, 120, 8, 255); + } else { + animSpeed = 1.0f; + } + + if (animChanged == true) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * animSpeed * 1.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void EnHorse_UpdateHorsebackArchery(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + s32 sp28; + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + EnHorse_PlayWalkingSound(this); + } + + if (globalCtx->interfaceCtx.hbaAmmo == 0) { + this->hbaTimer++; + } + + sp28 = Audio_IsSequencePlaying(0x41); + EnHorse_UpdateHbaRaceInfo(this, globalCtx, &sHbaInfo); + + if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { + gSaveContext.save.cutscene = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x40; + } + + if (globalCtx->interfaceCtx.hbaAmmo) {} + + if (((globalCtx->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { + this->hbaFlags &= ~4; + Audio_QueueSeqCmd(0x8041); + } + + if (this->hbaStarted == 0) { + this->actor.speedXZ = 0.0f; + if (this->animationIdx != ENHORSE_ANIM_IDLE) { + EnHorse_UpdateHbaAnim(this); + } + } + + if (this->animationIdx == ENHORSE_ANIM_WALK) { + playSpeed = this->actor.speedXZ * 0.5f; + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + playSpeed = this->actor.speedXZ * 0.25f; + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + playSpeed = this->actor.speedXZ * 0.2f; + } else { + playSpeed = 1.0f; + } + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime) || + ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->actor.speedXZ != 0.0f))) { + EnHorse_UpdateHbaAnim(this); + } +} + +#ifdef NON_MATCHING +void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToHome; + f32 playerDistToHome; + f32 distToPlayer; + s32 nextAnim; + s32 animFinished; + s16 yaw; + + if ((D_801BDAA4 != 0) || (this->type == HORSE_HNI)) { + EnHorse_StartIdleRidable(this); + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_NEIGH); + } + } + + distToHome = Math3D_Distance(&this->actor.home.pos, &this->actor.world.pos); + playerDistToHome = Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos); + distToPlayer = Math3D_Distance(&player->actor.world.pos, &this->actor.world.pos); + + if (playerDistToHome > 300.0f) { + if (distToHome > 150.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + } else if (distToPlayer < 300.0f) { + this->actor.speedXZ += 0.4f; + if (this->actor.speedXZ > 8.0f) { + this->actor.speedXZ = 8.0f; + } + } else { + this->actor.speedXZ -= 0.5f; + if (this->actor.speedXZ < 0.0f) { + this->actor.speedXZ = 0.0f; + } + } + + if (this->actor.speedXZ >= 6.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.3f; + nextAnim = ENHORSE_ANIM_GALLOP; + } else if (this->actor.speedXZ >= 3.0f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.375f; + nextAnim = ENHORSE_ANIM_TROT; + } else if (this->actor.speedXZ > 0.1f) { + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + nextAnim = ENHORSE_ANIM_WALK; + EnHorse_PlayWalkingSound(this); + } else { + if (Rand_ZeroOne() > 0.5f) { + nextAnim = ENHORSE_ANIM_WHINNEY; + } else { + nextAnim = ENHORSE_ANIM_IDLE; + } + EnHorse_IdleAnimSounds(this, globalCtx); + this->skin.skelAnime.playSpeed = 1.0f; + } + + if ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK)) { + if (playerDistToHome < 300.0f) { + yaw = player->actor.shape.rot.y; + yaw += ((Actor_YawBetweenActors(&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; + } + + if (yaw > 800.0f) { + this->actor.world.rot.y += 0x320; + } else if (yaw < -800.0f) { + this->actor.world.rot.y += -0x320; + } else { + this->actor.world.rot.y += yaw; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + animFinished = SkelAnime_Update(&this->skin.skelAnime); + + if (((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) && + ((nextAnim == ENHORSE_ANIM_GALLOP) || (nextAnim == ENHORSE_ANIM_TROT) || (nextAnim == ENHORSE_ANIM_WALK))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][nextAnim]), ANIMMODE_ONCE, -3.0f); + if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (this->animationIdx == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + } else if (animFinished) { + if (nextAnim == ENHORSE_ANIM_GALLOP) { + func_8087C1C0(this); + } else if (nextAnim == ENHORSE_ANIM_TROT) { + func_8087C178(this); + } + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) || (this->animationIdx == ENHORSE_ANIM_WHINNEY)) { + if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } else { + if (Rand_ZeroOne() > 0.5f) { + this->animationIdx = ENHORSE_ANIM_IDLE; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + } else { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + if (this->stateFlags & ENHORSE_DRAW) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_GROAN); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_GROAN); + } + } + } + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (nextAnim != this->animationIdx) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + } else if ((this->animationIdx == ENHORSE_ANIM_WALK) && + ((nextAnim == ENHORSE_ANIM_IDLE) || (nextAnim == ENHORSE_ANIM_WHINNEY))) { + this->animationIdx = nextAnim; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + -3.0f); + } +} +#else +void EnHorse_FleePlayer(EnHorse* this, GlobalContext* globalCtx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_FleePlayer.s") +#endif + +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; + + this->actor.world.rot.y = action->urot.y; + this->actor.shape.rot = this->actor.world.rot; + + this->actor.prevPos = this->actor.world.pos; +} + +void func_80883BEC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->animationIdx = ENHORSE_ANIM_IDLE; + this->unk_3E0 = 1; + this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); + this->stateFlags |= ENHORSE_SANDDUST_SOUND; +} + +void func_80883CB0(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_IdleAnimSounds(this, globalCtx); + if (SkelAnime_Update(&this->skin.skelAnime)) { + this->animationIdx = ENHORSE_ANIM_IDLE; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80883D64(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); +} + +void func_80883E10(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 5; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_808840C4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + EnHorse_PlayWalkingSound(this); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } +} + +void func_80884194(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + func_80883B70(this, action); + this->unk_3E0 = 6; + this->animationIdx = ENHORSE_ANIM_GALLOP; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); + func_8087C1C0(this); +} + +void func_8088424C(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + func_8087C1C0(this); + } +} + +void func_80884314(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + this->unk_3E0 = 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + SkelAnime_Update(&this->skin.skelAnime); + if (this->curFrame > 42.0f) { + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + } +} + +void func_80884444(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + 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); + func_8087C1C0(this); + } +} + +void func_80884564(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 20.0f); + func_80883B70(this, action); + 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, GlobalContext* globalCtx, CsCmdActorAction* action) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, this->unk_530); + 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); + } + + if (((s32)this->curFrame % 11) == 0) { + func_8087C1C0(this); + } +} + +void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { + Actor_MarkForDeath(&this->actor); +} + +void func_808846DC(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { +} + +void func_808846F0(EnHorse* this, GlobalContext* globalCtx) { + this->playerControlled = false; + this->action = ENHORSE_ACT_21; + this->unk_3E0 = -1; + this->actor.speedXZ = 0.0f; +} + +void func_80884718(EnHorse* this, GlobalContext* globalCtx) { + CsCmdActorAction* action; + + if (Cutscene_CheckActorAction(globalCtx, 0x70)) { + this->unk_530 = Cutscene_GetActorActionIndex(globalCtx, 0x70); + action = globalCtx->csCtx.actorActions[this->unk_530]; + + 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; + + this->actor.world.rot.y = action->urot.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, globalCtx, action); + } + } + + if (D_8088911C[this->unk_3E0] != NULL) { + D_8088911C[this->unk_3E0](this, globalCtx, action); + } + } +} + +void func_80884868(EnHorse* this) { + this->action = ENHORSE_ACT_23; + this->animationIdx = ENHORSE_ANIM_WALK; + Animation_PlayLoop(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + this->stateFlags |= ENHORSE_UNRIDEABLE; +} + +void func_808848C8(EnHorse* this, GlobalContext* globalCtx) { + Vec3f sp24 = { -1916.0f, -106.0f, -523.0f }; + + EnHorse_PlayWalkingSound(this); + this->actor.speedXZ = 4.0f; + func_800F415C(&this->actor, &sp24, 2000); + this->skin.skelAnime.playSpeed = this->actor.speedXZ * 0.75f; + SkelAnime_Update(&this->skin.skelAnime); + if (Math3D_Distance(&sp24, &this->actor.world.pos) < 30.0f) { + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + EnHorse_StartIdleRidable(this); + } +} + +void func_80884994(EnHorse* this) { + this->unk_534 = -1; + this->animationIdx = ENHORSE_ANIM_TROT; + this->action = ENHORSE_ACT_24; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, -3.0f); +} + +void func_80884A40(EnHorse* this, GlobalContext* globalCtx) { + s32 sp44[] = { 5, 6, 0 }; + s32 sp40; + s32 temp_v0; + + if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + temp_v0 = 0; + } else { + temp_v0 = this->animationIdx; + } + + sp40 = sp44[this->unk_538] != temp_v0; + + if (SkelAnime_Update(&this->skin.skelAnime) || sp40) { + this->animationIdx = sp44[this->unk_538]; + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (Rand_ZeroOne() < 0.5f)) { + this->animationIdx = ENHORSE_ANIM_WHINNEY; + } + + if (sp40) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_MorphToPlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + -3.0f); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), + ANIMMODE_ONCE, -3.0f); + } + } else if (this->animationIdx == ENHORSE_ANIM_IDLE) { + Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + } else { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], 2.0f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + } + + if ((this->unk_538 == 0) || (this->unk_538 == 1)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_RUN); + } else if (this->unk_538 == 2) { + if (this->animationIdx == ENHORSE_ANIM_IDLE) { + EnHorse_IdleAnimSounds(this, globalCtx); + } else if (this->animationIdx == ENHORSE_ANIM_WHINNEY) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HORSE_GROAN); + } + } + } +} + +void func_80884D04(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed; + + this->actor.speedXZ = 10.0f; + this->action = ENHORSE_ACT_25; + this->unk_540 = this->actor.world.pos; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_INGO_HORSE_NEIGH); + this->animationIdx = ENHORSE_ANIM_GALLOP; + playSpeed = this->actor.speedXZ * 0.2f; + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, 0.0f); +} + +void func_80884E0C(EnHorse* this, GlobalContext* globalCtx) { + f32 playSpeed = (this->unk_56C * 0.2f * 0.5f) + 1.0f; + Vec3f pos; + CollisionPoly* sp3C; + + this->skin.skelAnime.playSpeed = playSpeed; + + if (SkelAnime_Update(&this->skin.skelAnime)) { + Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx], + sPlaybackSpeeds[this->animationIdx] * playSpeed * 2.5f, 0.0f, + Animation_GetLastFrame(sAnimationHeaders[this->type][this->animationIdx]), ANIMMODE_ONCE, + 0.0f); + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_RUN); + } + + this->unk_57C = this->actor.world.pos; + this->actor.world.pos.x = this->unk_570.x; + this->actor.world.pos.z = this->unk_570.z; + + this->unk_56C = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); + if (((this->unk_550 == 5) || (this->unk_550 == 7)) && (Player_GetMask(globalCtx) != PLAYER_MASK_CIRCUS_LEADER)) { + this->rider->unk488 = 7; + } else { + EnHorse_SetIngoAnimation(this->animationIdx, this->skin.skelAnime.curFrame, this->unk_394 & 1, + &this->rider->unk488); + } + + pos = this->actor.world.pos; + pos.y += 10.0f; + + if (BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp3C, &pos) != BGCHECK_Y_MIN) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } + this->actor.world.pos.y += this->actor.velocity.y * 0.5f; + } else { + this->actor.world.pos.y = this->unk_570.y; + } +} + +void EnHorse_Vec3fOffset(Vec3f* src, s16 yaw, f32 dist, f32 height, Vec3f* dst) { + dst->x = (Math_SinS(yaw) * dist) + src->x; + dst->y = src->y + height; + dst->z = (Math_CosS(yaw) * dist) + src->z; +} + +s32 EnHorse_CalcFloorHeight(EnHorse* this, GlobalContext* globalCtx, Vec3f* pos, CollisionPoly** polyFloor, + f32* floorHeight, s32* bgId) { + f32 waterY; + WaterBox* waterbox; + + *polyFloor = NULL; + *floorHeight = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, polyFloor, bgId, pos); + if (*floorHeight == BGCHECK_Y_MIN) { + return 1; // No floor + } + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, pos->x, pos->z, &waterY, &waterbox) == 1) && + (*floorHeight < waterY)) { + return 2; // Water + } + + if ((COLPOLY_GET_NORMAL((*polyFloor)->normal.y) < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, *polyFloor, *bgId) || + (func_800C99D4(&globalCtx->colCtx, *polyFloor, *bgId) == 7)) { + return 3; // Horse blocked surface + } + + return 0; +} + +/** + * obstacleType: + * 1: Water in front + * 2: Water behind? + * 3: ? + * 4: Obstructed in front + * 5: Obstructed behind + */ +void EnHorse_ObstructMovement(EnHorse* this, GlobalContext* globalCtx, s32 obstacleType, s32 galloping) { + if (this->action != ENHORSE_ACT_HBA) { + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + this->actor.world.pos = this->actor.prevPos; + this->actor.world.rot.y -= 0x640; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->unk_1EC |= 4; + } else if (this->action == ENHORSE_ACT_25) { + this->unk_1EC |= 0x80; + this->actor.world.pos = this->actor.prevPos; + this->actor.speedXZ = 0.0f; + } else if ((globalCtx->sceneNum != SCENE_KOEPONARACE) || (this->unk_1EC & 2)) { + this->unk_1EC &= ~2; + this->actor.world.pos = this->lastPos; + this->stateFlags |= ENHORSE_OBSTACLE; + if (this->playerControlled == 0) { + if (this->animationIdx != 3) {} + } else if (this->action != ENHORSE_ACT_REVERSE) { + if (this->stateFlags & ENHORSE_JUMPING) { + this->stateFlags &= ~ENHORSE_JUMPING; + this->actor.gravity = -3.5f; + this->actor.world.pos.y = this->actor.floorHeight; + } + + if ((obstacleType == 1) || (obstacleType == 4)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if ((obstacleType == 2) || (obstacleType == 5)) { + this->stateFlags |= ENHORSE_FORCE_WALKING; + } + + if (galloping == true) { + EnHorse_StartRearing(this); + } + } + } + } +} + +void EnHorse_CheckFloors(EnHorse* this, GlobalContext* globalCtx) { + s32 pad; + CollisionPoly* frontFloor; + CollisionPoly* backFloor; + s32 bgId; + s16 floorSlope; + Vec3f frontPos; + Vec3f backPos; + Vec3f pos; + f32 nx; + f32 ny; + f32 nz; + s32 galloping = this->actor.speedXZ > 8.0f; + s32 status; + f32 waterHeight; + WaterBox* waterbox; + f32 dist; + + if ((WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterHeight, &waterbox) == true) && + (this->actor.floorHeight < waterHeight)) { + EnHorse_ObstructMovement(this, globalCtx, 1, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 30.0f, 55.0f, &frontPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, 15.0f, 30.0f, &frontPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &frontPos, &frontFloor, &this->yFront, &this->unk_24C); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + if (this->type != HORSE_2) { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -30.0f, 55.0f, &backPos); + } else { + EnHorse_Vec3fOffset(&this->actor.world.pos, this->actor.shape.rot.y, -15.0f, 30.0f, &backPos); + } + + status = EnHorse_CalcFloorHeight(this, globalCtx, &backPos, &backFloor, &this->yBack, &bgId); + if (status == 1) { + this->actor.shape.rot.x = 0; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if (status == 3) { + this->unk_1EC |= 2; + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + floorSlope = Math_Atan2S(this->yBack - this->yFront, 60.0f); + if (this->actor.floorPoly != NULL) { + nx = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x); + ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); + + pos = frontPos; + 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) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + return; + } + + pos = backPos; + 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) && + ((!(this->stateFlags & ENHORSE_JUMPING) && (dist < -40.0f)) || + ((this->stateFlags & ENHORSE_JUMPING) && (dist < -200.0f)))) { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + return; + } + + if ((ny < 0.81915206f) || + SurfaceType_IsHorseBlocked(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) || + (func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7)) { + if (this->actor.speedXZ >= 0.0f) { + EnHorse_ObstructMovement(this, globalCtx, 4, galloping); + } else { + EnHorse_ObstructMovement(this, globalCtx, 5, galloping); + } + } else if (this->stateFlags & 4) { + this->actor.shape.rot.x = 0; + } else if ((this->actor.floorHeight + 4.0f) < this->actor.world.pos.y) { + this->actor.shape.rot.x = 0; + } else if (!(fabsf(floorSlope) > 0x1FFF)) { + this->actor.shape.rot.x = floorSlope; + this->actor.shape.yOffset = + ((this->yFront + (((this->yBack - this->yFront) * 20.0f) / 45.0f)) - this->actor.floorHeight) + + this->unk_3E8; + } + } +} + +void EnHorse_MountDismount(EnHorse* this, GlobalContext* globalCtx) { + s32 mountSide = EnHorse_GetMountSide(this, globalCtx); + + if ((mountSide != 0) && !(this->stateFlags & ENHORSE_UNRIDEABLE)) { + Actor_SetRideActor(globalCtx, &this->actor, mountSide); + } + + if ((this->playerControlled == false) && (Actor_HasRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 26; + this->noInputTimerMax = 26; + this->playerControlled = true; + EnHorse_Freeze(this, globalCtx); + } else if ((this->playerControlled == true) && (Actor_HasNoRider(globalCtx, &this->actor) == true)) { + this->noInputTimer = 35; + this->noInputTimerMax = 35; + this->stateFlags &= ~ENHORSE_UNRIDEABLE; + this->playerControlled = false; + EnHorse_Freeze(this, globalCtx); + } +} + +void EnHorse_StickDirection(Vec2f* curStick, f32* stickMag, s16* angle) { + *stickMag = sqrtf(SQ(curStick->x) + SQ(curStick->z)); + *stickMag = CLAMP_MAX(*stickMag, 60.0f); + *angle = Math_Atan2S(-curStick->x, curStick->z); +} + +void EnHorse_UpdateStick(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + this->lastStick = this->curStick; + this->curStick.x = input->rel.stick_x; + this->curStick.z = input->rel.stick_y; +} + +void EnHorse_ResolveCollision(EnHorse* this, GlobalContext* globalCtx, CollisionPoly* colPoly) { + f32 dist; + f32 nx; + f32 ny; + f32 nz; + f32 offset; + + nx = COLPOLY_GET_NORMAL(colPoly->normal.x); + ny = COLPOLY_GET_NORMAL(colPoly->normal.y); + nz = COLPOLY_GET_NORMAL(colPoly->normal.z); + + if (!(Math_CosS(BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(colPoly->normal.x, colPoly->normal.z))) < + 0.7071f)) { // cos(45 degrees) + dist = Math3D_DistPlaneToPos(nx, ny, nz, colPoly->dist, &this->actor.world.pos); + offset = (1.0f / sqrtf(SQ(nx) + SQ(nz))); + offset = (30.0f - dist) * offset; + this->actor.world.pos.x += offset * nx; + this->actor.world.pos.z += offset * nz; + } +} + +void EnHorse_BgCheckSlowMoving(EnHorse* this, GlobalContext* globalCtx) { + f32 yOffset = 40.0f; + Vec3f start; + Vec3f end; + Vec3f intersect; + CollisionPoly* colPoly; + s32 bgId; + + Math_Vec3f_Copy(&start, &this->actor.world.pos); + start.y += yOffset; + + Math_Vec3f_Copy(&end, &start); + end.x += 30.0f * Math_SinS(this->actor.world.rot.y); + end.y += 30.0f * Math_SinS(-this->actor.shape.rot.x); + end.z += 30.0f * Math_CosS(this->actor.world.rot.y); + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &start, &end, &intersect, &colPoly, true, false, false, true, + &bgId)) { + EnHorse_ResolveCollision(this, globalCtx, colPoly); + } +} + +void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { + s32 pad2[2]; + Vec3f startPos; + Vec3f endPos; + Vec3f obstaclePos; + f32 temp_f0; + f32 intersectDist; + CollisionPoly* wall = NULL; + CollisionPoly* obstacleFloor = NULL; + s32 bgId; + f32 obstacleHeight; + f32 behindObstacleHeight; + DynaPolyActor* horseJump; + s32 movingFast; + s16 sp7E = 0; + DynaPolyActor* horseGameCheck = NULL; + s32 pad6; + s32 pad; + Vec3f intersect; + Vec3f obstacleTop; + s32 pad5; + s32 pad4; + + 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(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1D); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 35.0f, 100.0f, 0x1C); + } + + 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->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId); + + if (!(this->stateFlags & ENHORSE_JUMPING)) { + if ((horseJump != NULL) && (horseJump->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((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->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } else { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); + } + } + } else { + this->stateFlags &= ~ENHORSE_FLAG_28; + this->unk_3E8 *= 0.5f; + } + } + + if ((this->stateFlags & ENHORSE_JUMPING) || (this->stateFlags & ENHORSE_FLAG_28) || (this->actor.speedXZ < 0.0f) || + (this->action == ENHORSE_ACT_LOW_JUMP) || (this->action == ENHORSE_ACT_REVERSE)) { + return; + } + + if (this->actor.speedXZ > 8.0f) { + if (this->actor.speedXZ < 12.8f) { + intersectDist = 160.0f; + movingFast = false; + } else { + intersectDist = 230.0f; + movingFast = true; + } + } else { + EnHorse_BgCheckSlowMoving(this, globalCtx); + return; + } + + startPos = this->actor.world.pos; + startPos.y += 19.0f; + + endPos = startPos; + endPos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + endPos.y += intersectDist * Math_SinS(-this->actor.shape.rot.x); + endPos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + intersect = endPos; + wall = NULL; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &startPos, &endPos, &intersect, &wall, true, false, false, true, + &bgId) == true) { + intersectDist = sqrtf(Math3D_Vec3fDistSq(&startPos, &intersect)); + this->stateFlags |= ENHORSE_OBSTACLE; + } + + if (wall != NULL) { + if (intersectDist < 30.0f) { + EnHorse_ResolveCollision(this, globalCtx, wall); + } + + sp7E = BINANG_ROT180(this->actor.world.rot.y - Math_Atan2S(wall->normal.x, wall->normal.z)); + + if ((Math_CosS(sp7E) < 0.5f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, wall, bgId)) { + return; + } + + if (((movingFast == false) && (intersectDist < 80.0f)) || ((movingFast == true) && (intersectDist < 150.0f))) { + if ((globalCtx->sceneNum != SCENE_KOEPONARACE) && (Math_CosS(sp7E) < 0.9f) && + (this->playerControlled == true)) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + + horseJump = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((this->stateFlags & ENHORSE_FLAG_26) && + (((horseJump != NULL) && (horseJump->actor.id != ACTOR_BG_UMAJUMP)) || (horseJump == NULL))) { + if (this->playerControlled == true) { + if (movingFast == false) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + } else if (movingFast == true) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } + return; + } + } + + intersectDist += 5.0f; + obstaclePos = startPos; + + obstaclePos.x += intersectDist * Math_SinS(this->actor.world.rot.y); + obstaclePos.y = this->actor.world.pos.y + 120.0f; + obstaclePos.z += intersectDist * Math_CosS(this->actor.world.rot.y); + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + obstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if ((this->actor.floorPoly == NULL) || (obstacleFloor == NULL)) { + return; + } + + if ((Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.x), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y), + COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z), this->actor.floorPoly->dist, + &obstacleTop) < -40.0f) && + (Math3D_DistPlaneToPos(COLPOLY_GET_NORMAL(obstacleFloor->normal.x), COLPOLY_GET_NORMAL(obstacleFloor->normal.y), + COLPOLY_GET_NORMAL(obstacleFloor->normal.z), obstacleFloor->dist, + &this->actor.world.pos) > 40.0f)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + this->stateFlags |= ENHORSE_OBSTACLE; + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((Math_CosS(sp7E) < 0.9f) && (movingFast == true) && (this->playerControlled == true) && + (this->action != ENHORSE_ACT_LOW_JUMP) && (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + return; + } + + if (wall == NULL) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + return; + } + } + + if (((obstacleTop.y < intersect.y) && + ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5))) || + ((this->stateFlags & ENHORSE_CANT_JUMP) && (this->action != ENHORSE_ACT_MOUNTED_IDLE))) { + return; + } + + if ((this->action == ENHORSE_ACT_MOUNTED_IDLE) && !(this->stateFlags & ENHORSE_FLAG_30)) { + horseGameCheck = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + if ((horseGameCheck != NULL) && (horseGameCheck->actor.id == ACTOR_EN_HORSE_GAME_CHECK) && + ((horseGameCheck->actor.params & 0xFF) == 5)) { + this->stateFlags |= ENHORSE_FLAG_30; + this->postDrawFunc = func_8088126C; + } + } + + if (this->playerControlled == false) { + return; + } + + obstaclePos = startPos; + obstaclePos.y = this->actor.world.pos.y + 120.0f; + + if (movingFast == false) { + obstaclePos.x += 276.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 276.0f * Math_CosS(this->actor.world.rot.y); + } else { + obstaclePos.x += 390.0f * Math_SinS(this->actor.world.rot.y); + obstaclePos.z += 390.0f * Math_CosS(this->actor.world.rot.y); + } + + obstacleTop = obstaclePos; + obstacleTop.y = BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &obstacleFloor, &bgId, &obstaclePos); + + if (obstacleTop.y == BGCHECK_Y_MIN) { + return; + } + + behindObstacleHeight = obstacleTop.y - this->actor.world.pos.y; + + if (obstacleFloor == NULL) { + return; + } + + temp_f0 = COLPOLY_GET_NORMAL(obstacleFloor->normal.y); + if ((temp_f0 < 0.81915206f) || SurfaceType_IsHorseBlocked(&globalCtx->colCtx, obstacleFloor, bgId) || + (func_800C99D4(&globalCtx->colCtx, obstacleFloor, bgId) == 7)) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else if (behindObstacleHeight < -70.0f) { + if ((movingFast == true) && (this->playerControlled == true) && (this->action != ENHORSE_ACT_LOW_JUMP) && + (globalCtx->sceneNum != SCENE_KOEPONARACE)) { + this->stateFlags |= ENHORSE_FORCE_REVERSING; + EnHorse_StartBraking(this, globalCtx); + } + } else { + temp_f0 = (this->actor.scale.y * 100.0f); + + if ((horseGameCheck == NULL) || (horseGameCheck->actor.id != ACTOR_EN_HORSE_GAME_CHECK) || + ((horseGameCheck->actor.params & 0xFF) != 5)) { + if ((movingFast == false) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (40.0f * temp_f0))) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if ((movingFast == true) && + (((this->actor.speedXZ < 13.8f) && ((19.0f * temp_f0) < obstacleHeight) && + (obstacleHeight <= (72.0f * temp_f0))) || + ((this->actor.speedXZ > 13.8f) && (obstacleHeight <= (112.0f * temp_f0))))) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } else if (movingFast == false) { + EnHorse_Stub1(this); + this->postDrawFunc = EnHorse_LowJumpInit; + } else if (movingFast == true) { + EnHorse_Stub2(this); + this->postDrawFunc = EnHorse_HighJumpInit; + } + } +} + +void func_80886C00(EnHorse* this, GlobalContext* globalCtx) { + Input* input = &globalCtx->state.input[this->unk_52C]; + + if (((this->action == ENHORSE_ACT_MOUNTED_GALLOP) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_STOPPING)) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || (func_801A5100() == 5)) && + (globalCtx->interfaceCtx.unk_212 == 8) && !(this->stateFlags & ENHORSE_BOOST) && + !(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { + if (this->numBoosts > 0) { + func_8013ECE0(0.0f, 180, 20, 100); + this->stateFlags |= ENHORSE_BOOST; + this->stateFlags |= ENHORSE_FIRST_BOOST_REGEN; + this->stateFlags |= ENHORSE_FLAG_8; + this->numBoosts--; + this->boostTimer = 0; + if (this->numBoosts == 0) { + this->boostRegenTime = 140; + } else if (this->type == HORSE_EPONA) { + if (this->stateFlags & ENHORSE_FIRST_BOOST_REGEN) { + this->boostRegenTime = 60; + this->stateFlags &= ~ENHORSE_FIRST_BOOST_REGEN; + } else { + this->boostRegenTime = 8; + } + } else { + this->boostRegenTime = 70; + } + } else if ((this->stateFlags & ENHORSE_DRAW) && (Rand_ZeroOne() < 0.1f)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } +} + +void EnHorse_RegenBoost(EnHorse* this, GlobalContext* globalCtx) { + s32 playSfx; + + if ((this->numBoosts < 6) && (this->numBoosts > 0)) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->numBoosts++; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + + if (this->numBoosts < 6) { + this->boostRegenTime = 11; + } + } + } else if (this->numBoosts == 0) { + this->boostRegenTime--; + this->boostTimer++; + if (this->boostRegenTime <= 0) { + this->boostRegenTime = 0; + this->numBoosts = 6; + if (((this->action == ENHORSE_ACT_MOUNTED_TURN) || (this->action == ENHORSE_ACT_FROZEN) || + (this->action == ENHORSE_ACT_MOUNTED_WALK)) && + !(this->stateFlags & ENHORSE_FLAG_19) && !(this->stateFlags & ENHORSE_FLAG_25)) { + playSfx = true; + } else { + playSfx = false; + } + + if (!playSfx) { + play_sound(NA_SE_SY_CARROT_RECOVER); + } + } + } + + if (this->boostTimer == 8) { + if ((Rand_ZeroOne() < 0.25f) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + } + + globalCtx->interfaceCtx.numHorseBoosts = this->numBoosts; +} + +void EnHorse_UpdatePlayerDir(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 angle = Actor_YawBetweenActors(&this->actor, &player->actor) - this->actor.world.rot.y; + f32 s = Math_SinS(angle); + f32 c = Math_CosS(angle); + + if (s > 0.8660254f) { // sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_L; + } else if (s < -0.8660254f) { // -sin(60 degrees) + this->playerDir = PLAYER_DIR_SIDE_R; + } else if (c > 0.0f) { + if (s > 0.0f) { + this->playerDir = PLAYER_DIR_FRONT_L; + } else { + this->playerDir = PLAYER_DIR_FRONT_R; + } + } else if (s > 0.0f) { + this->playerDir = PLAYER_DIR_BACK_L; + } else { + this->playerDir = PLAYER_DIR_BACK_R; + } +} + +void EnHorse_TiltBody(EnHorse* this, GlobalContext* globalCtx) { + f32 speed; + f32 rollDiff; + s32 targetRoll; + s16 turnVel; + + speed = this->actor.speedXZ / 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; + + if (fabsf(targetRoll) < 100.0f) { + this->actor.world.rot.z = 0; + } else if (fabsf(rollDiff) < 100.0f) { + this->actor.world.rot.z = targetRoll; + } else if (rollDiff > 0.0f) { + this->actor.world.rot.z += 0x64; + } else { + this->actor.world.rot.z -= 0x64; + } + + this->actor.shape.rot.z = this->actor.world.rot.z; +} + +s32 EnHorse_UpdateConveyors(EnHorse* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 conveyorDir; + + if ((this->actor.floorPoly == NULL) || (&this->actor != player->rideActor) || + !SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + return false; + } + + conveyorDir = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + conveyorDir = (conveyorDir * 0x400) - this->actor.world.rot.y; + if (conveyorDir > 0x640) { + this->actor.world.rot.y += 0x640; + } else if (conveyorDir < -0x640) { + this->actor.world.rot.y -= 0x640; + } else { + this->actor.world.rot.y += conveyorDir; + } + this->actor.shape.rot.y = this->actor.world.rot.y; + return true; +} + +s32 EnHorse_RandInt(f32 arg0) { + return Rand_ZeroOne() * arg0; +} + +#ifdef NON_MATCHING +void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx) { + static EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, + }; + s32 pad; + EnHorse* this = THIS; + Vec3f dustAcc = { 0.0f, 0.0f, 0.0f }; + Vec3f dustVel = { 0.0f, 1.0f, 0.0f }; + Player* player = GET_PLAYER(globalCtx); + + if (this->type == HORSE_2) { + Actor_SetScale(&this->actor, 0.00648f); + } else if (this->type == HORSE_4) { + Actor_SetScale(&this->actor, 0.008f); + } else { + Actor_SetScale(&this->actor, 0.01f); + } + + this->lastYaw = this->actor.shape.rot.y; + EnHorse_UpdateStick(this, globalCtx); + EnHorse_UpdatePlayerDir(this, globalCtx); + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + EnHorse_MountDismount(this, globalCtx); + } + + if (this->stateFlags & ENHORSE_FLAG_19) { + if ((this->stateFlags & ENHORSE_FLAG_20) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_20; + EnHorse_StartRearing(this); + } else if (!(this->stateFlags & ENHORSE_FLAG_20) && (this->stateFlags & ENHORSE_FLAG_21) && + (this->action != ENHORSE_ACT_REVERSE) && (this->inRace == true)) { + this->stateFlags &= ~ENHORSE_FLAG_21; + EnHorse_StartRearing(this); + } + } + + sActionFuncs[this->action](this, globalCtx); + + this->stateFlags &= ~ENHORSE_OBSTACLE; + this->unk_3EC = this->actor.world.rot.y; + if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { + this->skin.skelAnime.jointTable[0].y += 0x154; + } + + this->curFrame = this->skin.skelAnime.curFrame; + this->lastPos = this->actor.world.pos; + + if (!(this->stateFlags & ENHORSE_INACTIVE)) { + if ((this->action == ENHORSE_ACT_STOPPING) || (this->action == ENHORSE_ACT_MOUNTED_REARING) || + (this->action == ENHORSE_ACT_MOUNTED_GALLOP)) { + func_80886C00(this, globalCtx); + } + + if (this->playerControlled == true) { + EnHorse_RegenBoost(this, globalCtx); + } + + if (ActorCutscene_GetCurrentIndex() != -1) { + this->actor.speedXZ = 0.0f; + } + + if (this->action != ENHORSE_ACT_25) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->rider != NULL) { + if ((this->action == ENHORSE_ACT_INGO_RACE) || (this->action == ENHORSE_ACT_MOUNTED_IDLE) || + (this->action == ENHORSE_ACT_25)) { + this->rider->actor.world.pos.x = this->actor.world.pos.x; + this->rider->actor.world.pos.y = this->actor.world.pos.y + 10.0f; + this->rider->actor.world.pos.z = this->actor.world.pos.z; + this->rider->actor.shape.rot.x = this->actor.shape.rot.x; + this->rider->actor.shape.rot.y = this->actor.shape.rot.y; + } else if (this->action == ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING) { + EnIn* in = this->rider; + s16 jnt = in->jointTable[0].y; + + in->actor.world.pos.x = this->riderPos.x; + in->actor.world.pos.y = this->riderPos.y - (jnt * 0.01f * this->unk_528 * 0.01f); + in->actor.world.pos.z = this->riderPos.z; + in->actor.shape.rot.x = this->actor.shape.rot.x; + in->actor.shape.rot.y = this->actor.shape.rot.y; + } + } + + if (this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) { + if (this->actor.speedXZ > 10.0f) { + this->actor.speedXZ -= 1.0f; + } + } + + if ((this->colliderJntSph.base.acFlags & AC_HIT) && (this->stateFlags & ENHORSE_DRAW)) { + if (this->type == HORSE_2) { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_KID_HORSE_NEIGH); + } else { + Audio_PlaySfxAtPos(&this->unk_218, NA_SE_EV_HORSE_NEIGH); + } + } + + if ((this->action != ENHORSE_ACT_INGO_RACE) && (this->action != ENHORSE_ACT_MOUNTED_IDLE) && + (this->action != ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING)) { + EnHorse_TiltBody(this, globalCtx); + } + + if ((this->playerControlled == false) && (this->unk_1EC & 8)) { + if ((this->colliderJntSph.elements->info.ocElemFlags & OCELEM_HIT) && + (this->colliderJntSph.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder1.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder1.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + + if ((this->colliderCylinder2.base.ocFlags1 & OC1_HIT) && + (this->colliderCylinder2.base.oc->id == ACTOR_EN_IN)) { + func_80884868(this); + } + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder1); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder2); + + if (this->type == HORSE_2) { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * -18.0f) + this->colliderCylinder2.dim.pos.z; + } else { + this->colliderCylinder1.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.x; + this->colliderCylinder1.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * 6.6000004f) + this->colliderCylinder1.dim.pos.z; + this->colliderCylinder2.dim.pos.x = + (s16)(Math_SinS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.x; + this->colliderCylinder2.dim.pos.z = + (s16)(Math_CosS(this->actor.shape.rot.y) * -10.8f) + this->colliderCylinder2.dim.pos.z; + } + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + if (!(this->stateFlags & ENHORSE_JUMPING) && !(this->unk_1EC & 0x20)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } else { + this->unk_1EC &= ~0x20; + } + + if (this->unk_1EC & 0x100) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder2.base); + } + + if ((player->stateFlags1 & ENHORSE_BOOST) && (player->rideActor != NULL)) { + EnHorse_UpdateConveyors(this, globalCtx); + } + + EnHorse_UpdateBgCheckInfo(this, globalCtx); + EnHorse_CheckFloors(this, globalCtx); + if (this->actor.world.pos.y < this->yFront) { + if (this->actor.world.pos.y < this->yBack) { + if (this->yBack < this->yFront) { + this->actor.world.pos.y = this->yBack; + } else { + this->actor.world.pos.y = this->yFront; + } + } + } + + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 70.0f; + + if ((Rand_ZeroOne() < 0.025f) && (this->blinkTimer == 0)) { + this->blinkTimer++; + } else if (this->blinkTimer > 0) { + this->blinkTimer++; + if (this->blinkTimer > 3) { + this->blinkTimer = 0; + } + } + + if ((this->actor.speedXZ == 0.0f) && !(this->stateFlags & ENHORSE_FLAG_19)) { + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->actor.colChkInfo.mass = MASS_HEAVY; + } + + if (this->actor.speedXZ >= 5.0f) { + this->colliderCylinder1.base.atFlags |= AT_ON; + } else { + this->colliderCylinder1.base.atFlags &= ~AT_ON; + } + + if (this->dustFlags & 1) { + this->dustFlags &= ~1; + func_800B12F0(globalCtx, &this->frontRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 2) { + this->dustFlags &= ~2; + func_800B12F0(globalCtx, &this->frontLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 4) { + this->dustFlags &= ~4; + func_800B12F0(globalCtx, &this->backRightHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } else if (this->dustFlags & 8) { + this->dustFlags &= ~8; + func_800B12F0(globalCtx, &this->backLeftHoof, &dustVel, &dustAcc, EnHorse_RandInt(100.0f) + 200, + EnHorse_RandInt(10.0f) + 30, EnHorse_RandInt(20.0f) + 30); + } + this->stateFlags &= ~ENHORSE_DRAW; + } +} +#else +EnHorseActionFunc sActionFuncs[] = { + EnHorse_Frozen, + EnHorse_Inactive, + EnHorse_Idle, + EnHorse_FollowPlayer, + EnHorse_UpdateIngoRace, + func_808819D8, + func_80881398, + EnHorse_MountedIdle, + EnHorse_MountedIdleWhinneying, + EnHorse_MountedTurn, + EnHorse_MountedWalk, + EnHorse_MountedTrot, + EnHorse_MountedGallop, + EnHorse_MountedRearing, + EnHorse_Stopping, + EnHorse_Reverse, + EnHorse_LowJump, + EnHorse_HighJump, + EnHorse_CutsceneUpdate, + EnHorse_UpdateHorsebackArchery, + EnHorse_FleePlayer, + func_80884718, + func_8087CA04, + func_808848C8, + func_80884A40, + func_80884E0C, +}; +Vec3f D_808891C8 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_808891D4 = { 0.0f, 1.0f, 0.0f }; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Update.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D20.s") +s32 EnHorse_PlayerDirToMountSide(EnHorse* this, GlobalContext* globalCtx, Player* player) { + if (this->playerDir == PLAYER_DIR_SIDE_L) { + return -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887D60.s") + if (this->playerDir == PLAYER_DIR_SIDE_R) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887E64.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887EBC.s") +s32 EnHorse_MountSideCheck(EnHorse* this, GlobalContext* globalCtx, Player* player) { + s32 mountSide; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80887F58.s") + if (Actor_XZDistanceBetweenActors(&this->actor, &player->actor) > 75.0f) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888C48.s") + if (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) > 30.0f) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/func_80888D18.s") + if (Math_CosS(Actor_YawBetweenActors(&player->actor, &this->actor) - player->actor.world.rot.y) < + 0.17364818f) { // cos(80 degrees) + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse/EnHorse_Draw.s") + mountSide = EnHorse_PlayerDirToMountSide(this, globalCtx, player); + if (mountSide == -1) { + return -1; + } + + if (mountSide == 1) { + return 1; + } + + return 0; +} + +s32 EnHorse_GetMountSide(EnHorse* this, GlobalContext* globalCtx) { + if (this->action != ENHORSE_ACT_IDLE) { + return 0; + } + + if ((this->animationIdx != ENHORSE_ANIM_IDLE) && (this->animationIdx != ENHORSE_ANIM_WHINNEY)) { + return 0; + } + + return EnHorse_MountSideCheck(this, globalCtx, GET_PLAYER(globalCtx)); +} + +void EnHorse_RandomOffset(Vec3f* src, f32 dist, Vec3f* dst) { + dst->x = ((Rand_ZeroOne() * (2.0f * dist)) + src->x) - dist; + dst->y = ((Rand_ZeroOne() * (2.0f * dist)) + src->y) - dist; + dst->z = ((Rand_ZeroOne() * (2.0f * dist)) + src->z) - dist; +} + +void EnHorse_PostDraw(Actor* thisx, GlobalContext* globalCtx, Skin* skin) { + s32 pad; + EnHorse* this = THIS; + Vec3f sp7C = { 0.0f, 0.0f, 0.0f }; + Vec3f hoofOffset = { 5.0f, -4.0f, 5.0f }; + Vec3f sp64; + f32 curFrame = this->skin.skelAnime.curFrame; + Vec3f center; + Vec3f newCenter; + s32 i; + Vec3f sp38; + f32 sp34; + + if (!(this->stateFlags & ENHORSE_CALC_RIDER_POS)) { + if (this->type == HORSE_2) { + Skin_GetVertexPos(skin, 5, 120, &this->riderPos); + this->riderPos.y += 13.0f; + } else { + Vec3f riderOffset = { 600.0f, -1670.0f, 0.0f }; + + Skin_GetLimbPos(skin, 30, &riderOffset, &this->riderPos); + } + this->riderPos.x -= this->actor.world.pos.x; + this->riderPos.y -= this->actor.world.pos.y; + this->riderPos.z -= this->actor.world.pos.z; + } else { + this->stateFlags &= ~ENHORSE_CALC_RIDER_POS; + } + + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } else { + Skin_GetLimbPos(skin, 13, &sp7C, &sp38); + } + + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp38, &this->unk_218, &sp34); + + if ((this->animationIdx == ENHORSE_ANIM_IDLE) && (this->action != ENHORSE_ACT_FROZEN) && + (((curFrame > 40.0f) && (curFrame < 45.0f) && (this->type == 0)) || + ((curFrame > 28.0f) && (curFrame < 33.0f) && (this->type == 1)))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + Skin_GetLimbPos(skin, 28, &hoofOffset, &this->frontRightHoof); + this->frontRightHoof.y -= 5.0f; + } + } else { + if (this->action == ENHORSE_ACT_LOW_JUMP) { + if (((curFrame > 10.0f) && (curFrame < 13.0f)) || ((curFrame > 25.0f) && (curFrame < 33.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + curFrame = curFrame; + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontRightHoof); + } + } + + if (((curFrame > 6.0f) && (curFrame < 10.0f)) || ((curFrame > 23.0f) && (curFrame < 29.0f))) { + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } + + if ((((curFrame > 7.0f) && (curFrame < 14.0f)) || ((curFrame > 26.0f) && (curFrame < 30.0f))) && + (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if (this->animationIdx == ENHORSE_ANIM_GALLOP) { + if ((curFrame > 14.0f) && (curFrame < 16.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 1; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 5.0f, &this->frontRightHoof); + } else if ((curFrame > 8.0f) && (curFrame < 10.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 2; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 20, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->frontLeftHoof); + } else if ((curFrame > 1.0f) && (curFrame < 3.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } else if ((curFrame > 26.0f) && (curFrame < 28.0f) && (Rand_ZeroOne() < 0.02f)) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + } else if ((this->action == ENHORSE_ACT_BRIDGE_JUMP) && (curFrame > 6.0f) && + (Rand_ZeroOne() < (1.0f - ((curFrame - 6.0f) * (1.0f / 17.0f))))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } else if ((this->action == ENHORSE_ACT_CS_UPDATE) && (curFrame > 5.0f)) { + if (Rand_ZeroOne() < (1.0f - ((curFrame - 5.0f) * 0.04f))) { + if (Rand_ZeroOne() < 0.05f) { + this->dustFlags |= 8; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 36, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 37, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backLeftHoof); + } + + if (Rand_ZeroOne() < 0.02f) { + this->dustFlags |= 4; + if (this->type == HORSE_2) { + Skin_GetLimbPos(skin, 44, &hoofOffset, &sp64); + } else { + Skin_GetLimbPos(skin, 45, &hoofOffset, &sp64); + } + EnHorse_RandomOffset(&sp64, 10.0f, &this->backRightHoof); + } + } + } + } + + for (i = 0; i < this->colliderJntSph.count; i++) { + center.x = this->colliderJntSph.elements[i].dim.modelSphere.center.x; + center.y = this->colliderJntSph.elements[i].dim.modelSphere.center.y; + center.z = this->colliderJntSph.elements[i].dim.modelSphere.center.z; + + Skin_GetLimbPos(skin, this->colliderJntSph.elements[i].dim.limb, ¢er, &newCenter); + + this->colliderJntSph.elements[i].dim.worldSphere.center.x = newCenter.x; + this->colliderJntSph.elements[i].dim.worldSphere.center.y = newCenter.y; + this->colliderJntSph.elements[i].dim.worldSphere.center.z = newCenter.z; + + this->colliderJntSph.elements[i].dim.worldSphere.radius = + this->colliderJntSph.elements[i].dim.modelSphere.radius * this->colliderJntSph.elements[i].dim.scale; + } + + //! @bug Setting colliders in a draw function allows for duplicate entries to be added to their respective lists + //! under certain conditions, like when pausing and unpausing the game. + //! Actors will draw for a couple of frames between the pauses, but some important logic updates will not occur. + //! In the case of OC, this can cause unwanted effects such as a very large amount of displacement being applied to + //! a colliding actor. + if (!(this->stateFlags & ENHORSE_JUMPING)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnHorse_OverrideLimbDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbIndex, Skin* skin) { + static TexturePtr D_80889204[] = { + object_horse_link_child_Tex_001D28, + object_horse_link_child_Tex_001928, + object_horse_link_child_Tex_001B28, + }; + static u8 D_80889210[] = { 0, 1, 2, 1 }; + EnHorse* this = THIS; + s32 drawOriginalLimb = true; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((limbIndex != 13) || (this->type != HORSE_EPONA)) { + if ((limbIndex == 13) && (this->type == HORSE_2)) { + u8 idx = D_80889210[this->blinkTimer]; + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80889204[idx])); + } else if ((this->type == HORSE_HNI) && (this->stateFlags & ENHORSE_FLAG_18) && (limbIndex == 30)) { + drawOriginalLimb = false; + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return drawOriginalLimb; +} + +s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + Vec3f sp1C = { -98.0f, -1454.0f, 0.0f }; + EnHorse* this = THIS; + + if (limbIndex == 3) { + Matrix_MultiplyVector3fByState(&sp1C, &this->riderPos); + } + return false; +} + +void EnHorse_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorse* this = THIS; + + if (!(this->stateFlags & ENHORSE_INACTIVE) && (this->actor.update != func_8087D540)) { + func_8012C28C(globalCtx->state.gfxCtx); + this->stateFlags |= ENHORSE_DRAW; + if (!(this->unk_1EC & 1)) { + if (this->stateFlags & ENHORSE_JUMPING) { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, false); + } else { + func_80138258(&this->actor, globalCtx, &this->skin, EnHorse_PostDraw, EnHorse_OverrideLimbDraw, true); + } + } else { + if (this->stateFlags & ENHORSE_JUMPING) { + this->skin.skelAnime.jointTable->x = 0; + this->skin.skelAnime.jointTable->y = 0; + this->skin.skelAnime.jointTable->z = 0; + } + SkelAnime_DrawFlexOpa(globalCtx, this->skin.skelAnime.skeleton, this->skin.skelAnime.jointTable, + this->skin.skelAnime.dListCount, func_80888D18, NULL, &this->actor); + } + + if (this->postDrawFunc != NULL) { + this->postDrawFunc(this, globalCtx); + } + } +} 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 787fd8b57..2dc5e44f5 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -2,16 +2,218 @@ #define Z_EN_HORSE_H #include "global.h" +#include "z64skin.h" +#include "overlays/actors/ovl_En_In/z_en_in.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ha/object_ha.h" struct EnHorse; +typedef void (*EnHorseActionFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorsePostdrawFunc)(struct EnHorse*, GlobalContext*); +typedef void (*EnHorseCsFunc)(struct EnHorse*, GlobalContext*, CsCmdActorAction*); + +#define ENHORSE_BOOST (1 << 0) /* 0x1 */ +#define ENHORSE_BOOST_DECEL (1 << 1) /* 0x2 */ +#define ENHORSE_JUMPING (1 << 2) /* 0x4 */ +#define ENHORSE_CALC_RIDER_POS (1 << 3) /* 0x8 */ +#define ENHORSE_FORCE_REVERSING (1 << 4) /* 0x10 */ +#define ENHORSE_FORCE_WALKING (1 << 5) /* 0x20 */ +#define ENHORSE_FLAG_6 (1 << 6) /* 0x40 */ +#define ENHORSE_FLAG_7 (1 << 7) /* 0x80 */ +#define ENHORSE_FLAG_8 (1 << 8) /* 0x100 */ +#define ENHORSE_FLAG_9 (1 << 9) /* 0x200 */ +#define ENHORSE_STOPPING_NEIGH_SOUND (1 << 10) /* 0x400 */ +#define ENHORSE_LAND2_SOUND (1 << 11) /* 0x800 */ +#define ENHORSE_SANDDUST_SOUND (1 << 12) /* 0x1000 */ +#define ENHORSE_INACTIVE (1 << 13) /* 0x2000 */ +#define ENHORSE_OBSTACLE (1 << 14) /* 0x4000 */ +#define ENHORSE_TURNING_TO_PLAYER (1 << 15) /* 0x8000 */ +#define ENHORSE_UNRIDEABLE (1 << 16) /* 0x10000 */ +#define ENHORSE_CANT_JUMP (1 << 17) /* 0x20000 */ +#define ENHORSE_FLAG_18 (1 << 18) /* 0x40000 */ +#define ENHORSE_FLAG_19 (1 << 19) /* 0x80000 */ +#define ENHORSE_FLAG_20 (1 << 20) /* 0x100000 */ +#define ENHORSE_FLAG_21 (1 << 21) /* 0x200000 */ +#define ENHORSE_FIRST_BOOST_REGEN (1 << 22) /* 0x400000 */ +#define ENHORSE_INGO_WON (1 << 23) /* 0x800000 */ +#define ENHORSE_FLAG_24 (1 << 24) /* 0x1000000 */ +#define ENHORSE_FLAG_25 (1 << 25) /* 0x2000000 */ +#define ENHORSE_FLAG_26 (1 << 26) /* 0x4000000 */ +#define ENHORSE_DRAW (1 << 27) /* 0x8000000 */ +#define ENHORSE_FLAG_28 (1 << 28) /* 0x10000000 */ +#define ENHORSE_FLAG_29 (1 << 29) /* 0x20000000 */ +#define ENHORSE_FLAG_30 (1 << 30) /* 0x40000000 */ +#define ENHORSE_FLAG_31 (1 << 31) /* 0x80000000 */ + +typedef enum { + /* 0 */ ENHORSE_ACT_FROZEN, + /* 1 */ ENHORSE_ACT_INACTIVE, + /* 2 */ ENHORSE_ACT_IDLE, + /* 3 */ ENHORSE_ACT_FOLLOW_PLAYER, + /* 4 */ ENHORSE_ACT_INGO_RACE, + /* 5 */ ENHORSE_ACT_MOUNTED_IDLE, + /* 6 */ ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING, + /* 7 */ ENHORSE_ACT_MOUNTED_TURN, + /* 8 */ ENHORSE_ACT_MOUNTED_WALK, + /* 9 */ ENHORSE_ACT_MOUNTED_TROT, + /* 10 */ ENHORSE_ACT_MOUNTED_GALLOP, + /* 11 */ ENHORSE_ACT_MOUNTED_REARING, + /* 12 */ ENHORSE_ACT_STOPPING, + /* 13 */ ENHORSE_ACT_REVERSE, + /* 14 */ ENHORSE_ACT_LOW_JUMP, + /* 15 */ ENHORSE_ACT_HIGH_JUMP, + /* 16 */ ENHORSE_ACT_BRIDGE_JUMP, + /* 17 */ ENHORSE_ACT_CS_UPDATE, + /* 18 */ ENHORSE_ACT_HBA, + /* 19 */ ENHORSE_ACT_FLEE_PLAYER, + /* 20 */ ENHORSE_ACT_20, + /* 21 */ ENHORSE_ACT_21, + /* 22 */ ENHORSE_ACT_22, + /* 23 */ ENHORSE_ACT_23, + /* 24 */ ENHORSE_ACT_24, + /* 25 */ ENHORSE_ACT_25, +} EnHorseAction; + +typedef enum { + /* 0 */ PLAYER_DIR_FRONT_R, + /* 1 */ PLAYER_DIR_FRONT_L, + /* 2 */ PLAYER_DIR_BACK_R, + /* 3 */ PLAYER_DIR_BACK_L, + /* 4 */ PLAYER_DIR_SIDE_R, + /* 5 */ PLAYER_DIR_SIDE_L +} EnHorsePlayerDir; + +typedef enum { + /* 0 */ ENHORSE_ANIM_IDLE, + /* 1 */ ENHORSE_ANIM_WHINNEY, + /* 2 */ ENHORSE_ANIM_STOPPING, + /* 3 */ ENHORSE_ANIM_REARING, + /* 4 */ ENHORSE_ANIM_WALK, + /* 5 */ ENHORSE_ANIM_TROT, + /* 6 */ ENHORSE_ANIM_GALLOP, + /* 7 */ ENHORSE_ANIM_LOW_JUMP, + /* 8 */ ENHORSE_ANIM_HIGH_JUMP +} EnHorseAnimationIndex; + +typedef enum { + /* 0 */ HORSE_EPONA, + /* 1 */ HORSE_HNI, + /* 2 */ HORSE_2, + /* 3 */ HORSE_3, + /* 4 */ HORSE_4 +} HorseType; + +#define ENHORSE_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENHORSE_GET_4000(thisx) ((thisx)->params & 0x4000) +#define ENHORSE_GET_8000(thisx) ((thisx)->params & 0x8000) + +enum { + /* 0 */ ENHORSE_0, + /* 1 */ ENHORSE_1, + /* 2 */ ENHORSE_2, + /* 3 */ ENHORSE_3, + /* 4 */ ENHORSE_4, + /* 5 */ ENHORSE_5, + /* 6 */ ENHORSE_6, + /* 7 */ ENHORSE_7, + /* 8 */ ENHORSE_8, + /* 9 */ ENHORSE_9, + /* 10 */ ENHORSE_10, + /* 11 */ ENHORSE_11, + /* 12 */ ENHORSE_12, + /* 13 */ ENHORSE_13, + /* 14 */ ENHORSE_14, + /* 15 */ ENHORSE_15, + /* 16 */ ENHORSE_16, + /* 17 */ ENHORSE_17, + /* 18 */ ENHORSE_18, + /* 19 */ ENHORSE_19, + /* 20 */ ENHORSE_20, +}; + typedef struct EnHorse { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xC]; - /* 0x150 */ s32 unk_150; - /* 0x154 */ char unk_154[0x98]; - /* 0x1EC */ UNK_TYPE4 unk_1EC; - /* 0x1F0 */ char unk_1F0[0x3A4]; + /* 0x144 */ s32 action; + /* 0x148 */ s32 noInputTimer; + /* 0x14C */ s32 noInputTimerMax; + /* 0x150 */ s32 type; + /* 0x154 */ s8 bankIndex; + /* 0x158 */ Skin skin; + /* 0x1E8 */ s32 stateFlags; + /* 0x1EC */ s32 unk_1EC; + /* 0x1F0 */ Vec3f lastPos; + /* 0x1FC */ s16 lastYaw; + /* 0x200 */ s32 curRaceWaypoint; + /* 0x204 */ s32 boostSpeed; + /* 0x208 */ s32 playerControlled; + /* 0x20C */ s32 animationIdx; + /* 0x210 */ f32 curFrame; + /* 0x214 */ s32 soundTimer; + /* 0x218 */ Vec3f unk_218; + /* 0x224 */ UNK_TYPE1 unk224[0xC]; + /* 0x230 */ s32 unk_230; + /* 0x234 */ u8 numBoosts; + /* 0x238 */ s32 boostRegenTime; + /* 0x23C */ s32 boostTimer; + /* 0x240 */ EnHorsePostdrawFunc postDrawFunc; + /* 0x244 */ f32 yFront; + /* 0x248 */ f32 yBack; + /* 0x24C */ s32 unk_24C; + /* 0x250 */ s16 followTimer; + /* 0x254 */ s32 prevAction; + /* 0x258 */ Vec3f riderPos; + /* 0x264 */ Vec2f curStick; + /* 0x26C */ Vec2f lastStick; + /* 0x274 */ f32 jumpStartY; + /* 0x278 */ ColliderCylinder colliderCylinder1; + /* 0x2C4 */ ColliderCylinder colliderCylinder2; + /* 0x310 */ ColliderJntSph colliderJntSph; + /* 0x330 */ ColliderJntSphElement colliderJntSphElements[1]; + /* 0x370 */ s32 playerDir; + /* 0x374 */ UNK_TYPE1 unk374[0x2]; + /* 0x376 */ s16 angleToPlayer; + /* 0x378 */ s16 followPlayerTurnSpeed; + /* 0x37A */ u8 blinkTimer; + /* 0x37C */ s16 waitTimer; + /* 0x380 */ s32 cutsceneAction; + /* 0x384 */ u16 cutsceneFlags; + /* 0x388 */ s32 inRace; + /* 0x38C */ struct EnIn* rider; + /* 0x390 */ UNK_TYPE1 unk390[0x4]; + /* 0x394 */ u16 unk_394; + /* 0x398 */ f32 unk_398; + /* 0x39C */ s32 unk_39C; + /* 0x3A0 */ s32 hbaStarted; + /* 0x3A4 */ s32 hbaFlags; + /* 0x3A8 */ s32 hbaTimer; + /* 0x3AC */ u16 dustFlags; + /* 0x3B0 */ Vec3f frontRightHoof; + /* 0x3BC */ Vec3f frontLeftHoof; + /* 0x3C8 */ Vec3f backRightHoof; + /* 0x3D4 */ Vec3f backLeftHoof; + /* 0x3E0 */ s32 unk_3E0; + /* 0x3E4 */ UNK_TYPE1 unk3E4[0x4]; + /* 0x3E8 */ f32 unk_3E8; + /* 0x3EC */ s16 unk_3EC; + /* 0x3EE */ Vec3s jointTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x48A */ Vec3s morphTable[OBJECT_HA_1_LIMB_MAX]; + /* 0x528 */ f32 unk_528; + /* 0x52C */ s32 unk_52C; + /* 0x530 */ s32 unk_530; + /* 0x534 */ s32 unk_534; + /* 0x538 */ s32 unk_538; + /* 0x53C */ s32 unk_53C; + /* 0x540 */ Vec3f unk_540; + /* 0x54C */ UNK_TYPE1 unk54C[0x4]; + /* 0x550 */ s32 unk_550; + /* 0x554 */ UNK_TYPE1 unk554[0x18]; + /* 0x56C */ f32 unk_56C; + /* 0x570 */ Vec3f unk_570; + /* 0x57C */ Vec3f unk_57C; + /* 0x588 */ UNK_TYPE1 unk588[0x4]; + /* 0x58C */ s32 unk_58C; + /* 0x590 */ s32 unk_590; } EnHorse; // size = 0x594 extern const ActorInit En_Horse_InitVars; 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 423acc7bf..7b9fa684e 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 @@ -5,8 +5,9 @@ */ #include "z_en_horse_game_check.h" +#include "objects/object_horse_game_check/object_horse_game_check.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnHorseGameCheck*)thisx) @@ -15,7 +16,25 @@ void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx); void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2); +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx); +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx); + const ActorInit En_Horse_Game_Check_InitVars = { ACTOR_EN_HORSE_GAME_CHECK, ACTORCAT_BG, @@ -28,63 +47,454 @@ const ActorInit En_Horse_Game_Check_InitVars = { (ActorFunc)EnHorseGameCheck_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F9BDC[] = { +#include "overlays/ovl_En_Horse_Game_Check/ovl_En_Horse_Game_Check.c" + +s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.001f; + this->dyna.actor.flags |= ACTOR_FLAG_400000; + + DynaPolyActor_Init(&this->dyna, 0); + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_003918, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_5; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 3.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_SetCurrentState(&sp38); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp38); + + func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F8C24(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F8C5C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +s32 func_808F8C70(EnHorseGameCheck* this, GlobalContext* globalCtx) { + if (Matrix_NewMtx(globalCtx->state.gfxCtx) == NULL) { + return true; + } else { + Gfx_DrawDListXlu(globalCtx, object_horse_game_check_DL_003030); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0030C0); + } + return true; +} + +s32 func_808F8CCC(EnHorseGameCheck* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 pad; + Vec3f sp4C = { -1262.0f, 15.0f, 780.0f }; + Vec3f sp40 = { -1262.0f, -26.0f, 470.0f }; + + this->unk_164 = 0; + this->unk_168 = 0; + this->unk_174 = 0; + + if (GET_RACE_FLAGS != RACE_FLAG_START) { + Actor_MarkForDeath(&this->dyna.actor); + return false; + } + + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + + this->horse1 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1149.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2004); + if (this->horse1 == NULL) { + __assert("../z_en_horse_game_check.c", 1517); + } + + this->horse2 = (EnHorse*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -1376.0f, -106.0f, 470.0f, 0, + 0x7FFF, 0, 0x2005); + if (this->horse2 == NULL) { + __assert("../z_en_horse_game_check.c", 1526); + } + + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 10); + Play_CameraSetAtEye(globalCtx, 0, &sp40, &sp4C); + Play_CameraSetFov(globalCtx, 0, 45.0f); + func_800FE484(); + return false; +} + +s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + return true; +} + +s32 func_808F8EB0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (globalCtx->nextEntranceIndex == 0xCE20) { + return false; + } + + if (GET_RACE_FLAGS == RACE_FLAG_3) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 2; + } else if (GET_RACE_FLAGS == RACE_FLAG_2) { + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; + } else if (GET_RACE_FLAGS == RACE_FLAG_4) { + SET_RACE_FLAGS(RACE_FLAG_3); + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + } + + D_801BDA9C = 0; + if (player->stateFlags1 & 0x800000) { + D_801BDAA0 = 1; + } + globalCtx->nextEntranceIndex = 0xCE20; + globalCtx->sceneLoadFlag = 0x14; + return false; +} + +f32 D_808F9BAC[] = { + -1825.0f, + -237.0f, + -2867.0f, + -1987.0f, +}; + +f32 D_808F9BBC[] = { + 1564.0f, + 3395.0f, + -1665.0f, + -200.0f, +}; + +f32 D_808F9BCC[] = { + -22.0f, + 2005.0f, + 3869.0f, + 5368.0f, +}; + +s32 func_808F8FAC(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + EnHorse* horse = (EnHorse*)player->rideActor; + s32 pad3[2]; + EnHorseGameCheck* horseGameCheck; + + if (horse == NULL) { + return true; + } + + if ((this->unk_168 > 50) && !(this->unk_164 & 2)) { + this->unk_164 |= 2; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 1)) { + this->unk_164 |= 1; + horse->inRace = true; + } else if ((globalCtx->interfaceCtx.unk_280 >= 8) && !(this->unk_164 & 8)) { + EnHorse* horse = this->horse1; + + horse->inRace = true; + horse = this->horse2; + horse->inRace = true; + + this->unk_164 |= 8; + this->unk_17C = this->unk_168; + } + + if ((this->unk_17C != -1) && ((this->unk_168 - this->unk_17C) > 10)) { + this->unk_17C = -1; + func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 4); + } + + this->unk_168++; + if ((this->unk_164 & 0x4000) && (this->unk_164 & 0x200000)) { + if (!(this->unk_164 & 0x10)) { + this->unk_164 |= 0x10; + } + } + + if ((this->unk_164 & 0x800) || (this->unk_164 & 0x40000) || (this->unk_164 & 0x02000000)) { + if (this->unk_174 > 0) { + this->unk_174--; + } else { + func_808F8EB0(this, globalCtx); + } + return true; + } + + if (gSaveContext.unk_3DE0[4] >= 0x4650) { + Audio_QueueSeqCmd(0x8041); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_4) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x1000; + } + } + + if (!(this->unk_164 & 0x2000) && (this->unk_164 & 0x1000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x2000; + } + } + + if (!(this->unk_164 & 0x4000) && (this->unk_164 & 0x2000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse1->actor.world.pos.x, this->horse1->actor.world.pos.z)) { + this->unk_164 |= 0x4000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse1->unk_24C); + 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); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x40000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x80000; + } + } + + if (!(this->unk_164 & 0x100000) && (this->unk_164 & 0x80000)) { + if (Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x100000; + } + } + + if (!(this->unk_164 & 0x200000) && (this->unk_164 & 0x100000)) { + if (Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], + this->horse2->actor.world.pos.x, this->horse2->actor.world.pos.z)) { + this->unk_164 |= 0x200000; + } + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, this->horse2->unk_24C); + 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); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x02000000; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_3) + this->unk_174 = 60; + } + + if (!(this->unk_164 & 0x20) && Math3D_XZBoundCheck(D_808F9BAC[0], D_808F9BAC[1], D_808F9BAC[2], D_808F9BAC[3], + horse->actor.world.pos.x, horse->actor.world.pos.z)) { + this->unk_164 |= 0x20; + } + + if (!(this->unk_164 & 0x40) && (this->unk_164 & 0x20) && + Math3D_XZBoundCheck(D_808F9BBC[0], D_808F9BBC[1], D_808F9BBC[2], D_808F9BBC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x40; + } + + if (!(this->unk_164 & 0x80) && (this->unk_164 & 0x40) && + Math3D_XZBoundCheck(D_808F9BCC[0], D_808F9BCC[1], D_808F9BCC[2], D_808F9BCC[3], horse->actor.world.pos.x, + horse->actor.world.pos.z)) { + this->unk_164 |= 0x80; + } + + horseGameCheck = (EnHorseGameCheck*)DynaPoly_GetActor(&globalCtx->colCtx, horse->unk_24C); + 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); + play_sound(NA_SE_SY_START_SHOT); + this->unk_164 |= 0x800; + gSaveContext.unk_3DD0[4] = 6; + SET_RACE_FLAGS(RACE_FLAG_2) + this->unk_174 = 60; + } + return true; +} + +s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp78 = NULL; + MtxF sp38; + + this->dyna.actor.scale.x = this->dyna.actor.scale.y = this->dyna.actor.scale.z = this->unk_160 * 0.01f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&ovl_En_Horse_Game_Check_Colheader_0010C8, &sp78); + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->unk_15C = ENHORSEGAMECHECK_FF_7; + this->dyna.actor.floorPoly = NULL; + this->dyna.actor.world.pos.y += 100.0f; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor2( + globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->dyna.actor.world.pos); + this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight + 1.0f; + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp38); + + Matrix_SetCurrentState(&sp38); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.y, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp38); + + func_8018219C(&sp38, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + return true; +} + +s32 func_808F9830(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} + +s32 func_808F9868(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 2400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_STOP), }; -#endif +s32 func_808F987C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + s32 pad[3]; + CollisionHeader* sp28 = NULL; + s32 pad2; -extern InitChainEntry D_808F9BDC[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.scale.z = 1.0f; + this->dyna.actor.scale.y = 1.0f; + this->dyna.actor.scale.x = 1.0f; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_002FB8, &sp28); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp28); + this->unk_15C = ENHORSEGAMECHECK_FF_8; + return true; +} -extern UNK_TYPE D_060014B0; -extern UNK_TYPE D_06002FB8; -extern UNK_TYPE D_06003030; -extern UNK_TYPE D_06003918; +s32 func_808F990C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8AA0.s") +s32 func_808F9944(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C24.s") +s32 func_808F9958(EnHorseGameCheck* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0014B0); + Gfx_DrawDListOpa(globalCtx, object_horse_game_check_DL_0013A0); + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C5C.s") +s32 func_808F999C(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8C70.s") +s32 func_808F99B0(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8CCC.s") +s32 func_808F99C4(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8E94.s") +s32 func_808F99D8(EnHorseGameCheck* this, GlobalContext* globalCtx) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8EB0.s") +EnHorseGameCheckUnkFunc D_808F9BE4[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8AA0, func_808F8CCC, func_808F96E4, func_808F987C, func_808F999C, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F8FAC.s") +EnHorseGameCheckUnkFunc D_808F9C0C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C24, func_808F8E94, func_808F9830, func_808F990C, func_808F99B0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F96E4.s") +EnHorseGameCheckUnkFunc D_808F9C34[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C5C, func_808F8FAC, func_808F9868, func_808F9944, func_808F99C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9830.s") +EnHorseGameCheckUnkFunc D_808F9C5C[] = { + NULL, NULL, NULL, NULL, NULL, func_808F8C70, NULL, NULL, func_808F9958, func_808F99D8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9868.s") +void EnHorseGameCheck_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F987C.s") + this->unk_15C = ENHORSEGAMECHECK_GET_FF(&this->dyna.actor); + this->unk_160 = ENHORSEGAMECHECK_GET_FF00(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F990C.s") + if (this->unk_15C >= ENHORSEGAMECHECK_FF_MAX) { + this->unk_15C = ENHORSEGAMECHECK_FF_0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9944.s") + if (D_808F9BE4[this->unk_15C] != NULL) { + D_808F9BE4[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F9958.s") +void EnHorseGameCheck_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F999C.s") + if (D_808F9C0C[this->unk_15C] != NULL) { + D_808F9C0C[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99B0.s") +void EnHorseGameCheck_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99C4.s") + if (D_808F9C34[this->unk_15C] != NULL) { + D_808F9C34[this->unk_15C](this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/func_808F99D8.s") +void EnHorseGameCheck_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHorseGameCheck* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Horse_Game_Check/EnHorseGameCheck_Draw.s") + if (D_808F9C5C[this->unk_15C] != NULL) { + D_808F9C5C[this->unk_15C](this, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h index 4c0461982..1e4bf4f5a 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h @@ -2,12 +2,57 @@ #define Z_EN_HORSE_GAME_CHECK_H #include "global.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" struct EnHorseGameCheck; +typedef s32 (*EnHorseGameCheckUnkFunc)(struct EnHorseGameCheck*, GlobalContext*); + +#define ENHORSEGAMECHECK_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENHORSEGAMECHECK_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +enum { + /* 0 */ ENHORSEGAMECHECK_FF_0, + /* 1 */ ENHORSEGAMECHECK_FF_1, + /* 2 */ ENHORSEGAMECHECK_FF_2, + /* 3 */ ENHORSEGAMECHECK_FF_3, + /* 4 */ ENHORSEGAMECHECK_FF_4, + /* 5 */ ENHORSEGAMECHECK_FF_5, + /* 6 */ ENHORSEGAMECHECK_FF_6, + /* 7 */ ENHORSEGAMECHECK_FF_7, + /* 8 */ ENHORSEGAMECHECK_FF_8, + /* 9 */ ENHORSEGAMECHECK_FF_9, + /* 10 */ ENHORSEGAMECHECK_FF_MAX, +}; + +#define RACE_FLAG_END 0 +#define RACE_FLAG_START 1 +#define RACE_FLAG_2 2 +#define RACE_FLAG_3 3 +#define RACE_FLAG_4 4 +#define RACE_FLAGS 7 + +#define GET_RACE_FLAGS (gSaveContext.save.weekEventReg[92] & RACE_FLAGS) + +#define SET_RACE_FLAGS(flag) \ + { \ + gSaveContext.save.weekEventReg[92] &= (u8)~RACE_FLAGS; \ + gSaveContext.save.weekEventReg[92] = \ + gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ + } + typedef struct EnHorseGameCheck { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x74]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s32 unk_15C; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ s32 unk_168; + /* 0x16C */ EnHorse* horse1; + /* 0x170 */ EnHorse* horse2; + /* 0x174 */ s32 unk_174; + /* 0x178 */ UNK_TYPE1 pad178[0x4]; + /* 0x17C */ s32 unk_17C; + /* 0x180 */ UNK_TYPE1 pad180[0x38]; } EnHorseGameCheck; // size = 0x1B8 extern const ActorInit En_Horse_Game_Check_InitVars; 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 fca05f277..da62a57e0 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 @@ -6,7 +6,7 @@ #include "z_en_horse_link_child.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnHorseLinkChild*)thisx) diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h index 16ac6a616..ecc816c52 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.h @@ -2,6 +2,7 @@ #define Z_EN_HORSE_LINK_CHILD_H #include "global.h" +#include "z64skin.h" struct EnHorseLinkChild; 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 abf9966ff..e15e3adb3 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -6,7 +6,7 @@ #include "z_en_hs.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnHs*)thisx) @@ -23,7 +23,6 @@ void func_809532D0(EnHs* this, GlobalContext* globalCtx); void func_80953354(EnHs* this, GlobalContext* globalCtx); void func_8095345C(EnHs* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Hs_InitVars = { ACTOR_EN_HS, ACTORCAT_NPC, @@ -36,51 +35,322 @@ const ActorInit En_Hs_InitVars = { (ActorFunc)EnHs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80953910 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 40, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_8095393C = { 300.0f, 1000.0f, 0.0f }; -extern ColliderCylinderInit D_80953910; +void func_80952C50(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; -extern UNK_TYPE D_060005C0; + for (i = 0; i < ARRAY_COUNT(this->unk_2A4); i++) { + Math_Vec3f_Copy(&this->unk_2A4[i], &player->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952C50.s") + this->actor.home.rot.x = 0; + this->actor.home.rot.z = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Init.s") +void EnHs_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable, + this->morphTable, OBJECT_HS_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_8095345C; + if (globalCtx->curSpawn == 1) { + this->actor.flags |= ACTOR_FLAG_10000; + } + this->unk_2A0 = 0; + this->actor.targetMode = 6; + func_80952C50(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952DFC.s") +void EnHs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952E50.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952F00.s") +void func_80952DFC(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + func_80151BB4(globalCtx, 0x2E); + } + func_80151BB4(globalCtx, 0x10); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80952FE0.s") +void func_80952E50(Vec3f* dst, Vec3f src, f32 arg2) { + Vec3f sp1C; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953098.s") + Math_Vec3f_Diff(&src, dst, &sp1C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953180.s") + temp_f0 = SQ(sp1C.x) + SQ(sp1C.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532C0.s") + if (SQ(arg2) > temp_f0) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809532D0.s") + temp_f0 = sqrtf(temp_f0); + sp1C.x *= (temp_f0 - arg2) / temp_f0; + sp1C.z *= (temp_f0 - arg2) / temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953354.s") + dst->x += sp1C.x; + dst->z += sp1C.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_809533A0.s") +void func_80952F00(EnHs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 phi_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095345C.s") + if (this->actor.home.rot.z >= 20) { + phi_f20 = 15.0f; + } else { + phi_f20 = 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Update.s") + func_80952E50(&this->unk_2A4[0], player->actor.world.pos, phi_f20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_8095376C.s") + for (i = 1; i < ARRAY_COUNT(this->unk_2A4); i++) { + func_80952E50(&this->unk_2A4[i], this->unk_2A4[i - 1], phi_f20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/func_80953848.s") +void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { + if (this->unk_2A2 < 40) { + Math_SmoothStepToS(&this->unk_294.y, 0x1F40, 6, 0x1838, 0x64); + } else if (this->unk_2A2 < 80) { + Math_SmoothStepToS(&this->unk_294.y, -0x1F40, 6, 0x1838, 0x64); + } else { + this->actionFunc = func_80953180; + this->unk_2A0 &= ~4; + func_80151938(globalCtx, 0x33F6); + func_80952DFC(globalCtx); + } + this->unk_2A2++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Hs/EnHs_Draw.s") +void func_80953098(EnHs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_8095345C; + this->actor.flags |= ACTOR_FLAG_10000; + this->unk_2A0 |= 0x10; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + this->unk_2A0 |= 8; + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_BUNNY, 10000.0f, 50.0f); + } + } +} + +void func_80953180(EnHs* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x33F4: + case 0x33F6: + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F7: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_80953098; + func_80953098(this, globalCtx); + break; + + case 0x33F9: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + + case 0x33F5: + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80952FE0; + this->unk_2A2 = 0; + this->unk_294.z = 0; + this->unk_2A0 |= 4; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_8095345C; + break; + } + } +} + +void func_809532C0(EnHs* this, GlobalContext* globalCtx) { +} + +void func_809532D0(EnHs* this, GlobalContext* globalCtx) { + if (DECR(this->unk_2A2) == 0) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENHS_GET_F(&this->actor)]; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[25] |= 8; + this->actionFunc = func_809532C0; + } +} + +void func_80953354(EnHs* this, GlobalContext* globalCtx) { + if (!Play_InCsMode(globalCtx)) { + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = func_809532D0; + } +} + +void func_809533A0(EnHs* this, GlobalContext* globalCtx) { + u16 sp1E; + + if ((globalCtx->curSpawn == 1) && !(this->unk_2A0 & 0x20)) { + sp1E = 0x33F7; + this->unk_2A0 |= 0x20; + } else if (this->unk_2A0 & 0x10) { + sp1E = 0x33F9; + this->unk_2A0 &= ~0x10; + } else if (gSaveContext.save.weekEventReg[25] & 8) { + sp1E = 0x33F4; + } else { + sp1E = 0x33F5; + } + + Message_StartTextbox(globalCtx, sp1E, &this->actor); + + if (sp1E == 0x33F4) { + func_80952DFC(globalCtx); + } +} + +void func_8095345C(EnHs* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80953180; + func_809533A0(this, globalCtx); + if (this->unk_2A0 & 8) { + func_80952DFC(globalCtx); + this->unk_2A0 &= ~8; + } + } else if (this->actor.home.rot.x >= 20) { + this->actionFunc = func_80953354; + this->unk_2A2 = 40; + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + this->unk_2A0 |= 1; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + this->unk_2A0 |= 1; + } else { + this->unk_2A0 &= ~1; + } +} + +void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnHs* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = 0.0f; + } + + this->actionFunc(this, globalCtx); + + func_80952F00(this, globalCtx); + + if (this->unk_2A0 & 4) { + Math_SmoothStepToS(&this->unk_294.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + } else if (this->unk_2A0 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_294, &this->unk_29A, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_294.x, 0x3200, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_294.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_29A.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnHs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + switch (limbIndex) { + case OBJECT_HS_LIMB_09: + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + break; + + case OBJECT_HS_LIMB_0A: + rot->x += this->unk_294.y; + rot->z += this->unk_294.x; + break; + + case OBJECT_HS_LIMB_0B: + *dList = NULL; + return false; + + case OBJECT_HS_LIMB_0C: + if (this->actor.params == ENHS_1) { + *dList = NULL; + return false; + } + break; + + case OBJECT_HS_LIMB_0D: + if (this->actor.params == ENHS_1) { + *dList = NULL; + return false; + } + break; + } + return false; +} + +void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnHs* this = THIS; + + if (limbIndex == OBJECT_HS_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_8095393C, &this->actor.focus.pos); + } +} + +void EnHs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHs* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnHs_OverrideLimbDraw, EnHs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.h b/src/overlays/actors/ovl_En_Hs/z_en_hs.h index b9442c03d..0a50ee360 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -2,14 +2,27 @@ #define Z_EN_HS_H #include "global.h" +#include "objects/object_hs/object_hs.h" struct EnHs; typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); +#define ENHS_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENHS_1 1 + typedef struct EnHs { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x250]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; + /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; + /* 0x0294 */ Vec3s unk_294; + /* 0x029A */ Vec3s unk_29A; + /* 0x02A0 */ u16 unk_2A0; + /* 0x02A2 */ s16 unk_2A2; + /* 0x02A4 */ Vec3f unk_2A4[20]; /* 0x0394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 diff --git a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c index 7efec2c4d..02625ff9e 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -6,7 +6,7 @@ #include "z_en_hs2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnHs2*)thisx) 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 e6ccf277a..861f91d74 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_dai/object_dai.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIg*)thisx) @@ -112,12 +112,17 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dai_Anim_0048B4, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0048B4, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_005100, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_005100, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_0010F8, 1.0f, 0, -1, 2, 0 }, { &object_dai_Anim_001E44, 1.0f, 0, -1, 0, -4 }, - { &object_dai_Anim_0014BC, 1.0f, 0, -1, 2, 0 }, { &object_dai_Anim_003CAC, 1.0f, 0, -1, 2, -4 }, - { &object_dai_Anim_0040E0, 1.0f, 0, -1, 0, 0 }, { &object_dai_Anim_0040E0, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_0010F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dai_Anim_001E44, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dai_Anim_0014BC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dai_Anim_003CAC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; Actor* func_80BF1150(EnIg* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { @@ -201,7 +206,7 @@ s32 func_80BF1284(EnIg* this, s32 arg1) { if (phi_v1) { this->unk_3FC = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); this->unk_3D4 = this->skelAnime.playSpeed; } @@ -326,8 +331,8 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 2: case 4: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), - this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_3F6++; ret = true; @@ -340,7 +345,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { ActorCutscene_Stop(sp2A); this->unk_3F6 = 5; } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_3F6++; ret = true; @@ -386,7 +391,7 @@ s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { if (this->unk_3D0 & 7) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_3D0, 0, 7); + SubS_UpdateFlags(&this->unk_3D0, 0, 7); this->unk_3F6 = 0; this->unk_3F8 = NULL; this->actor.child = this->unk_2A8; @@ -430,7 +435,7 @@ s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & 0xC40) { @@ -473,7 +478,7 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -495,7 +500,7 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (func_80BF1C44(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { func_80BF1284(this, 0); - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x20; this->unk_3D0 |= 0x100; sp2C = true; @@ -506,7 +511,7 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.save.time - 0x3FFC; u8 sp55 = ENIG_GET_FF(&this->actor); - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -514,13 +519,13 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_274 = NULL; - sp50 = func_80BF1200(globalCtx, arg2->unk0); + door = func_80BF1200(globalCtx, arg2->unk0); if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp55, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_274 != NULL) { sp4C = Lib_SegmentedToVirtual(this->unk_274->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -530,7 +535,7 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, sp50->actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_2A4 = -75; } else { this->unk_2A4 = 75; @@ -538,7 +543,7 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3E0 = arg2->unk8 - arg2->unk4; this->unk_3E2 = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); this->actor.gravity = 0.0f; @@ -558,7 +563,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->unk0]); } if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { @@ -588,7 +593,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3D0 &= ~0x8; this->unk_3D0 &= ~0x10; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 2); this->actor.gravity = -1.0f; @@ -608,7 +613,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = func_8013BB34(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); } if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { @@ -624,7 +629,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 1); break; @@ -632,7 +637,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar case 4: this->actor.world.rot.y += 0x8000; this->actor.shape.rot.y = this->actor.world.rot.y; - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 |= 0x100; func_80BF1284(this, 8); break; @@ -647,7 +652,7 @@ s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.targetMode = 0; this->unk_3D0 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; switch (arg2->unk0) { case 5: @@ -692,17 +697,17 @@ s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { - EnDoor* sp44 = func_80BF1200(globalCtx, this->unk_298.unk0); + EnDoor* door = func_80BF1200(globalCtx, this->unk_298.unk0); Vec3f sp38; f32 temp; s32 pad; if (!func_8013AD6C(globalCtx) && (this->unk_3EC != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { - sp44->unk_1A7 = this->unk_2A4; + door->unk_1A7 = this->unk_2A4; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } this->unk_3E2 = CLAMP(this->unk_3E2, 0, this->unk_3E0); @@ -795,7 +800,7 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { func_80BF1284(this, 7); } } else if ((this->unk_3FC == 7) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); func_80BF1284(this, 9); } return true; @@ -843,11 +848,11 @@ void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { if (!func_80133038(globalCtx, D_80BF3260, &sp20) || ((this->unk_298.unk0 != sp20.unk0) && !func_80BF2368(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; sp20.unk0 = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk_2A8 = func_80BF146C(this, globalCtx); this->unk_298.unk0 = sp20.unk0; @@ -860,7 +865,7 @@ void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { Vec3f sp2C; if (func_8010BF58(&this->actor, globalCtx, this->unk_298.unk4, this->unk_3F8, &this->unk_298.unk8)) { - func_8013AED4(&this->unk_3D0, 3, 7); + SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 &= ~0x20; this->unk_3D0 |= 0x200; this->unk_3EE = 20; 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 59cd63487..b782b82a3 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -6,7 +6,7 @@ #include "z_en_ik.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnIk*)thisx) 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 2516b49e5..31bd34cc6 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -6,25 +6,12 @@ #include "z_en_in.h" #include "objects/object_in/object_in.h" +#include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnIn*)thisx) -#define SET_FLAGS_FINISH_RACE \ - { \ - gSaveContext.save.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.save.weekEventReg[92] = \ - gSaveContext.save.weekEventReg[92] | (u8)(gSaveContext.save.weekEventReg[92] & ~(1 | 2 | 4)); \ - } - -#define SET_FLAGS_START_RACE \ - { \ - gSaveContext.save.weekEventReg[92] &= (u8) ~(1 | 2 | 4); \ - gSaveContext.save.weekEventReg[92] = \ - gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~(1 | 2 | 4)) | 1); \ - } - void EnIn_Init(Actor* thisx, GlobalContext* globalCtx); void EnIn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnIn_Update(Actor* thisx, GlobalContext* globalCtx); @@ -131,16 +118,25 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_in_Anim_001D10, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_001D10, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_014F8C, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_014F8C, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_000CB0, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_0003B4, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_001BE0, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_015918, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01C0B0, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01C0B0, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01A140, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01A140, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01B904, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01B904, 1.0f, 0, -1, 0, -4 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, 0, 0 }, { &object_in_Anim_01B3C4, 0.0f, 0, -1, 2, 0 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, 0, -4 }, { &object_in_Anim_019EB4, 1.0f, 0, -1, 2, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_000CB0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_0003B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_001BE0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_015918, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_in_Anim_01B3C4, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; static u16 D_808F6C0C[] = { @@ -155,11 +151,11 @@ s32 func_808F30B0(SkelAnime* skelAnime, s16 animIndex) { ret = true; frameCount = sAnimations[animIndex].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[animIndex].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[animIndex].animation); } - Animation_Change(skelAnime, sAnimations[animIndex].animationSeg, sAnimations[animIndex].playbackSpeed, - sAnimations[animIndex].frame, frameCount, sAnimations[animIndex].mode, - sAnimations[animIndex].transitionRate); + Animation_Change(skelAnime, sAnimations[animIndex].animation, sAnimations[animIndex].playSpeed, + sAnimations[animIndex].startFrame, frameCount, sAnimations[animIndex].mode, + sAnimations[animIndex].morphFrames); } return ret; } @@ -169,11 +165,11 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { u8 prevUnk261 = this->unk261; u8 tmp; - this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); + this->unk260 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } - this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); + this->unk261 = tmp = SubS_IsFloorAbove(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp) { Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_WALK_CONCRETE); } @@ -215,20 +211,18 @@ s32 func_808F3334(EnIn* this, GlobalContext* globalCtx) { if (this->colliderJntSph.base.atFlags & AT_BOUNCED) { return 0; } - Actor_PlaySfxAtPos(&player->actor, 0x83E); + Actor_PlaySfxAtPos(&player->actor, NA_SE_PL_BODY_HIT); func_800B8D98(globalCtx, &this->actor, 3.0f, this->actor.yawTowardsPlayer, 6.0f); } return 1; } s32 func_808F33B8(void) { - s32 ret; + s32 ret = (((gSaveContext.save.day == 1) && + ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= CLOCK_TIME(6, 0)))) || + (gSaveContext.save.day >= 2)) && + !(gSaveContext.save.weekEventReg[22] & 1); - if (((ret = gSaveContext.save.day == 1) && (ret = gSaveContext.save.time >= 0x3AAA) && - (ret = gSaveContext.save.time <= 0x4000)) || - (ret = gSaveContext.save.day >= 2)) { - ret = (gSaveContext.save.weekEventReg[22] & 1) == 0; - } return ret; } @@ -239,7 +233,7 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { if (this->unk23D == 0) { this->unk494 = SkelAnime_Update(&this->skelAnime); } - if (func_8013D5E8(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; @@ -255,7 +249,7 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { } func_808F322C(this, 3); func_808F3178(this, globalCtx); - func_8013D9C8(globalCtx, this->unk376, this->unk39E, 20); + SubS_FillLimbRotTables(globalCtx, this->unk376, this->unk39E, ARRAY_COUNT(this->unk376)); } void func_808F35AC(EnIn* this, GlobalContext* globalCtx) { @@ -292,7 +286,7 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); sp36 = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->unk244, &sp28) && func_8013D768(&this->actor, &sp28, sp36)) { + if (SubS_CopyPointFromPath(this->path, this->unk244, &sp28) && SubS_MoveActorToPoint(&this->actor, &sp28, sp36)) { this->unk244++; if (this->unk244 >= this->path->count) { this->unk244 = 0; @@ -301,9 +295,10 @@ void func_808F3690(EnIn* this, GlobalContext* globalCtx) { } void func_808F374C(EnIn* this, GlobalContext* globalCtx) { - AnimationHeader* animations[] = { &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, - &object_in_Anim_016484, &object_in_Anim_0170DC, &object_in_Anim_018240, - &object_in_Anim_0187C8, &object_in_Anim_0198A8 }; + AnimationHeader* sAnimations[] = { + &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, &object_in_Anim_016484, + &object_in_Anim_0170DC, &object_in_Anim_018240, &object_in_Anim_0187C8, &object_in_Anim_0198A8, + }; if (this->skelAnime.animation == &object_in_Anim_016484 || this->skelAnime.animation == &object_in_Anim_0170DC) { if (Animation_OnFrame(&this->skelAnime, 8.0f)) { @@ -318,9 +313,10 @@ void func_808F374C(EnIn* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_CRY_0); } if (SkelAnime_Update(&this->skelAnime)) { - this->unk486 = this->unk488 %= 8; - Animation_Change(&this->skelAnime, animations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(animations[this->unk488]), 2, -10.0f); + this->unk488 %= ARRAY_COUNT(sAnimations); + this->unk486 = this->unk488; + Animation_Change(&this->skelAnime, sAnimations[this->unk488], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[this->unk488]), 2, -10.0f); } } @@ -337,11 +333,11 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { } void func_808F395C(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5A94; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = func_808F5A34; this->unk48C = 1; } else { @@ -353,30 +349,30 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { u16 textId = 0; if (gSaveContext.save.day != 3) { - switch (gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x347A; break; - case 3: + case RACE_FLAG_3: textId = 0x3476; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } else { - switch (gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) { - case 2: + switch (GET_RACE_FLAGS) { + case RACE_FLAG_2: textId = 0x349D; break; - case 3: + case RACE_FLAG_3: textId = 0x3499; break; } - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actor.textId = textId; this->actionFunc = func_808F395C; - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -385,7 +381,7 @@ void func_808F39DC(EnIn* this, GlobalContext* globalCtx) { void func_808F3AD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -398,7 +394,7 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3AD4; textId = gSaveContext.save.day != 3 ? 0x3481 : 0x34A4; this->actor.textId = textId; @@ -409,7 +405,7 @@ void func_808F3B40(EnIn* this, GlobalContext* globalCtx) { void func_808F3BD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -422,7 +418,7 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3BD4; textId = gSaveContext.save.day != 3 ? 0x346A : 0x3492; this->actor.textId = textId; @@ -433,7 +429,7 @@ void func_808F3C40(EnIn* this, GlobalContext* globalCtx) { void func_808F3CD4(EnIn* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk48C = 1; this->actionFunc = func_808F5A94; } else { @@ -449,7 +445,7 @@ void func_808F3D40(EnIn* this, GlobalContext* globalCtx) { this->actionFunc = func_808F3CD4; textId = gSaveContext.save.day != 3 ? 0x347D : 0x34A0; this->actor.textId = textId; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else { Actor_PickUp(&this->actor, globalCtx, GI_MASK_GARO, 500.0f, 100.0f); } @@ -638,7 +634,7 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext s32 func_808F43E0(EnIn* this) { this->unk48C = 0; this->actor.textId = 0; - SET_FLAGS_FINISH_RACE; + SET_RACE_FLAGS(RACE_FLAG_END); return 0; } @@ -735,7 +731,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 1: switch (textId) { case 0x3463: - gSaveContext.save.weekEventReg[15] |= 16; + gSaveContext.save.weekEventReg[15] |= 0x10; func_800E8EA0(globalCtx, &this->actor, 0x3464); ret = false; break; @@ -820,7 +816,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { func_80151BB4(globalCtx, 0x11); break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; @@ -1067,7 +1063,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { ret = false; break; case 0x3475: - SET_FLAGS_START_RACE; + SET_RACE_FLAGS(RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; @@ -1190,7 +1186,7 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 4: case 5: - if (func_80147624(globalCtx) && func_808F4414(globalCtx, this, arg2)) { + if (Message_ShouldAdvance(globalCtx) && func_808F4414(globalCtx, this, arg2)) { func_801477B4(globalCtx); ret = true; } @@ -1202,14 +1198,13 @@ s32 func_808F5674(GlobalContext* globalCtx, EnIn* this, s32 arg2) { s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { s16 rotDiff; s16 yawDiff; - s16 yawDiffA; Player* player; if (*arg3 == 4) { return 0; } if (*arg3 == 2) { - func_801518B0(globalCtx, this->actor.textId, &this->actor); + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); *arg3 = 1; return 0; } @@ -1247,9 +1242,8 @@ s32 func_808F5728(GlobalContext* globalCtx, EnIn* this, s32 arg2, s32* arg3) { if (!func_800B8934(globalCtx, &this->actor)) { return 0; } - yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - yawDiffA = ABS_ALT(yawDiff); - if (yawDiffA >= 0x4300) { + yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)); + if (yawDiff >= 0x4300) { return 0; } if (this->actor.xyzDistToPlayerSq > SQ(160.0f) && !this->actor.isTargeted) { @@ -1327,7 +1321,7 @@ void func_808F5B58(EnIn* this, GlobalContext* globalCtx) { } void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == 0) { + if (this->unk4B0 == RACE_FLAG_END) { this->actionFunc = func_808F5B58; } if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || @@ -1339,7 +1333,7 @@ void func_808F5C98(EnIn* this, GlobalContext* globalCtx) { } } if (this->unk4A8 == 2) { - if (this->unk4B0 == 2) { + if (this->unk4B0 == RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -1372,8 +1366,8 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk48C = 0; this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); - this->unk4B0 = gSaveContext.save.weekEventReg[92] & (1 | 2 | 4); - if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == 4) { + this->unk4B0 = GET_RACE_FLAGS; + if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == ENIN_BLUE_SHIRT) { this->unk4AC |= 8; } if (type == ENIN_HORSE_RIDER_YELLOW_SHIRT || type == ENIN_HORSE_RIDER_BLUE_SHIRT) { @@ -1390,23 +1384,22 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, &this->colliderJntSphElement); Actor_SetScale(&this->actor, 0.01f); this->actor.gravity = -4.0f; - this->path = func_8013D648(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENIN_GET_PATH(&this->actor), 0x3F); this->unk23D = 0; if (type == ENIN_YELLOW_SHIRT || type == ENIN_BLUE_SHIRT) { - if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 2 || - (gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 3) { + if (GET_RACE_FLAGS == RACE_FLAG_2 || GET_RACE_FLAGS == RACE_FLAG_3) { gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk4A8 = 0; this->unk4AC |= 2; func_808F35AC(this, globalCtx); this->unk23C = 0; D_801BDAA0 = 0; - if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { func_808F30B0(&this->skelAnime, 6); } else { func_808F30B0(&this->skelAnime, 4); } - if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) == 2) { + if (GET_RACE_FLAGS == RACE_FLAG_2) { this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; } if (this->unk4AC & 8) { @@ -1415,7 +1408,7 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808F5C98; } } else { - if ((gSaveContext.save.weekEventReg[92] & (1 | 2 | 4)) != 1) { + if (GET_RACE_FLAGS != RACE_FLAG_START) { gSaveContext.save.weekEventReg[56] &= (u8)~8; this->unk23C = 0; this->unk4AC |= 2; @@ -1488,7 +1481,7 @@ void func_808F6334(EnIn* this, GlobalContext* globalCtx) { Matrix_InsertTranslation(this->unk4C4, 0.0f, 0.0f, MTXMODE_APPLY); if (&this->actor == player->targetActor && - !(globalCtx->msgCtx.unk11F04 >= 0xFF && globalCtx->msgCtx.unk11F04 <= 0x200) && newUnk4C8 == 3 && + !(globalCtx->msgCtx.currentTextId >= 0xFF && globalCtx->msgCtx.currentTextId <= 0x200) && newUnk4C8 == 3 && this->unk4C8 == 3) { if (!(globalCtx->state.frames & 1)) { this->unk4C0 = this->unk4C0 != 0.0f ? 0.0f : 1.0f; 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 b3c1d2dd1..75c70113e 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -5,6 +5,7 @@ */ #include "z_en_insect.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,15 +16,22 @@ void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx); void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8091AC78(EnInsect* this); void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx); +void func_8091AE10(EnInsect* this); void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx); +void func_8091B030(EnInsect* this); void func_8091B07C(EnInsect* this, GlobalContext* globalCtx); void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx); +void func_8091B3D0(EnInsect* this); void func_8091B440(EnInsect* this, GlobalContext* globalCtx); +void func_8091B618(EnInsect* this); void func_8091B670(EnInsect* this, GlobalContext* globalCtx); +void func_8091B928(EnInsect* this); void func_8091B984(EnInsect* this, GlobalContext* globalCtx); -#if 0 +s16 D_8091BD60 = 0; + const ActorInit En_Insect_InitVars = { ACTOR_EN_INSECT, ACTORCAT_ITEMACTION, @@ -36,74 +44,466 @@ const ActorInit En_Insect_InitVars = { (ActorFunc)EnInsect_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8091BD84[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 5 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8091BDA8 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_8091BD84, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091BDBC[] = { +u16 D_8091BDB8[] = { 0, 5 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 700, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 20, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 30, ICHAIN_STOP), }; -#endif +Vec3f D_8091BDCC = { 0.0f, 0.0f, 0.0f }; -extern ColliderJntSphElementInit D_8091BD84[1]; -extern ColliderJntSphInit D_8091BDA8; -extern InitChainEntry D_8091BDBC[]; +void func_8091A8A0(EnInsect* this) { + this->unk_30C = D_8091BDB8[ENINSECT_GET_1(&this->actor)]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8A0.s") +f32 EnInsect_XZDistanceSquared(Vec3f* arg0, Vec3f* arg1) { + return SQ(arg0->x - arg1->x) + SQ(arg0->z - arg1->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8C4.s") +s32 EnInsect_InBottleRange(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A8F4.s") + if (this->actor.xzDistToPlayer < 32.0f) { + sp1C.x = player->actor.world.pos.x + (Math_SinS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + sp1C.y = player->actor.world.pos.y; + sp1C.z = player->actor.world.pos.z + (Math_CosS(BINANG_ROT180(this->actor.yawTowardsPlayer)) * 16.0f); + if (EnInsect_XZDistanceSquared(&sp1C, &this->actor.world.pos) <= SQ(20.0f)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091A9E4.s") +void func_8091A9E4(EnInsect* this) { + if (this->unk_316 > 0) { + this->unk_316--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Init.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MUSI_WALK); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Destroy.s") + this->unk_316 = 3.0f / CLAMP_MIN(this->skelAnime.playSpeed, 0.1f); + if (this->unk_316 < 2) { + this->unk_316 = 2; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AC78.s") +void EnInsect_Init(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + f32 rand; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091ACC4.s") + this->actor.world.rot.y = Rand_Next() & 0xFFFF; + this->actor.home.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AE10.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + func_8091A8A0(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091AE5C.s") + SkelAnime_Init(globalCtx, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, + this->jointTable, this->morphTable, 24); + Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, 1, 0.0f); + Collider_InitJntSph(globalCtx, &this->collider); + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B030.s") + { + ColliderJntSphElement* colliderElement = &this->collider.elements[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B07C.s") + colliderElement->dim.worldSphere.radius = colliderElement->dim.modelSphere.radius * colliderElement->dim.scale; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B274.s") + this->actor.colChkInfo.mass = 30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B2D8.s") + if (this->unk_30C & 1) { + this->actor.gravity = -0.2f; + this->actor.terminalVelocity = -2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B3D0.s") + if (this->unk_30C & 4) { + this->unk_314 = Rand_S16Offset(200, 40); + this->actor.flags |= ACTOR_FLAG_10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B440.s") + rand = Rand_ZeroOne(); + if (rand < 0.3f) { + func_8091AC78(this); + } else if (rand < 0.4f) { + func_8091AE10(this); + } else { + func_8091B030(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B618.s") +void EnInsect_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B670.s") +void func_8091AC78(EnInsect* this) { + this->unk_312 = Rand_S16Offset(5, 35); + this->actionFunc = func_8091ACC4; + this->unk_30C |= 0x100; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B928.s") +void func_8091ACC4(EnInsect* this, GlobalContext* globalCtx) { + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/func_8091B984.s") + Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Update.s") + temp_f2 = (Rand_ZeroOne() * 0.8f) + (this->actor.speedXZ * 1.2f); + if (temp_f2 < 0.0f) { + this->skelAnime.playSpeed = 0.0f; + } else { + f32 clamped = CLAMP_MAX(temp_f2, 1.9f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Insect/EnInsect_Draw.s") + this->skelAnime.playSpeed = clamped; + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (this->unk_312 <= 0) { + func_8091AE10(this); + } + + if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { + func_8091B3D0(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } else if (this->actor.xzDistToPlayer < 40.0f) { + func_8091B030(this); + } +} + +void func_8091AE10(EnInsect* this) { + this->unk_312 = Rand_S16Offset(10, 45); + this->actionFunc = func_8091AE5C; + this->unk_30C |= 0x100; +} + +void func_8091AE5C(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + f32 temp_f0; + + Math_SmoothStepToF(&this->actor.speedXZ, 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)) { + Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), + 0x7D0); + } else if ((this->actor.child != NULL) && (&this->actor != this->actor.child)) { + Math_ScaledStepToS(&this->actor.world.rot.y, + Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.child->world.pos), 0x7D0); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + temp_f0 = this->actor.speedXZ * 1.4f; + this->skelAnime.playSpeed = CLAMP(temp_f0, 0.7f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_312 <= 0) { + func_8091AC78(this); + } + + if ((this->unk_30C & 4) && (this->unk_314 <= 0)) { + func_8091B3D0(this); + } else if ((this->unk_30C & 1) && (this->actor.bgCheckFlags & 0x40)) { + func_8091B618(this); + } else if (this->actor.xzDistToPlayer < 40.0f) { + func_8091B030(this); + } +} + +void func_8091B030(EnInsect* this) { + this->unk_312 = Rand_S16Offset(10, 40); + this->actionFunc = func_8091B07C; + this->unk_30C |= 0x100; +} + +void func_8091B07C(EnInsect* this, GlobalContext* globalCtx) { + s32 pad; + f32 speed; + s16 frames; + s16 yaw; + s32 sp38 = this->actor.xzDistToPlayer < 40.0f; + + Math_SmoothStepToF(&this->actor.speedXZ, 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)) { + Math_ScaledStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), + 0x7D0); + } else if (sp38) { + frames = globalCtx->state.frames; + yaw = BINANG_ROT180(this->actor.yawTowardsPlayer); + if ((frames & 0x10) != 0) { + if ((frames & 0x20) != 0) { + yaw += 0x2000; + } + } else if ((frames & 0x20) != 0) { + yaw -= 0x2000; + } + + if (globalCtx) {} + Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 0x7D0); + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + speed = this->actor.speedXZ * 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)) { + func_8091B618(this); + } +} + +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->skelAnime.playSpeed = 0.3f; + this->actionFunc = func_8091B2D8; + this->unk_30C &= ~0x100; +} + +void func_8091B2D8(EnInsect* this, GlobalContext* globalCtx) { + if ((this->unk_312 == 20) && !(this->unk_30C & 4)) { + this->actor.draw = EnInsect_Draw; + } else if (this->unk_312 == 0) { + if (this->unk_30C & 4) { + Actor_MarkForDeath(&this->actor); + return; + } + + Actor_SetScale(&this->actor, 0.01f); + func_8091AC78(this); + } else if (this->unk_312 < 20) { + Actor_SetScale(&this->actor, CLAMP_MAX(this->actor.scale.x + 0.001f, 0.01f)); + SkelAnime_Update(&this->skelAnime); + } +} + +void func_8091B3D0(EnInsect* this) { + this->unk_312 = 60; + this->skelAnime.playSpeed = 1.9f; + Actor_PlaySfxAtPos(&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; + this->unk_30C |= 8; +} + +void func_8091B440(EnInsect* this, GlobalContext* globalCtx) { + s32 pad[2]; + Vec3f sp34; + + Math_SmoothStepToF(&this->actor.speedXZ, 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)); + + this->actor.shape.yOffset -= 0.8f; + this->actor.world.pos.x = (Rand_ZeroOne() + this->actor.home.pos.x) - 0.5f; + this->actor.world.pos.z = (Rand_ZeroOne() + this->actor.home.pos.z) - 0.5f; + + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_312 > 20) && (Rand_ZeroOne() < 0.1f)) { + sp34.x = Math_SinS(this->actor.shape.rot.y) * -0.6f; + sp34.y = Math_SinS(this->actor.shape.rot.x) * 0.6f; + sp34.z = Math_CosS(this->actor.shape.rot.y) * -0.6f; + func_800B1210(globalCtx, &this->actor.world.pos, &sp34, &D_8091BDCC, (Rand_ZeroOne() * 5.0f) + 8.0f, + (Rand_ZeroOne() * 5.0f) + 8.0f); + } + + if (this->unk_312 <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_8091B618(EnInsect* this) { + this->unk_312 = Rand_S16Offset(120, 50); + this->unk_310 = 0; + this->unk_30E = this->unk_310; + this->actionFunc = func_8091B670; + this->unk_30C &= ~0x100; +} + +void func_8091B670(EnInsect* this, GlobalContext* globalCtx) { + s32 pad[2]; + s16 temp; + Vec3f sp40; + + if (this->unk_312 > 80) { + Math_StepToF(&this->actor.speedXZ, 0.6f, 0.08f); + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.02f); + } + + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y += this->actor.depthInWater; + + this->skelAnime.playSpeed = CLAMP(this->unk_312 * 0.018f, 0.1f, 1.9f); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_312 > 80) { + this->unk_30E += Rand_S16Offset(-50, 100); + this->unk_310 += Rand_S16Offset(-300, 600); + } + + temp = this->skelAnime.playSpeed * 200.0f; + this->unk_30E = CLAMP(this->unk_30E, -temp, temp); + this->actor.world.rot.y += this->unk_30E; + + temp = this->skelAnime.playSpeed * 1000.0f; + this->unk_310 = CLAMP(this->unk_310, -temp, temp); + + this->actor.shape.rot.y += this->unk_310; + Math_ScaledStepToS(&this->actor.world.rot.x, 0, 0xBB8); + this->actor.shape.rot.x = this->actor.world.rot.x; + + if (Rand_ZeroOne() < 0.03f) { + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + this->actor.depthInWater; + sp40.z = this->actor.world.pos.z; + EffectSsGRipple_Spawn(globalCtx, &sp40, 40, 200, 4); + } + + if ((this->unk_312 <= 0) || ((this->unk_30C & 4) && (this->unk_314 <= 0))) { + func_8091B928(this); + } else if (!(this->actor.bgCheckFlags & 0x40)) { + func_8091AC78(this); + } +} + +void func_8091B928(EnInsect* this) { + this->unk_312 = 100; + this->actor.velocity.y = 0.0f; + this->actor.speedXZ = 0.0f; + this->actor.terminalVelocity = -0.8f; + this->actor.gravity = -0.04f; + this->unk_30C &= ~1; + this->actionFunc = func_8091B984; + this->unk_30C &= ~0x100; + this->unk_30C |= 8; +} + +void func_8091B984(EnInsect* this, GlobalContext* globalCtx) { + this->actor.shape.rot.x -= 0x1F4; + this->actor.shape.rot.y += 0xC8; + Actor_SetScale(&this->actor, CLAMP_MIN(this->actor.scale.x - 0.00005f, 0.001f)); + + if ((this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && (Rand_ZeroOne() < 0.3f)) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, (Rand_ZeroOne() * 0.04f) + 0.02f); + } + + if (this->unk_312 <= 0) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnInsect_Update(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + s32 phi_v0; + + if ((this->actor.child != NULL) && (this->actor.child->update == NULL) && (&this->actor != this->actor.child)) { + this->actor.child = NULL; + } + + if (this->unk_312 > 0) { + this->unk_312--; + } + + if (this->unk_314 > 0) { + this->unk_314--; + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update != NULL) { + Actor_MoveWithGravity(&this->actor); + if (this->unk_30C & 0x100) { + if (this->unk_30C & 1) { + if (this->actor.bgCheckFlags & 1) { + func_8091A9E4(this); + } + } else { + func_8091A9E4(this); + } + } + + phi_v0 = 0; + if (this->unk_30C & 1) { + phi_v0 = 4; + } + + if (phi_v0 != 0) { + phi_v0 |= 0x40; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 8.0f, 5.0f, 0.0f, phi_v0); + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_8091B274(this); + } else if ((this->actor.xzDistToPlayer < 50.0f) && (this->actionFunc != func_8091B2D8)) { + if (!(this->unk_30C & 0x20) && (this->unk_314 < 180)) { + ColliderJntSphElement* colliderElement = &this->collider.elements[0]; + + colliderElement->dim.worldSphere.center.x = this->actor.world.pos.x; + colliderElement->dim.worldSphere.center.y = this->actor.world.pos.y; + colliderElement->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (!(this->unk_30C & 8) && (D_8091BD60 < 4) && EnInsect_InBottleRange(this, globalCtx) && + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 60.0f, 30.0f)) { + D_8091BD60++; + } + } + + Actor_SetFocus(&this->actor, 0.0f); + } +} + +void EnInsect_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnInsect* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + D_8091BD60 = 0; +} diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.h b/src/overlays/actors/ovl_En_Insect/z_en_insect.h index be1ea96dd..612c6ab20 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -7,11 +7,22 @@ struct EnInsect; typedef void (*EnInsectActionFunc)(struct EnInsect*, GlobalContext*); +#define ENINSECT_GET_1(thisx) ((thisx)->params & 1) + typedef struct EnInsect { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C4]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; + /* 0x01A4 */ SkelAnime skelAnime; + /* 0x01E8 */ Vec3s jointTable[24]; + /* 0x0278 */ Vec3s morphTable[24]; /* 0x0308 */ EnInsectActionFunc actionFunc; - /* 0x030C */ char unk_30C[0xC]; + /* 0x030C */ u16 unk_30C; + /* 0x030E */ s16 unk_30E; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 unk_312; + /* 0x0314 */ s16 unk_314; + /* 0x0316 */ s16 unk_316; } EnInsect; // size = 0x318 extern const ActorInit En_Insect_InitVars; 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 728297ea9..8d2f416a7 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -12,7 +12,7 @@ #include "objects/object_cow/object_cow.h" #include "objects/object_uch/object_uch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnInvadepoh*)thisx) @@ -630,7 +630,8 @@ void func_80B439B0(s32 arg0, s32 arg1) { 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); + gSaveContext.save.unk_E88[arg0 >> 1] = + (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF) | ((arg1 & 0xFFFF) << 0x10); } } @@ -1350,7 +1351,7 @@ s32 func_80B45550(EnInvadepoh* this, GlobalContext* globalCtx, f32 range, s32 ar void EnInvadepoh_SetTextID(EnInvadepoh* this, GlobalContext* globalCtx, u16 arg2) { this->textId = arg2; - func_801518B0(globalCtx, arg2, &this->actor); + Message_StartTextbox(globalCtx, arg2, &this->actor); } void func_80B45648(EnInvadepoh* this) { @@ -1629,7 +1630,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { s32 invadepohType; s32 i; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; invadepohType = (this->actor.params >> 8) & 0x7F; for (i = 1; i < 8; i++) { @@ -1677,14 +1678,14 @@ void EnInvadepoh_InitAlien(EnInvadepoh* this, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); ActorShape_Init(&this->actor.shape, 6800.0f, ActorShadow_DrawWhiteCircle, 150.0f); this->actor.shape.shadowAlpha = 140; - this->actor.flags = 0x80001010; + this->actor.flags = (ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000); if (INVADEPOH_TYPE(this) == TYPE_ALIEN1) { 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(globalCtx, &this->collider, &this->actor, &sCylinderInitAlien); - this->actor.colChkInfo.mass = 0x28; + this->actor.colChkInfo.mass = 40; } this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_UCH); if (this->bankIndex < 0) { @@ -1731,7 +1732,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B48620; } else if (temp == 5) { this->actor.update = func_80B48FB0; - this->actor.flags = 0x19; + 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) { @@ -1747,7 +1748,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } if (temp == 5) { - if (gSaveContext.save.weekEventReg[22] & 0x1) { + if (gSaveContext.save.weekEventReg[22] & 1) { Actor_MarkForDeath(&this->actor); return; } @@ -1763,7 +1764,7 @@ void EnInvadepoh_InitRomani(EnInvadepoh* this, GlobalContext* globalCtx) { return; } } else if (temp == 0xC) { - if (!(gSaveContext.save.weekEventReg[22] & 0x1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F4 = this; @@ -1796,7 +1797,7 @@ void EnInvadepoh_InitDog(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.update = func_80B4B8BC; Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInitDog); - this->actor.colChkInfo.mass = 0x50; + this->actor.colChkInfo.mass = 80; ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 24.0f); this->bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG); if (this->bankIndex < 0) { @@ -1818,7 +1819,7 @@ void EnInvadepoh_InitCremia(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->bankIndex < 0) { Actor_MarkForDeath(&this->actor); } - if (!(gSaveContext.save.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } D_80B503F8 = this; @@ -2064,10 +2065,10 @@ void EnInvadepoh_Update(Actor* thisx, GlobalContext* globalCtx) { } void func_80B47380(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; - this->actor.flags &= ~0x80000000; + 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; @@ -2089,10 +2090,10 @@ void func_80B473E4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47478(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; - this->actor.flags &= ~0x80000000; + 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; @@ -2115,15 +2116,15 @@ void func_80B474DC(EnInvadepoh* this, GlobalContext* globalCtx) { void func_80B47568(EnInvadepoh* this) { Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); - this->collider.base.atFlags &= ~0x1; - this->collider.base.acFlags &= ~0x1; - this->collider.base.ocFlags1 &= ~0x1; + 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 |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B47600; } @@ -2141,9 +2142,9 @@ void func_80B47600(EnInvadepoh* this, GlobalContext* globalCtx) { this->alienAlpha += 6; } if (this->alienAlpha > 128) { - this->collider.base.atFlags |= 1; - this->collider.base.acFlags |= 1; - this->collider.base.ocFlags1 |= 1; + 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) { @@ -2159,15 +2160,15 @@ void func_80B4770C(EnInvadepoh* this) { if (this->skelAnime.animation != &object_uch_Anim_001D80) { Animation_MorphToLoop(&this->skelAnime, &object_uch_Anim_001D80, -6.0f); } - this->collider.base.atFlags |= 1; - this->collider.base.acFlags |= 1; - this->collider.base.ocFlags1 |= 1; + 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 |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B477B4; } @@ -2182,9 +2183,9 @@ void func_80B477B4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47830(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 |= 1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 |= OC1_ON; Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_0006C8); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 16); this->alienAlpha = 255; @@ -2194,7 +2195,7 @@ void func_80B47830(EnInvadepoh* this) { this->alienBeamAlpha = 0; this->actionTimer = 8; this->counter = 0; - this->actor.flags |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B478F4; } @@ -2207,18 +2208,18 @@ void func_80B478F4(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B47938(EnInvadepoh* this) { - this->collider.base.atFlags &= ~1; - this->collider.base.acFlags &= ~1; - this->collider.base.ocFlags1 &= ~1; + this->collider.base.atFlags &= ~AT_ON; + this->collider.base.acFlags &= ~AC_ON; + this->collider.base.ocFlags1 &= ~OC1_ON; Animation_PlayLoop(&this->skelAnime, &object_uch_Anim_000608); - this->actor.flags &= ~1; + 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 |= 0x80000000; + this->actor.flags |= ACTOR_FLAG_80000000; this->actionFunc = func_80B479E8; } @@ -2317,7 +2318,7 @@ void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - } else if (this->collider.base.acFlags & 2) { + } else if (this->collider.base.acFlags & AC_HIT) { Actor* acAttached = this->collider.base.ac; thisx->speedXZ = acAttached->speedXZ * 0.5f; @@ -2364,8 +2365,9 @@ void func_80B47FA8(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, thisx); this->actor.update = func_80B48060; this->actor.draw = func_80B4E158; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowBodySkel, NULL, this->jointTable, this->morphTable, 6); - Animation_PlayLoop(&this->skelAnime, &gCowBodyMoveHeadAnim); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowSkel, NULL, this->jointTable, this->morphTable, + COW_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gCowMooAnim); } } @@ -2407,7 +2409,8 @@ void func_80B481C4(Actor* thisx, GlobalContext* globalCtx) { Actor_SetObjectDependency(globalCtx, &this->actor); this->actor.update = func_80B4827C; this->actor.draw = func_80B4E1B0; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, 6); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, + COW_TAIL_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gCowTailSwishAnim); } } @@ -2572,7 +2575,7 @@ void func_80B48848(EnInvadepoh* this, GlobalContext* globalCtx) { Math_StepToS(&this->behaviorInfo.unk4C, 0x7D0, 0x46); } func_80B43E6C(this, 6, this->behaviorInfo.unk4C, 0x46); - if (((this->actor.flags & 0x40) == 0x40) && + 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); } @@ -2738,7 +2741,7 @@ void func_80B48FB0(Actor* thisx, GlobalContext* globalCtx) { void func_80B490F0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3019,13 +3022,13 @@ void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), temp_v0_2); } } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (((this->actor.flags & 0x40) == 0x40) && + 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); } @@ -3121,7 +3124,7 @@ void func_80B4A168(Actor* thisx, GlobalContext* globalCtx) { void func_80B4A1B8(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3151,7 +3154,7 @@ void func_80B4A2C0(EnInvadepoh* this) { substruct->unk2C = 1500; this->actionTimer = Rand_S16Offset(200, 200); this->unk304 = this->actor.shape.rot.y; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4A350; } @@ -3208,7 +3211,7 @@ void func_80B4A570(EnInvadepoh* this) { substruct->unk26.z = 0; substruct->unk30 = 0.1f; substruct->unk2C = 800; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4A5E4; } @@ -3246,12 +3249,12 @@ void func_80B4A67C(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->unk378 == 0) { this->unk378 = func_80B45550(this, globalCtx, SQ(80.0f), -0xF); } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } - if (((this->actor.flags & 0x40) == 0x40) && + 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); } @@ -3350,7 +3353,7 @@ void func_80B4AB8C(Actor* thisx, GlobalContext* globalCtx) { void func_80B4ABDC(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3376,13 +3379,13 @@ void func_80B4ACDC(EnInvadepoh* this) { void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[22] & 1) { this->actor.draw = func_80B4E324; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B4AD3C(this); } } void func_80B4AD3C(EnInvadepoh* this) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_80B4AD60; } @@ -3400,7 +3403,7 @@ void func_80B4ADB8(EnInvadepoh* this) { } void func_80B4ADCC(EnInvadepoh* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x3331) { if (gSaveContext.save.weekEventReg[22] & 2) { EnInvadepoh_SetTextID(this, globalCtx, 0x3334); @@ -3458,7 +3461,7 @@ void func_80B4AF94(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B024(EnInvadepoh* this) { - this->actor.flags &= ~9; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actionFunc = func_80B4B048; } @@ -3499,7 +3502,7 @@ void func_80B4B218(Actor* thisx, GlobalContext* globalCtx) { s16 diff; EnInvadepoh* this = THIS; s16 temp_v1; - s32 sp38 = (this->actor.flags & 0x40) == 0x40; + s32 sp38 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); Player* player; AlienBehaviorInfo* substruct = &this->behaviorInfo; @@ -3531,7 +3534,7 @@ void func_80B4B3DC(EnInvadepoh* this) { } void func_80B4B430(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_0021C8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogWalkAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 80); this->actionFunc = func_80B4B484; } @@ -3554,7 +3557,7 @@ void func_80B4B484(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B510(EnInvadepoh* this) { - Animation_MorphToLoop(&this->skelAnime, &object_dog_Anim_001BD8, -6.0f); + Animation_MorphToLoop(&this->skelAnime, &gDogRunAnim, -6.0f); this->actionTimer = Rand_S16Offset(50, 200); this->actionFunc = func_80B4B564; } @@ -3598,7 +3601,7 @@ void func_80B4B564(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B724(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_000998, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogBarkAnim, -6.0f); this->actionFunc = func_80B4B768; } @@ -3618,7 +3621,7 @@ void func_80B4B768(EnInvadepoh* this, GlobalContext* globalCtx) { } void func_80B4B820(EnInvadepoh* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_dog_Anim_001560, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gDogJumpAnim, -6.0f); this->actionFunc = func_80B4B864; } @@ -3637,8 +3640,8 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->bankIndex)) { this->actor.objBankIndex = this->bankIndex; Actor_SetObjectDependency(globalCtx, &this->actor); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_dog_Skel_0080F0, &object_dog_Anim_0021C8, - this->jointTable, this->morphTable, 13); + SkelAnime_InitFlex(globalCtx, &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, globalCtx); EnInvadepoh_SetPathPointToWorldPos(this, 0); @@ -3648,7 +3651,7 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { if (D_80B4E940 == 2) { this->actor.update = func_80B4BA84; this->actor.draw = func_80B4E660; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B4B430(this); } else if (D_80B4E940 == 1) { this->actor.update = func_80B4BA30; @@ -3665,7 +3668,7 @@ void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { if (D_80B4E940 == 2) { this->actor.update = func_80B4BA84; this->actor.draw = func_80B4E660; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B4B430(this); } } @@ -3673,7 +3676,7 @@ void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { void func_80B4BA84(Actor* thisx, GlobalContext* globalCtx) { EnInvadepoh* this = THIS; s32 temp_v0_3; - s32 sp34 = (this->actor.flags & 0x40) == 0x40; + s32 sp34 = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 temp_v1_2; s32 sp2C; s32 temp_v0_2; @@ -3744,16 +3747,16 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { if (temp_v0 == 0) { this->xzPosAdjFactor = 40.0f; this->unk304 = -0x8000; - this->actor.flags &= ~(0x8 | 0x1); + 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 |= (0x8 | 0x1); + 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 &= ~(0x8 | 0x1); + 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; @@ -3785,7 +3788,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { } } - if (((this->actor.flags & 0x40) == 0x40) && + 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); } @@ -3912,7 +3915,7 @@ void func_80B4C568(Actor* thisx, GlobalContext* globalCtx) { void func_80B4C5C0(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -3981,10 +3984,10 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { } } - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } else { this->unk378 = 0; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); } temp_v1_3 = globalCtx->gameplayFrames % 128; @@ -4006,7 +4009,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { substruct->unk26.y = CLAMP(temp_v1_4, -8000, 8000); } - if (((this->actor.flags & 0x40) == 0x40) && + 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); } @@ -4128,7 +4131,7 @@ void func_80B4CFFC(Actor* thisx, GlobalContext* globalCtx) { void func_80B4D054(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnInvadepoh* this = THIS; - s32 sp2C = (this->actor.flags & 0x40) == 0x40; + s32 sp2C = CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_40); s32 isTalking = Actor_ProcessTalkRequest(&this->actor, &globalCtx->state); if (isTalking) { @@ -4431,7 +4434,7 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { gfx = sp6C->polyXlu.p; gfx = func_8012C868(gfx); - gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetDither(gfx++, G_CD_NOISE); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_NEW); @@ -4550,7 +4553,8 @@ void func_80B4E3F0(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { - if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7)) { + 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; @@ -4564,7 +4568,7 @@ s32 func_80B4E5B0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnInvadepoh* this = THIS; - if (limbIndex == 5) { + if (limbIndex == DOG_LIMB_HEAD) { Matrix_GetStateTranslationAndScaledY(20.0f, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c index ff1f9b6ca..5696764dd 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c @@ -6,7 +6,7 @@ #include "z_en_invadepoh_demo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnInvadepohDemo*)thisx) 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 5e7292df5..ac42d0c7a 100644 --- a/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c +++ b/src/overlays/actors/ovl_En_Ishi/z_en_ishi.c @@ -9,7 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_ishi/object_ishi.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnIshi*)thisx) @@ -255,7 +255,7 @@ void func_8095DABC(Actor* thisx, GlobalContext* globalCtx) { } EffectSsKakera_Spawn(globalCtx, &spCC, &spD8, &this->actor.world.pos, phi_v1, phi_v0, 30, 5, 0, D_8095F758[i], - 5, 2, 70, 0, 2, gameplay_field_keep_DL_006420); + 5, 2, 70, 0, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); } } @@ -310,9 +310,9 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { sp3C = Item_DropCollectible(globalCtx, &this->actor.world.pos, temp | (ENISHI_GET_FE00(&this->actor) << 8)); if (sp3C != NULL) { Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); - Matrix_InsertXRotation_s(this->actor.shape.rot.x, 1); - Matrix_InsertZRotation_s(this->actor.shape.rot.z, 1); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); Matrix_GetStateTranslationAndScaledY(1.0f, &sp30); sp2C = Math3D_Parallel(&sp30, &D_8095F778); if (sp2C < 0.707f) { @@ -444,7 +444,7 @@ void func_8095E5AC(EnIshi* this) { void func_8095E5C0(EnIshi* this, GlobalContext* globalCtx) { if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_196)) { this->actor.objBankIndex = this->unk_196; - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; if (!ENISHI_GET_8(&this->actor)) { this->actor.draw = func_8095F61C; } else { @@ -522,7 +522,7 @@ void func_8095E660(EnIshi* this, GlobalContext* globalCtx) { void func_8095E934(EnIshi* this) { this->actionFunc = func_8095E95C; this->actor.room = -1; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; } void func_8095E95C(EnIshi* this, GlobalContext* globalCtx) { @@ -652,7 +652,7 @@ void func_8095EBDC(EnIshi* this, GlobalContext* globalCtx) { } void func_8095F060(EnIshi* this) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->actionFunc = func_8095F0A4; } 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 7d8099dbd..392d8091e 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -5,8 +5,9 @@ */ #include "z_en_ja.h" +#include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJa*)thisx) @@ -17,8 +18,30 @@ void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BC21A8(EnJa* this, GlobalContext* globalCtx); void func_80BC22F4(EnJa* this, GlobalContext* globalCtx); +void func_80BC2EA4(EnJa* this); +void func_80BC32D8(EnJa* this, GlobalContext* globalCtx); +void func_80BC3594(EnJa* this, GlobalContext* globalCtx); + +s32 D_80BC35F0[] = { + 0x0C000301, 0x05020600, 0x1200080A, 0x00610304, 0x0002050A, 0x006C0304, 0x00010500, +}; + +s32 D_80BC360C[] = { + 0x0E29370C, 0x170E2938, 0x0C180E29, 0x390C170E, 0x293A0C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC362C[] = { + 0x0E29400C, 0x170E2941, 0x0C180E29, 0x420C170E, 0x29430C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC364C[] = { + 0x0E293C0C, 0x170E293D, 0x0C180E29, 0x3E0C170E, 0x293F0C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; + +s32 D_80BC366C[] = { + 0x0E29440C, 0x170E2945, 0x0C180E29, 0x460C170E, 0x29470C09, 0x0000180E, 0x293B0C09, 0x00001000, +}; -#if 0 const ActorInit En_Ja_InitVars = { ACTOR_EN_JA, ACTORCAT_NPC, @@ -31,81 +54,708 @@ const ActorInit En_Ja_InitVars = { (ActorFunc)EnJa_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BC36DC = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +Vec3f D_80BC36AC = { -10.0f, 56.0f, 25.0f }; +Vec3f D_80BC36B8 = { 0.0f, 60.0f, 20.0f }; +Vec3f D_80BC36C4 = { 10.0f, 60.0f, 25.0f }; +Vec3f D_80BC36D0 = { 0.0f, 58.0f, 20.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 12, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BC3708 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_boj_Anim_002734, 1.0f, 0, -1, 0, 0 }, { &object_boj_Anim_0033B0, 1.0f, 0, -1, 0, 0 }, + { &object_boj_Anim_002734, 1.0f, 0, -1, 0, -4 }, { &object_boj_Anim_0033B0, 1.0f, 0, -1, 0, -4 }, + { &object_boj_Anim_004078, 1.0f, 0, -1, 0, 0 }, { &object_boj_Anim_005CE4, 1.0f, 0, -1, 0, 0 }, +}; -extern ColliderCylinderInit D_80BC36DC; -extern CollisionCheckInfoInit2 D_80BC3708; +void func_80BC1900(EnJa* this) { + this->skelAnime.playSpeed = this->unk_344; + SkelAnime_Update(&this->skelAnime); +} -extern UNK_TYPE D_0600BA30; -extern UNK_TYPE D_0600BCC8; -extern UNK_TYPE D_0600C240; +s32 func_80BC192C(EnJa* this, s32 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1900.s") + if (arg1 != this->unk_36C) { + this->unk_36C = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->unk_344 = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC192C.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1984.s") +void func_80BC1984(EnJa* this, GlobalContext* globalCtx) { + s32 pad[2]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC19FC.s") + Collider_UpdateCylinder(&this->actor, &this->collider); + this->collider.dim.height = (s16)fabsf(this->actor.focus.pos.y - this->actor.world.pos.y) + 5; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1A68.s") +s32 func_80BC19FC(EnJa* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1AE0.s") + if ((this->unk_340 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_340, 0, 7); + this->actionFunc = func_80BC22F4; + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1B50.s") +void func_80BC1A68(EnJa* this) { + if (DECR(this->unk_360) == 0) { + this->unk_362++; + if (this->unk_362 >= 4) { + this->unk_360 = Rand_S16Offset(30, 30); + this->unk_362 = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1B60.s") +s32 func_80BC1AE0(EnJa* this, GlobalContext* globalCtx) { + Actor* ja = SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_NPC, ACTOR_EN_JA); + Vec3f sp30; + Vec3f sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1D70.s") + if (ja != NULL) { + this->actor.child = ja; + Math_Vec3f_Copy(&sp24, &ja->world.pos); + Math_Vec3f_Copy(&sp30, &this->actor.world.pos); + this->actor.world.rot.y = Math_Vec3f_Yaw(&sp30, &sp24); + } else { + this->actor.child = NULL; + } + return this->actor.child; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1E40.s") +Player* func_80BC1B50(EnJa* this, GlobalContext* globalCtx) { + return GET_PLAYER(globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC1FC8.s") +s32 func_80BC1B60(EnJa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC203C.s") + Math_Vec3f_Copy(&sp40, &this->unk_1D8.player->actor.world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); + Math_ApproachS(&this->unk_356, (sp32 - this->unk_35A) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_356 = CLAMP(this->unk_356, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC20D0.s") + Math_ApproachS(&this->unk_35A, (sp32 - this->unk_356) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_35A = CLAMP(this->unk_35A, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC213C.s") + if (this->unk_1D8.player->actor.id == ACTOR_PLAYER) { + sp40.y = this->unk_1D8.player->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1D8.player->actor.focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2150.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + Math_ApproachS(&this->unk_354, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_358, 4, 0x2AA8); + this->unk_354 = CLAMP(this->unk_354, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC21A8.s") + Math_ApproachS(&this->unk_358, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_354, 4, 0x2AA8); + this->unk_358 = CLAMP(this->unk_358, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2274.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC22F4.s") +s32 func_80BC1D70(EnJa* this, GlobalContext* globalCtx) { + if (this->unk_340 & 8) { + this->unk_1D8.player = func_80BC1B50(this, globalCtx); + if (this->unk_1D8.player != NULL) { + func_80BC1B60(this, globalCtx); + } + this->unk_340 &= ~0x10; + this->unk_340 |= 0x20; + } else if (this->unk_340 & 0x20) { + this->unk_340 &= ~0x20; + this->unk_354 = 0; + this->unk_356 = 0; + this->unk_358 = 0; + this->unk_35A = 0; + this->unk_35E = 20; + } else if (DECR(this->unk_35E) == 0) { + this->unk_340 |= 0x10; + this->unk_35E = 20; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Init.s") +void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20 = Message_GetState(&globalCtx->msgCtx); + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Destroy.s") + if (((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && + (this->unk_374 == 3) && (&this->actor == player->targetActor)) { + if ((globalCtx->state.frames % 2) == 0) { + if (this->unk_348 != 0.0f) { + this->unk_348 = 0.0f; + } else { + this->unk_348 = 1.0f; + } + } + } else { + this->unk_348 = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Update.s") + this->unk_34C += (this->unk_348 != 0.0f) ? 60.0f : -60.0f; + this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC25E0.s") + Matrix_InsertTranslation(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); + this->unk_374 = sp20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2620.s") +s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2B30.s") + if (func_80BC1AE0(this, globalCtx)) { + SubS_UpdateFlags(&this->unk_340, 3, 7); + this->unk_340 |= 0x10; + func_80BC192C(this, 5); + func_80BC2EA4(this); + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/EnJa_Draw.s") +s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC2EA4.s") + if (func_80BC1AE0(this, globalCtx)) { + if (ENJA_GET_3(&this->actor) == 0) { + func_80BC192C(this, 1); + } else { + func_80BC192C(this, 4); + } + SubS_UpdateFlags(&this->unk_340, 3, 7); + this->actor.shape.shadowDraw = NULL; + this->unk_340 |= 0x50; + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC3154.s") +s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC32D8.s") + this->unk_340 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC33C0.s") + switch (arg2->unk0) { + case 1: + ret = func_80BC1FC8(this, globalCtx, arg2); + if (ret == 1) {} + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ja/func_80BC3594.s") + case 2: + ret = func_80BC203C(this, globalCtx, arg2); + break; + } + return ret; +} + +s32 func_80BC213C(EnJa* this, GlobalContext* globalCtx) { + return true; +} + +void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { + if ((this->unk_1D8.unk_00 == 1) || (this->unk_1D8.unk_00 == 2)) { + func_80BC213C(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 4, 0x1554); +} + +void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { + u32* unk_14 = &gSaveContext.save.daySpeed; + struct_80133038_arg2 sp18; + + this->unk_35C = REG(15) + *unk_14; + if (!func_80133038(globalCtx, D_80BC35F0, &sp18) || + ((this->unk_1D8.unk_00 != sp18.unk0) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1D8.unk_00 = sp18.unk0; + func_80BC2150(this, globalCtx); +} + +s32* func_80BC2274(EnJa* this, GlobalContext* globalCtx) { + switch (this->unk_1D8.unk_00) { + case 1: + if (ENJA_GET_3(&this->actor) == 0) { + return D_80BC360C; + } + return D_80BC364C; + + case 2: + if (ENJA_GET_3(&this->actor) == 0) { + return D_80BC362C; + } + return D_80BC366C; + } + return D_80BC360C; +} + +void func_80BC22F4(EnJa* this, GlobalContext* globalCtx) { + if (func_8010BF58(&this->actor, globalCtx, func_80BC2274(this, globalCtx), this->unk_368, &this->unk_1D8.unk_04)) { + this->unk_340 &= ~8; + SubS_UpdateFlags(&this->unk_340, 3, 7); + this->unk_1D8.unk_04 = 0; + this->unk_340 |= 0x10; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80BC21A8; + } +} + +void EnJa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, NULL, this->jointTable, this->morphTable, + 16); + this->unk_36C = -1; + func_80BC192C(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + this->actor.targetMode = 0; + this->actor.uncullZoneForward = 800.0f; + this->actor.gravity = 0.0f; + SubS_UpdateFlags(&this->unk_340, 0, 7); + this->unk_340 |= 0x10; + this->unk_1D8.unk_00 = 0; + this->unk_368 = NULL; + this->actionFunc = func_80BC21A8; +} + +void EnJa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnJa_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJa* this = THIS; + f32 height; + f32 radius; + + func_80BC19FC(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1D8.unk_00 != 0) { + func_80BC1900(this); + func_80BC1A68(this); + func_80BC1D70(this, globalCtx); + + radius = this->collider.dim.radius + 30; + height = this->collider.dim.height + 10; + func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_340 & 7); + + if (this->unk_1D8.unk_00 != 2) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + } + func_80BC1984(this, globalCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + func_80BC32D8(this, globalCtx); + } +} + +s32 EnJa_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnJa* this = THIS; + + if (limbIndex == 15) { + func_80BC1E40(this, globalCtx); + } + return false; +} + +void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80BC3774 = { -87.0f, 444.0f, -49.0f }; + static Vec3f D_80BC3780 = { 600.0f, 0.0f, 0.0f }; + static Vec3f D_80BC378C = { 400.0f, 0.0f, -400.0f }; + static Vec3f D_80BC3798 = { 400.0, 0.0f, 400.0f }; + static Vec3s D_80BC37A4 = { 0x7770, -0x4BC, -0x251C }; + s32 pad; + EnJa* this = THIS; + s32 pad2; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_80BC3780, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } else if ((this->unk_340 & 0x40) && (limbIndex == 11)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_JointPosition(&D_80BC3774, &D_80BC37A4); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BA30); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + if ((limbIndex == 11) && (((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 6.0f)) || + ((this->skelAnime.curFrame >= 35.0f) && (this->skelAnime.curFrame <= 47.0f)))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_InsertTranslation(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (this->unk_364) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else if (limbIndex == 14) { + if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 18.0f)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + Matrix_InsertTranslation(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (this->unk_366) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } + } +} + +void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnJa* this = THIS; + s32 phi_v1; + s32 phi_v0; + + if (this->unk_340 & 0x10) { + phi_v1 = false; + } else { + phi_v1 = true; + } + + if (this->unk_340 & 0x20) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (!phi_v1) { + phi_v0 = false; + } + + if (limbIndex != 8) { + if (limbIndex == 15) { + func_8013AD9C(this->unk_354 + this->unk_358 + 0x4000, + this->unk_356 + this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1EC, + &this->unk_274, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1EC.x, this->unk_1EC.y, this->unk_1EC.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_274.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_274.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_274.z, MTXMODE_APPLY); + Matrix_StatePush(); + } + } else { + func_8013AD9C(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, + &this->unk_27A, phi_v1, phi_v0); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_27A.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_27A.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_27A.z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnJa_Draw(Actor* thisx, GlobalContext* globalCtx) { + static Color_RGBA8 D_80BC37AC[] = { + { 200, 0, 80, 0 }, + { 0, 130, 220, 0 }, + }; + static Color_RGBA8 D_80BC37B4[] = { + { 255, 255, 255, 0 }, + { 255, 255, 255, 0 }, + }; + static TexturePtr D_80BC37BC[] = { + object_boj_Tex_0062B0, + object_boj_Tex_0063B0, + object_boj_Tex_0064B0, + object_boj_Tex_0063B0, + }; + s32 pad; + EnJa* this = THIS; + s32 phi_t2; + + if (ENJA_GET_3(&this->actor) == 0) { + phi_t2 = 0; + } else { + phi_t2 = 1; + } + + if (this->unk_1D8.unk_00 != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80BC37AC[phi_t2].r, D_80BC37AC[phi_t2].g, + D_80BC37AC[phi_t2].b, D_80BC37AC[phi_t2].a)); + gSPSegment(POLY_OPA_DISP++, 0x09, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80BC37B4[phi_t2].r, D_80BC37B4[phi_t2].g, + D_80BC37B4[phi_t2].b, D_80BC37B4[phi_t2].a)); + gSPSegment(POLY_OPA_DISP++, 0x0A, Lib_SegmentedToVirtual(D_80BC37BC[this->unk_362])); + gDPPipeSync(POLY_OPA_DISP++); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnJa_OverrideLimbDraw, EnJa_PostLimbDraw, + EnJa_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + + if (this->unk_1D8.unk_00 == 1) { + func_80BC3594(this, globalCtx); + } +} + +void func_80BC2EA4(EnJa* this) { + f32 sp44; + f32 sp40; + f32 sp3C; + f32 sp38; + s32 i; + Vec3f sp28; + + sp44 = Math_SinS(this->actor.shape.rot.y); + sp40 = Math_CosS(this->actor.shape.rot.y); + sp3C = Math_SinS(this->actor.child->shape.rot.y); + sp38 = Math_CosS(this->actor.child->shape.rot.y); + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++) { + this->unk_234[i].unk_0E = i * 0x30; + this->unk_234[i].unk_0C = i; + } + + sp28 = this->actor.world.pos; + this->unk_210 = sp28; + this->unk_204 = sp28; + + sp28 = this->actor.child->world.pos; + this->unk_228 = sp28; + this->unk_21C = sp28; + + this->unk_204.x += (D_80BC36AC.z * sp44) + (D_80BC36AC.x * sp40); + this->unk_204.y += D_80BC36AC.y; + this->unk_204.z += (D_80BC36AC.z * sp40) - (D_80BC36AC.x * sp44); + + this->unk_210.x += (D_80BC36B8.z * sp44) + (D_80BC36B8.x * sp40); + this->unk_210.y += D_80BC36B8.y; + this->unk_210.z += (D_80BC36B8.z * sp40) - (D_80BC36B8.x * sp44); + + this->unk_21C.x += (D_80BC36C4.z * sp3C) + (D_80BC36C4.x * sp38); + this->unk_21C.y += D_80BC36C4.y; + this->unk_21C.z += (D_80BC36C4.z * sp38) - (D_80BC36C4.x * sp3C); + + this->unk_228.x += (D_80BC36D0.z * sp3C) + (D_80BC36D0.x * sp38); + this->unk_228.y += D_80BC36D0.y; + this->unk_228.z += (D_80BC36D0.z * sp38) - (D_80BC36D0.x * sp3C); + + this->unk_364 = 2; + this->unk_366 = 0; +} + +void func_80BC3154(EnJa* this, EnJaStruct* ptr) { + if ((ptr->unk_0E >= 18) && (ptr->unk_0E < 83)) { + f32 temp_f0 = ptr->unk_0E - 18; + + ptr->unk_00.x = (((65.0f - temp_f0) * this->unk_204.x) + (temp_f0 * this->unk_228.x)) / 65.0f; + ptr->unk_00.y = (((65.0f - temp_f0) * this->unk_204.y) + (temp_f0 * this->unk_228.y)) / 65.0f; + ptr->unk_00.z = (((65.0f - temp_f0) * this->unk_204.z) + (temp_f0 * this->unk_228.z)) / 65.0f; + + temp_f0 -= 32.5f; + temp_f0 = SQ(temp_f0); + + ptr->unk_00.y += -0.11360947f * temp_f0 + 120.0f; + } else if ((ptr->unk_0E >= 102) && (ptr->unk_0E < 191)) { + f32 temp_f0 = ptr->unk_0E - 102; + + ptr->unk_00.x = (((89.0f - temp_f0) * this->unk_21C.x) + (temp_f0 * this->unk_210.x)) / 89.0f; + ptr->unk_00.y = (((89.0f - temp_f0) * this->unk_21C.y) + (temp_f0 * this->unk_210.y)) / 89.0f; + ptr->unk_00.z = (((89.0f - temp_f0) * this->unk_21C.z) + (temp_f0 * this->unk_210.z)) / 89.0f; + + temp_f0 -= 44.5f; + temp_f0 = SQ(temp_f0); + + ptr->unk_00.y += -0.08079788f * temp_f0 + 160.0f; + } +} + +void func_80BC32D8(EnJa* this, GlobalContext* globalCtx) { + EnJaStruct* phi_s0 = &this->unk_234[0]; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++, phi_s0++) { + func_80BC3154(this, phi_s0); + if (phi_s0->unk_0E != 191) { + phi_s0->unk_0E++; + } else { + phi_s0->unk_0E = 0; + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_366 > 0) { + this->unk_366--; + } else { + this->unk_366 = 3; + } + } else if (Animation_OnFrame(&this->skelAnime, 34.0f)) { + if (this->unk_364 > 0) { + this->unk_364--; + } else { + this->unk_364 = 3; + } + } +} + +void func_80BC33C0(EnJaStruct* ptr, GlobalContext* globalCtx) { + s32 pad; + + if (((ptr->unk_0E < 0) || (ptr->unk_0E >= 19)) && ((ptr->unk_0E < 83) || (ptr->unk_0E >= 103))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + + switch (ptr->unk_0C) { + case 0: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 1: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); + break; + + case 2: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 255, 255); + break; + + case 3: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, 255); + break; + + default: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_00BCC8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80BC3594(EnJa* this, GlobalContext* globalCtx) { + EnJaStruct* phi_s0 = this->unk_234; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++, phi_s0++) { + func_80BC33C0(phi_s0, globalCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.h b/src/overlays/actors/ovl_En_Ja/z_en_ja.h index 1df6d8962..561f76f55 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.h +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.h @@ -7,11 +7,57 @@ struct EnJa; typedef void (*EnJaActionFunc)(struct EnJa*, GlobalContext*); +#define ENJA_GET_3(thisx) (((thisx)->params & 3) & 0xFF) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 unk_0E; +} EnJaStruct; // size = 0x10 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Player* player; +} EnJaStruct2; // size = 0x10 + typedef struct EnJa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnJaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1EC]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ EnJaStruct2 unk_1D8; + /* 0x01E4 */ Vec3s unk_1E4; + /* 0x01EC */ Vec3f unk_1EC; + /* 0x01F8 */ Vec3f unk_1F8; + /* 0x0204 */ Vec3f unk_204; + /* 0x0210 */ Vec3f unk_210; + /* 0x021C */ Vec3f unk_21C; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ EnJaStruct unk_234[4]; + /* 0x0274 */ Vec3s unk_274; + /* 0x027A */ Vec3s unk_27A; + /* 0x0280 */ Vec3s jointTable[16]; + /* 0x02E0 */ Vec3s morphTable[16]; + /* 0x0340 */ u16 unk_340; + /* 0x0344 */ f32 unk_344; + /* 0x0348 */ f32 unk_348; + /* 0x034C */ f32 unk_34C; + /* 0x0350 */ UNK_TYPE1 unk350[0x4]; + /* 0x0354 */ s16 unk_354; + /* 0x0356 */ s16 unk_356; + /* 0x0358 */ s16 unk_358; + /* 0x035A */ s16 unk_35A; + /* 0x035C */ s16 unk_35C; + /* 0x035E */ s16 unk_35E; + /* 0x0360 */ s16 unk_360; + /* 0x0362 */ s16 unk_362; + /* 0x0364 */ s16 unk_364; + /* 0x0366 */ s16 unk_366; + /* 0x0368 */ void* unk_368; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ UNK_TYPE1 unk370[4]; + /* 0x0374 */ s32 unk_374; } EnJa; // size = 0x378 extern const ActorInit En_Ja_InitVars; diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 46122b537..4e50ceba6 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 @@ -7,7 +7,7 @@ #include "z_en_jc_mato.h" #include "objects/object_tru/object_tru.h" -#define FLAGS 0x00004030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000) #define THIS ((EnJcMato*)thisx) @@ -95,7 +95,7 @@ s32 EnJcMato_CheckForHit(EnJcMato* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); globalCtx->interfaceCtx.unk_25C = 1; - this->hitFlag = 1; + this->hitFlag = true; return 1; } else { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); @@ -111,7 +111,7 @@ void EnJcMato_SetupIdle(EnJcMato* this) { void EnJcMato_Idle(EnJcMato* this, GlobalContext* globalCtx) { s16 shouldDespawn; - if (this->hitFlag != 0) { + if (this->hitFlag) { if (this->despawnTimer == 0) { shouldDespawn = 0; } else { @@ -133,7 +133,7 @@ void EnJcMato_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.worldSphere.radius = 0xF; this->actor.colChkInfo.damageTable = &sDamageTable; Actor_SetScale(&this->actor, 0.008f); - this->hitFlag = 0; + this->hitFlag = false; this->despawnTimer = 25; EnJcMato_SetupIdle(this); } 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 ce8651d3c..9412e5594 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -5,17 +5,65 @@ */ #include "z_en_jg.h" +#include "overlays/actors/ovl_En_S_Goro/z_en_s_goro.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJg*)thisx) +#define FLAG_SHRINE_GORON_ARMS_RAISED (1 << 0) +#define FLAG_LOOKING_AT_PLAYER (1 << 2) +#define FLAG_DRUM_SPAWNED (1 << 3) + void EnJg_Init(Actor* thisx, GlobalContext* globalCtx); void EnJg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJg_Update(Actor* thisx, GlobalContext* globalCtx); void EnJg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx); +void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx); +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx); +void EnJg_Walk(EnJg* this, GlobalContext* globalCtx); +void EnJg_Talk(EnJg* this, GlobalContext* globalCtx); +void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx); +void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx); +void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx); +void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx); +void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx); +s32 EnJg_GetNextTextId(EnJg* this); +s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx); +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_JG_ANIMATION_IDLE, + /* 1 */ EN_JG_ANIMATION_WALK, + /* 2 */ EN_JG_ANIMATION_WAVING, + /* 3 */ EN_JG_ANIMATION_SHAKING_HEAD, + /* 4 */ EN_JG_ANIMATION_SURPRISE_START, + /* 5 */ EN_JG_ANIMATION_SURPRISE_LOOP, + /* 6 */ EN_JG_ANIMATION_ANGRY, + /* 7 */ EN_JG_ANIMATION_FROZEN_START, + /* 8 */ EN_JG_ANIMATION_FROZEN_LOOP, + /* 9 */ EN_JG_ANIMATION_WALK_2, + /* 10 */ EN_JG_ANIMATION_TAKING_OUT_DRUM, + /* 11 */ EN_JG_ANIMATION_DRUM_IDLE, + /* 12 */ EN_JG_ANIMATION_PLAYING_DRUM, + /* 13 */ EN_JG_ANIMATION_THINKING, + /* 14 */ EN_JG_ANIMATION_REMEMBERING, + /* 15 */ EN_JG_ANIMATION_STRONG_REMEMBERING, + /* 16 */ EN_JG_ANIMATION_DEPRESSED, + /* 17 */ EN_JG_ANIMATION_CUTSCENE_IDLE, + /* 18 */ EN_JG_ANIMATION_CRADLE, + /* 19 */ EN_JG_ANIMATION_MAX, +} EnJgAnimationIndex; + +typedef enum { + /* 0x0 */ EN_JG_ACTION_FIRST_THAW, + /* 0x1 */ EN_JG_ACTION_SPAWNING, + /* 0x2 */ EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW, + /* 0x3 */ EN_JG_ACTION_LULLABY_INTRO_CS, +} EnJgAction; + const ActorInit En_Jg_InitVars = { ACTOR_EN_JG, ACTORCAT_NPC, @@ -28,18 +76,29 @@ const ActorInit En_Jg_InitVars = { (ActorFunc)EnJg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B75820 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B7584C = { 0, 50, 80, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 50, 80, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80B75858 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,70 +133,905 @@ static DamageTable D_80B75858 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfoS sAnimations[] = { + { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderWavingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderHeadShakeAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -10 }, + { &gGoronElderSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderAngryAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderSurpriseStartAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderSurpriseStartAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderWalkAnim, -1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gGoronElderTakeOutDrumAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderDrumIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderPlayingDrumAnim, 1.0f, 1, 44, ANIMMODE_ONCE, 0 }, + { &gGoronElderThinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderStrongRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gGoronElderDepressedAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gGoronElderCradleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_80B75820; -extern CollisionCheckInfoInit2 D_80B7584C; -extern DamageTable D_80B75858; +static Vec3f sSfxPos = { 0.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0601ADC0; +static Vec3f sFocusOffset = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73A90.s") +static Vec3f sBreathPosOffset = { 1000.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73AE4.s") +static Vec3f sBreathVelOffset = { 0.0f, 0.0f, 0.75f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73B98.s") +static Vec3f sBreathAccelOffset = { 0.0f, 0.0f, -0.070000000298f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73C58.s") +/** + * When the elder and the Gorons in the shrine are doing a cheer + * for Darmani, the camera will focus on specific Gorons for + * certain parts of the cheer. This function is responsible for + * returning a pointer to the specified Goron so the camera + * can focus on them. + */ +Actor* EnJg_GetShrineGoronToFocusOn(GlobalContext* globalCtx, u8 focusedShrineGoronParam) { + Actor* actorIterator = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73DF4.s") + while (actorIterator != NULL) { + if ((actorIterator->id == ACTOR_EN_S_GORO) && + (EN_S_GORO_GET_PARAM_F(actorIterator) == focusedShrineGoronParam)) { + return actorIterator; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73E3C.s") + actorIterator = actorIterator->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B73F1C.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7406C.s") +void EnJg_UpdateCollision(EnJg* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7408C.s") + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 30.0f, 7); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74134.s") +s16 EnJg_GetWalkingYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { + Vec3s* points; + f32 diffX; + f32 diffZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B741F8.s") + if (path != NULL) { + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + diffX = points[0].x - pos->x; + diffZ = points[0].z - pos->z; + } else { + diffX = 0.0f; + diffZ = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B742F8.s") + *distSQ = SQ(diffX) + SQ(diffZ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74440.s") + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74550.s") +s32 EnJg_ReachedPoint(EnJg* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B747C8.s") + Math_Vec3s_ToVec3f(&point, &points[pointIndex]); + if (currentPoint == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (currentPoint == (pathCount - 1)) { + diffX = points[pathCount - 1].x - points[pathCount - 2].x; + diffZ = points[pathCount - 1].z - points[pathCount - 2].z; + } else { + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74840.s") + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B749D0.s") + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74AD8.s") + return reached; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74B54.s") +s16 EnJg_GetCutsceneForTeachingLullabyIntro(EnJg* this) { + s16 temp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74BC8.s") + if (temp > 0) { + return this->actor.cutscene; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B74E5C.s") + return ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B750A0.s") +void EnJg_SetupGoronShrineCheer(EnJg* this) { + ActorCutscene_Stop(this->cutscene); + if (this->focusedShrineGoronParam == 10) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + this->actionFunc = EnJg_GoronShrineTalk; + } else { + this->cutscene = 0x7C; + } + } else { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B7517C.s") + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_GoronShrineCheer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B751F8.s") + switch (this->textId) { + case 0xDD0: // The greatest Goron hero of all? + case 0xDD2: // The immortal Goron? + case 0xDD3: // The star we wish upon? + case 0xDD4: // "Darmani, greatest of Gorons!" + case 0xDD6: // Darmani, greatest in the world! + this->flags |= FLAG_SHRINE_GORON_ARMS_RAISED; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Init.s") + default: + this->flags &= ~FLAG_SHRINE_GORON_ARMS_RAISED; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Destroy.s") +void EnJg_SetupTalk(EnJg* this, GlobalContext* globalCtx) { + switch (this->textId) { + case 0xDAC: // What was I doing? + this->animationIndex = EN_JG_ANIMATION_SHAKING_HEAD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Update.s") + case 0xDAD: // I must hurry! + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B75658.s") + case 0xDB7: // You're Darmani! + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/func_80B75708.s") + case 0xDAE: // Do you have business with the Elder? + case 0xDB3: // As Elder, I must do something + case 0xDB6: // "Hunh???" + case 0xDBA: // I've been made a fool of! + case 0xDBD: // "...What?" + case 0xDC4: // It's so cold I can't play + this->animationIndex = EN_JG_ANIMATION_IDLE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jg/EnJg_Draw.s") + case 0xDB0: // It's this cold snap + case 0xDBB: // If I can see past the illusion, you'll vanish + case 0xDBC: // Following me won't do you any good + case 0xDC6: // I am counting on you + this->animationIndex = EN_JG_ANIMATION_ANGRY; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; + + case 0xDB4: // This is our problem (first) + case 0xDB5: // This is our problem (repeat) + this->animationIndex = EN_JG_ANIMATION_WAVING; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Talk; + break; + } +} + +void EnJg_Idle(EnJg* this, GlobalContext* globalCtx) { + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); +} + +void EnJg_GoronShrineIdle(EnJg* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->flags |= FLAG_LOOKING_AT_PLAYER; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_GoronShrineTalk; + } else if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { + func_800B863C(&this->actor, globalCtx); + this->textId = EnJg_GetStartingConversationTextId(this, globalCtx); + } +} + +void EnJg_GoronShrineTalk(EnJg* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { + if ((this->textId == 0xDCC) || (this->textId == 0xDDD) || (this->textId == 0xDE0)) { + // There is nothing more to say after these lines, so end the current conversation. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_GoronShrineIdle; + } else { + this->textId = EnJg_GetNextTextId(this); + Message_StartTextbox(globalCtx, this->textId, &this->actor); + } + } +} + +void EnJg_GoronShrineCheer(EnJg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + switch (this->textId) { + case 0xDD0: // The greatest Goron hero of all? + case 0xDD2: // The immortal Goron? + case 0xDD3: // The star we wish upon? + case 0xDD4: // "Darmani, greatest of Gorons!" + case 0xDD6: // Darmani, greatest in the world! + // Focus on a specifc Goron for these lines + this->shrineGoron = EnJg_GetShrineGoronToFocusOn(globalCtx, this->focusedShrineGoronParam); + ActorCutscene_Start(this->cutscene, this->shrineGoron); + Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); + break; + + default: + // Focus on the whole group for these lines + ActorCutscene_Start(this->cutscene, &this->actor); + Camera_SetTargetActor(globalCtx->cameraPtrs[CAM_ID_MAIN], this->shrineGoron); + break; + } + this->actionFunc = EnJg_GoronShrineTalk; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + if (this->focusedShrineGoronParam == 10) { + this->actionFunc = EnJg_GoronShrineTalk; + } else { + ActorCutscene_Stop(0x7C); + } + } + ActorCutscene_SetIntentToPlay(this->cutscene); + } +} + +/** + * You need to reach a certain point in the conversation when talking with the elder before + * he starts walking for the first time. This function specifically handles this scenario; the + * reason they used this instead of EnJg_Talk is seemingly to bypass EnJg_SetupWalk resetting + * the freeze timer. + * + * Additionally, when the elder has reached the end of his specified path, this function will + * set his speed to 0, causing him to walk in place. + */ +void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, GlobalContext* globalCtx) { + u8 messageState = Message_GetState(&globalCtx->msgCtx); + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + + if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) { + if (currentFrame == lastFrame) { + this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + } + } else if (this->animationIndex == EN_JG_ANIMATION_SURPRISE_LOOP) { + if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->animationIndex = EN_JG_ANIMATION_WALK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } + } else if (this->animationIndex == EN_JG_ANIMATION_WALK) { + Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.2f, 1.0f); + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); + } +} + +void EnJg_Walk(EnJg* this, GlobalContext* globalCtx) { + s16 yRotation; + f32 distSQ; + + if (this->path != NULL) { + yRotation = EnJg_GetWalkingYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSQ); + if (this->actor.bgCheckFlags & 8) { + yRotation = this->actor.wallYaw; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (EnJg_ReachedPoint(this, this->path, this->currentPoint)) { + if (this->currentPoint >= (this->path->count - 1)) { + // Force the elder to walk in place + this->animationIndex = EN_JG_ANIMATION_WALK; + this->actionFunc = EnJg_AlternateTalkOrWalkInPlace; + } else { + this->currentPoint++; + Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + } + } else { + Math_ApproachF(&this->actor.speedXZ, 0.5f, 0.2f, 1.0f); + } + } + + EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(this, globalCtx); +} + +void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { + u8 messageState = Message_GetState(&globalCtx->msgCtx); + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + u16 temp; + + if ((this->animationIndex == EN_JG_ANIMATION_SURPRISE_START) && (currentFrame == lastFrame)) { + this->animationIndex = EN_JG_ANIMATION_SURPRISE_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + } + + if ((messageState == 5) && (Message_ShouldAdvance(globalCtx))) { + temp = this->textId; + if ((temp == 0xDB4) || (temp == 0xDB5) || (temp == 0xDC4) || (temp == 0xDC6)) { + // There is nothing more to say after these lines, so end the current conversation. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_SetupWalk; + return; + } + + temp = this->textId; + if ((temp == 0xDBB) || (temp == 0xDBC)) { + if (!(gSaveContext.save.weekEventReg[24] & 0x80)) { + // The player hasn't talked to the Goron Child at least once, so they can't learn + // the Lullaby Intro. End the current conversation with the player. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->actionFunc = EnJg_SetupWalk; + } else if (((gSaveContext.save.weekEventReg[24] & 0x40)) || + (CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { + // The player already has the Lullaby or Lullaby Intro, so say "I'm counting on you" + this->textId = EnJg_GetNextTextId(this); + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } else { + // To get to this point, the player *has* talked to the Goron Child, but doesn't + // already have the Lullaby or Lullaby Intro. End the current conversation and + // start the cutscene that teaches the Lullaby Intro. + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->flags &= ~FLAG_LOOKING_AT_PLAYER; + this->cutscene = EnJg_GetCutsceneForTeachingLullabyIntro(this); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_TeachLullabyIntro; + } + } else { + this->textId = EnJg_GetNextTextId(this); + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } + } +} + +void EnJg_SetupWalk(EnJg* this, GlobalContext* globalCtx) { + if (this->animationIndex != EN_JG_ANIMATION_WALK) { + this->animationIndex = EN_JG_ANIMATION_WALK; + this->freezeTimer = 1000; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } else { + this->freezeTimer = 1000; + this->actionFunc = EnJg_Walk; + } +} + +void EnJg_Freeze(EnJg* this, GlobalContext* globalCtx) { + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + + if (this->action == EN_JG_ACTION_SPAWNING) { + this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; + this->freezeTimer = 1000; + this->skelAnime.curFrame = lastFrame; + this->icePoly = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, 0xFF50); + this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_FrozenIdle; + } else if (this->animationIndex == EN_JG_ANIMATION_FROZEN_START) { + this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; + if (currentFrame == lastFrame) { + this->freezeTimer = 1000; + this->icePoly = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, + this->actor.world.rot.y, this->actor.world.rot.z, 0xFF50); + this->animationIndex = EN_JG_ANIMATION_FROZEN_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_FrozenIdle; + } + } +} + +void EnJg_FrozenIdle(EnJg* this, GlobalContext* globalCtx) { + if (this->icePoly->update == NULL) { + this->icePoly = NULL; + if (this->animationIndex == EN_JG_ANIMATION_FROZEN_LOOP) { + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + this->animationIndex = EN_JG_ANIMATION_IDLE; + + // If you've never talked to the elder before, he stands + // around idle until you've talked to him at least once. + // Otherwise, he immediately begins walking after being + // thawed out. + if (this->textId == 0xDAC) { + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Idle; + } else { + this->freezeTimer = 1000; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Walk; + } + } + } + } else { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x236, &this->actor); // The old Goron is frozen solid! + this->actionFunc = EnJg_EndFrozenInteraction; + } else if (this->actor.isTargeted) { + func_800B863C(&this->actor, globalCtx); + } + } +} + +void EnJg_EndFrozenInteraction(EnJg* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx) != 0) { + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = EnJg_FrozenIdle; + } +} + +void EnJg_TeachLullabyIntro(EnJg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Start(this->cutscene, &this->actor); + this->actionFunc = EnJg_LullabyIntroCutsceneAction; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + } +} + +void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { + s32 pad; + + if (Cutscene_CheckActorAction(globalCtx, 470)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 470); + + if (this->csAction != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actionIndex]->action; + + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_CUTSCENE_IDLE; + if (this->drum != NULL) { + Actor_MarkForDeath(this->drum); + this->drum = NULL; + } + break; + + case 2: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_TAKING_OUT_DRUM; + break; + + case 3: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_DRUM_IDLE; + break; + + case 4: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_PLAYING_DRUM; + break; + + case 5: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_THINKING; + break; + + case 6: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_REMEMBERING; + break; + + case 7: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_STRONG_REMEMBERING; + break; + + case 8: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_DEPRESSED; + break; + + case 9: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_CRADLE; + break; + + default: + this->cutsceneAnimationIndex = EN_JG_ANIMATION_IDLE; + break; + } + + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->cutsceneAnimationIndex); + } + + if ((!(this->flags & FLAG_DRUM_SPAWNED)) && + (((this->cutsceneAnimationIndex == EN_JG_ANIMATION_TAKING_OUT_DRUM) && + (Animation_OnFrame(&this->skelAnime, 14.0f)) && (this->action != EN_JG_ACTION_LULLABY_INTRO_CS)) || + (((this->cutsceneAnimationIndex == EN_JG_ANIMATION_DRUM_IDLE) || + (this->cutsceneAnimationIndex == EN_JG_ANIMATION_PLAYING_DRUM)) && + (this->action == EN_JG_ACTION_LULLABY_INTRO_CS)))) { + this->flags |= FLAG_DRUM_SPAWNED; + this->drum = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, 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); + } + + if (this->cutsceneAnimationIndex == EN_JG_ANIMATION_TAKING_OUT_DRUM) { + if (Animation_OnFrame(&this->skelAnime, 23.0f)) { + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_WOOD_BOUND_S); + } else if (Animation_OnFrame(&this->skelAnime, 38.0f)) { + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_OBJECT_SLIDE); + } + } + } else { + this->csAction = 99; + this->freezeTimer = 1000; + gSaveContext.save.weekEventReg[24] |= 0x40; + this->actionFunc = EnJg_Idle; + } +} + +/** + * Returns the "next" text ID that the elder should use based on his current text ID. + * Note that the results here can be counterintuitive, because his current text ID can + * cause multiple text boxes to display in sequence; this function will return the text + * ID that starts the *next* sequence. + * + * Sequences generally seem to be tied to text IDs that should all share the same animation. + */ +s32 EnJg_GetNextTextId(EnJg* this) { + switch (this->textId) { + case 0xDAC: // What was I doing? + return 0xDAD; // I must hurry! + + case 0xDAE: // Do you have business with the Elder? + return 0xDB0; // It's this cold snap + + case 0xDB0: // It's this cold snap + return 0xDB3; // As Elder, I must do something + + case 0xDB3: // As Elder, I must do something + return 0xDB4; // This is our problem (first) + + case 0xDB6: // "Hunh???" + return 0xDB7; // You're Darmani! + + case 0xDB7: // You're Darmani! + return 0xDBA; // I've been made a fool of! + + case 0xDBA: // I've been made a fool of! + return 0xDBB; // If I can see past the illusion, you'll vanish + + case 0xDBB: // If I can see past the illusion, you'll vanish + case 0xDBC: // Following me won't do you any good + return 0xDC6; // I am counting on you + + case 0xDCB: // Welcome to spring + return 0xDCC; // We're holding the Goron Races + + case 0xDDE: // Come back after entering the race + return 0xDDF; // My son is waiting for you + + case 0xDDF: // My son is waiting for you + return 0xDE0; // Go beyond Twin Islands Cave + + case 0xDCD: // I've been waiting impatiently for you + return 0xDCE; // I heard you sealed the blizzard + + case 0xDCE: // I heard you sealed the blizzard + return 0xDCF; // Spring has come thanks to you + + case 0xDCF: // Spring has come thanks to you + this->focusedShrineGoronParam = 3; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); + this->actionFunc = EnJg_GoronShrineCheer; + return 0xDD0; // The greatest Goron hero of all? + + case 0xDD0: // The greatest Goron hero of all? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD1: // "Darmani!" + switch (this->focusedShrineGoronParam) { + case 3: + this->focusedShrineGoronParam = 4; + EnJg_SetupGoronShrineCheer(this); + return 0xDD2; // The immortal Goron? + + case 4: + this->focusedShrineGoronParam = 5; + EnJg_SetupGoronShrineCheer(this); + return 0xDD3; // The star we wish upon? + + case 5: + this->focusedShrineGoronParam = 6; + EnJg_SetupGoronShrineCheer(this); + return 0xDD4; // "Darmani, greatest of Gorons!" + + default: + return 0xDD4; // "Darmani, greatest of Gorons!" + } + break; + + case 0xDD2: // The immortal Goron? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD3: // The star we wish upon? + EnJg_SetupGoronShrineCheer(this); + return 0xDD1; // "Darmani!" + + case 0xDD4: // "Darmani, greatest of Gorons!" + EnJg_SetupGoronShrineCheer(this); + return 0xDD5; // "Greatest of Gorons!" + + case 0xDD5: // "Greatest of Gorons!" + this->focusedShrineGoronParam = 7; + EnJg_SetupGoronShrineCheer(this); + return 0xDD6; // Darmani, greatest in the world! + + case 0xDD6: // Darmani, greatest in the world! + EnJg_SetupGoronShrineCheer(this); + return 0xDD7; // "Greatest in the world!" + + case 0xDD7: // "Greatest in the world!" + this->focusedShrineGoronParam = 10; + EnJg_SetupGoronShrineCheer(this); + this->flags &= ~FLAG_SHRINE_GORON_ARMS_RAISED; + return 0xDD8; // My son went to see the races + + case 0xDD8: // My son went to see the races + return 0xDD9; // I yield to a younger one + + case 0xDD9: // I yield to a younger one + return 0xDDA; // A Goron who takes care of all + + case 0xDDA: // A Goron who takes care of all + return 0xDDB; // The chosen one, Darmani! + + case 0xDDB: // The chosen one, Darmani! + return 0xDDC; // Everyone would accept you + + case 0xDDC: // Everyone would accept you + gSaveContext.save.weekEventReg[77] |= 0x80; + return 0xDDD; // Think it over slowly + + default: + return 0; + } +} + +/** + * Returns the text ID of the first thing the elder should say when you talk to him + * under most circumstances. Some circumstances (like the very first time the player + * talks to him after he thaws) bypass this function. + */ +s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!EN_JG_IS_IN_GORON_SHRINE(&this->actor)) { + if (player->transformation == PLAYER_FORM_GORON) { + if ((gSaveContext.save.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { + // The player has already talked as a Goron at least once. + return 0xDBC; // Following me won't do you any good + } + + // The player has never talked as a Goron. + return 0xDB6; // "Hunh???" + } + + if (gSaveContext.save.weekEventReg[24] & 0x20) { + // The player has already talked as a non-Goron at least once. + return 0xDB5; // This is our problem (repeat) + } + + // The player has never talked as a non-Goron. + return 0xDAE; // Do you have business with the Elder? + } + + if (player->transformation == PLAYER_FORM_GORON) { + if (gSaveContext.save.weekEventReg[77] & 0x80) { + // The player has heard the Goron Shrine cheer as a Goron at least once. + return 0xDDE; // Come back after entering the race + } + + // The player has never heard the Goron Shrine cheer as a Goron. + return 0xDCD; // I've been waiting impatiently for you + } + + // The player is talking to the elder in Goron Shrine as a non-Goron. + return 0xDCB; // Welcome to spring +} + +void EnJg_SpawnBreath(EnJg* this, GlobalContext* globalCtx) { + s16 scale = (Rand_ZeroOne() * 20.0f) + 30.0f; + + if (globalCtx->state.frames % 8 == 0) { + EffectSsIceSmoke_Spawn(globalCtx, &this->breathPos, &this->breathVelocity, &this->breathAccel, scale); + } +} + +/** + * This function has two purposes: + * - If the player starts talking to the elder, this stops him from moving, makes him face + * towards the player, updates certain weekEventRegs, and calls EnJg_SetupTalk. + * - If the player is *not* talking to the elder, this decrements his freeze timer. If his + * freeze timer is 0 or negative, this function starts the process of freezing him before + * handing it off to EnJg_Freeze. + */ +void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, GlobalContext* globalCtx) { + s16 currentFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->flags |= FLAG_LOOKING_AT_PLAYER; + this->actor.speedXZ = 0.0f; + + if (this->textId == 0xDAC) { + this->action = EN_JG_ACTION_FIRST_THAW; + } else if (this->textId == 0xDAE) { + gSaveContext.save.weekEventReg[24] |= 0x20; + } else if (this->textId == 0xDB6) { + gSaveContext.save.weekEventReg[24] |= 0x10; + } + + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->actionFunc = EnJg_SetupTalk; + } else { + if ((this->actor.xzDistToPlayer < 100.0f) || (this->actor.isTargeted)) { + func_800B863C(&this->actor, globalCtx); + if (this->action == EN_JG_ACTION_FIRST_THAW) { + this->textId = EnJg_GetStartingConversationTextId(this, globalCtx); + } + } + + this->freezeTimer--; + if ((this->freezeTimer <= 0) && (currentFrame == lastFrame)) { + this->animationIndex = EN_JG_ANIMATION_FROZEN_START; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + Audio_PlaySfxAtPos(&sSfxPos, NA_SE_EV_FREEZE_S); + this->actionFunc = EnJg_Freeze; + } + } +} + +void EnJg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnJg* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGoronElderSkel, &gGoronElderIdleAnim, this->jointTable, + this->morphTable, GORON_ELDER_LIMB_MAX); + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + Actor_SetScale(&this->actor, 0.01f); + + if (!EN_JG_IS_IN_GORON_SHRINE(thisx)) { + if ((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7) && + (globalCtx->csCtx.currentCsIndex == 0)) { + // This is the elder that appears in the cutscene for learning the full Goron Lullaby. + this->animationIndex = EN_JG_ANIMATION_IDLE; + this->action = EN_JG_ACTION_LULLABY_INTRO_CS; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_LullabyIntroCutsceneAction; + } else { + // This is the elder that appears in Mountain Village or the Path to Goron Village in winter. + this->path = SubS_GetPathByIndex(globalCtx, EN_JG_GET_PATH(thisx), 0x3F); + this->animationIndex = EN_JG_ANIMATION_SURPRISE_START; + this->action = EN_JG_ACTION_SPAWNING; + this->freezeTimer = 1000; + this->textId = 0xDAC; // What was I doing? + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_Freeze; + } + } else { + // This is the elder that appears in Goron Shrine in spring. + this->animationIndex = EN_JG_ANIMATION_IDLE; + this->cutscene = this->actor.cutscene; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->actionFunc = EnJg_GoronShrineIdle; + } +} + +void EnJg_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnJg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + if ((this->actionFunc != EnJg_FrozenIdle) && (this->actionFunc != EnJg_EndFrozenInteraction)) { + EnJg_UpdateCollision(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + if ((this->action != EN_JG_ACTION_LULLABY_INTRO_CS) && (!EN_JG_IS_IN_GORON_SHRINE(&this->actor))) { + EnJg_SpawnBreath(this, globalCtx); + } + + func_800E9250(globalCtx, &this->actor, &this->unusedRotation1, &this->unusedRotation2, this->actor.focus.pos); + } + this->actionFunc(this, globalCtx); +} + +s32 EnJg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnJg* this = THIS; + + if (limbIndex == GORON_ELDER_LIMB_ROOT) { + if (this->flags & FLAG_LOOKING_AT_PLAYER) { + Math_SmoothStepToS(&this->rootRotationWhenTalking, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, + 5, 0x1000, 0x100); + Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + } else { + Math_SmoothStepToS(&this->rootRotationWhenTalking, 0, 5, 0x1000, 0x100); + Matrix_RotateY(this->rootRotationWhenTalking, MTXMODE_APPLY); + } + } + + return false; +} + +void EnJg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnJg* this = THIS; + + if (limbIndex == GORON_ELDER_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&sFocusOffset, &this->actor.focus.pos); + } + + if (limbIndex == GORON_ELDER_LIMB_LOWER_LIP) { + Matrix_MultiplyVector3fByState(&sBreathPosOffset, &this->breathPos); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&sBreathVelOffset, &this->breathVelocity); + Matrix_MultiplyVector3fByState(&sBreathAccelOffset, &this->breathAccel); + } +} + +void EnJg_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJg* this = THIS; + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnJg_OverrideLimbDraw, EnJg_PostLimbDraw, &this->actor); +} 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 3a860feb2..67ba1d638 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.h +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.h @@ -2,16 +2,42 @@ #define Z_EN_JG_H #include "global.h" +#include "objects/object_jg/object_jg.h" + +#define EN_JG_IS_IN_GORON_SHRINE(thisx) ((thisx)->params & 0x1) +#define EN_JG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) struct EnJg; typedef void (*EnJgActionFunc)(struct EnJg*, GlobalContext*); typedef struct EnJg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x98]; - /* 0x01DC */ EnJgActionFunc actionFunc; - /* 0x01E0 */ char unk_1E0[0x1F4]; + /* 0x000 */ Actor actor; + /* 0x144 */ Actor* shrineGoron; + /* 0x148 */ Actor* icePoly; + /* 0x14C */ ColliderCylinder collider; + /* 0x198 */ SkelAnime skelAnime; + /* 0x1DC */ EnJgActionFunc actionFunc; + /* 0x1E0 */ Path* path; + /* 0x1E4 */ s32 currentPoint; + /* 0x1E8 */ Actor* drum; + /* 0x1EC */ Vec3s unusedRotation1; // probably meant to be a head rotation to look at the player + /* 0x1F2 */ Vec3s unusedRotation2; // probably meant to be a body rotation to look at the player + /* 0x1F8 */ Vec3s jointTable[GORON_ELDER_LIMB_MAX]; + /* 0x2CA */ Vec3s morphTable[GORON_ELDER_LIMB_MAX]; + /* 0x39C */ s16 rootRotationWhenTalking; + /* 0x39E */ s16 animationIndex; + /* 0x3A0 */ s16 action; + /* 0x3A2 */ s16 freezeTimer; + /* 0x3A4 */ Vec3f breathPos; + /* 0x3B0 */ Vec3f breathVelocity; + /* 0x3BC */ Vec3f breathAccel; + /* 0x3C8 */ s16 cutscene; + /* 0x3CA */ u8 cutsceneAnimationIndex; + /* 0x3CB */ u8 csAction; + /* 0x3CC */ u16 flags; + /* 0x3CE */ u16 textId; + /* 0x3D0 */ u8 focusedShrineGoronParam; } EnJg; // size = 0x3D4 extern const ActorInit En_Jg_InitVars; 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 46f9ec21d..a3878d9f2 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 @@ -5,8 +5,9 @@ */ #include "z_en_jgame_tsn.h" +#include "overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnJgameTsn*)thisx) @@ -15,7 +16,26 @@ void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13B74(EnJgameTsn* this); +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13E6C(EnJgameTsn* this); +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14030(EnJgameTsn* this); +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C141DC(EnJgameTsn* this); +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C145FC(EnJgameTsn* this); +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx); +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx); +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1); +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx); + const ActorInit En_Jgame_Tsn_InitVars = { ACTOR_EN_JGAME_TSN, ACTORCAT_NPC, @@ -28,81 +48,600 @@ const ActorInit En_Jgame_Tsn_InitVars = { (ActorFunc)EnJgameTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C15078 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_tsn_Anim_0092FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_tsn_Anim_000964, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_tsn_Anim_001198, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +TexturePtr D_80C150A4[] = { + object_tsn_Tex_0073B8, + object_tsn_Tex_0085B8, +}; -extern ColliderCylinderInit D_80C15078; +void EnJgameTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnJgameTsn* this = THIS; -extern UNK_TYPE D_060092FC; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, this->jointTable, + this->morphTable, OBJECT_TSN_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Init.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13A2C.s") + this->actor.targetMode = 6; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.velocity.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Destroy.s") + if (gSaveContext.save.entranceIndex == 0x68D0) { + this->actor.flags |= ACTOR_FLAG_10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13B74.s") + this->unk_2F8 = 0; + this->unk_2FA = 0; + this->unk_21C = 0; + this->unk_2FE = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13BB8.s") + func_80C13A2C(this, globalCtx); + func_80C13B74(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E6C.s") +void func_80C13A2C(EnJgameTsn* this, GlobalContext* globalCtx) { + Path* path = &globalCtx->setupPathList[ENJGAMETSN_GET_FF(&this->actor)]; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13E90.s") + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F88.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + this->unk_1D8[i].points = Lib_SegmentedToVirtual(path->points); + this->unk_1D8[i].count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C13F9C.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14030.s") + this->unk_1F8.points = Lib_SegmentedToVirtual(path->points); + this->unk_1F8.count = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14044.s") + path = &globalCtx->setupPathList[path->unk1]; + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1410C.s") + this->unk_200.points = Lib_SegmentedToVirtual(path->points); + this->unk_200.count = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1418C.s") +void EnJgameTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C141DC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14230.s") +void func_80C13B74(EnJgameTsn* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = func_80C13BB8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144E4.s") +void func_80C13BB8(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C144F8.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (this->actor.flags & ACTOR_FLAG_10000) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (gSaveContext.unk_3DE0[4] > 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else if (gSaveContext.minigameScore < 20) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x10A2, &this->actor); + this->unk_300 = 0x10A2; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A3, &this->actor); + this->unk_300 = 0x10A3; + } + } else if (((gSaveContext.save.time > CLOCK_TIME(4, 0)) && (gSaveContext.save.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.save.time > CLOCK_TIME(16, 0)) && (gSaveContext.save.time < CLOCK_TIME(19, 0)))) { + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else if (this->unk_2F8 == 0) { + this->unk_2F8 = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1095, &this->actor); + this->unk_300 = 0x1095; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + } + func_80C14030(this); + } else if (this->actor.flags & ACTOR_FLAG_10000) { + func_800B8614(&this->actor, globalCtx, 200.0f); + } else { + func_800B8614(&this->actor, globalCtx, 80.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14540.s") + if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & 0x2000) && (this->unk_2FE == 0) && + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) && func_80C149B0(globalCtx, &this->unk_1F8)) { + this->unk_2FE = 1; + func_80C13E6C(this); + } else if (!(player->actor.bgCheckFlags & 1)) { + this->unk_2FE = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14554.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C145FC.s") +void func_80C13E6C(EnJgameTsn* this) { + this->actor.flags |= ACTOR_FLAG_10000; + this->actionFunc = func_80C13E90; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14610.s") +void func_80C13E90(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + if (((gSaveContext.save.time > CLOCK_TIME(4, 0)) && (gSaveContext.save.time < CLOCK_TIME(7, 0))) || + ((gSaveContext.save.time > CLOCK_TIME(16, 0)) && (gSaveContext.save.time < CLOCK_TIME(19, 0)))) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x1094, &this->actor); + this->unk_300 = 0x1094; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(globalCtx, 0x1098, &this->actor); + this->unk_300 = 0x1098; + } + func_80C14030(this); + } else { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14684.s") +void func_80C13F88(EnJgameTsn* this) { + this->actionFunc = func_80C13F9C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C1476C.s") +void func_80C13F9C(EnJgameTsn* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80C14030(this); + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } else { + func_80C14030(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C147B4.s") +void func_80C14030(EnJgameTsn* this) { + this->actionFunc = func_80C14044; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14960.s") +void func_80C14044(EnJgameTsn* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + case 3: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C149B0.s") + case 4: + func_80C14684(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14BCC.s") + case 5: + func_80C147B4(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D14.s") + case 6: + if (Message_ShouldAdvance(globalCtx)) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_80C13B74(this); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14D58.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x71C, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Update.s") +void func_80C1410C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14E64.s") + player->stateFlags1 |= 0x20; + func_801A2BB8(0x25); + globalCtx->interfaceCtx.unk_280 = 1; + Interface_InitMinigame(globalCtx); + gSaveContext.save.weekEventReg[90] |= 0x20; + func_8010E9F0(4, 0x78); + this->actionFunc = func_80C1418C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/func_80C14EE4.s") +void func_80C1418C(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Jgame_Tsn/EnJgameTsn_Draw.s") + if (globalCtx->interfaceCtx.unk_280 == 8) { + func_80C141DC(this); + player->stateFlags1 &= ~0x20; + } +} + +void func_80C141DC(EnJgameTsn* this) { + this->unk_218 = Rand_Next() & 3; + this->unk_2FC = 0; + *this->unk_208[this->unk_218] |= 1; + this->actionFunc = func_80C14230; +} + +void func_80C14230(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 rand; + + if ((this->unk_2FC > 100) || func_80C14BCC(this, globalCtx)) { + rand = (u32)Rand_Next() % 3; + + this->unk_2FC = 0; + if (rand < this->unk_218) { + this->unk_218 = rand; + } else { + this->unk_218 = rand + 1; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_208); i++) { + if (i == this->unk_218) { + *this->unk_208[i] |= 1; + *this->unk_208[i] &= ~8; + } else { + *this->unk_208[i] |= 8; + } + } + } + + this->unk_2FC++; + + if ((player->actor.bgCheckFlags & 2) && func_80C149B0(globalCtx, &this->unk_200)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109F, &this->actor); + this->unk_300 = 0x109F; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } else if ((player->actor.bgCheckFlags & 0x40) || (player->actor.bgCheckFlags & 0x20)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x10A0, &this->actor); + this->unk_300 = 0x10A0; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } + + if (gSaveContext.unk_3DE0[4] == 0) { + Message_StartTextbox(globalCtx, 0x10A1, &this->actor); + this->unk_300 = 0x10A1; + player->stateFlags1 |= 0x20; + *this->unk_208[this->unk_218] &= ~1; + func_801A2C20(); + func_80C14030(this); + } +} + +void func_80C144E4(EnJgameTsn* this) { + this->actionFunc = func_80C144F8; +} + +void func_80C144F8(EnJgameTsn* this, GlobalContext* globalCtx) { + globalCtx->nextEntranceIndex = 0x68D0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 0x50; + gSaveContext.nextTransition = 3; +} + +void func_80C14540(EnJgameTsn* this) { + this->actionFunc = func_80C14554; +} + +void func_80C14554(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.save.weekEventReg[82] & 0x10)) { + gSaveContext.save.weekEventReg[82] |= 0x10; + } + func_80C145FC(this); + } else if (gSaveContext.save.weekEventReg[82] & 0x10) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } +} + +void func_80C145FC(EnJgameTsn* this) { + this->actionFunc = func_80C14610; +} + +void func_80C14610(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x10A4, &this->actor); + this->unk_300 = 0x10A4; + func_80C14030(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +void func_80C14684(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.save.playerData.rupees >= 20) { + Message_StartTextbox(globalCtx, 0x109E, &this->actor); + this->unk_300 = 0x109E; + Rupees_ChangeBy(-20); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109D, &this->actor); + this->unk_300 = 0x109D; + } + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Message_StartTextbox(globalCtx, 0x109C, &this->actor); + this->unk_300 = 0x109C; + } + } +} + +void func_80C1476C(EnJgameTsn* this, GlobalContext* globalCtx) { + Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (prop != NULL) { + if (prop->id == ACTOR_OBJ_JGAME_LIGHT) { + this->unk_208[OBJJGAMELIGHT_GET_7F(prop)] = &prop->colChkInfo.health; + } + prop = prop->next; + } +} + +void func_80C147B4(EnJgameTsn* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + switch (this->unk_300) { + case 0x1095: + Message_StartTextbox(globalCtx, 0x1096, &this->actor); + this->unk_300 = 0x1096; + break; + + case 0x1096: + Message_StartTextbox(globalCtx, 0x1097, &this->actor); + this->unk_300 = 0x1097; + break; + + case 0x1098: + Message_StartTextbox(globalCtx, 0x1099, &this->actor); + this->unk_300 = 0x1099; + func_80C13F88(this); + break; + + case 0x1099: + Message_StartTextbox(globalCtx, 0x109A, &this->actor); + this->unk_300 = 0x109A; + break; + + case 0x109A: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Message_StartTextbox(globalCtx, 0x109B, &this->actor); + this->unk_300 = 0x109B; + break; + + case 0x109E: + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + ActorCutscene_Stop(this->actor.cutscene); + } + func_801477B4(globalCtx); + func_80C1476C(this, globalCtx); + func_80C1410C(this, globalCtx); + break; + + case 0x109F: + case 0x10A0: + case 0x10A1: + func_801477B4(globalCtx); + gSaveContext.minigameState = 3; + gSaveContext.unk_3DD0[4] = 5; + gSaveContext.save.weekEventReg[90] &= (u8)~0x20; + func_80C144E4(this); + break; + + case 0x10A3: + func_801477B4(globalCtx); + func_80C14540(this); + func_80C14554(this, globalCtx); + break; + } + } +} + +s32 func_80C14960(Vec2f arg0, Vec2f arg1) { + s32 phi_v1; + + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { + phi_v1 = 1; + } else { + phi_v1 = -1; + } + return phi_v1; +} + +s32 func_80C149B0(GlobalContext* globalCtx, EnJgameTsnStruct* arg1) { + s32 i = 1; + s32 temp_s3; + Player* player = GET_PLAYER(globalCtx); + Vec2f sp64; + Vec2f sp5C; + s32 sp58 = true; + s32 pad; + s32 sp50 = 0; + f32 temp_f20 = player->actor.world.pos.z; + f32 temp_f22 = player->actor.world.pos.x; + + sp64.x = arg1->points[0].z - temp_f20; + sp64.z = arg1->points[0].x - temp_f22; + sp5C.x = arg1->points[1].z - temp_f20; + sp5C.z = arg1->points[1].x - temp_f22; + temp_s3 = func_80C14960(sp64, sp5C); + + while (i != 0) { + sp50++; + if (i < (arg1->count - 1)) { + i++; + } else { + i = 0; + } + + sp64.x = arg1->points[sp50].z - temp_f20; + sp64.z = arg1->points[sp50].x - temp_f22; + sp5C.x = arg1->points[i].z - temp_f20; + sp5C.z = arg1->points[i].x - temp_f22; + + if (func_80C14960(sp64, sp5C) != temp_s3) { + sp58 = false; + break; + } + } + + return sp58; +} + +s32 func_80C14BCC(EnJgameTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 phi_s3 = -1; + + if (player->actor.bgCheckFlags & 2) { + for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { + if (func_80C149B0(globalCtx, &this->unk_1D8[i])) { + phi_s3 = i; + } + } + + if (phi_s3 == -1) { + return false; + } + + if (phi_s3 == this->unk_218) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + return true; + } + + if (*this->unk_208[phi_s3] & 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + *this->unk_208[phi_s3] |= 2; + globalCtx->interfaceCtx.unk_25C = 1; + } else { + *this->unk_208[phi_s3] |= 4; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + } + } + + return false; +} + +void func_80C14D14(EnJgameTsn* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80C14D58(EnJgameTsn* this, GlobalContext* globalCtx) { + func_800E9250(globalCtx, &this->actor, &this->unk_2EC, &this->unk_2F2, this->actor.focus.pos); + + if (DECR(this->unk_2FA) == 0) { + this->unk_2FA = Rand_S16Offset(60, 60); + } + + if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { + this->unk_21C = 1; + } else { + this->unk_21C = 0; + } +} + +void EnJgameTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_80C14D14(this, globalCtx); + func_80C14D58(this, globalCtx); +} + +s32 EnJgamesTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnJgameTsn* this = THIS; + s16 temp_v0 = this->unk_2EC.x >> 1; + + if (limbIndex == OBJECT_TSN_LIMB_0F) { + rot->x += this->unk_2EC.y; + rot->z += temp_v0; + } else if (limbIndex == OBJECT_TSN_LIMB_08) { + rot->x += this->unk_2F2.y; + rot->z += temp_v0; + } + return false; +} + +void EnJgamesTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == OBJECT_TSN_LIMB_0F) { + Matrix_GetStateTranslation(&thisx->focus.pos); + } +} + +void EnJgameTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnJgameTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80C150A4[this->unk_21C])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnJgamesTsn_OverrideLimbDraw, EnJgamesTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h index c7e53da1a..08d07376d 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.h @@ -2,16 +2,39 @@ #define Z_EN_JGAME_TSN_H #include "global.h" +#include "objects/object_tsn/object_tsn.h" struct EnJgameTsn; typedef void (*EnJgameTsnActionFunc)(struct EnJgameTsn*, GlobalContext*); +#define ENJGAMETSN_GET_FF(thisx) ((thisx)->params & 0xFF) + +typedef struct { + /* 0x00 */ Vec3s* points; + /* 0x04 */ s32 count; +} EnJgameTsnStruct; // size = 0x8 + typedef struct EnJgameTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnJgameTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x12C]; + /* 0x01D8 */ EnJgameTsnStruct unk_1D8[4]; + /* 0x01F8 */ EnJgameTsnStruct unk_1F8; + /* 0x0200 */ EnJgameTsnStruct unk_200; + /* 0x0208 */ u8* unk_208[4]; + /* 0x0218 */ s32 unk_218; + /* 0x021C */ s32 unk_21C; + /* 0x0220 */ Vec3s jointTable[OBJECT_TSN_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TSN_LIMB_MAX]; + /* 0x02EC */ Vec3s unk_2EC; + /* 0x02F2 */ Vec3s unk_2F2; + /* 0x02F8 */ s16 unk_2F8; + /* 0x02FA */ s16 unk_2FA; + /* 0x02FC */ s16 unk_2FC; + /* 0x02FE */ s16 unk_2FE; + /* 0x0300 */ u16 unk_300; } EnJgameTsn; // size = 0x304 extern const ActorInit En_Jgame_Tsn_InitVars; 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 ecd2fafa1..15426db82 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -6,7 +6,7 @@ #include "z_en_js.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnJs*)thisx) diff --git a/src/overlays/actors/ovl_En_Jso/z_en_jso.c b/src/overlays/actors/ovl_En_Jso/z_en_jso.c index e20a4de3a..3c7e5ce75 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.c +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.c @@ -6,7 +6,7 @@ #include "z_en_jso.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnJso*)thisx) diff --git a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c index ad00e6d87..8d29b9383 100644 --- a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c +++ b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c @@ -6,7 +6,7 @@ #include "z_en_jso2.h" -#define FLAGS 0x80100035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnJso2*)thisx) 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 eef75acf9..721e8c1a4 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -6,7 +6,7 @@ #include "z_en_kaizoku.h" -#define FLAGS 0x00100015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_100000) #define THIS ((EnKaizoku*)thisx) 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 3e6f67ca8..c3194461d 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -7,7 +7,7 @@ #include "z_en_kakasi.h" #include "objects/object_ka/object_ka.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnKakasi*)thisx) @@ -46,9 +46,6 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx); void EnKakasi_SetupDialogue(EnKakasi* this); -void EnKakasi_PostLimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - struct Actor* thisx); - static ColliderCylinderInit D_80971D80 = { { COLTYPE_NONE, @@ -132,8 +129,10 @@ static AnimationHeader* kakasiAnimations[] = { &object_ka_Anim_00686C, &object_ka_Anim_0081A4, &object_ka_Anim_000214, }; -static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, - ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE }; +static u8 sAnimModes[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, +}; void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnKakasi* this = THIS; @@ -164,7 +163,7 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(this); this->actor.world.rot.x = 0; - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; this->actor.colChkInfo.mass = MASS_IMMOVABLE; Actor_SetScale(&this->actor, 0.01f); @@ -177,14 +176,14 @@ void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { } if (this->aboveGroundStatus) { - if (gSaveContext.save.weekEventReg[79] & 0x8) { + if (gSaveContext.save.weekEventReg[79] & 8) { this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { Actor_SetFocus(&this->actor, 60.0f); this->unkFunc = EnKakasi_8096F88C; - if (gSaveContext.save.weekEventReg[83] & 0x1) { + if (gSaveContext.save.weekEventReg[83] & 1) { EnKakasi_InitTimeSkipDialogue(this); } else { EnKakasi_SetupIdleStanding(this); @@ -257,7 +256,7 @@ void EnKakasi_CheckPlayerPosition(EnKakasi* this, GlobalContext* globalCtx) { * something to do with cutscene camera? */ void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { Math_ApproachF(&this->unk214.x, this->unk238.x, 0.4f, 4.0f); Math_ApproachF(&this->unk214.y, this->unk238.y, 0.4f, 4.0f); Math_ApproachF(&this->unk214.z, this->unk238.z, 0.4f, 4.0f); @@ -269,7 +268,7 @@ void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { Math_ApproachF(&this->unk20C, this->unk210, 0.3f, 10.0f); Play_CameraSetAtEye(globalCtx, this->cutsceneCamId, &this->unk220, &this->unk214); - func_80169940(globalCtx, this->cutsceneCamId, this->unk20C); + Play_CameraSetFov(globalCtx, this->cutsceneCamId, this->unk20C); } } @@ -309,16 +308,16 @@ void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { if (this->actor.textId == 0) { // dialogue after skipped time 'did you feel that? went by in an instant' this->actor.textId = 0x1653; - gSaveContext.save.weekEventReg[0x53] &= (u8)~1; + gSaveContext.save.weekEventReg[83] &= (u8)~1; this->unkMsgState1AC = 5; player->stateFlags1 |= 0x20; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags1 &= ~0x20; this->unkState196 = 2; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actionFunc = EnKakasi_RegularDialogue; } else { func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); @@ -334,8 +333,8 @@ void EnKakasi_SetupIdleStanding(EnKakasi* this) { void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { u32 saveContextDay = gSaveContext.save.day; - s16 passedValue1; - s16 passedValue2; + s16 x; + s16 y; // first talk to scarecrow dialogue this->actor.textId = 0x1644; @@ -350,9 +349,9 @@ void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { return; } if (globalCtx->actorCtx.unk5 & 0x4) { - Actor_GetScreenPos(globalCtx, &this->actor, &passedValue1, &passedValue2); - if (this->actor.projectedPos.z > -20.0f && passedValue1 > 0 && passedValue1 < 0x140 && passedValue2 > 0 && - passedValue2 < 0xF0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + Actor_GetScreenPos(globalCtx, &this->actor, &x, &y); + if (this->actor.projectedPos.z > -20.0f && x > 0 && x < SCREEN_WIDTH && y > 0 && y < SCREEN_HEIGHT && + this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { // faster shaking EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); this->skelanime.playSpeed = 2.0f; @@ -416,7 +415,7 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 0; } - if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + if (this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx) && Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); if (this->unkMsgState1AC == 5) { // bad song input @@ -547,8 +546,8 @@ void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { this->actor.textId = 0x1646; - func_801518B0(globalCtx, this->actor.textId, &this->actor); - this->cutsceneCamId = MAIN_CAM; + Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + this->cutsceneCamId = CAM_ID_MAIN; this->unk20C = 0.0f; this->unk210 = 60.0f; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); @@ -561,7 +560,7 @@ void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { * before actually teaching */ void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { func_80152434(globalCtx, 0x35); this->unkState1A8 = 0; if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -626,7 +625,7 @@ void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YASE_DEAD); if (this) {} this->unkState196 = 2; - this->cutsceneCamId = MAIN_CAM; + this->cutsceneCamId = CAM_ID_MAIN; this->actor.textId = 0x1647; this->unkState1A8 = 2; this->unkMsgState1AC = 5; @@ -660,7 +659,7 @@ void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCt this->unk190 = 0; this->unkCounter1A4 = 0; EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); - this->cutsceneCamId = MAIN_CAM; + this->cutsceneCamId = CAM_ID_MAIN; this->unkMsgState1AC = 5; this->unkState1A8 = 1; this->actionFunc = EnKakasi_PostSongLearnDialogue; @@ -680,7 +679,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); func_800B7298(globalCtx, &this->actor, 0x56); this->actor.textId = 0x1648; - func_801518B0(globalCtx, (this->actor.textId), &this->actor); + Message_StartTextbox(globalCtx, (this->actor.textId), &this->actor); this->unkState1A8 = 0; this->unk190 = 1; } @@ -718,7 +717,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { this->unkState1A8 = 1; } - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { this->unk22C.y = this->actor.home.pos.y + 50.0f; EnKakasi_CheckPlayerPosition(this, globalCtx); this->unk238.x = D_80971FA0[this->unk190].x; @@ -736,7 +735,7 @@ void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { func_8096FAAC(this, globalCtx); if (this->unkState1A8 != 0 && Message_GetState(&globalCtx->msgCtx) == this->unkMsgState1AC && - func_80147624(globalCtx) != 0) { + Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); @@ -932,9 +931,9 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { if (this->unk204 == 0) { player = GET_PLAYER(globalCtx); - func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0, - player->unk_3CC); - func_80169EFC(globalCtx); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + func_80169EFC(&globalCtx->state); if (0) {} if (gSaveContext.save.time > CLOCK_TIME(18, 0) || gSaveContext.save.time < CLOCK_TIME(6, 0)) { @@ -945,7 +944,7 @@ void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { gSaveContext.save.time = CLOCK_TIME(18, 0); gSaveContext.respawnFlag = -8; } - gSaveContext.save.weekEventReg[0x53] |= 1; + gSaveContext.save.weekEventReg[83] |= 1; this->unk190 = 0; this->actionFunc = EnKakasi_DoNothing; } @@ -972,7 +971,7 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { Vec3f tempunk238; Vec3f tempWorldPos; - if (this->cutsceneCamId != MAIN_CAM) { + if (this->cutsceneCamId != CAM_ID_MAIN) { this->unk22C.y = this->actor.home.pos.y + 50.0f; this->unk238.x = D_80972030.x; this->unk238.y = D_80972030.y; @@ -1026,15 +1025,15 @@ void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_SetupIdleUnderground(EnKakasi* this) { this->actor.shape.yOffset = -7000.0; this->actor.draw = NULL; - this->actor.flags |= 0x8000000; + this->actor.flags |= ACTOR_FLAG_8000000; this->unkState196 = 5; this->actionFunc = EnKakasi_IdleUnderground; } void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { - if ((gSaveContext.save.weekEventReg[79] & 0x8) && this->actor.xzDistToPlayer < this->songSummonDist && + if ((gSaveContext.save.weekEventReg[79] & 8) && this->actor.xzDistToPlayer < this->songSummonDist && (BREG(1) != 0 || globalCtx->msgCtx.ocarinaMode == 0xD)) { - this->actor.flags &= ~0x8000000; + this->actor.flags &= ~ACTOR_FLAG_8000000; globalCtx->msgCtx.ocarinaMode = 4; this->actionFunc = EnKakasi_SetupRiseOutOfGround; } @@ -1102,7 +1101,7 @@ void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); EnKakasi_SetupIdleRisen(this); } @@ -1125,7 +1124,7 @@ void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk1BC); this->actor.focus.pos.y += 10.0f; - if (this->cutsceneCamId == MAIN_CAM) { + if (this->cutsceneCamId == CAM_ID_MAIN) { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } else { Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.home.rot); 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 86c924298..e457ec219 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -7,7 +7,7 @@ #include "z_en_kame.h" #include "objects/object_tl/object_tl.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnKame*)thisx) @@ -163,23 +163,23 @@ void func_80AD6F34(EnKame* this) { } void func_80AD6F9C(EnKame* this) { - this->unk_29D = 10; - this->unk_2B4 = 0.6f; - this->unk_2B8 = 0.90000004f; - this->unk_2B0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffFrozenSteamScale = 0.90000004f; + this->drawDmgEffAlpha = 1.0f; this->collider.base.colType = COLTYPE_HIT3; this->unk_2A2 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80AD7018(EnKame* this, GlobalContext* globalCtx) { - if (this->unk_29D == 10) { - this->unk_29D = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2B0 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2C8, 10, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; } } @@ -320,7 +320,7 @@ void func_80AD76CC(EnKame* this) { Math_Vec3f_Copy(&this->unk_2BC, &this->actor.home.pos); this->unk_29E = 0; } - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80AD7798; } @@ -388,7 +388,7 @@ void func_80AD7948(EnKame* this, GlobalContext* globalCtx) { this->unk_2AC -= 0.1f; this->collider.base.atFlags &= ~AT_ON; if (this->unk_2AC < 0.5f) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_80AD7B18(this); } } else { @@ -438,7 +438,7 @@ void func_80AD7C54(EnKame* this) { this->collider.base.acFlags &= ~AC_ON; this->collider.base.atFlags &= ~AT_ON; this->collider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.shape.rot.z = 0; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_REVERSE); this->actionFunc = func_80AD7D40; @@ -555,8 +555,8 @@ void func_80AD8148(EnKame* this, GlobalContext* globalCtx) { } } this->actor.bgCheckFlags &= ~0x1; - this->actor.flags &= ~0x1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PAMET_DEAD); this->unk_29E = 0; this->actionFunc = func_80AD825C; @@ -617,7 +617,8 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_HIT; Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_29D == 10) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return; } @@ -644,9 +645,9 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { this->unk_2A2 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2B4 = 0.6f; - this->unk_2B0 = 2.0f; - this->unk_29D = 30; + 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; @@ -662,13 +663,13 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { func_80AD7FA4(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 0; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2B4 = 0.6f; - this->unk_2B0 = 4.0f; - this->unk_29D = 20; + this->drawDmgEffScale = 0.6f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -683,7 +684,7 @@ void func_80AD84C0(EnKame* this, GlobalContext* globalCtx) { } } - if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < 40000.0f) && + if ((globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f)) && (this->collider.base.acFlags & AC_ON)) { func_80AD7018(this, globalCtx); func_80AD7C54(this); @@ -732,16 +733,16 @@ void EnKame_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2B0 > 0.0f) { - if (this->unk_29D != 10) { - Math_StepToF(&this->unk_2B0, 0.0f, 0.05f); - this->unk_2B4 = (this->unk_2B0 + 1.0f) * 0.3f; - if (this->unk_2B4 > 0.6f) { - this->unk_2B4 = 0.6f; + 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.3f; + if (this->drawDmgEffScale > 0.6f) { + this->drawDmgEffScale = 0.6f; } else { - this->unk_2B4 = this->unk_2B4; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B8, 0.6f, 0.015000001f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.6f, 0.015000001f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -769,7 +770,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* EnKame* this = THIS; if (D_80AD8EA4[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2C8[D_80AD8EA4[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80AD8EA4[limbIndex]]); } if (limbIndex == 1) { @@ -782,7 +783,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } ptr2 = D_80AD8E68; - ptr = &this->unk_2C8[5]; + ptr = &this->limbPos[5]; for (i = 0; i < ARRAY_COUNT(D_80AD8E68); i++) { Matrix_MultiplyVector3fByState(ptr2, ptr); ptr2++; @@ -807,8 +808,8 @@ void EnKame_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime1.skeleton, this->skelAnime1.jointTable, this->skelAnime1.dListCount, func_80AD8A48, func_80AD8AF8, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2C8, 10, this->unk_2B4, this->unk_2B8, this->unk_2B0, - this->unk_29D); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); if (this->actor.shape.shadowDraw == NULL) { ActorShadow_DrawCircle(&this->actor, NULL, globalCtx); diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.h b/src/overlays/actors/ovl_En_Kame/z_en_kame.h index 115bf137f..d47e96d54 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -17,7 +17,7 @@ typedef struct EnKame { /* 0x0280 */ Vec3s morphTable2[4]; /* 0x0298 */ EnKameActionFunc actionFunc; /* 0x029C */ u8 unk_29C; - /* 0x029D */ u8 unk_29D; + /* 0x029D */ u8 drawDmgEffType; /* 0x029E */ s16 unk_29E; /* 0x02A0 */ s16 unk_2A0; /* 0x02A2 */ s16 unk_2A2; @@ -25,11 +25,11 @@ typedef struct EnKame { /* 0x02A6 */ s16 unk_2A6; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ f32 unk_2B8; + /* 0x02B0 */ f32 drawDmgEffAlpha; + /* 0x02B4 */ f32 drawDmgEffScale; + /* 0x02B8 */ f32 drawDmgEffFrozenSteamScale; /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ Vec3f unk_2C8[10]; + /* 0x02C8 */ Vec3f limbPos[10]; /* 0x0340 */ ColliderCylinder collider; } EnKame; // size = 0x38C 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 5968f6897..33474cda5 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -8,7 +8,7 @@ #include "objects/object_kanban/object_kanban.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnKanban*)thisx) @@ -146,7 +146,7 @@ void EnKanban_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); if (this->actor.params != ENKANBAN_PIECE) { this->actor.targetMode = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_19A = Rand_ZeroFloat(1.9f); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); @@ -230,7 +230,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->zTargetTimer == 1) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } if (this->partFlags == 0xFFFF) { @@ -381,8 +381,8 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { piece->direction = -1; } piece->airTimer = 100; - piece->actor.flags &= ~1; - piece->actor.flags |= 0x2000000; + piece->actor.flags &= ~ACTOR_FLAG_1; + piece->actor.flags |= ACTOR_FLAG_2000000; this->cutMarkTimer = 5; Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SWORD_STRIKE); } @@ -397,7 +397,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (this->actor.xzDistToPlayer > 500.0f) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->partFlags = 0xFFFF; } @@ -875,7 +875,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { ((pDiff + yDiff + rDiff + this->spinRot.x + this->spinRot.z) == 0) && (this->floorRot.x == 0.0f) && (this->floorRot.z == 0.0f)) { signpost->partFlags |= this->partFlags; - signpost->actor.flags |= 1; + signpost->actor.flags |= ACTOR_FLAG_1; Actor_MarkForDeath(&this->actor); return; } @@ -995,7 +995,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { f32 shadowAlpha; if (dayTime >= CLOCK_TIME(12, 0)) { - dayTime = (0xFFFF - dayTime) & 0xFFFF; + dayTime = 0xFFFF - dayTime; } shadowAlpha = (dayTime * 0.00275f) + 10.0f; diff --git a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h index b667bd9e8..201364bc0 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h @@ -66,7 +66,7 @@ typedef enum { typedef struct EnKanban { /* 0x000 */ Actor actor; - /* 0x144 */ UNK_TYPE1 unk144[4]; // actionFunc? + /* 0x144 */ UNK_TYPE1 unk_144[4]; // actionFunc? /* 0x148 */ u8 frameCount; /* 0x14A */ s16 airTimer; /* 0x14C */ u8 actionState; 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 dd2233e4c..7a59e702c 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.c @@ -5,8 +5,10 @@ */ #include "z_en_karebaba.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_dekubaba/object_dekubaba.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnKarebaba*)thisx) @@ -15,19 +17,28 @@ void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx); void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_808F155C(EnKarebaba* this); void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1648(EnKarebaba* this); void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F16FC(EnKarebaba* this); void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1878(EnKarebaba* this); void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1A3C(EnKarebaba* this); void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1BF8(EnKarebaba* this); void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F1FAC(EnKarebaba* this); void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx); void func_808F21A4(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F220C(EnKarebaba* this); void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx); +void func_808F238C(EnKarebaba* this); void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx); void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Karebaba_InitVars = { ACTOR_EN_KAREBABA, ACTORCAT_ENEMY, @@ -40,25 +51,49 @@ const ActorInit En_Karebaba_InitVars = { (ActorFunc)EnKarebaba_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808F2DA0 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 7, 25, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808F2DCC = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_WOOD, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_WOOD, + BUMP_NONE, + OCELEM_ON, + }, { 4, 25, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808F2DF8 = { 1, 15, 80, MASS_HEAVY }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 15, 80, MASS_HEAVY }; -// static DamageTable sDamageTable = { -static DamageTable D_808F2E00 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(3, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -93,79 +128,614 @@ static DamageTable D_808F2E00 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808F2E20[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2500, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 1, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_808F2E28 = { 0, 0, 0, 0 }; -extern ColliderCylinderInit D_808F2DA0; -extern ColliderCylinderInit D_808F2DCC; -extern CollisionCheckInfoInit D_808F2DF8; -extern DamageTable D_808F2E00; -extern InitChainEntry D_808F2E20[]; +Gfx* D_808F2E2C[] = { object_dekubaba_DL_001330, object_dekubaba_DL_001628, object_dekubaba_DL_001828 }; -extern UNK_TYPE D_060002B8; -extern UNK_TYPE D_06003070; +void EnKarebaba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekubaba_Skel_002A40, &object_dekubaba_Anim_0002B8, + this->jointTable, this->morphTable, 8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Destroy.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit2); + Collider_UpdateCylinder(&this->actor, &this->collider1); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1374.s") + this->unk_22C = NULL; + if (this->actor.params == ENKAREBABA_2) { + this->actor.hintId = 2; + } else { + this->actor.hintId = 9; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F13FC.s") + if (this->actor.params == ENKAREBABA_0) { + func_808F155C(this); + } else { + func_808F1648(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F152C.s") +void EnKarebaba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F155C.s") + Collider_DestroyCylinder(globalCtx, &this->collider2); + Collider_DestroyCylinder(globalCtx, &this->collider1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F15B0.s") +void func_808F1374(EnKarebaba* this, GlobalContext* globalCtx) { + s32 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1648.s") + 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; + } else { + phi_a3 = 4; + } + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, phi_a3, 4, 0.3f, 0.2f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F169C.s") +void func_808F13FC(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->actor.colChkInfo.damageEffect == 2) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->drawDmgEffScale = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 3.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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, + CLEAR_TAG_SMALL_LIGHT_RAYS); + } else if (this->actor.colChkInfo.damageEffect == 3) { + 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) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F16FC.s") +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; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1778.s") +void func_808F155C(EnKarebaba* this) { + Actor_SetScale(&this->actor, 0.0f); + this->actor.shape.rot.x = -0x4000; + this->unk_1EE = 0; + this->actor.world.pos.y = this->actor.home.pos.y + 14.0f; + this->actionFunc = func_808F15B0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1878.s") +void func_808F15B0(EnKarebaba* this, GlobalContext* globalCtx) { + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F190C.s") + 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); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1A3C.s") +void func_808F1648(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; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1A58.s") +void func_808F169C(EnKarebaba* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(this->actor.playerHeightRel) < 30.0f)) { + func_808F16FC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1BF8.s") +void func_808F16FC(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 4.0f, 0.0f, + Animation_GetLastFrame(&object_dekubaba_Anim_0002B8), 0, -3.0f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_WAKEUP); + this->actionFunc = func_808F1778; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1C84.s") +void func_808F1778(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F1FAC.s") + if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { + func_808F1878(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F200C.s") + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F20FC.s") + 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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F21A4.s") + this->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F220C.s") +void func_808F1878(EnKarebaba* this) { + if (this->actionFunc != func_808F1A58) { + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F228C.s") + this->collider2.base.colType = COLTYPE_HIT6; + this->collider2.base.acFlags &= ~AC_HARD; + this->collider2.dim.radius = 15; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F238C.s") + if (this->actor.params == ENKAREBABA_1) { + this->collider2.dim.height = 80; + this->collider1.dim.height = 80; + } else { + this->collider2.dim.height = 35; + this->collider1.dim.height = 35; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F241C.s") + this->unk_1EE = 40; + this->actionFunc = func_808F190C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F24F8.s") +void func_808F190C(EnKarebaba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F254C.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Update.s") + if (this->unk_1EE != 0) { + this->unk_1EE--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/func_808F280C.s") + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_MIZUBABA1_MOUTH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Karebaba/EnKarebaba_Draw.s") + if (this->collider2.base.acFlags & AC_HIT) { + func_808F13FC(this, globalCtx); + if (this->actor.params == ENKAREBABA_1) { + func_808F1BF8(this); + } else { + func_808F1FAC(this); + } + Enemy_StartFinishingBlow(globalCtx, &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); + } +} + +void func_808F1A3C(EnKarebaba* this) { + this->unk_1EE = 40; + this->actionFunc = func_808F1A58; +} + +void func_808F1A58(EnKarebaba* this, GlobalContext* globalCtx) { + s32 phi_v0; + f32 sp28; + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + 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); + } + + phi_v0 = 20 - this->unk_1EE; + phi_v0 = 20 - ABS_ALT(phi_v0); + if (phi_v0 > 10) { + phi_v0 = 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->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; + + if (this->collider2.base.acFlags & AC_HIT) { + func_808F13FC(this, globalCtx); + func_808F1BF8(this); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } else if (this->unk_1EE == 0) { + func_808F1878(this); + } +} + +void func_808F1BF8(EnKarebaba* this) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->unk_1EE = 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; + } else { + this->unk_1EE = 3; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKU_JR_DEAD); + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actionFunc = func_808F1C84; +} + +void func_808F1C84(EnKarebaba* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp78; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->unk_1EE--; + if (this->unk_1EE == 0) { + this->actor.gravity = -0.8f; + this->actor.speedXZ = 3.0f; + this->actor.velocity.y = 4.0f; + this->actor.world.rot.y = BINANG_ROT180(this->actor.shape.rot.y); + func_808F1374(this, globalCtx); + } + } else { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.1f); + + if (this->unk_1EE == 0) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4800, 0x71C); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); + + if ((this->actor.scale.x > 0.005f) && ((this->actor.bgCheckFlags & 2) || (this->actor.bgCheckFlags & 8))) { + 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.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 15, -1, 10, NULL); + } + + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + this->unk_1EE = 1; + } + } else if (this->unk_1EE == 1) { + Math_Vec3f_Copy(&sp78, &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); + + for (i = 0; i < 4; i++) { + func_800B1210(globalCtx, &sp78, &gZeroVec3f, &gZeroVec3f, 500, 50); + sp78.x += temp_f20; + sp78.y += temp_f24; + sp78.z += temp_f22; + } + + func_800B1210(globalCtx, &this->actor.home.pos, &gZeroVec3f, &gZeroVec3f, 500, 100); + func_808F20FC(this, globalCtx); + } + } +} + +void func_808F1FAC(EnKarebaba* this) { + Actor_PlaySfxAtPos(&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->actionFunc = func_808F200C; +} + +void func_808F200C(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->unk_1EE--; + if (this->unk_1EE == 0) { + func_808F1374(this, globalCtx); + } + } else { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0005f)) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_NUTS_1); + func_808F238C(this); + } else { + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.world.pos, 3.0f, 0, 12, 5, 1, -1, 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; + } +} + +void func_808F20FC(EnKarebaba* this, GlobalContext* globalCtx) { + 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(globalCtx, &globalCtx->actorCtx, &this->actor, 8); + this->unk_1EE = 200; + this->actor.flags &= ~ACTOR_FLAG_20; + this->drawDmgEffAlpha = 0.0f; + this->actionFunc = func_808F21A4; +} + +void func_808F21A4(EnKarebaba* this, GlobalContext* globalCtx) { + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (Actor_HasParent(&this->actor, globalCtx) || (this->unk_1EE == 0)) { + func_808F238C(this); + } else { + Actor_PickUpNearby(&this->actor, globalCtx, 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, 2, -3.0f); + func_808F152C(this); + this->actionFunc = func_808F228C; +} + +void func_808F228C(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Math_StepToF(&this->actor.scale.x, 0.005f, 0.0005f) && (this->actor.params == ENKAREBABA_2)) { + func_808F1648(this); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = 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); + } + + this->actor.shape.rot.y += 0x1999; + EffectSsHahen_SpawnBurst(globalCtx, &this->actor.home.pos, 3.0f, 0, 12, 5, 1, -1, 10, NULL); +} + +void func_808F238C(EnKarebaba* this) { + Animation_Change(&this->skelAnime, &object_dekubaba_Anim_0002B8, 0.0f, 0.0f, 0.0f, 2, 0.0f); + func_808F152C(this); + this->actor.shape.rot.x = -0x4000; + this->unk_1EE = 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; +} + +void func_808F241C(EnKarebaba* this, GlobalContext* globalCtx) { + f32 sp1C; + + 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) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + if (this->actor.params == ENKAREBABA_1) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + } + func_808F1648(this); + } +} + +void func_808F24F8(EnKarebaba* this) { + this->actor.shape.yOffset = 0.0f; + this->actor.shape.shadowScale = 22.0f; + this->collider1.dim.radius = sCylinderInit2.dim.radius; + Actor_SetScale(&this->actor, 0.0f); + this->actionFunc = func_808F241C; +} + +void func_808F254C(EnKarebaba* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (this->unk_1EE == 0) { + func_808F24F8(this); + } +} + +void EnKarebaba_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKarebaba* this = THIS; + f32 max; + + this->actionFunc(this, globalCtx); + + 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; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; + } else { + this->drawDmgEffScale = this->drawDmgEffScale; + } + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + + if (this->actionFunc != func_808F254C) { + if (this->actionFunc == func_808F1C84) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 10.0f, 5); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + if (this->unk_22C == 0) { + this->unk_22C = 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(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + Actor_SetFocus(&this->actor, (this->actor.scale.x * 10.0f) / 0.01f); + + max = this->actor.home.pos.y + 40.0f; + this->actor.focus.pos.x = this->actor.home.pos.x; + this->actor.focus.pos.y = CLAMP_MAX(this->actor.focus.pos.y, max); + this->actor.focus.pos.z = this->actor.home.pos.z; + } + } +} + +void func_808F280C(EnKarebaba* this, GlobalContext* globalCtx) { + MtxF sp40; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + 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_InsertMatrix(&sp40, MTXMODE_NEW); + Matrix_Scale(0.15f, 1.0f, 0.15f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKarebaba* this = THIS; + s32 i; + s32 sp94; + s16 limbCount; + f32 sp8C = 0.01f; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Math_Vec3f_Copy(this->limbPos, &this->actor.world.pos); + + if (this->actionFunc == func_808F21A4) { + if ((this->unk_1EE > 40) || (this->unk_1EE & 1)) { + Matrix_InsertTranslation(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_003070); + } + } else if (this->actionFunc != func_808F254C) { + func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, NULL); + Matrix_InsertTranslation(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; + } + + Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_InsertRotation(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; + } else { + sp94 = 3; + } + + for (i = 0; i < sp94; i++) { + Matrix_InsertTranslation(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_808F2E2C[i]); + + Matrix_GetStateTranslation(&this->limbPos[1 + i]); + if ((i == 0) && (this->actionFunc == func_808F1C84)) { + Matrix_GetStateTranslation(&this->actor.focus.pos); + } + } + + func_800AE5A0(globalCtx); + } + + func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); + Matrix_InsertTranslation(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; + } + + Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); + Matrix_RotateY(this->actor.home.rot.y, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_0010F0); + + if (this->actionFunc == func_808F1C84) { + Matrix_InsertRotation(-0x4000, this->actor.shape.rot.y - this->actor.home.rot.y, 0, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dekubaba_DL_001828); + + Matrix_GetStateTranslation(&this->limbPos[3]); + } + + func_800AE5A0(globalCtx); + + if (this->actor.params == ENKAREBABA_2) { + limbCount = 1; + } else { + limbCount = ARRAY_COUNT(this->limbPos); + } + + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, limbCount, this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); + + if (this->unk_22C != 0) { + func_808F280C(this, globalCtx); + } + + CLOSE_DISPS(globalCtx->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 094876643..e91e151ae 100644 --- a/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h +++ b/src/overlays/actors/ovl_En_Karebaba/z_en_karebaba.h @@ -7,11 +7,27 @@ struct EnKarebaba; typedef void (*EnKarebabaActionFunc)(struct EnKarebaba*, GlobalContext*); +enum { + /* 0 */ ENKAREBABA_0, + /* 1 */ ENKAREBABA_1, + /* 2 */ ENKAREBABA_2, +}; + typedef struct EnKarebaba { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnKarebabaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x13C]; + /* 0x018C */ Vec3s jointTable[8]; + /* 0x01BC */ Vec3s morphTable[8]; + /* 0x01EC */ u8 drawDmgEffType; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ f32 drawDmgEffAlpha; + /* 0x01F4 */ f32 drawDmgEffScale; + /* 0x01F8 */ f32 drawDmgEffFrozenSteamScale; + /* 0x01FC */ Vec3f limbPos[4]; + /* 0x022C */ CollisionPoly* unk_22C; + /* 0x0230 */ ColliderCylinder collider1; + /* 0x027C */ ColliderCylinder collider2; } EnKarebaba; // size = 0x2C8 extern const ActorInit En_Karebaba_InitVars; 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 a937dbcd6..9a42980db 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -6,7 +6,7 @@ #include "z_en_kbt.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKbt*)thisx) @@ -15,10 +15,13 @@ void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx); void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80B33E64(GlobalContext* globalCtx); +s32 func_80B33E8C(GlobalContext* globalCtx); +void func_80B33EF0(EnKbt* this, s16 arg1); +Actor* func_80B3403C(GlobalContext* globalCtx); void func_80B34314(EnKbt* this, GlobalContext* globalCtx); void func_80B34598(EnKbt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kbt_InitVars = { ACTOR_EN_KBT, ACTORCAT_NPC, @@ -31,36 +34,543 @@ const ActorInit En_Kbt_InitVars = { (ActorFunc)EnKbt_Draw, }; -#endif +void EnKbt_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; -extern UNK_TYPE D_06004274; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_kbt_Skel_00DEE8, &object_kbt_Anim_004274, this->jointTable, + this->morphTable, OBJECT_KBT_LIMB_MAX); + this->unk_27C = 0; + this->actor.home.rot.z = 0; + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_280 = 13; + this->unk_282 = 13; + this->unk_278 = func_80B3403C(globalCtx); + this->unk_284 = 0; + this->actor.textId = 0; + if (func_80B33E64(globalCtx)) { + func_80B33EF0(this, 6); + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + this->unk_27C |= 1; + } + this->actionFunc = func_80B34314; + } else { + func_80B33EF0(this, 0); + this->unk_282 = 0; + this->actionFunc = func_80B34598; + } + this->actor.flags &= ~ACTOR_FLAG_1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Init.s") +void EnKbt_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Destroy.s") +s32 func_80B33E64(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E64.s") +s32 func_80B33E8C(GlobalContext* globalCtx) { + if ((CURRENT_DAY == 3) || + ((CURRENT_DAY == 2) && (gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 2))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33E8C.s") +void func_80B33EF0(EnKbt* this, s16 arg1) { + static AnimationHeader* sAnimations[] = { + &object_kbt_Anim_000670, &object_kbt_Anim_001674, &object_kbt_Anim_002084, &object_kbt_Anim_000FE8, + &object_kbt_Anim_001940, &object_kbt_Anim_00E7BC, &object_kbt_Anim_00F0C8, &object_kbt_Anim_002710, + &object_kbt_Anim_002DE0, &object_kbt_Anim_003414, &object_kbt_Anim_003D24, &object_kbt_Anim_001BF4, + &object_kbt_Anim_002084, + }; + u8 sp38[] = { + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, + ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B33EF0.s") + if (arg1 != this->unk_280) { + if (arg1 >= 12) { + Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, + Animation_GetLastFrame(sAnimations[arg1]) - 1.0f, 0.0f, sp38[arg1], -5.0f); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + sp38[arg1], -5.0f); + } + this->unk_280 = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3403C.s") +Actor* func_80B3403C(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34078.s") + while (npc != NULL) { + if (npc->id == ACTOR_EN_KGY) { + return npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B3415C.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34314.s") +void func_80B34078(EnKbt* this) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + switch (this->unk_280) { + case 2: + switch (this->unk_282) { + case 0: + func_80B33EF0(this, 12); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34574.s") + case 5: + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34598.s") + default: + func_80B33EF0(this, 5); + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Update.s") + case 12: + func_80B33EF0(this, 0); + this->actor.home.rot.z = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B349C8.s") + case 4: + func_80B33EF0(this, 1); + this->unk_27E = 2; + this->actor.home.rot.z = 0; + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/func_80B34A00.s") +void func_80B3415C(EnKbt* this) { + if (this->unk_27C & 2) { + if (this->unk_284 > 0) { + this->unk_284--; + } else { + this->unk_27F = 0; + this->unk_282 = 3; + this->unk_27C &= ~2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kbt/EnKbt_Draw.s") + switch (this->unk_282) { + case 0: + if ((this->unk_280 != 2) && (this->unk_280 != 12)) { + func_80B33EF0(this, 0); + } + break; + + case 1: + func_80B33EF0(this, 2); + this->unk_282 = 0; + break; + + case 2: + if (this->unk_280 != 12) { + func_80B33EF0(this, 3); + } + break; + + case 3: + if (this->unk_280 != 1) { + func_80B33EF0(this, 4); + } + break; + + case 10: + func_80B33EF0(this, 11); + break; + + case 4: + func_80B33EF0(this, 2); + this->unk_282 = 6; + break; + + case 6: + if (this->unk_280 != 2) { + func_80B33EF0(this, 5); + } + break; + + case 11: + func_80B33EF0(this, 6); + break; + + case 7: + if (this->unk_280 != 2) { + func_80B33EF0(this, 7); + } + break; + + case 8: + if (this->unk_280 != 2) { + func_80B33EF0(this, 8); + } + break; + + case 9: + if (this->unk_280 != 2) { + func_80B33EF0(this, 9); + } + break; + + case 12: + func_80B33EF0(this, 10); + break; + } +} + +void func_80B34314(EnKbt* this, GlobalContext* globalCtx) { + s32 playerForm; + + func_80B34078(this); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B34598; + Actor_ChangeFocus(&this->actor, globalCtx, this->unk_278); + this->unk_278->textId = this->actor.textId; + this->unk_27C &= ~4; + if (this->actor.textId == 0xC4E) { + this->unk_27C |= 0x10; + } + } else if (this->actor.xzDistToPlayer < 250.0f) { + if ((this->unk_278 != NULL) && (this->unk_278->xzDistToPlayer < 250.0f)) { + if (this->unk_27C & 4) { + playerForm = gSaveContext.save.playerForm; + if (((playerForm ^ 0) != PLAYER_FORM_HUMAN) || ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_RAZOR) && + (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_GILDED))) { + this->actor.textId = 0xC38; + } else if (CURRENT_DAY == 3) { + this->actor.textId = 0xC39; + } else if (this->unk_27C & 8) { + this->actor.textId = 0xC3E; + } else { + this->actor.textId = 0xC3A; + } + } + + if (this->actor.textId != 0xC37) { + if (((this->actor.textId == 0xC4E) || (this->actor.textId == 0xC4F) || (this->actor.textId == 0xC50)) && + (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN)) { + this->actor.textId = 0xC37; + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else { + this->actor.textId = 0xC4E; + } + } + func_800B8614(&this->actor, globalCtx, 260.0f); + } + } + func_80B3415C(this); +} + +void func_80B34574(EnKbt* this) { + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 6; + this->actionFunc = func_80B34314; +} + +void func_80B34598(EnKbt* this, GlobalContext* globalCtx) { + func_80B34078(this); + + switch (this->actor.textId) { + case 0x1: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + break; + + case 0x2: + func_80B34574(this); + this->actor.textId = 0xC3E; + this->unk_27C |= 0x4; + this->unk_27C |= 0x8; + return; + + case 0x3: + func_80B34574(this); + this->actor.textId = 0xC58; + return; + + case 0x4: + func_80B34574(this); + this->actor.textId = 0xC4B; + return; + + case 0x5: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 0; + func_80B33EF0(this, 12); + break; + + case 0x6: + func_80B34574(this); + this->actor.textId = 0xC3A; + this->unk_27C |= 4; + return; + + case 0x7: + this->unk_27E = 4; + this->unk_27F = 0; + this->unk_282 = 11; + if (func_80B33E8C(globalCtx)) { + this->actor.textId = 0xC50; + } else if (this->unk_27C & 0x10) { + this->actor.textId = 0xC4F; + } else { + this->actor.textId = 0xC4E; + } + this->actionFunc = func_80B34314; + return; + + case 0x8: + func_80B34574(this); + this->actor.textId = 0xC56; + return; + + case 0xC1E: + this->unk_27E = 2; + this->unk_27F = 1; + break; + + case 0xC1F: + case 0xC2E: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 1; + this->unk_284 = 20; + break; + + case 0xC20: + case 0xC23: + case 0xC2F: + this->unk_27E = 0; + this->unk_282 = 2; + break; + + case 0xC21: + case 0xC29: + this->unk_284 = 10; + this->unk_27C |= 2; + break; + + case 0xC22: + case 0xC2A: + this->unk_27F = 1; + break; + + case 0xC2C: + this->unk_27E = 0; + this->unk_27F = 0; + this->unk_282 = 2; + break; + + case 0xC31: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 4; + break; + + case 0xC32: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC34: + this->unk_27E = 0; + this->unk_282 = 8; + break; + + case 0xC35: + this->unk_27E = 4; + this->unk_27F = 0; + func_80B33EF0(this, 2); + this->unk_282 = 5; + break; + + case 0xC36: + this->unk_27E = 1; + this->unk_27F = 1; + func_80B33EF0(this, 7); + this->unk_282 = 7; + break; + + case 0xC37: + func_80B33EF0(this, 10); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC38: + case 0xC39: + func_80B33EF0(this, 7); + this->unk_27E = 0; + this->unk_27F = 1; + break; + + case 0xC3A: + case 0xC4D: + case 0xC58: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3C: + case 0xC57: + this->unk_27E = 1; + this->unk_282 = 7; + break; + + case 0xC3D: + this->unk_27E = 0; + break; + + case 0xC3E: + this->unk_27F = 1; + this->unk_282 = 8; + break; + + case 0xC3F: + case 0xC47: + case 0xC4C: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC40: + this->unk_27E = 3; + this->unk_282 = 6; + break; + + case 0xC45: + case 0xC4B: + case 0xC56: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 7; + break; + + case 0xC46: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 9; + break; + + case 0xC48: + this->unk_27E = 2; + this->unk_27F = 0; + this->unk_282 = 10; + break; + + case 0xC49: + this->unk_27F = 1; + break; + + case 0xC4A: + this->unk_27E = 0; + this->unk_282 = 7; + break; + + case 0xC4E: + this->unk_27E = 1; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC4F: + this->unk_27E = 2; + this->unk_27F = 1; + this->unk_282 = 12; + break; + + case 0xC50: + this->unk_27E = 0; + this->unk_27F = 1; + this->unk_282 = 12; + break; + } + + this->actor.textId = 0; + func_80B3415C(this); +} + +void EnKbt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnKbt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (!(this->unk_27C & 1) && (limbIndex == OBJECT_KBT_LIMB_0E)) { + *dList = NULL; + } + return false; +} + +Vec3f D_80B34B84 = { 500.0f, 500.0f, 0.0f }; + +void EnKbt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnKbt* this = THIS; + + if (limbIndex == OBJECT_KBT_LIMB_09) { + Matrix_MultiplyVector3fByState(&D_80B34B84, &this->actor.focus.pos); + } +} + +TexturePtr D_80B34B90[] = { + object_kbt_Tex_00A5B8, + object_kbt_Tex_00ADB8, +}; + +TexturePtr D_80B34B98[] = { + object_kbt_Tex_00B5B8, object_kbt_Tex_00BDB8, object_kbt_Tex_00C5B8, object_kbt_Tex_00CDB8, object_kbt_Tex_00D5B8, +}; + +void EnKbt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKbt* this = THIS; + Gfx* gfx; + TexturePtr tex; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + tex = Lib_SegmentedToVirtual(D_80B34B98[this->unk_27E]); + gSPSegment(&gfx[0], 0x08, tex); + + tex = Lib_SegmentedToVirtual(D_80B34B90[this->unk_27F]); + gSPSegment(&gfx[1], 0x09, tex); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKbt_OverrideLimbDraw, EnKbt_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h index 9d68dce1d..7556e3f5c 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -2,6 +2,7 @@ #define Z_EN_KBT_H #include "global.h" +#include "objects/object_kbt/object_kbt.h" struct EnKbt; @@ -9,7 +10,16 @@ typedef void (*EnKbtActionFunc)(struct EnKbt*, GlobalContext*); typedef struct EnKbt { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x144]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0200 */ Vec3s morphTable[OBJECT_KBT_LIMB_MAX]; + /* 0x0278 */ Actor* unk_278; + /* 0x027C */ u16 unk_27C; + /* 0x027E */ u8 unk_27E; + /* 0x027F */ u8 unk_27F; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; /* 0x0288 */ EnKbtActionFunc actionFunc; } EnKbt; // size = 0x28C 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 2cd8dd5e9..234415d76 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 @@ -5,8 +5,10 @@ */ #include "z_en_kendo_js.h" +#include "overlays/actors/ovl_En_Maruta/z_en_maruta.h" +#include "objects/object_js/object_js.h" -#define FLAGS 0x0A000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnKendoJs*)thisx) @@ -15,7 +17,26 @@ void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx); void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B26538(EnKendoJs* this); +void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B26AE8(EnKendoJs* this); +void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2701C(EnKendoJs* this); +void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2714C(EnKendoJs* this); +void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B273D0(EnKendoJs* this); +void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B276C4(EnKendoJs* this); +void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B27760(EnKendoJs* this); +void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx); +void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx); +s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1); +void func_80B279F0(EnKendoJs* this, GlobalContext* globalCtx, s32 arg2); +void func_80B27A90(EnKendoJs* this, GlobalContext* globalCtx); + const ActorInit En_Kendo_Js_InitVars = { ACTOR_EN_KENDO_JS, ACTORCAT_NPC, @@ -28,86 +49,720 @@ const ActorInit En_Kendo_Js_InitVars = { (ActorFunc)EnKendoJs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B27C30 = { - { 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, + }, { 18, 30, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B27C5C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfo sAnimations[] = { + { &object_js_Anim_000C7C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_js_Anim_000F4C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, + { &object_js_Anim_00016C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_js_Anim_0003DC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, + { &object_js_Anim_000AD4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +}; -extern ColliderCylinderInit D_80B27C30; -extern CollisionCheckInfoInit2 D_80B27C5C; +s16 D_80B27CE0[][3] = { + { 0x2731, 0x2732, 0x2733 }, + { 0x2734, 0x2735, 0x2736 }, + { 0x2737, 0x2738, 0x2739 }, +}; -extern UNK_TYPE D_0600016C; -extern UNK_TYPE D_06000F4C; +s16 D_80B27CF4[][3] = { + { 0x2710, 0x2712, 0x2714 }, + { 0x2711, 0x2713, 0x2715 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Init.s") +s16 D_80B27D00[] = { + 0x271C, 0x271E, 0x2720, 0x2722, 0x2724, 0x2726, 0x2728, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Destroy.s") +s16 D_80B27D10[] = { + 0x271B, 0x271D, 0x271F, 0x2721, 0x2723, 0x2725, 0x2727, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26538.s") +void EnKendoJs_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnKendoJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2654C.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26758.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B269A4.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, + this->morphTable, 13); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26AE8.s") + if ((CURRENT_DAY == 3) && + !((gSaveContext.save.time <= CLOCK_TIME(23, 0)) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)))) { + if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_KANBAN, this->actor.home.pos.x, + this->actor.home.pos.y, this->actor.home.pos.z - 10.0f, this->actor.home.rot.x, + this->actor.home.rot.y, this->actor.home.rot.z, 0x10); + Actor_MarkForDeath(&this->actor); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + } + } else if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26AFC.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26BF8.s") + if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { + Path* path = &globalCtx->setupPathList[ENKENDOJS_GET_FF00(&this->actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26EB4.s") + this->unk_274 = Lib_SegmentedToVirtual(path->points); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26F14.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; + this->actor.child = NULL; + this->unk_28A = 0; + this->unk_28C = 0; + this->unk_28E = 0; + this->unk_286 = 0; + func_80B26538(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B26F6C.s") +void EnKendoJs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2701C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); + gSaveContext.save.weekEventReg[82] &= (u8)~8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27030.s") +void func_80B26538(EnKendoJs* this) { + this->actionFunc = func_80B2654C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2714C.s") +void func_80B2654C(EnKendoJs* this, GlobalContext* globalCtx) { + s32 phi_v0; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27188.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { + if (CURRENT_DAY != 0) { + sp30 = CURRENT_DAY - 1; + } else { + sp30 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B273D0.s") + if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { + Message_StartTextbox(globalCtx, 0x273C, &this->actor); + this->unk_288 = 0x273C; + } else if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + switch (gSaveContext.save.playerForm) { + case PLAYER_FORM_DEKU: + phi_v0 = 0; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2740C.s") + case PLAYER_FORM_GORON: + phi_v0 = 1; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B274BC.s") + case PLAYER_FORM_ZORA: + phi_v0 = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B276C4.s") + default: + phi_v0 = 0; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B276D8.s") + Message_StartTextbox(globalCtx, D_80B27CE0[phi_v0][sp30], &this->actor); + this->unk_288 = D_80B27CE0[phi_v0][sp30]; + } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_NONE) && (Player_GetMask(globalCtx) < PLAYER_MASK_GIANT)) { + u16 sp2E = Player_GetMask(globalCtx) + 0x273C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27760.s") + if (0) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27774.s") + Message_StartTextbox(globalCtx, sp2E, &this->actor); + this->unk_288 = sp2E; + } else { + if (this->unk_28A == 0) { + this->unk_28A = 1; + phi_v0 = 0; + } else { + phi_v0 = 1; + } + Message_StartTextbox(globalCtx, D_80B27CF4[phi_v0][sp30], &this->actor); + this->unk_288 = D_80B27CF4[phi_v0][sp30]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B2783C.s") + func_80B26AE8(this); + } else { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27880.s") +void func_80B26758(EnKendoJs* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx) && (this->unk_288 == 0x2716)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x272C, &this->actor); + this->unk_288 = 0x272C; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk1206C) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2718, &this->actor); + this->unk_288 = 0x2718; + } else { + func_8019F208(); + Rupees_ChangeBy(-globalCtx->msgCtx.unk1206C); + Message_StartTextbox(globalCtx, 0x2719, &this->actor); + this->unk_288 = 0x2719; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B278C4.s") + case 1: + if (GET_CUR_EQUIP_VALUE(EQUIP_SWORD) == EQUIP_SWORD) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x272C, &this->actor); + this->unk_288 = 0x272C; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } else if (gSaveContext.save.playerData.rupees < globalCtx->msgCtx.unk12070) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2718, &this->actor); + this->unk_288 = 0x2718; + } else { + func_8019F208(); + Rupees_ChangeBy(-globalCtx->msgCtx.unk12070); + Message_StartTextbox(globalCtx, 0x273A, &this->actor); + this->unk_288 = 0x273A; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B279AC.s") + case 2: + func_8019F230(); + Message_StartTextbox(globalCtx, 0x2717, &this->actor); + this->unk_288 = 0x2717; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B279F0.s") +void func_80B269A4(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27A90.s") + if (!Message_ShouldAdvance(globalCtx)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Update.s") + switch (this->unk_288) { + case 0x2710: + case 0x2711: + case 0x2712: + case 0x2713: + case 0x2714: + case 0x2715: + Message_StartTextbox(globalCtx, 0x2716, &this->actor); + this->unk_288 = 0x2716; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27B54.s") + case 0x2719: + func_801477B4(globalCtx); + player->stateFlags1 |= 0x20; + func_80B2701C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/func_80B27B8C.s") + case 0x271A: + func_801477B4(globalCtx); + func_80B2714C(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kendo_Js/EnKendoJs_Draw.s") + case 0x273A: + Message_StartTextbox(globalCtx, 0x273B, &this->actor); + this->unk_288 = 0x273B; + break; + + case 0x273B: + func_801477B4(globalCtx); + Interface_InitMinigame(globalCtx); + player->stateFlags1 |= 0x20; + func_80B273D0(this); + break; + + case 0x272D: + func_801477B4(globalCtx); + gSaveContext.minigameState = 3; + func_80B276C4(this); + func_80B276D8(this, globalCtx); + break; + } +} + +void func_80B26AE8(EnKendoJs* this) { + this->actionFunc = func_80B26AFC; +} + +void func_80B26AFC(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + func_80B26758(this, globalCtx); + break; + + case 5: + func_80B269A4(this, globalCtx); + break; + + case 6: + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_288 == 0x272C) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } + + if ((this->unk_288 == 0x272E) || (this->unk_288 == 0x272F) || (this->unk_288 == 0x2730)) { + gSaveContext.minigameState = 3; + } + + player->stateFlags1 &= ~0x20; + func_80B26538(this); + } + + case 0: + case 1: + case 2: + case 3: + break; + } +} + +s32 func_80B26BF8(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_284) { + case 0: + if (func_80122FCC(globalCtx)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + return 1; + } + break; + + case 1: + if ((player->stateFlags3 & 0x8000000)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags2 & 0x80000)) { + return 1; + } + break; + + case 2: + if (func_80122F9C(globalCtx)) { + return 0; + } + + if ((player->swordState != 0) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + return 1; + } + this->unk_28E = 0; + break; + + case 3: + if ((this->unk_28E == 1) && ((player->swordAnimation == 4) || (player->swordAnimation == 6))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 4: + if ((this->unk_28E == 1) && ((player->swordAnimation == 0) || (player->swordAnimation == 2))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 5: + if ((this->unk_28E == 1) && (player->swordAnimation == 12)) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + + case 6: + if ((this->unk_28E == 1) && ((player->swordAnimation == 17) || (player->swordAnimation == 20))) { + this->unk_28E = 0; + return 0; + } + + if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + this->unk_28E = 0; + return 1; + } + break; + } + return 2; +} + +void func_80B26EB4(EnKendoJs* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, D_80B27D00[this->unk_284], &this->actor); + this->unk_288 = D_80B27D00[this->unk_284]; + this->unk_284++; +} + +void func_80B26F14(EnKendoJs* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, D_80B27D10[this->unk_284], &this->actor); + this->unk_288 = D_80B27D10[this->unk_284]; +} + +s32 func_80B26F6C(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (this->unk_288) { + case 0x271D: + if (func_80124190(player)) { + Message_StartTextbox(globalCtx, 0x272A, &this->actor); + this->unk_288 = 0x272A; + return true; + } + break; + + case 0x2721: + if (this->unk_292 != 0) { + Message_StartTextbox(globalCtx, 0x272B, &this->actor); + this->unk_288 = 0x272B; + return true; + } + break; + } + return false; +} + +void func_80B2701C(EnKendoJs* this) { + this->actionFunc = func_80B27030; +} + +void func_80B27030(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp20 = this->actor.world.pos; + + sp20.z += 200.0f; + + if (func_80B278C4(globalCtx, sp20)) { + this->actor.flags |= ACTOR_FLAG_10000; + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + player->stateFlags1 &= ~0x20; + func_80B279F0(this, globalCtx, 0); + Message_StartTextbox(globalCtx, 0x271A, &this->actor); + this->unk_288 = 0x271A; + func_80B26AE8(this); + } else { + func_800B8614(&this->actor, globalCtx, 800.0f); + } + } +} + +void func_80B2714C(EnKendoJs* this) { + gSaveContext.save.weekEventReg[82] |= 8; + this->unk_28C = 1; + this->unk_290 = 0; + this->unk_284 = 0; + this->unk_286 = 1; + this->actionFunc = func_80B27188; +} + +void func_80B27188(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_288 == 0x2729) { + func_80B26F14(this, globalCtx); + } else if (!func_80B26F6C(this, globalCtx)) { + if (this->skelAnime.animation == &object_js_Anim_00016C) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } + this->unk_286 = 2; + func_801477B4(globalCtx); + player->stateFlags1 &= ~0x20; + } + } else if (this->unk_286 == 2) { + this->unk_286 = 1; + } + + if (this->unk_286 == 1) { + switch (func_80B26BF8(this, globalCtx)) { + case 0: + this->unk_286 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + player->stateFlags1 |= 0x20; + func_80B26EB4(this, globalCtx); + break; + + case 1: + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + this->unk_286 = 0; + player->stateFlags1 |= 0x20; + Message_StartTextbox(globalCtx, 0x2729, &this->actor); + this->unk_288 = 0x2729; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + break; + + default: + if (this->unk_28C == 0) { + this->unk_290++; + if (this->unk_290 == 30) { + this->unk_290 = 0; + func_80B279F0(this, globalCtx, 0); + } + } + break; + } + + if ((this->skelAnime.animation == &object_js_Anim_0003DC) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + } + + if (this->unk_284 == 7) { + gSaveContext.save.weekEventReg[82] &= (u8)~8; + func_80B26AE8(this); + } + } +} + +void func_80B273D0(EnKendoJs* this) { + gSaveContext.save.weekEventReg[82] |= 8; + this->unk_290 = 120; + this->unk_284 = 0; + this->unk_286 = 1; + this->actionFunc = func_80B2740C; +} + +void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp18 = this->actor.world.pos; + + sp18.z += 300.0f; + + if (func_80B278C4(globalCtx, sp18)) { + this->unk_28C = 0; + player->stateFlags1 &= ~0x20; + this->actionFunc = func_80B274BC; + } +} + +void func_80B274BC(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_290 >= 140) { + if (this->unk_284 == 5) { + if (gSaveContext.minigameScore == 30) { + Message_StartTextbox(globalCtx, 0x272D, &this->actor); + this->unk_288 = 0x272D; + } else { + Message_StartTextbox(globalCtx, 0x272E, &this->actor); + this->unk_288 = 0x272E; + } + player->stateFlags1 |= 0x20; + gSaveContext.save.weekEventReg[82] &= (u8)~8; + func_80B26AE8(this); + return; + } + + play_sound(NA_SE_SY_FOUND); + func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 1); + func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 4); + this->unk_290 = 0; + this->unk_284++; + } else if (this->unk_290 == 120) { + func_80B27A90(this, globalCtx); + this->unk_290++; + } else { + this->unk_290++; + } + + if (this->unk_28E == 1) { + if ((player->swordAnimation == 17) || (player->swordAnimation == 20)) { + globalCtx->interfaceCtx.unk_25C = 3; + if (gSaveContext.minigameScore >= 27) { + player->stateFlags1 |= 0x20; + } + } else if (player->swordAnimation == 12) { + globalCtx->interfaceCtx.unk_25C = 2; + } else { + globalCtx->interfaceCtx.unk_25C = 1; + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + this->unk_28E = 0; + } + func_80B2783C(this, globalCtx); +} + +void func_80B276C4(EnKendoJs* this) { + this->actionFunc = func_80B276D8; +} + +void func_80B276D8(EnKendoJs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + func_80B27760(this); + } else if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 800.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 800.0f, 100.0f); + } +} + +void func_80B27760(EnKendoJs* this) { + this->actionFunc = func_80B27774; +} + +void func_80B27774(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if (!(gSaveContext.save.weekEventReg[63] & 0x20)) { + gSaveContext.save.weekEventReg[63] |= 0x20; + Message_StartTextbox(globalCtx, 0x272F, &this->actor); + this->unk_288 = 0x272F; + } else { + Message_StartTextbox(globalCtx, 0x2730, &this->actor); + this->unk_288 = 0x2730; + } + func_80B26AE8(this); + player->stateFlags1 &= ~0x20; + } else { + func_800B85E0(&this->actor, globalCtx, 1000.0f, -1); + } +} + +void func_80B2783C(EnKendoJs* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + Camera_ChangeDataIdx(globalCtx->cameraPtrs[CAM_ID_MAIN], + ActorCutscene_GetCutscene(this->actor.cutscene)->csCamSceneDataId); + } +} + +void func_80B27880(EnKendoJs* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0 = this->actor.world.pos.z + 70.0f; + + if ((ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) && (player->actor.world.pos.z < temp_f0)) { + player->actor.world.pos.z = temp_f0; + } +} + +s32 func_80B278C4(GlobalContext* globalCtx, Vec3f arg1) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0; + f32 sp28; + s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); + + temp_f0 = Math_Vec3f_DistXZ(&player->actor.world.pos, &arg1); + + if (temp_f0 < 20.0f) { + sp28 = 10.0f; + } else if (temp_f0 < 40.0f) { + sp28 = 40.0f; + } else { + sp28 = 80.0f; + } + + globalCtx->actorCtx.unk268 = 1; + func_800B6F20(globalCtx, &globalCtx->actorCtx.unk_26C, sp28, sp22); + + if (temp_f0 < 20.0f) { + return true; + } else { + return false; + } +} + +void func_80B279AC(EnKendoJs* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80B279F0(EnKendoJs* this, GlobalContext* globalCtx, s32 arg2) { + f32 x = this->unk_274[arg2].x; + f32 y = this->unk_274[arg2].y; + f32 z = this->unk_274[arg2].z; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MARUTA, x, y, z, 0, 0, 0, 0); + this->unk_28C++; +} + +void func_80B27A90(EnKendoJs* this, GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + + while (actor != NULL) { + if (actor->id == ACTOR_EN_MARUTA) { + ((EnMaruta*)actor)->unk_220 = 1; + } + actor = actor->next; + } + + this->unk_28C = 0; +} + +void EnKendoJs_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + func_800E9250(globalCtx, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); + func_80B279AC(this, globalCtx); + func_80B27880(this, globalCtx); +} + +s32 EnKendoJs_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnKendoJs* this = THIS; + + if (limbIndex == 12) { + rot->y -= this->unk_278.y; + } + return false; +} + +void EnKendoJs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void EnKendoJs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKendoJs* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnKendoJs_OverrideLimbDraw, EnKendoJs_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h index 33da3ea09..2820aac21 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h @@ -7,11 +7,29 @@ struct EnKendoJs; typedef void (*EnKendoJsActionFunc)(struct EnKendoJs*, GlobalContext*); +#define ENKENDOJS_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENKENDOJS_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + +#define ENKENDOJS_FF_1 1 + typedef struct EnKendoJs { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnKendoJsActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0xBC]; + /* 0x01D8 */ Vec3s jointTable[13]; + /* 0x0226 */ Vec3s morphTable[13]; + /* 0x0274 */ Vec3s* unk_274; + /* 0x0278 */ Vec3s unk_278; + /* 0x027E */ Vec3s unk_27E; + /* 0x0284 */ s16 unk_284; + /* 0x0286 */ s16 unk_286; + /* 0x0288 */ s16 unk_288; + /* 0x028A */ s16 unk_28A; + /* 0x028C */ s16 unk_28C; + /* 0x028E */ s16 unk_28E; + /* 0x0290 */ s16 unk_290; + /* 0x0292 */ u8 unk_292; } EnKendoJs; // size = 0x294 extern const ActorInit En_Kendo_Js_InitVars; 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 0998937e0..0d1933bb6 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -10,7 +10,7 @@ #include "objects/object_kgy/object_kgy.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKgy*)thisx) @@ -62,7 +62,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { Flags_UnsetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); if (Flags_GetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor)) || (gSaveContext.save.weekEventReg[33] & 0x80)) { Flags_SetSwitch(globalCtx, ENKGY_GET_FE00(&this->actor) + 1); - globalCtx->envCtx.unk_C3 = 1; + globalCtx->envCtx.lightSettingOverride = 1; gSaveContext.save.weekEventReg[21] |= 1; if (!func_80B40D64(globalCtx)) { EnKgy_ChangeAnim(this, 4, 0, 0); @@ -101,7 +101,7 @@ void EnKgy_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.pos.z, 255, 64, 64, -1); this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); this->unk_300 = -1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnKgy_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -457,10 +457,10 @@ void func_80B4163C(EnKgy* this, GlobalContext* globalCtx) { void func_80B417B8(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B419B0; func_80B40E18(this, 7); } @@ -481,14 +481,14 @@ void func_80B41858(EnKgy* this, GlobalContext* globalCtx) { void func_80B418C4(EnKgy* this, GlobalContext* globalCtx) { func_80B4163C(this, globalCtx); if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx) && - ((globalCtx->msgCtx.unk11F04 == 0xC4E) || (globalCtx->msgCtx.unk11F04 == 0xC4F))) { + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx) && + ((globalCtx->msgCtx.currentTextId == 0xC4E) || (globalCtx->msgCtx.currentTextId == 0xC4F))) { func_801477B4(globalCtx); this->actor.textId = 0xC4F; func_80B413C8(this); ActorCutscene_SetIntentToPlay(this->unk_2D4[5]); this->actionFunc = func_80B41858; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; } func_80B40EE8(this, globalCtx); } @@ -575,7 +575,7 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { this->actionFunc = func_80B41C30; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; } func_80B40EE8(this, globalCtx); } @@ -583,7 +583,7 @@ void func_80B41C54(EnKgy* this, GlobalContext* globalCtx) { void func_80B41CBC(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80B40E18(this, this->actor.textId); this->actionFunc = func_80B41E18; func_80B411DC(this, globalCtx, 4); @@ -596,7 +596,7 @@ void func_80B41D64(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if (Actor_HasParent(&this->actor, globalCtx)) { this->actionFunc = func_80B41CBC; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { Actor_PickUp(&this->actor, globalCtx, this->unk_2EA, 2000.0f, 1000.0f); @@ -616,8 +616,8 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC3B: @@ -658,8 +658,8 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - temp = globalCtx->msgCtx.unk11F04; + if (Message_ShouldAdvance(globalCtx)) { + temp = globalCtx->msgCtx.currentTextId; switch (temp) { case 0xC35: @@ -718,7 +718,7 @@ void func_80B41E18(EnKgy* this, GlobalContext* globalCtx) { func_80B41368(this, globalCtx, 0); this->actor.textId = 0xC43; CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; - TAKE_EQUIPPED_ITEM(EQUIP_SWORD); + SET_EQUIP_VALUE(EQUIP_SWORD, 0); Interface_LoadItemIconImpl(globalCtx, 0); func_80B40C74(globalCtx); break; @@ -856,10 +856,10 @@ void func_80B425A0(EnKgy* this, GlobalContext* globalCtx) { void func_80B42660(EnKgy* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.focus.pos = this->unk_2A8; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); func_80B413C8(this); - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->actionFunc = func_80B42714; func_80B40E18(this, 7); } @@ -897,8 +897,8 @@ void func_80B427C8(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC30: @@ -947,9 +947,9 @@ void func_80B4296C(EnKgy* this, GlobalContext* globalCtx) { } func_80B411DC(this, globalCtx, 0); func_80B40E18(this, this->actor.textId); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } } @@ -969,8 +969,8 @@ void func_80B42A8C(EnKgy* this, GlobalContext* globalCtx) { } if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0) && - (Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - temp_a2 = globalCtx->msgCtx.unk11F04; + (Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + temp_a2 = globalCtx->msgCtx.currentTextId; switch (temp_a2) { case 0xC1D: case 0xC2D: diff --git a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c index 3ad020f92..5a83ecad4 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c @@ -6,7 +6,7 @@ #include "z_en_kitan.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnKitan*)thisx) diff --git a/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/src/overlays/actors/ovl_En_Knight/z_en_knight.c index 3c71d5a40..8f6464411 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -6,7 +6,7 @@ #include "z_en_knight.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnKnight*)thisx) 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 b7abdebdf..0b6c348c0 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -2,11 +2,14 @@ * File: z_en_kujiya.c * Overlay: ovl_En_Kujiya * Description: Clock Town - Lottery Shop + * + * (kuji = lottery, ya = shop) */ #include "z_en_kujiya.h" +#include "objects/object_kujiya/object_kujiya.h" -#define FLAGS 0x08000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_8000000) #define THIS ((EnKujiya*)thisx) @@ -15,14 +18,22 @@ void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupWait(EnKujiya* this); +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTalk(EnKujiya* this); +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupGivePrize(EnKujiya* this); +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupFinishGivePrize(EnKujiya* this); +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx); +s32 EnKujiya_CheckBoughtTicket(void); +void EnKujiya_SetBoughtTicket(void); +void EnKujiya_UnsetBoughtTicket(void); +void EnKujiya_SetupTurnToOpen(EnKujiya* this); +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTurnToClosed(EnKujiya* this); +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, ACTORCAT_NPC, @@ -35,48 +46,332 @@ const ActorInit En_Kujiya_InitVars = { (ActorFunc)EnKujiya_Draw, }; -#endif +#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))) -extern UNK_TYPE D_06006198; +void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Init.s") + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Destroy.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09A8.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 30.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB09BC.s") + if (EnKujiya_CheckBoughtTicket() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + this->actor.shape.rot.y = 0; + } else { + this->actor.shape.rot.y = 0x7555; + } + EnKujiya_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0B28.s") +void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0BF8.s") +void EnKujiya_SetupWait(EnKujiya* this) { + this->actionFunc = EnKujiya_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E44.s") +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { + if (EnKujiya_CheckBoughtTicket()) { + Message_StartTextbox(globalCtx, 0x2B61, &this->actor); + this->textId = 0x2B61; // Come back tomorrow + } else { + Message_StartTextbox(globalCtx, 0x2B5C, &this->actor); + this->textId = 0x2B5C; // Pick 3 numbers + } + } else if (EnKujiya_CheckBoughtTicket()) { + Message_StartTextbox(globalCtx, 0x2B64, &this->actor); + this->textId = 0x2B64; // Announce winning numbers + } else { + Message_StartTextbox(globalCtx, 0x2B63, &this->actor); + this->textId = 0x2B63; // Exchanging winning tickets + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0E58.s") + EnKujiya_SetupTalk(this); + } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && EnKujiya_CheckBoughtTicket() && + (this->actor.shape.rot.y == 0)) { + EnKujiya_SetupTurnToOpen(this); + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F24.s") +void EnKujiya_HandlePlayerChoice(EnKujiya* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.choiceIndex == 0) { // Buy + if (gSaveContext.save.playerData.rupees < 10) { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x2B62, &this->actor); + this->textId = 0x2B62; // Not enough Rupees + } else { + func_8019F208(); + Rupees_ChangeBy(-10); + Message_StartTextbox(globalCtx, 0x2B5F, &this->actor); + this->textId = 0x2B5F; // Enter number + } + } else { // Don't buy + func_8019F230(); + Message_StartTextbox(globalCtx, 0x2B5E, &this->actor); + this->textId = 0x2B5E; // Too bad + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F38.s") +void EnKujiya_ChooseNextDialogue(EnKujiya* this, GlobalContext* globalCtx) { + // Build suspense + if (this->textId == 0x2B65) { // Your numbers vs winning numbers + if (this->timer != 0) { + this->timer--; + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0F94.s") + if (Message_ShouldAdvance(globalCtx)) { + switch (this->textId) { + case 0x2B5C: + Message_StartTextbox(globalCtx, 0x2B5D, &this->actor); + this->textId = 0x2B5D; // Buy or not + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FA8.s") + case 0x2B60: + EnKujiya_SetBoughtTicket(); + func_801477B4(globalCtx); + EnKujiya_SetupTurnToClosed(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB0FF8.s") + case 0x2B64: + EnKujiya_UnsetBoughtTicket(); + this->timer = 20; + Message_StartTextbox(globalCtx, 0x2B65, &this->actor); + this->textId = 0x2B65; // Your numbers vs winning numbers + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1088.s") + case 0x2B65: + if (CHECK_LOTTERY_NUMBERS) { + Message_StartTextbox(globalCtx, 0x2B66, &this->actor); + this->textId = 0x2B66; // Won 50 Rupees + } else { + Message_StartTextbox(globalCtx, 0x2B67, &this->actor); + this->textId = 0x2B67; // Lost, come back tomorrow + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB10F8.s") + case 0x2B66: + func_801477B4(globalCtx); + EnKujiya_SetupGivePrize(this); + EnKujiya_GivePrize(this, globalCtx); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1168.s") +void EnKujiya_SetupTalk(EnKujiya* this) { + this->actionFunc = EnKujiya_Talk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1180.s") +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx) { + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1250.s") + case 4: + EnKujiya_HandlePlayerChoice(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/func_80BB1268.s") + case 5: + EnKujiya_ChooseNextDialogue(this, globalCtx); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Update.s") + case 6: + if (Message_ShouldAdvance(globalCtx)) { + EnKujiya_SetupWait(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kujiya/EnKujiya_Draw.s") + case 17: + if (Message_ShouldAdvance(globalCtx)) { + Inventory_SaveLotteryCodeGuess(globalCtx); + Message_StartTextbox(globalCtx, 0x2B60, &this->actor); + this->textId = 0x2B60; // Will announce winning numbers after 6 + } + break; + } +} + +void EnKujiya_SetupGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_GivePrize; +} + +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + EnKujiya_SetupFinishGivePrize(this); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } +} + +void EnKujiya_SetupFinishGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_FinishGivePrize; +} + +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { + EnKujiya_SetupWait(this); + } +} + +s32 EnKujiya_CheckBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + if (gSaveContext.save.weekEventReg[33] & 0x10) { + return true; + } + break; + + case 2: + if (gSaveContext.save.weekEventReg[33] & 0x20) { + return true; + } + break; + + case 3: + if (gSaveContext.save.weekEventReg[33] & 0x40) { + return true; + } + break; + } + return false; +} + +void EnKujiya_SetBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] |= 0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] |= 0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] |= 0x40; + break; + } +} + +/** + * Used when player turns in a ticket + */ +void EnKujiya_UnsetBoughtTicket(void) { + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[33] &= (u8)~0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[33] &= (u8)~0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[33] &= (u8)~0x40; + break; + } +} + +void EnKujiya_SetupTurnToOpen(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToOpen; +} + +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + 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); + } + EnKujiya_SetupWait(this); + } else { + this->timer++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void EnKujiya_SetupTurnToClosed(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToClosed; +} + +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx) { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + + 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); + } + EnKujiya_SetupWait(this); + } else { + this->timer++; + } + } else { + func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); + } +} + +void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKujiya* this = THIS; + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gLotteryShopTexAnim)); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopCylinderDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBackSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopOpenBoxDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingEffectsDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopRedRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopGreenRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBlueRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopTargetArrowAndSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingArrowDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopMaskDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h index 72aeb93b7..b95a5bb36 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h @@ -8,9 +8,10 @@ struct EnKujiya; typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, GlobalContext*); typedef struct EnKujiya { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKujiyaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKujiyaActionFunc actionFunc; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 textId; } EnKujiya; // size = 0x14C extern const ActorInit En_Kujiya_InitVars; 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 194b99b7a..02bd93aef 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -5,8 +5,11 @@ */ #include "z_en_kusa.h" +#include "objects/object_kusa/object_kusa.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnKusa*)thisx) @@ -14,15 +17,46 @@ void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809358D8(EnKusa* this, GlobalContext* globalCtx); -void func_809359AC(EnKusa* this, GlobalContext* globalCtx); -void func_80935BBC(EnKusa* this, GlobalContext* globalCtx); -void func_80935D64(EnKusa* this, GlobalContext* globalCtx); -void func_809361A4(EnKusa* this, GlobalContext* globalCtx); -void func_80936220(EnKusa* this, GlobalContext* globalCtx); -void func_809362D8(EnKusa* this, GlobalContext* globalCtx); +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset); +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_UpdateVelY(EnKusa* this); +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor); +void EnKusa_SetScaleSmall(EnKusa* this); +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupWaitObject(EnKusa* this); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupLiftedUp(EnKusa* this); +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupInteract(EnKusa* this); +void EnKusa_SetupFall(EnKusa* this); +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupCut(EnKusa* this); +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this); +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_SetupRegrow(EnKusa* this); +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx); +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2); +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx); + +s16 rotSpeedXtarget = 0; +s16 rotSpeedX = 0; +s16 rotSpeedYtarget = 0; +s16 rotSpeedY = 0; +s16 D_809366B0 = 0; +u8 D_809366B4 = true; + +u32 kusaGameplayFrames; +MtxF D_80936AD8[8]; +s16 D_80936CD8; +s16 D_80936CDA; +s16 D_80936CDC; +s16 D_80936CDE; +s16 D_80936CE0; -#if 0 const ActorInit En_Kusa_InitVars = { ACTOR_EN_KUSA, ACTORCAT_PROP, @@ -35,18 +69,40 @@ const ActorInit En_Kusa_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809366E0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static s16 objectIds[] = { GAMEPLAY_FIELD_KEEP, OBJECT_KUSA, OBJECT_KUSA, OBJECT_KUSA }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8093670C = { 0, 12, 30, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 30, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80936754[] = { +static Vec3f sUnitDirections[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +static s16 sFragmentScales[] = { 108, 102, 96, 84, 66, 55, 42, 38 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), @@ -55,72 +111,623 @@ static InitChainEntry D_80936754[] = { ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +/** + * @brief Applies a "swaying" motion to the provided matrix + * + */ +void EnKusa_ApplySway(MtxF* matrix) { + MtxF* mtxState = Matrix_GetCurrentState(); + f32* tmp = &mtxState->mf[0][0]; + f32* tmp2 = &matrix->mf[0][0]; + s32 i; -extern ColliderCylinderInit D_809366E0; -extern CollisionCheckInfoInit D_8093670C; -extern InitChainEntry D_80936754[]; + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -extern UNK_TYPE D_060002E0; +/** + * @brief Updates the matrix controlling movement of the leaves of grass to simulate a swaying motion from the wind + * blowing. + */ +void EnKusa_Sway(void) { + s32 i; + s32 pad; + f32 sin_6CDA; + f32* ptr; + f32 sin_6CDE; + f32 sin_6CE0; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 sp7C[8]; + f32 cos_6CE0; + f32 cos_6CDA; + f32 cos_6CDC; + f32 cos_6CDE; + f32 cos_6CD8; + f32 sin_6CD8; + f32 sin_6CDC; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809349E0.s") + D_80936CD8 += 0x46; + D_80936CDA += 0x12C; + D_80936CDC += 0x2BC; + D_80936CDE += 0x514; + D_80936CE0 += 0x22C4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934AB4.s") + sin_6CD8 = Math_SinS(D_80936CD8); + sin_6CDA = Math_SinS(D_80936CDA); + sin_6CDC = Math_SinS(D_80936CDC); + sin_6CDE = Math_SinS(D_80936CDE) * 1.2f; + sin_6CE0 = Math_SinS(D_80936CE0) * 1.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934F58.s") + cos_6CD8 = Math_CosS(D_80936CD8); + cos_6CDA = Math_CosS(D_80936CDA); + cos_6CDC = Math_CosS(D_80936CDC); + cos_6CDE = Math_CosS(D_80936CDE) * 1.3f; + cos_6CE0 = Math_CosS(D_80936CE0) * 1.7f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80934FFC.s") + sp7C[0] = (sin_6CD8 - cos_6CDA) * sin_6CDC * cos_6CD8 * sin_6CD8 * 0.0015f; + sp7C[1] = (sin_6CDA - cos_6CDC) * sin_6CDE * cos_6CDA * sin_6CD8 * 0.0015f; + sp7C[2] = (sin_6CDC - cos_6CDE) * cos_6CDC * sin_6CD8 * cos_6CD8 * 0.0015f; + sp7C[3] = (sin_6CDE - cos_6CDA) * cos_6CDE * sin_6CDA * cos_6CD8 * 0.0015f; + sp7C[4] = (sin_6CD8 - cos_6CDC) * sin_6CD8 * sin_6CDA * sin_6CE0 * 0.0015f; + sp7C[5] = (sin_6CDA - cos_6CDE) * sin_6CDC * sin_6CDE * sin_6CE0 * 0.0015f; + sp7C[6] = (sin_6CDC - cos_6CD8) * cos_6CD8 * cos_6CDA * cos_6CE0 * 0.0015f; + sp7C[7] = (sin_6CDE - cos_6CDA) * cos_6CDC * cos_6CDE * cos_6CE0 * 0.0015f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350C4.s") + for (i = 0; i < ARRAY_COUNT(D_80936AD8); i++) { + ptr = &D_80936AD8[i].mf[0][0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809350F8.s") + tempf1 = sp7C[i & 7]; + tempf2 = sp7C[(i + 1) & 7]; + tempf3 = sp7C[(i + 2) & 7]; + tempf4 = sp7C[(i + 3) & 7]; + tempf5 = sp7C[(i + 4) & 7]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093517C.s") + ptr[0] = sp7C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809351A0.s") + ptr[4] = tempf3; + ptr[5] = sp7C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809354F8.s") + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp7C[3] * 0.2f; + ptr[11] = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809355A4.s") + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_8093561C.s") +/** + * @brief Detects if a bush is able to snap to the floor. BgCheck_EntityRaycastFloor5 will give the intersect point + * if no poit is found, a false value is returned. + * + * @param this + * @param globalCtx + * @param yOffset offset of Y coordinate, can be positive or negative. + * @return true/false if the bush is able to snap to the floor and is above BGCHECK_Y_MIN + */ +s32 EnKusa_SnapToFloor(EnKusa* this, GlobalContext* globalCtx, f32 yOffset) { + s32 pad; + CollisionPoly* poly; + Vec3f pos; + s32 bgId; + f32 floorY; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Init.s") + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 30.0f; + pos.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Destroy.s") + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &poly, &bgId, &this->actor, &pos); + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY + yOffset; + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358C4.s") +void EnKusa_DropCollectible(EnKusa* this, GlobalContext* globalCtx) { + s32 collectible; + s32 collectableParams; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809358D8.s") + if ((GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_GRASS) || (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH)) { + if (!(KUSA_GET_PARAMS_0C(&this->actor))) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, + KUSA_GET_RAND_COLLECTIBLE_ID(&this->actor) * 0x10); + } + } else if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_REGROWING_GRASS) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, 3); + } else { + collectible = func_800A8150(KUSA_GET_PARAMS_3F(&this->actor)); + if (collectible >= 0) { + collectableParams = KUSA_GET_COLLECTIBLE_ID(&this->actor); + Item_DropCollectible(globalCtx, &this->actor.world.pos, (collectableParams << 8) | collectible); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935988.s") +void EnKusa_UpdateVelY(EnKusa* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809359AC.s") +/** + * @brief Scales a vector down by provided scale factor + * + * @param vec vector to be scaled + * @param scaleFactor scale factor to be applied to vector + */ +void EnKusa_RandScaleVecToZero(Vec3f* vec, f32 scaleFactor) { + scaleFactor += ((Rand_ZeroOne() * 0.2f) - 0.1f) * scaleFactor; + vec->x -= vec->x * scaleFactor; + vec->y -= vec->y * scaleFactor; + vec->z -= vec->z * scaleFactor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935B94.s") +void EnKusa_SetScaleSmall(EnKusa* this) { + this->actor.scale.y = 160.0f * 0.001f; + this->actor.scale.x = 120.0f * 0.001f; + this->actor.scale.z = 120.0f * 0.001f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935BBC.s") +void EnKusa_SpawnFragments(EnKusa* this, GlobalContext* globalCtx) { + Vec3f velocity; + Vec3f pos; + s32 i; + s32 scaleIndex; + Vec3f* directon; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935CE8.s") + for (i = 0; i < ARRAY_COUNT(sUnitDirections); i++) { + directon = &sUnitDirections[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80935D64.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 20.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 20.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 20.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936120.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) & 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936168.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361A4.s") + pos.x = this->actor.world.pos.x + (directon->x * this->actor.scale.x * 40.0f); + pos.y = this->actor.world.pos.y + (directon->y * this->actor.scale.y * 40.0f) + 10.0f; + pos.z = this->actor.world.pos.z + (directon->z * this->actor.scale.z * 40.0f); + velocity.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + velocity.y = Rand_ZeroOne() * 10.0f; + velocity.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809361B4.s") + scaleIndex = (s32)(Rand_ZeroOne() * 111.1f) % 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936220.s") + EffectSsKakera_Spawn(globalCtx, &pos, &velocity, &pos, -100, 64, 40, 3, 0, sFragmentScales[scaleIndex], 0, 0, + 0x50, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936290.s") +void EnKusa_SpawnBugs(EnKusa* this, GlobalContext* globalCtx) { + u32 numBugs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809362D8.s") + for (numBugs = 0; numBugs < 3; numBugs++) { + Actor* bug = Actor_SpawnAsChildAndCutscene( + &globalCtx->actorCtx, globalCtx, ACTOR_EN_INSECT, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 1, this->actor.cutscene, this->actor.unk20, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/EnKusa_Update.s") + if (bug == NULL) { + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_80936414.s") +s32 EnKusa_GetWaterBox(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* waterBox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kusa/func_809365CC.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterBox, &bgId) && + (this->actor.world.pos.y < ySurface)) { + return true; + } + return false; +} + +void EnKusa_InitCollider(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(thisx, &this->collider); +} + +void EnKusa_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + s32 pad; + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + EnKusa_InitCollider(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.shape.shadowScale = 1.0f; + this->actor.shape.shadowAlpha = 60; + } else { + this->actor.shape.shadowScale = 0.9f; + this->actor.shape.shadowAlpha = 70; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = ((u32)Rand_Next() >> 0x10); + this->actor.home.rot.y = this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + } + if (!EnKusa_SnapToFloor(this, globalCtx, 0.0f)) { + Actor_MarkForDeath(&this->actor); + return; + } + if (EnKusa_GetWaterBox(this, globalCtx)) { + this->isInWater |= 1; + } + + this->objIndex = Object_GetIndex(&globalCtx->objectCtx, objectIds[(GET_KUSA_TYPE(&this->actor))]); + if (this->objIndex < 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + EnKusa_SetupWaitObject(this); + if (D_809366B4) { + D_80936CD8 = ((u32)Rand_Next() >> 0x10); + D_80936CDA = ((u32)Rand_Next() >> 0x10); + D_80936CDC = ((u32)Rand_Next() >> 0x10); + D_80936CDE = ((u32)Rand_Next() >> 0x10); + D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_809366B4 = false; + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } + this->kusaMtxIdx = D_809366B0 & 7; + D_809366B0++; +} + +void EnKusa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + GlobalContext* globalCtx2 = globalCtx; + EnKusa* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnKusa_SetupWaitObject(EnKusa* this) { + this->actionFunc = EnKusa_WaitObject; +} + +void EnKusa_WaitObject(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { + s32 kusaType = GET_KUSA_TYPE(&this->actor); + + if (this->isCut) { + EnKusa_SetupCut(this); + } else { + EnKusa_SetupInteract(this); + } + if (kusaType == ENKUSA_TYPE_BUSH) { + this->actor.draw = EnKusa_DrawBush; + } else { + this->actor.draw = EnKusa_DrawGrass; + } + this->actor.objBankIndex = this->objIndex; + this->actor.flags &= ~ACTOR_FLAG_10; + } +} + +void EnKusa_SetupInteract(EnKusa* this) { + this->actionFunc = EnKusa_WaitForInteract; + this->actor.flags &= ~ACTOR_FLAG_10; +} + +void EnKusa_WaitForInteract(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + + if (Actor_HasParent(&this->actor, globalCtx)) { + EnKusa_SetupLiftedUp(this); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + + } else if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + + if (KUSA_SHOULD_SPAWN_BUGS(&this->actor)) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + EnKusa_SpawnBugs(this, globalCtx); + } + } + if (GET_KUSA_TYPE(&this->actor) == ENKUSA_TYPE_BUSH) { + Actor_MarkForDeath(&this->actor); + } else { + EnKusa_SetupCut(this); + this->isCut = true; + } + + } else { + if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 12.0f)) { + this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; + } + + if (this->actor.xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.xzDistToPlayer < 400.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + if (GET_KUSA_TYPE(&this->actor) != ENKUSA_TYPE_GRASS_2) { + Actor_LiftActor(&this->actor, globalCtx); + } + } + } + } + } +} + +void EnKusa_SetupLiftedUp(EnKusa* this) { + this->actionFunc = EnKusa_LiftedUp; + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; +} + +void EnKusa_LiftedUp(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f pos; + s32 bgId; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.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.colChkInfo.mass = 80; + this->actor.gravity = -0.1f; + EnKusa_UpdateVelY(this); + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.005f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + this->actor.gravity = -3.2f; + } else { + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 20.0f; + pos.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, &pos); + } +} + +void EnKusa_SetupFall(EnKusa* this) { + this->actionFunc = EnKusa_Fall; + rotSpeedXtarget = -0xBB8; + rotSpeedYtarget = (Rand_ZeroOne() - 0.5f) * 1600.0f; + rotSpeedX = 0; + rotSpeedY = 0; + this->timer = 0; +} + +void EnKusa_Fall(EnKusa* this, GlobalContext* globalCtx) { + s32 pad; + s32 wasHit; + Vec3f contactPos; + s32 i; + s16 angleOffset; + + wasHit = (this->collider.base.atFlags & AT_HIT) != 0; + + if (wasHit) { + this->collider.base.atFlags &= ~AT_HIT; + } + this->timer++; + if ((this->actor.bgCheckFlags & 0xB) || wasHit || (this->timer >= 100)) { + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + EnKusa_SpawnFragments(this, globalCtx); + EnKusa_DropCollectible(this, globalCtx); + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_BUSH: + case ENKUSA_TYPE_GRASS: + Actor_MarkForDeath(&this->actor); + break; + + case ENKUSA_TYPE_REGROWING_GRASS: + EnKusa_SetupUprootedWaitRegrow(this); + this->actor.shape.shadowDraw = NULL; + break; + } + + } else { + if (this->actor.bgCheckFlags & 0x40) { + contactPos.y = this->actor.world.pos.y + this->actor.depthInWater; + for (angleOffset = 0, i = 0; i < 4; i++, angleOffset += 0x4000) { + contactPos.x = + (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.x; + contactPos.z = + (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + angleOffset) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 190); + } + contactPos.x = this->actor.world.pos.x; + contactPos.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &contactPos, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &contactPos, 300, 700, 0); + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + rotSpeedX >>= 1; + rotSpeedXtarget >>= 1; + rotSpeedY >>= 1; + rotSpeedYtarget >>= 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + EnKusa_UpdateVelY(this); + Math_StepToS(&rotSpeedX, rotSpeedXtarget, 500); + Math_StepToS(&rotSpeedY, rotSpeedYtarget, 170); + this->actor.shape.rot.x += rotSpeedX; + this->actor.shape.rot.y += rotSpeedY; + EnKusa_RandScaleVecToZero(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnKusa_SetupCut(EnKusa* this) { + switch (GET_KUSA_TYPE(&this->actor)) { + case ENKUSA_TYPE_GRASS: + case ENKUSA_TYPE_GRASS_2: + this->actionFunc = EnKusa_DoNothing; + break; + case ENKUSA_TYPE_REGROWING_GRASS: + this->actionFunc = EnKusa_CutWaitRegrow; + break; + } + this->timer = 0; +} + +void EnKusa_CutWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer >= 120) { + EnKusa_SetupRegrow(this); + } +} + +void EnKusa_DoNothing(EnKusa* this, GlobalContext* globalCtx) { +} + +void EnKusa_SetupUprootedWaitRegrow(EnKusa* this) { + this->actor.world.pos.x = this->actor.home.pos.x; + this->actor.world.pos.y = this->actor.home.pos.y - 9.0f; + this->actor.world.pos.z = this->actor.home.pos.z; + EnKusa_SetScaleSmall(this); + this->timer = 0; + this->actor.shape.rot = this->actor.home.rot; + this->actionFunc = EnKusa_UprootedWaitRegrow; +} + +void EnKusa_UprootedWaitRegrow(EnKusa* this, GlobalContext* globalCtx) { + this->timer++; + if (this->timer > 120) { + if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.6f) && (this->timer >= 170)) { + EnKusa_SetupRegrow(this); + } + } +} + +void EnKusa_SetupRegrow(EnKusa* this) { + this->actionFunc = EnKusa_Regrow; + EnKusa_SetScaleSmall(this); + this->isCut = false; + this->actor.shape.rot = this->actor.home.rot; +} + +void EnKusa_Regrow(EnKusa* this, GlobalContext* globalCtx) { + s32 isFullyGrown = 1; + + isFullyGrown &= Math_StepToF(&this->actor.scale.y, 0.4f, 0.014f); + isFullyGrown &= Math_StepToF(&this->actor.scale.x, 0.4f, 0.011f); + this->actor.scale.z = this->actor.scale.x; + if (isFullyGrown) { + Actor_SetScale(&this->actor, 0.4f); + EnKusa_SetupInteract(this); + this->collider.base.ocFlags1 &= ~OC1_TYPE_PLAYER; + } +} + +void EnKusa_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->isCut) { + this->actor.shape.yOffset = -6.25f; + } else { + this->actor.shape.yOffset = 0.0f; + } + if ((kusaGameplayFrames != globalCtx->gameplayFrames) && (globalCtx->roomCtx.currRoom.unk3 == 0)) { + EnKusa_Sway(); + kusaGameplayFrames = globalCtx->gameplayFrames; + } +} + +void EnKusa_DrawBush(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnKusa* this = THIS; + + if ((this->actor.projectedPos.z <= 1200.0f) || ((this->isInWater & 1) && (this->actor.projectedPos.z < 1300.0f))) { + + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract) && + (this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); + + } else if (this->actor.projectedPos.z < 1300.0f) { + s32 alpha; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + alpha = (1300.0f - this->actor.projectedPos.z) * 2.55f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, alpha); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnKusa_DrawGrass(Actor* thisx, GlobalContext* globalCtx) { + EnKusa* this = THIS; + + if (this->isCut) { + Gfx_DrawDListOpa(globalCtx, gKusaStump); + } else { + if ((globalCtx->roomCtx.currRoom.unk3 == 0) && (this->actionFunc == EnKusa_WaitForInteract)) { + if ((this->actor.projectedPos.z > -150.0f) && (this->actor.projectedPos.z < 400.0f)) { + EnKusa_ApplySway(&D_80936AD8[this->kusaMtxIdx]); + } + } + Gfx_DrawDListOpa(globalCtx, gKusaSprout); + } +} diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h index 612f7b2ef..2f0d29dd9 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.h @@ -7,12 +7,33 @@ struct EnKusa; typedef void (*EnKusaActionFunc)(struct EnKusa*, GlobalContext*); +typedef enum { + /* 0 */ ENKUSA_TYPE_BUSH, + /* 1 */ ENKUSA_TYPE_REGROWING_GRASS, + /* 2 */ ENKUSA_TYPE_GRASS, + /* 3 */ ENKUSA_TYPE_GRASS_2 +} EnKusaType; + typedef struct EnKusa { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnKusaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x54]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKusaActionFunc actionFunc; + /* 0x148 */ ColliderCylinder collider; + /* 0x194 */ u8 timer; + /* 0x195 */ s8 objIndex; + /* 0x196 */ s8 kusaMtxIdx; + /* 0x197 */ u8 isCut; + /* 0x198 */ u8 isInWater; } EnKusa; // size = 0x19C extern const ActorInit En_Kusa_InitVars; +#define KUSA_GET_COLLECTIBLE_ID(thisx) ((((thisx)->params >> 8) & 0x7F)) +#define KUSA_GET_RAND_COLLECTIBLE_ID(thisx) (((thisx)->params >> 8) & 0xF) +#define KUSA_SHOULD_SPAWN_BUGS(thisx) (((thisx)->params >> 0x4) & 1) +#define KUSA_GET_PARAMS_0C(thisx) (((thisx)->params >> 0xC) & 0x1) +#define KUSA_GET_PARAMS_3F(thisx) (((thisx)->params >> 0x2) & 0x3F) + + +#define GET_KUSA_TYPE(thisx)((thisx)->params & 0x3) + #endif // Z_EN_KUSA_H 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 12ce6eecf..1b8d1ccbc 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -8,7 +8,7 @@ #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnKusa2*)thisx) @@ -282,7 +282,7 @@ void func_80A5BB40(EnKusa2* this, GlobalContext* globalCtx, s32 arg2) { f32 temp_f24; s16 temp_s0; - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { for (i = 0; i <= arg2; i++) { temp_s0 = Rand_S16Offset(-16000, 32000) + this->actor.world.rot.y; temp_f20 = Math_SinS(temp_s0); @@ -372,7 +372,7 @@ void func_80A5BF84(EnKusa2* this, GlobalContext* globalCtx) { } s32 func_80A5BFD8(EnKusa2* this, GlobalContext* globalCtx) { - if (this->collider.base.acFlags & 2) { + if (this->collider.base.acFlags & AC_HIT) { s32 pad; func_80A5CF44(this); @@ -860,7 +860,7 @@ void EnKusa2_Init(Actor* thisx, GlobalContext* globalCtx) { if (!ENKUSA2_GET_1(&this->actor)) { this->actor.update = func_80A5E604; this->actor.draw = NULL; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 1); this->unk_1BE = 0; if (D_80A5EAEC != 0) { @@ -1310,8 +1310,8 @@ void EnKusa2_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { static Gfx* D_80A5EB68[] = { - gameplay_keep_DL_0528B0, - gameplay_keep_DL_0527F0, + gKakeraLeafTip, + gKakeraLeafMiddle, }; EnKusa2* this = THIS; s32 i; @@ -1343,7 +1343,7 @@ void func_80A5E80C(GlobalContext* globalCtx, s32 arg1) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, arg1); - gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_007938); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1356,7 +1356,7 @@ void EnKusa2_Draw(Actor* thisx, GlobalContext* globalCtx) { (this->actor.projectedPos.z < 400.0f)) { func_80A5B954(&D_80A60908[this->unk_1CE], 0.0015f); } - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else if (this->actor.projectedPos.z < 1300.0f) { func_80A5E80C(globalCtx, (1300.0f - this->actor.projectedPos.z) * 2.55f); } @@ -1370,14 +1370,14 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; Matrix_SetStateRotationAndTranslation(thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, &sp18); Matrix_Scale(thisx->scale.x, thisx->scale.y, thisx->scale.z, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } void func_80A5EA48(Actor* thisx, GlobalContext* globalCtx) { EnKusa2* this = THIS; if (this->unk_1CF == 0xFF) { - Gfx_DrawDListOpa(globalCtx, gameplay_field_keep_DL_0078A0); + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); } else { func_80A5E80C(globalCtx, this->unk_1CF); } 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 bfe535600..8669a3544 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 @@ -6,7 +6,7 @@ #include "z_en_lift_nuts.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnLiftNuts*)thisx) 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 fdb2cf123..f815147a2 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -5,6 +5,7 @@ */ #include "z_en_light.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -15,7 +16,8 @@ void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLight_Update(Actor* thisx, GlobalContext* globalCtx); void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80865F38(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Light_InitVars = { ACTOR_EN_LIGHT, ACTORCAT_ITEMACTION, @@ -28,16 +30,173 @@ const ActorInit En_Light_InitVars = { (ActorFunc)EnLight_Draw, }; -#endif +typedef struct { + /* 0x00 */ Color_RGBA8 unk_00; + /* 0x04 */ Color_RGB8 unk_04; + /* 0x07 */ u8 unk_07; +} EnLightStruct; // size = 0x8 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Init.s") +EnLightStruct D_808666D0[] = { + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, { { 255, 235, 175, 255 }, { 255, 0, 0 }, 75 }, + { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, + { { 255, 200, 0, 255 }, { 255, 0, 0 }, 40 }, { { 255, 200, 0, 255 }, { 255, 0, 0 }, 75 }, + { { 170, 255, 0, 255 }, { 0, 150, 0 }, 75 }, { { 0, 170, 255, 255 }, { 0, 0, 255 }, 75 }, + { { 255, 0, 170, 255 }, { 200, 0, 0 }, 75 }, { { 255, 255, 170, 255 }, { 255, 50, 0 }, 75 }, + { { 255, 255, 170, 255 }, { 255, 255, 0 }, 75 }, { { 255, 255, 170, 255 }, { 100, 255, 0 }, 75 }, + { { 255, 170, 255, 255 }, { 255, 0, 100 }, 75 }, { { 255, 170, 255, 255 }, { 100, 0, 255 }, 75 }, + { { 170, 255, 255, 255 }, { 0, 0, 255 }, 75 }, { { 170, 255, 255, 255 }, { 0, 150, 255 }, 75 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Destroy.s") +void EnLight_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865BF8.s") + if (!ENLIGHT_GET_4000(&this->actor)) { + if ((gSaveContext.gameMode == 3) || 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); + } else { + Lights_PointGlowSetInfo(&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); + } + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Update.s") + Actor_SetScale(&this->actor, D_808666D0[ENLIGHT_GET_F(&this->actor)].unk_07 * 0.0001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/func_80865F38.s") + this->unk_144 = (s8)(Rand_ZeroOne() * 255.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Light/EnLight_Draw.s") + if (ENLIGHT_GET_800(&this->actor)) { + this->actor.update = func_80865F38; + if (ENLIGHT_GET_1000(&this->actor) && Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Actor_SetScale(&this->actor, 0.0f); + } + } else if (ENLIGHT_GET_2000(&this->actor)) { + this->actor.draw = NULL; + } +} + +void EnLight_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + } +} + +void func_80865BF8(EnLight* this, GlobalContext* globalCtx) { + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + if (this->actor.parent != NULL) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.parent->world.pos); + this->actor.world.pos.y += 17.0f; + } + + this->unk_144++; +} + +void EnLight_Update(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + + if (!ENLIGHT_GET_4000(&this->actor)) { + EnLightStruct* sp28 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + s32 radius = (this->actor.params < 0) ? 100 : ENLIGHT_GET_2000(&this->actor) ? 730 : 300; + + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp28->unk_00.r * temp_f2), (u8)(sp28->unk_00.g * temp_f2), + (u8)(sp28->unk_00.b * temp_f2), radius); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && !ENLIGHT_GET_4000(&this->actor)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void func_80865F38(Actor* thisx, GlobalContext* globalCtx) { + EnLight* this = THIS; + EnLightStruct* sp38 = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + f32 temp_f2; + f32 sp30 = this->actor.scale.x / (sp38->unk_07 * 0.0001f); + s32 sp2C = false; + + if (ENLIGHT_GET_1000(&this->actor)) { + if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } else { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } + } else if (Flags_GetSwitch(globalCtx, ENLIGHT_SWITCHFLAG(&this->actor))) { + if (sp30 < 0.1f) { + Actor_SetScale(&this->actor, 0.0f); + sp30 = 0.0f; + } + Math_StepToF(&sp30, 0.0f, 0.05f); + } else { + Math_StepToF(&sp30, 1.0f, 0.05f); + sp2C = true; + } + + Actor_SetScale(&this->actor, sp38->unk_07 * 0.0001f * sp30); + + if (!ENLIGHT_GET_4000(&this->actor)) { + temp_f2 = (Rand_ZeroOne() * 0.5f) + 0.5f; + Lights_PointSetColorAndRadius(&this->lightInfo, (u8)(sp38->unk_00.r * temp_f2), (u8)(sp38->unk_00.g * temp_f2), + (u8)(sp38->unk_00.b * temp_f2), 300.0f * sp30); + } + + func_80865BF8(this, globalCtx); + + if ((this->actor.params >= 0) && (sp2C == true)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + } +} + +void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLight* this = THIS; + EnLightStruct* sp6C = &D_808666D0[ENLIGHT_GET_F(&this->actor)]; + Gfx* sp68; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->actor.params >= 0) { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, (this->unk_144 * -20) & 0x1FF, + 0x20, 0x80)); + sp68 = gGameplayKeepDrawFlameDL; + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, sp6C->unk_00.r, sp6C->unk_00.g, sp6C->unk_00.b, sp6C->unk_00.a); + gDPSetEnvColor(POLY_XLU_DISP++, sp6C->unk_04.r, sp6C->unk_04.g, sp6C->unk_04.b, 0); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x10, 0x20, 1, (this->unk_144 * 2) & 0x3F, + (this->unk_144 * -6) & 0x7F, 0x10, 0x20)); + sp68 = gameplay_keep_DL_01ACF0; + gDPSetPrimColor(POLY_XLU_DISP++, 0xC0, 0xC0, 255, 200, 0, 0); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + } + + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y), + MTXMODE_APPLY); + + if (ENLIGHT_GET_1(&this->actor)) { + Matrix_InsertYRotation_f(M_PI, MTXMODE_APPLY); + } + + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, sp68); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Light/z_en_light.h b/src/overlays/actors/ovl_En_Light/z_en_light.h index f1aff8de9..b17f55fd7 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.h +++ b/src/overlays/actors/ovl_En_Light/z_en_light.h @@ -5,9 +5,19 @@ struct EnLight; +#define ENLIGHT_GET_1(thisx) ((thisx)->params & 1) +#define ENLIGHT_GET_F(thisx) ((thisx)->params & 0xF) +#define ENLIGHT_GET_800(thisx) ((thisx)->params & 0x800) +#define ENLIGHT_SWITCHFLAG(thisx) (((thisx)->params & 0x7F0) >> 4) +#define ENLIGHT_GET_1000(thisx) ((thisx)->params & 0x1000) +#define ENLIGHT_GET_2000(thisx) ((thisx)->params & 0x2000) +#define ENLIGHT_GET_4000(thisx) ((thisx)->params & 0x4000) + typedef struct EnLight { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x144 */ u8 unk_144; + /* 0x148 */ LightNode* lightNode; + /* 0x14C */ LightInfo lightInfo; } EnLight; // size = 0x15C extern const ActorInit En_Light_InitVars; 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 22a1f73cc..07b9e8db0 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 @@ -6,7 +6,7 @@ #include "z_en_look_nuts.h" -#define FLAGS 0x80000000 +#define FLAGS (ACTOR_FLAG_80000000) #define THIS ((EnLookNuts*)thisx) @@ -15,7 +15,14 @@ void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnLookNuts_SetupPatrol(EnLookNuts* this); +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupStandAndWait(EnLookNuts* this); +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx); +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this); +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx); + const ActorInit En_Look_Nuts_InitVars = { ACTOR_EN_LOOK_NUTS, ACTORCAT_NPC, @@ -28,15 +35,29 @@ const ActorInit En_Look_Nuts_InitVars = { (ActorFunc)EnLookNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A68600 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 20, 50, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A68630 = { +s32 D_80A6862C = 0; + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(1, 0xF), @@ -71,34 +92,302 @@ static DamageTable D_80A68630 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -#endif +typedef enum { + /* 0x01 */ PALACE_GUARD_PATROLLING, + /* 0x01 */ PALACE_GUARD_WAITING, + /* 0x02 */ PALACE_GUARD_RUNNING_TO_PLAYER, + /* 0x03 */ PALACE_GUARD_CAUGHT_PLAYER +} PalaceGuardState; -extern ColliderCylinderInit D_80A68600; -extern DamageTable D_80A68630; +void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -extern UNK_TYPE D_06000430; -extern UNK_TYPE D_06002B6C; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuPalaceGuardSkel, &gDekuPalaceGuardDigAnim, this->jointTable, + this->morphTable, OBJECT_DNK_LIMB_MAX); + Actor_SetScale(&this->actor, 0.01f); + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.flags |= ACTOR_FLAG_8000000; + this->pathLocation = LOOKNUTS_GET_PATROL_LOCATION(&this->actor); + this->switchFlag = LOOKNUTS_GET_SCENE_FLAG(&this->actor); + this->spawnIndex = LOOKNUTS_GET_SPAWN_INDEX(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Init.s") + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { + Actor_MarkForDeath(&this->actor); + return; + } + if (this->pathLocation == 0x1F) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Destroy.s") + this->state = PALACE_GUARD_PATROLLING; + EnLookNuts_SetupPatrol(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67A34.s") +void EnLookNuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67AA8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67C48.s") +void EnLookNuts_SetupPatrol(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_PATROLLING; + this->actionFunc = EnLookNuts_Patrol; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67D0C.s") +void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { + f32 sp34 = 0.0f; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67F30.s") + SkelAnime_Update(&this->skelAnime); + if (Play_InCsMode(globalCtx)) { + this->actor.speedXZ = 0.0f; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A67FC4.s") + this->actor.speedXZ = 2.0f; + if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_WALK); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A68080.s") + if (D_80A6862C != 0) { + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/func_80A680FC.s") + this->path = SubS_GetPathByIndex(globalCtx, this->pathLocation, 0x1F); + if (this->path != NULL) { + sp34 = SubS_GetDistSqAndOrientPath(this->path, this->currentPathIndex, &this->actor.world.pos, &sp30); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Update.s") + if (sp30 < 10.0f) { + if (this->path != NULL) { + this->currentPathIndex++; + if (this->currentPathIndex >= this->path->count) { + this->currentPathIndex = 0; + } + if (Rand_ZeroOne() < 0.6f) { + EnLookNuts_SetupStandAndWait(this); + return; + } + } + } + Math_SmoothStepToS(&this->actor.shape.rot.y, sp34, 1, 0x1388, 0); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Look_Nuts/EnLookNuts_Draw.s") +void EnLookNuts_SetupStandAndWait(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->waitTimer = Rand_S16Offset(1, 3); + this->headRotTarget.y = 10000.0f; + + if (Rand_ZeroOne() < 0.5f) { + this->headRotTarget.y = -10000.0f; + } + this->eventTimer = 10; + this->state = PALACE_GUARD_WAITING; + this->actionFunc = EnLookNuts_StandAndWait; +} + +// Patrol Guards will stand in place and wait for a maximum of ~12 frames. +void EnLookNuts_StandAndWait(EnLookNuts* this, GlobalContext* globalCtx) { + s16 randOffset; + + SkelAnime_Update(&this->skelAnime); + Math_ApproachZeroF(&this->actor.speedXZ, 0.3f, 1.0f); + if (!Play_InCsMode(globalCtx) && (D_80A6862C == 0) && (this->eventTimer == 0)) { + this->eventTimer = 10; + switch (this->waitTimer) { + case 0: + case 1: + case 2: + case 3: + case 4: + this->waitTimer++; + this->headRotTarget.y *= -1.0f; + break; + case 5: + this->headRotTarget.y = 0.0f; + randOffset = Rand_S16Offset(1, 2); + this->eventTimer = 0; + this->waitTimer += randOffset; + break; + case 6: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->waitTimer = 10; + this->headRotTarget.x = 4000.0f; + this->eventTimer = 5; + } + break; + case 7: + if (fabsf(this->headRotTarget.y - this->headRotation.y) < 10.0f) { + this->headRotTarget.z = 4000.0f; + this->waitTimer++; + } + break; + case 8: + this->waitTimer = 10; + this->eventTimer = 20; + this->headRotTarget.z = -8000.0f; + break; + case 10: + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->waitTimer = 11; + break; + case 11: + if ((fabsf(this->headRotation.x) < 30.0f) && (fabsf(this->headRotation.y) < 30.0f) && + (fabsf(this->headRotation.z) < 30.0f)) { + this->waitTimer = 12; + } + break; + } + if (this->waitTimer == 12) { + this->waitTimer = 0; + EnLookNuts_SetupPatrol(this); + } + } +} + +void EnLookNuts_DetectedPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 2.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 0, -10.0f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + this->eventTimer = 300; + Message_StartTextbox(globalCtx, 0x833, &this->actor); + this->actionFunc = EnLookNuts_RunToPlayer; +} + +void EnLookNuts_RunToPlayer(EnLookNuts* this, GlobalContext* globalCtx) { + 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); + } + + this->actor.speedXZ = 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; + EnLookNuts_SetupSendPlayerToSpawn(this); + } +} + +void EnLookNuts_SetupSendPlayerToSpawn(EnLookNuts* this) { + Animation_Change(&this->skelAnime, &gDekuPalaceGuardWalkAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gDekuPalaceGuardWalkAnim), 2, -10.0f); + this->state = PALACE_GUARD_CAUGHT_PLAYER; + this->actionFunc = EnLookNuts_SendPlayerToSpawn; +} + +void EnLookNuts_SendPlayerToSpawn(EnLookNuts* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + globalCtx->nextEntranceIndex = Entrance_CreateIndexFromSpawn(this->spawnIndex); + gSaveContext.nextCutsceneIndex = 0; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[17] |= 4; + } +} + +static Vec3f effectVecInitialize = { 0.0f, 0.0f, 0.0f }; + +void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnLookNuts* this = THIS; + Vec3f effectVelOffset; + Vec3f effectPos; + Vec3f effectVel; + + if (this->blinkTimer == 0) { + this->eyeState++; + if (this->eyeState >= 3) { + this->eyeState = 0; + this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; + } + } + this->actionFunc(this, globalCtx); + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->eventTimer != 0) { + this->eventTimer--; + } + Actor_MoveWithGravity(&this->actor); + if (D_80A6862C == 0) { + if ((this->state < 2) && (this->actor.xzDistToPlayer < 320.0f) && (this->actor.playerHeightRel < 80.0f)) { + effectVelOffset = effectVecInitialize; + Math_Vec3f_Copy(&effectPos, &this->actor.world.pos); + effectPos.x += Math_SinS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + effectPos.y += 30.0f; + effectPos.z += Math_CosS((this->actor.world.rot.y + (s16)this->headRotation.y)) * 10.0f; + Matrix_StatePush(); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + effectVelOffset.z = 20.0f; + Matrix_MultiplyVector3fByState(&effectVelOffset, &effectVel); + Matrix_StatePop(); + if (!this->isPlayerDetected) { + s16 drawFlag = 1; + if (gSaveContext.save.isNight) { + drawFlag = 0; + } + if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { + EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, + &this->isPlayerDetected, drawFlag); + } + } + + if ((this->isPlayerDetected == true) || (this->actor.xzDistToPlayer < 20.0f)) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags3 & 0x100) && !Play_InCsMode(globalCtx)) { + Math_Vec3f_Copy(&this->headRotTarget, &gZeroVec3f); + this->state = PALACE_GUARD_RUNNING_TO_PLAYER; + play_sound(NA_SE_SY_FOUND); + func_800B7298(globalCtx, &this->actor, 0x1A); + D_80A6862C = 1; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); + this->actor.gravity = 0.0f; + EnLookNuts_DetectedPlayer(this, globalCtx); + } else { + this->isPlayerDetected = false; + } + } + } + Math_ApproachF(&this->headRotation.x, this->headRotTarget.x, 1.0f, 3000.0f); + Math_ApproachF(&this->headRotation.y, this->headRotTarget.y, 1.0f, 6000.0f); + Math_ApproachF(&this->headRotation.z, this->headRotTarget.z, 1.0f, 2000.0f); + this->actor.shape.rot.y = this->actor.world.rot.y; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +static TexturePtr sEyeTextures[] = { + gDekuPalaceGuardEyeOpenTex, + gDekuPalaceGuardEyeHalfTex, + gDekuPalaceGuardEyeClosedTex, +}; + +void EnLookNuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnLookNuts* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeState])); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h index cb011be7a..c06f0e2cd 100644 --- a/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h +++ b/src/overlays/actors/ovl_En_Look_Nuts/z_en_look_nuts.h @@ -2,16 +2,37 @@ #define Z_EN_LOOK_NUTS_H #include "global.h" +#include "objects/object_dnk/object_dnk.h" struct EnLookNuts; typedef void (*EnLookNutsActionFunc)(struct EnLookNuts*, GlobalContext*); +#define LOOKNUTS_GET_SPAWN_INDEX(thisx) (((thisx)->params >> 0xC) & 0xF) +#define LOOKNUTS_GET_SCENE_FLAG(thisx) ((thisx)->params & 0x7F) +#define LOOKNUTS_GET_PATROL_LOCATION(thisx) (((thisx)->params >> 0x7) & 0x1F) + typedef struct EnLookNuts { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[OBJECT_DNK_LIMB_MAX]; + /* 0x01CA */ Vec3s morphTable[OBJECT_DNK_LIMB_MAX]; /* 0x020C */ EnLookNutsActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x80]; + /* 0x0210 */ Path *path; + /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path + /* 0x0216 */ s16 eyeState; + /* 0x0218 */ s16 blinkTimer; + /* 0x021A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen + /* 0x021C */ s16 state; + /* 0x021E */ s16 switchFlag; + /* 0x0220 */ s16 pathLocation; // Determines path that a guard will patrol + /* 0x0222 */ s16 isPlayerDetected; + /* 0x0224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for + /* 0x0226 */ s16 spawnIndex; + /* 0x0228 */ UNK_TYPE4 pad228; // Unused necessary padding + /* 0x022C */ Vec3f headRotation; + /* 0x0238 */ Vec3f headRotTarget; // Target value for head rotation + /* 0x0244 */ ColliderCylinder collider; } EnLookNuts; // size = 0x290 extern const ActorInit En_Look_Nuts_InitVars; 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 4a21cdefd..a7f83a42c 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 @@ -6,7 +6,7 @@ #include "z_en_m_thunder.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMThunder*)thisx) 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 6f87fbab5..4d96184be 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -7,7 +7,7 @@ #include "z_en_ma4.h" #include "objects/object_ma1/object_ma1.h" -#define FLAGS 0x02000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnMa4*)thisx) @@ -112,33 +112,33 @@ void EnMa4_UpdateEyes(EnMa4* this) { } } -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma1_Anim_009E58, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_009E58, 1.0f, 0, -6.0f }, // Idle anim - { &object_ma1_Anim_002A8C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_002A8C, 1.0f, 0, -6.0f }, // Looking around anim - { &object_ma1_Anim_018948, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_018948, 1.0f, 2, -6.0f }, // Starts holding hands anim - { &object_ma1_Anim_01B76C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_01B76C, 1.0f, 0, -6.0f }, // Holnding hands anim - { &object_ma1_Anim_007328, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007328, 1.0f, 0, -6.0f }, // Walking anim - { &object_ma1_Anim_014088, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_014088, 1.0f, 0, -6.0f }, // - { &object_ma1_Anim_015B7C, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_015B7C, 1.0f, 2, -6.0f }, // Shoot arrow anim - { &object_ma1_Anim_007D98, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007D98, 1.0f, 0, -6.0f }, // Sitting anim - { &object_ma1_Anim_00852C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_00852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim - { &object_ma1_Anim_008F6C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, -6.0f }, // Idle anim + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Looking around anim + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, -6.0f }, // Starts holding hands anim + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Holnding hands anim + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, -6.0f }, // Walking anim + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_ONCE, -6.0f }, // Shoot arrow anim + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting anim + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting traumatized anim + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting sad anim }; void EnMa4_ChangeAnim(EnMa4* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80ABDD9C(EnMa4* this, GlobalContext* globalCtx) { @@ -202,14 +202,14 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { this->type = MA4_TYPE_DAY1; - } else if (gSaveContext.save.weekEventReg[0x16] & 1) { // Aliens defeated + } else if (gSaveContext.save.weekEventReg[22] & 1) { // Aliens defeated this->type = MA4_TYPE_ALIENS_DEFEATED; } else { this->type = MA4_TYPE_ALIENS_WON; this->hasBow = false; } - if (func_800EE1D8(globalCtx) != 0) { // if (sceneSetupIndex != 0) + if (Cutscene_GetSceneSetupIndex(globalCtx) != 0) { // if (sceneSetupIndex != 0) EnMa4_ChangeAnim(this, 0); this->state = MA4_STATE_HORSEBACKGAME; EnMa4_InitHorsebackGame(this, globalCtx); @@ -240,7 +240,7 @@ void EnMa4_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnMa4* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - gSaveContext.save.weekEventReg[0x8] &= (u8)~0x01; + gSaveContext.save.weekEventReg[8] &= (u8)~1; } // Running in circles in the ranch @@ -332,7 +332,7 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { s16 yaw = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; if ((this->state == MA4_STATE_AFTERHORSEBACKGAME) || (this->state == MA4_STATE_AFTERDESCRIBETHEMCS)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } else if (this->type != MA4_TYPE_ALIENS_WON) { EnMa4_RunInCircles(this, globalCtx); } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -357,16 +357,16 @@ void EnMa4_Wait(EnMa4* this, GlobalContext* globalCtx) { // Chooses the next dialogue based on player's selection void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x3339: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x333A, &this->actor); + Message_StartTextbox(globalCtx, 0x333A, &this->actor); this->textId = 0x333A; } else { func_8019F208(); - func_801518B0(globalCtx, 0x333B, &this->actor); + Message_StartTextbox(globalCtx, 0x333B, &this->actor); this->textId = 0x333B; } break; @@ -374,13 +374,13 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3341: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.save.weekEventReg[0x15] |= 0x20; - func_801518B0(globalCtx, 0x3343, &this->actor); + gSaveContext.save.weekEventReg[21] |= 0x20; + Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(globalCtx, 0x3342, &this->actor); this->textId = 0x3342; this->state = MA4_STATE_DEFAULT; func_80151BB4(globalCtx, 5); @@ -390,13 +390,13 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3346: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - gSaveContext.save.weekEventReg[0x15] |= 0x20; - func_801518B0(globalCtx, 0x3343, &this->actor); + gSaveContext.save.weekEventReg[21] |= 0x20; + Message_StartTextbox(globalCtx, 0x3343, &this->actor); this->textId = 0x3343; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x3342, &this->actor); + Message_StartTextbox(globalCtx, 0x3342, &this->actor); this->textId = 0x3342; } break; @@ -404,11 +404,11 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3347: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); - func_801518B0(globalCtx, 0x3348, &this->actor); + Message_StartTextbox(globalCtx, 0x3348, &this->actor); this->textId = 0x3348; func_80151BB4(globalCtx, 5); } @@ -419,7 +419,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { s32 aux; func_8019F208(); - func_801518B0(globalCtx, 0x334E, &this->actor); + Message_StartTextbox(globalCtx, 0x334E, &this->actor); this->textId = 0x334E; if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { func_80151BB4(globalCtx, 0x1C); @@ -428,7 +428,7 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { } else { // No. func_8019F230(); EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; } break; @@ -436,12 +436,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3354: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 1, 0); - func_801518B0(globalCtx, 0x3355, &this->actor); + Message_StartTextbox(globalCtx, 0x3355, &this->actor); this->textId = 0x3355; func_80151BB4(globalCtx, 5); } @@ -457,13 +457,13 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { if (this->type == MA4_TYPE_ALIENS_DEFEATED) { func_8019F230(); EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3357, &this->actor); + Message_StartTextbox(globalCtx, 0x3357, &this->actor); this->textId = 0x3357; func_80151BB4(globalCtx, 5); } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x335B, &this->actor); + Message_StartTextbox(globalCtx, 0x335B, &this->actor); this->textId = 0x335B; func_80151BB4(globalCtx, 5); } @@ -473,12 +473,12 @@ void EnMa4_HandlePlayerChoice(EnMa4* this, GlobalContext* globalCtx) { case 0x3359: if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; } else { func_8019F230(); EnMa4_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x335A, &this->actor); + Message_StartTextbox(globalCtx, 0x335A, &this->actor); this->textId = 0x335A; func_80151BB4(globalCtx, 5); } @@ -491,7 +491,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 aux; - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x2390: func_801477B4(globalCtx); @@ -500,31 +500,31 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x3335: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3336, &this->actor); + Message_StartTextbox(globalCtx, 0x3336, &this->actor); this->textId = 0x3336; func_80151BB4(globalCtx, 5); break; case 0x3338: - func_801518B0(globalCtx, 0x3339, &this->actor); + Message_StartTextbox(globalCtx, 0x3339, &this->actor); this->textId = 0x3339; break; case 0x333A: case 0x333B: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x333C, &this->actor); + Message_StartTextbox(globalCtx, 0x333C, &this->actor); this->textId = 0x333C; break; case 0x333C: EnMa4_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x333D, &this->actor); + Message_StartTextbox(globalCtx, 0x333D, &this->actor); this->textId = 0x333D; break; case 0x333D: - func_801518B0(globalCtx, 0x333E, &this->actor); + Message_StartTextbox(globalCtx, 0x333E, &this->actor); this->textId = 0x333E; break; @@ -534,34 +534,34 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x333F: - func_801518B0(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(globalCtx, 0x3340, &this->actor); this->textId = 0x3340; break; case 0x3340: EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3341, &this->actor); + Message_StartTextbox(globalCtx, 0x3341, &this->actor); this->textId = 0x3341; break; case 0x3343: EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3344, &this->actor); + Message_StartTextbox(globalCtx, 0x3344, &this->actor); this->textId = 0x3344; break; case 0x3344: - func_801518B0(globalCtx, 0x3345, &this->actor); + Message_StartTextbox(globalCtx, 0x3345, &this->actor); this->textId = 0x3345; break; case 0x3345: - func_801518B0(globalCtx, 0x3349, &this->actor); + Message_StartTextbox(globalCtx, 0x3349, &this->actor); this->textId = 0x3349; break; case 0x3349: - func_801518B0(globalCtx, 0x334A, &this->actor); + Message_StartTextbox(globalCtx, 0x334A, &this->actor); this->textId = 0x334A; break; @@ -571,7 +571,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { break; case 0x334C: - func_801518B0(globalCtx, 0x334D, &this->actor); + Message_StartTextbox(globalCtx, 0x334D, &this->actor); this->textId = 0x334D; break; @@ -580,10 +580,10 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x335D: case 0x335E: if (this->type == MA4_TYPE_DAY1) { - func_801518B0(globalCtx, 0x3352, &this->actor); + Message_StartTextbox(globalCtx, 0x3352, &this->actor); this->textId = 0x3352; } else { - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } break; @@ -594,7 +594,7 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { // Check if player has Epona's song if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; } else { func_801477B4(globalCtx); @@ -606,11 +606,11 @@ void EnMa4_ChooseNextDialogue(EnMa4* this, GlobalContext* globalCtx) { case 0x3358: if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || !(CHECK_QUEST_ITEM(QUEST_SONG_EPONA))) { - func_801518B0(globalCtx, 0x335C, &this->actor); + Message_StartTextbox(globalCtx, 0x335C, &this->actor); this->textId = 0x335C; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3359, &this->actor); + Message_StartTextbox(globalCtx, 0x3359, &this->actor); this->textId = 0x3359; } break; @@ -643,7 +643,7 @@ void EnMa4_DialogueHandler(EnMa4* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { if ((globalCtx->msgCtx.unk120B1 == 0) || !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { EnMa4_SetupWait(this); } @@ -676,7 +676,7 @@ void EnMa4_BeginHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { void EnMa4_HorsebackGameCheckPlayerInteractions(EnMa4* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { // "You're feeling confident" - func_801518B0(globalCtx, 0x336E, &this->actor); + Message_StartTextbox(globalCtx, 0x336E, &this->actor); this->actionFunc = EnMa4_HorsebackGameTalking; } else if ((gSaveContext.unk_3DE0[4] < 115 * 100)) { // timer < 115 seconds func_800B8614(&this->actor, globalCtx, 100.0f); @@ -694,7 +694,7 @@ void EnMa4_InitHorsebackGame(EnMa4* this, GlobalContext* globalCtx) { globalCtx->interfaceCtx.unk_280 = 1; func_8010E9F0(4, 0); - gSaveContext.save.weekEventReg[0x8] |= 0x01; + gSaveContext.save.weekEventReg[8] |= 1; Interface_InitMinigame(globalCtx); player->stateFlags1 |= 0x20; this->actionFunc = EnMa4_SetupHorsebackGameWait; @@ -730,7 +730,7 @@ void EnMa4_HorsebackGameWait(EnMa4* this, GlobalContext* globalCtx) { } void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { - gSaveContext.save.weekEventReg[0x8] &= (u8)~0x01; + gSaveContext.save.weekEventReg[8] &= (u8)~1; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); @@ -749,10 +749,10 @@ void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { if (sFrameCounter == 25) { if (this->poppedBalloonCounter == 10) { - func_801518B0(globalCtx, 0x334F, &this->actor); + Message_StartTextbox(globalCtx, 0x334F, &this->actor); this->textId = 0x334F; } else { - func_801518B0(globalCtx, 0x334B, &this->actor); + Message_StartTextbox(globalCtx, 0x334B, &this->actor); this->textId = 0x334B; } } else if (sFrameCounter == 50) { @@ -802,15 +802,15 @@ void EnMa4_SetupEponasSongCs(EnMa4* this) { static u16 D_80AC0260 = 99; void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x78) != 0) { - u32 actionIndex = func_800EE200(globalCtx, 0x78); + if (Cutscene_CheckActorAction(globalCtx, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80AC0260) { - D_80AC0260 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80AC0260) { + D_80AC0260 = globalCtx->csCtx.actorActions[actionIndex]->action; this->animTimer = 0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMa4_ChangeAnim(this, 1); @@ -824,7 +824,7 @@ void EnMa4_EponasSongCs(EnMa4* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); if (D_80AC0260 == 2 && this->animTimer == 0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMa4_ChangeAnim(this, 7); } @@ -846,12 +846,12 @@ void EnMa4_SetupEndEponasSongCs(EnMa4* this) { void EnMa4_EndEponasSongCs(EnMa4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state) != 0) { player->stateFlags1 &= ~0x20; - func_801518B0(globalCtx, 0x334C, &this->actor); + Message_StartTextbox(globalCtx, 0x334C, &this->actor); this->textId = 0x334C; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; EnMa4_SetupDialogueHandler(this); } else { func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); @@ -877,35 +877,35 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { switch (this->type) { case MA4_TYPE_DAY1: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.save.weekEventReg[0x15] & 0x80)) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.save.weekEventReg[0x15] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - if ((gSaveContext.save.weekEventReg[0x15] & 0x40)) { - if (!(gSaveContext.save.weekEventReg[0x15] & 0x20)) { - func_801518B0(globalCtx, 0x3346, &this->actor); + if ((gSaveContext.save.weekEventReg[21] & 0x40)) { + if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { + Message_StartTextbox(globalCtx, 0x3346, &this->actor); this->textId = 0x3346; } else { - func_801518B0(globalCtx, 0x3347, &this->actor); + Message_StartTextbox(globalCtx, 0x3347, &this->actor); this->textId = 0x3347; } } else { - func_801518B0(globalCtx, 0x3338, &this->actor); + Message_StartTextbox(globalCtx, 0x3338, &this->actor); this->textId = 0x3338; - gSaveContext.save.weekEventReg[0x15] |= 0x40; + gSaveContext.save.weekEventReg[21] |= 0x40; } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Too bad Grasshopper" EnMa4_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336D, &this->actor); + Message_StartTextbox(globalCtx, 0x336D, &this->actor); this->textId = 0x336D; } else { time = gSaveContext.unk_3DE0[4]; @@ -913,92 +913,92 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { // [Score] New record! gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; } else { // [Score] Great. - func_801518B0(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(globalCtx, 0x3351, &this->actor); this->textId = 0x3351; } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } else if (this->state == MA4_STATE_AFTERDESCRIBETHEMCS) { // "Cremia doesn't believe me..." - func_801518B0(globalCtx, 0x3340, &this->actor); + Message_StartTextbox(globalCtx, 0x3340, &this->actor); this->textId = 0x3340; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; case MA4_TYPE_ALIENS_DEFEATED: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.save.weekEventReg[0x15] & 0x80)) { + if ((gSaveContext.save.weekEventReg[21] & 0x80)) { EnMa4_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x3337, &this->actor); + Message_StartTextbox(globalCtx, 0x3337, &this->actor); this->textId = 0x3337; func_80151BB4(globalCtx, 5); } else { - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; - gSaveContext.save.weekEventReg[0x15] |= 0x80; + gSaveContext.save.weekEventReg[21] |= 0x80; } } else if (this->state == MA4_STATE_DEFAULT) { - func_801518B0(globalCtx, 0x3354, &this->actor); + Message_StartTextbox(globalCtx, 0x3354, &this->actor); this->textId = 0x3354; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { gSaveContext.save.horseBackBalloonHighScore = time; EnMa4_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3350, &this->actor); + Message_StartTextbox(globalCtx, 0x3350, &this->actor); this->textId = 0x3350; } else { - func_801518B0(globalCtx, 0x3351, &this->actor); + Message_StartTextbox(globalCtx, 0x3351, &this->actor); this->textId = 0x3351; } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; case MA4_TYPE_ALIENS_WON: if (this->state == MA4_STATE_DEFAULT) { // "Huh... You?" - func_801518B0(globalCtx, 0x3358, &this->actor); + Message_StartTextbox(globalCtx, 0x3358, &this->actor); this->textId = 0x3358; } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { // "Try again?" - func_801518B0(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(globalCtx, 0x3356, &this->actor); this->textId = 0x3356; } else { time = gSaveContext.unk_3DE0[4]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // New record gSaveContext.save.horseBackBalloonHighScore = time; - func_801518B0(globalCtx, 0x335D, &this->actor); + Message_StartTextbox(globalCtx, 0x335D, &this->actor); this->textId = 0x335D; } else { // "Old record was: [record]" - func_801518B0(globalCtx, 0x335E, &this->actor); + Message_StartTextbox(globalCtx, 0x335E, &this->actor); this->textId = 0x335E; } } this->state = MA4_STATE_DEFAULT; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } break; default: // Dead code - func_801518B0(globalCtx, 0x3335, &this->actor); + Message_StartTextbox(globalCtx, 0x3335, &this->actor); this->textId = 0x3335; break; } 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 05e97af2c..bd92db4bc 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 @@ -7,7 +7,7 @@ #include "z_en_ma_yto.h" #include "objects/object_ma2/object_ma2.h" -#define FLAGS 0x02100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYto*)thisx) @@ -109,19 +109,19 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma2_Anim_00A174, 1.0f, 0, 0.0f }, { &object_ma2_Anim_00A174, 1.0f, 0, -6.0f }, // - { &object_ma2_Anim_00AF7C, 1.0f, 2, 0.0f }, { &object_ma2_Anim_00AF7C, 1.0f, 2, -6.0f }, // - { &object_ma2_Anim_000CC0, 1.0f, 0, 0.0f }, { &object_ma2_Anim_000CC0, 1.0f, 0, -6.0f }, // - { &object_ma2_Anim_016720, 1.0f, 0, 0.0f }, { &object_ma2_Anim_016720, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_005314, 1.0f, 0, 0.0f }, { &object_ma2_Anim_005314, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0093E8, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0093E8, 1.0f, 0, -10.0f }, // - { &object_ma2_Anim_007E28, 1.0f, 0, 0.0f }, { &object_ma2_Anim_007E28, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0070EC, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0070EC, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_003D54, 1.0f, 0, 0.0f }, { &object_ma2_Anim_003D54, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_001FD0, 1.0f, 0, 0.0f }, { &object_ma2_Anim_001FD0, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_0030B4, 1.0f, 0, 0.0f }, { &object_ma2_Anim_0030B4, 1.0f, 0, -8.0f }, // - { &object_ma2_Anim_004370, 1.0f, 0, 0.0f }, { &object_ma2_Anim_004370, 1.0f, 0, -8.0f }, // +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma2_Anim_00A174, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_00A174, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma2_Anim_00AF7C, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_ma2_Anim_00AF7C, 1.0f, ANIMMODE_ONCE, -6.0f }, // + { &object_ma2_Anim_000CC0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_000CC0, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma2_Anim_016720, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_016720, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_005314, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_005314, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0093E8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0093E8, 1.0f, ANIMMODE_LOOP, -10.0f }, // + { &object_ma2_Anim_007E28, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_007E28, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0070EC, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0070EC, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_003D54, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_003D54, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_001FD0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_001FD0, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_0030B4, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_0030B4, 1.0f, ANIMMODE_LOOP, -8.0f }, // + { &object_ma2_Anim_004370, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_ma2_Anim_004370, 1.0f, ANIMMODE_LOOP, -8.0f }, // }; static TexturePtr sMouthTextures[] = { @@ -146,7 +146,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk320 = 0; this->eyeTexIndex = 0; - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); } else { EnMaYto_SetFaceExpression(this, 5, 2); @@ -180,19 +180,19 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { switch (this->type) { case MA_YTO_TYPE_DEFAULT: - if (CURRENT_DAY == 3 && !(gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 3 && !(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_DINNER: - if (CURRENT_DAY != 1 && (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY != 1 && (gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case MA_YTO_TYPE_BARN: - if (gSaveContext.save.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (((this->actor.params & 0x0F00) >> 8) != 0) { return false; } @@ -205,9 +205,9 @@ s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { break; case MA_YTO_TYPE_AFTERMILKRUN: - // if (!(ProtectedCremia) && !(gSaveContext.save.weekEventReg[0x34] & 2)) || (PlayedMilkMinigame)) - if ((!(gSaveContext.save.weekEventReg[0x34] & 1) && !(gSaveContext.save.weekEventReg[0x34] & 2)) || - (gSaveContext.save.weekEventReg[0xE] & 1)) { + // if (!(ProtectedCremia) && !(gSaveContext.save.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) + if ((!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) || + (gSaveContext.save.weekEventReg[14] & 1)) { return false; } break; @@ -235,7 +235,7 @@ void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.save.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { EnMaYto_ChangeAnim(this, 12); } else { EnMaYto_ChangeAnim(this, 8); @@ -273,7 +273,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_AFTERMILKRUN: this->unk310 = 0; - if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.save.weekEventReg[0x34] & 1) && + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.save.weekEventReg[52] & 1) && (Rand_Next() & 0x80)) { EnMaYto_SetupBeginWarmFuzzyFeelingCs(this); } else { @@ -282,7 +282,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { break; case MA_YTO_TYPE_4: - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; EnMaYto_SetupWarmFuzzyFeelingCs(this); break; @@ -328,7 +328,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { return 0; case MA_YTO_TYPE_DINNER: - if (!(gSaveContext.save.weekEventReg[0x16] & 1) && CURRENT_DAY == 2) { + if (!(gSaveContext.save.weekEventReg[22] & 1) && CURRENT_DAY == 2) { return 0; } if (EnMaYto_SearchRomani(this, globalCtx)) { @@ -338,7 +338,7 @@ s32 EnMaYto_TryFindRomani(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_BARN: // if (AliensDefeated) - if (gSaveContext.save.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (EnMaYto_SearchRomani(this, globalCtx)) { return 2; } @@ -422,7 +422,7 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupDefaultWait(this); } @@ -443,47 +443,47 @@ void EnMaYto_DefaultDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DefaultHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - func_801518B0(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(globalCtx, 0x3392, &this->actor); this->textId = 0x3392; } else { // No func_8019F230(); // "Don't lie!" - func_801518B0(globalCtx, 0x3391, &this->actor); + Message_StartTextbox(globalCtx, 0x3391, &this->actor); this->textId = 0x3391; } } } void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3391: EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3392, &this->actor); + Message_StartTextbox(globalCtx, 0x3392, &this->actor); this->textId = 0x3392; break; case 0x3392: EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x3393, &this->actor); + Message_StartTextbox(globalCtx, 0x3393, &this->actor); this->textId = 0x3393; func_80151BB4(globalCtx, 6); break; case 0x3394: EnMaYto_ChangeAnim(this, 2); - func_801518B0(globalCtx, 0x3395, &this->actor); + Message_StartTextbox(globalCtx, 0x3395, &this->actor); this->textId = 0x3395; break; case 0x3395: EnMaYto_ChangeAnim(this, 1); - func_801518B0(globalCtx, 0x3396, &this->actor); + Message_StartTextbox(globalCtx, 0x3396, &this->actor); this->textId = 0x3396; func_80151BB4(globalCtx, 6); break; @@ -492,7 +492,7 @@ void EnMaYto_DefaultChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) } void EnMaYto_SetupDinnerWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 0); this->unk31E = 0; } else { @@ -533,7 +533,7 @@ void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -554,7 +554,7 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMaYto_SetupDinnerWait(this); } break; @@ -568,41 +568,41 @@ void EnMaYto_DinnerDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_DinnerHandlePlayerChoice(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { // Yes func_8019F208(); EnMaYto_SetFaceExpression(this, 0, 3); // "Milk Road is fixed!" - func_801518B0(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(globalCtx, 0x3399, &this->actor); this->textId = 0x3399; } else { // No func_8019F230(); // "Don't lie!" - func_801518B0(globalCtx, 0x3398, &this->actor); + Message_StartTextbox(globalCtx, 0x3398, &this->actor); this->textId = 0x3398; } } } void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x3398: EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x3399, &this->actor); + Message_StartTextbox(globalCtx, 0x3399, &this->actor); this->textId = 0x3399; break; case 0x3399: EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x339A, &this->actor); + Message_StartTextbox(globalCtx, 0x339A, &this->actor); this->textId = 0x339A; break; case 0x339A: this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x339B, &this->actor); + Message_StartTextbox(globalCtx, 0x339B, &this->actor); this->textId = 0x339B; break; @@ -610,7 +610,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 0); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x339C, &this->actor); + Message_StartTextbox(globalCtx, 0x339C, &this->actor); this->textId = 0x339C; break; @@ -618,7 +618,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x339D, &this->actor); + Message_StartTextbox(globalCtx, 0x339D, &this->actor); this->textId = 0x339D; break; @@ -626,7 +626,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x339E, &this->actor); + Message_StartTextbox(globalCtx, 0x339E, &this->actor); this->textId = 0x339E; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -634,12 +634,12 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 0x339F: this->unk31E = 0; - func_801518B0(globalCtx, 0x33A0, &this->actor); + Message_StartTextbox(globalCtx, 0x33A0, &this->actor); this->textId = 0x33A0; break; case 0x33A0: - func_801518B0(globalCtx, 0x33A1, &this->actor); + Message_StartTextbox(globalCtx, 0x33A1, &this->actor); this->textId = 0x33A1; break; @@ -647,7 +647,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x33A2, &this->actor); + Message_StartTextbox(globalCtx, 0x33A2, &this->actor); this->textId = 0x33A2; break; @@ -655,27 +655,27 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x33A3, &this->actor); + Message_StartTextbox(globalCtx, 0x33A3, &this->actor); this->textId = 0x33A3; break; case 0x33A3: this->unk31E = 0; EnMaYto_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x33A4, &this->actor); + Message_StartTextbox(globalCtx, 0x33A4, &this->actor); this->textId = 0x33A4; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); break; case 0x33A5: - func_801518B0(globalCtx, 0x33A6, &this->actor); + Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); break; case 0x33A7: - func_801518B0(globalCtx, 0x33A8, &this->actor); + Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); break; @@ -684,7 +684,7 @@ void EnMaYto_DinnerChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_ChangeAnim(this, 13); func_80B90E50(this, 0); this->unk31E = 0; @@ -712,7 +712,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_BarnStartDialogue(this, globalCtx); EnMaYto_SetupBarnDialogueHandler(this); - } else if (!(gSaveContext.save.weekEventReg[0x16] & 1) || ABS_ALT(direction) < 0x2000) { + } else if (!(gSaveContext.save.weekEventReg[22] & 1) || ABS_ALT(direction) < 0x2000) { func_800B8614(&this->actor, globalCtx, 100.0f); child = this->actor.child; @@ -724,7 +724,7 @@ void EnMaYto_BarnWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -740,7 +740,7 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->unk31E = 0; EnMaYto_SetupBarnWait(this); } @@ -756,20 +756,20 @@ void EnMaYto_BarnDialogueHandler(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33A9: func_80B90E50(this, 0); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33AA, &this->actor); + Message_StartTextbox(globalCtx, 0x33AA, &this->actor); this->textId = 0x33AA; break; case 0x33AA: Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; - func_801518B0(globalCtx, 0x33AB, &this->actor); + Message_StartTextbox(globalCtx, 0x33AB, &this->actor); this->textId = 0x33AB; break; @@ -777,14 +777,14 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33AC, &this->actor); + Message_StartTextbox(globalCtx, 0x33AC, &this->actor); this->textId = 0x33AC; break; case 0x33AC: this->unk31E = 0; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); - func_801518B0(globalCtx, 0x33AD, &this->actor); + Message_StartTextbox(globalCtx, 0x33AD, &this->actor); this->textId = 0x33AD; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -794,7 +794,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { func_80B90E50(this, 1); Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); EnMaYto_SetRomaniFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x33AF, &this->actor); + Message_StartTextbox(globalCtx, 0x33AF, &this->actor); this->textId = 0x33AF; break; @@ -802,7 +802,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 1; Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); EnMaYto_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x33B0, &this->actor); + Message_StartTextbox(globalCtx, 0x33B0, &this->actor); this->textId = 0x33B0; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -812,7 +812,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); // "I should had believed what Romani said" - func_801518B0(globalCtx, 0x33B2, &this->actor); + Message_StartTextbox(globalCtx, 0x33B2, &this->actor); this->textId = 0x33B2; func_80151BB4(globalCtx, 6); break; @@ -821,7 +821,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); this->unk31E = 0; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C7, &this->actor); + Message_StartTextbox(globalCtx, 0x33C7, &this->actor); this->textId = 0x33C7; break; @@ -829,7 +829,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C8, &this->actor); + Message_StartTextbox(globalCtx, 0x33C8, &this->actor); this->textId = 0x33C8; break; @@ -837,7 +837,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x33C9, &this->actor); + Message_StartTextbox(globalCtx, 0x33C9, &this->actor); this->textId = 0x33C9; break; @@ -845,13 +845,13 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, &this->actor); this->unk31E = 1; EnMaYto_SetFaceExpression(this, 3, 1); - func_801518B0(globalCtx, 0x33CA, &this->actor); + Message_StartTextbox(globalCtx, 0x33CA, &this->actor); this->textId = 0x33CA; break; case 0x33CA: this->unk31E = 1; - func_801518B0(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(globalCtx, 0x33CB, &this->actor); this->textId = 0x33CB; break; @@ -859,7 +859,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { Actor_ChangeFocus(&this->actor, globalCtx, this->actor.child); func_80B90E50(this, 1); EnMaYto_SetRomaniFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x33CC, &this->actor); + Message_StartTextbox(globalCtx, 0x33CC, &this->actor); this->textId = 0x33CC; func_80151BB4(globalCtx, 6); func_80151BB4(globalCtx, 5); @@ -872,7 +872,7 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { - if (gSaveContext.save.weekEventReg[0x34] & 1) { // if (ProtectedCremia) + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { func_801A3098(NA_BGM_FAILURE_1); @@ -882,21 +882,21 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { } void EnMaYto_AfterMilkRunInit(EnMaYto* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; - if (gSaveContext.save.weekEventReg[0x34] & 1) { // if (ProtectedCremia) - func_801518B0(globalCtx, 0x33C1, &this->actor); + if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) + Message_StartTextbox(globalCtx, 0x33C1, &this->actor); this->textId = 0x33C1; } else { // Fails milk minigame EnMaYto_SetFaceExpression(this, 5, 2); - func_801518B0(globalCtx, 0x33C0, &this->actor); + Message_StartTextbox(globalCtx, 0x33C0, &this->actor); this->textId = 0x33C0; // Attempted Cremia Cart Ride - gSaveContext.save.weekEventReg[0xE] |= 0x1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 4; EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); func_80151BB4(globalCtx, 6); @@ -932,12 +932,12 @@ void EnMaYto_AfterMilkRunDialogueHandler(EnMaYto* this, GlobalContext* globalCtx } void EnMaYto_AfterMilkRunChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x33C1: EnMaYto_SetFaceExpression(this, 3, 1); // "Thank you. You were cool back there." - func_801518B0(globalCtx, 0x33C2, &this->actor); + Message_StartTextbox(globalCtx, 0x33C2, &this->actor); this->textId = 0x33C2; break; @@ -975,10 +975,10 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { if (this->unk310 == 1) { // Romani's mask explanation EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C3, &this->actor); + Message_StartTextbox(globalCtx, 0x33C3, &this->actor); this->textId = 0x33C3; // Attempted Cremia Cart Ride - gSaveContext.save.weekEventReg[0xE] |= 0x1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 0x20); func_80151BB4(globalCtx, 0x1F); @@ -987,10 +987,10 @@ void EnMaYto_PostMilkRunExplainReward(EnMaYto* this, GlobalContext* globalCtx) { } else { // You already have the mask EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33D0, &this->actor); + Message_StartTextbox(globalCtx, 0x33D0, &this->actor); this->textId = 0x33D0; // Attempted Cremia Cart Ride - gSaveContext.save.weekEventReg[0xE] |= 0x1; + gSaveContext.save.weekEventReg[14] |= 1; this->unk310 = 3; func_80151BB4(globalCtx, 6); EnMaYto_SetupPostMilkRunWaitDialogueEnd(this); @@ -1024,11 +1024,11 @@ void EnMaYto_SetupWarmFuzzyFeelingCs(EnMaYto* this) { static u16 D_80B915F0 = 99; void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x22C) != 0) { - u32 csActionIndex = func_800EE200(globalCtx, 0x22C); + if (Cutscene_CheckActorAction(globalCtx, 556)) { + s32 csActionIndex = Cutscene_GetActorActionIndex(globalCtx, 556); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[csActionIndex]->startFrame) { - u16 action = globalCtx->csCtx.npcActions[csActionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[csActionIndex]->startFrame) { + u16 action = globalCtx->csCtx.actorActions[csActionIndex]->action; if (1) {} @@ -1041,7 +1041,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { case 2: // Attempted Cremia Cart Ride - gSaveContext.save.weekEventReg[0xE] |= 1; + gSaveContext.save.weekEventReg[14] |= 1; EnMaYto_ChangeAnim(this, 18); break; @@ -1052,7 +1052,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, csActionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, csActionIndex); if (D_80B915F0 == 2 && this->skelAnime.animation == &object_ma2_Anim_001FD0 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { EnMaYto_ChangeAnim(this, 20); @@ -1068,7 +1068,7 @@ void EnMaYto_SetupPostMilkRunWaitDialogueEnd(EnMaYto* this) { void EnMaYto_PostMilkRunWaitDialogueEnd(EnMaYto* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 6 || Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_ShouldAdvance(globalCtx) && Message_GetState(&globalCtx->msgCtx) == 5) { func_800B7298(globalCtx, &this->actor, 7); func_801477B4(globalCtx); } @@ -1102,53 +1102,53 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: - func_801518B0(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(globalCtx, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: EnMaYto_SetFaceExpression(this, 1, 3); - func_801518B0(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(globalCtx, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: EnMaYto_SetFaceExpression(this, 1, 2); - func_801518B0(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - func_801518B0(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(globalCtx, 0x2360, &this->actor); this->textId = 0x2360; break; default: - func_801518B0(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(globalCtx, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x3394, &this->actor); + Message_StartTextbox(globalCtx, 0x3394, &this->actor); this->textId = 0x3394; } else { EnMaYto_SetTalkedFlag(); // Asks the player if he came from town. - func_801518B0(globalCtx, 0x3390, &this->actor); + Message_StartTextbox(globalCtx, 0x3390, &this->actor); this->textId = 0x3390; } } } else if (CURRENT_DAY == 3) { if (EnMaYto_HasSpokeToPlayerToday()) { EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33C5, &this->actor); + Message_StartTextbox(globalCtx, 0x33C5, &this->actor); this->textId = 0x33C5; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 3); - func_801518B0(globalCtx, 0x33C4, &this->actor); + Message_StartTextbox(globalCtx, 0x33C4, &this->actor); this->textId = 0x33C4; func_80151BB4(globalCtx, 6); } @@ -1161,37 +1161,37 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (Player_GetMask(globalCtx)) { case PLAYER_MASK_ROMANI: - func_801518B0(globalCtx, 0x235D, &this->actor); + Message_StartTextbox(globalCtx, 0x235D, &this->actor); this->textId = 0x235D; break; case PLAYER_MASK_CIRCUS_LEADER: - func_801518B0(globalCtx, 0x235E, &this->actor); + Message_StartTextbox(globalCtx, 0x235E, &this->actor); this->textId = 0x235E; break; case PLAYER_MASK_KAFEIS_MASK: - func_801518B0(globalCtx, 0x235F, &this->actor); + Message_StartTextbox(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; break; case PLAYER_MASK_COUPLE: - func_801518B0(globalCtx, 0x2360, &this->actor); + Message_StartTextbox(globalCtx, 0x2360, &this->actor); this->textId = 0x2360; break; default: - func_801518B0(globalCtx, 0x2361, &this->actor); + Message_StartTextbox(globalCtx, 0x2361, &this->actor); this->textId = 0x2361; break; } } else { if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x339F, &this->actor); + Message_StartTextbox(globalCtx, 0x339F, &this->actor); this->textId = 0x339F; } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x3397, &this->actor); + Message_StartTextbox(globalCtx, 0x3397, &this->actor); this->textId = 0x3397; } } @@ -1199,24 +1199,24 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 2: if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x33A6, &this->actor); + Message_StartTextbox(globalCtx, 0x33A6, &this->actor); this->textId = 0x33A6; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A5, &this->actor); + Message_StartTextbox(globalCtx, 0x33A5, &this->actor); this->textId = 0x33A5; } break; case 3: if (EnMaYto_HasSpokeToPlayer()) { - func_801518B0(globalCtx, 0x33A8, &this->actor); + Message_StartTextbox(globalCtx, 0x33A8, &this->actor); this->textId = 0x33A8; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A7, &this->actor); + Message_StartTextbox(globalCtx, 0x33A7, &this->actor); this->textId = 0x33A7; } break; @@ -1225,26 +1225,26 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { // if (AliensDefeated) - if (gSaveContext.save.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (CURRENT_DAY == 2) { if (this->unk310 == 1) { - func_801518B0(globalCtx, 0x33AE, &this->actor); + Message_StartTextbox(globalCtx, 0x33AE, &this->actor); this->textId = 0x33AE; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); - func_801518B0(globalCtx, 0x33A9, &this->actor); + Message_StartTextbox(globalCtx, 0x33A9, &this->actor); this->textId = 0x33A9; } } else if (CURRENT_DAY == 3) { if (this->unk310 == 1) { - func_801518B0(globalCtx, 0x33CB, &this->actor); + Message_StartTextbox(globalCtx, 0x33CB, &this->actor); this->textId = 0x33CB; } else { this->unk310 = 1; EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 0, 1); - func_801518B0(globalCtx, 0x33C6, &this->actor); + Message_StartTextbox(globalCtx, 0x33C6, &this->actor); this->textId = 0x33C6; } } @@ -1252,22 +1252,22 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { if (EnMaYto_HasSpokeToPlayer()) { this->unk31E = 2; EnMaYto_SetFaceExpression(this, 5, 3); - func_801518B0(globalCtx, 0x33B3, &this->actor); + Message_StartTextbox(globalCtx, 0x33B3, &this->actor); this->textId = 0x33B3; func_80151BB4(globalCtx, 6); } else { EnMaYto_SetTalkedFlag(); EnMaYto_SetFaceExpression(this, 5, 3); - func_801518B0(globalCtx, 0x33B1, &this->actor); + Message_StartTextbox(globalCtx, 0x33B1, &this->actor); this->textId = 0x33B1; } } } void EnMaYto_ChangeAnim(EnMaYto* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80B90C78(EnMaYto* this, GlobalContext* globalCtx) { @@ -1348,7 +1348,7 @@ void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouth } void EnMaYto_InitFaceExpression(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYto_SetFaceExpression(this, 0, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 0); } else { @@ -1360,19 +1360,19 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { s32 EnMaYto_HasSpokeToPlayerToday(void) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.save.weekEventReg[0xD] & 0x4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } break; case 2: - if (gSaveContext.save.weekEventReg[0xD] & 0x8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } break; case 3: - if (gSaveContext.save.weekEventReg[0xD] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } break; @@ -1384,17 +1384,17 @@ s32 EnMaYto_HasSpokeToPlayer(void) { // Please note each case doesn't have their respective `break`s. switch (CURRENT_DAY) { case 3: - if (gSaveContext.save.weekEventReg[0xD] & 0x10) { + if (gSaveContext.save.weekEventReg[13] & 0x10) { return true; } case 2: - if (gSaveContext.save.weekEventReg[0xD] & 0x8) { + if (gSaveContext.save.weekEventReg[13] & 8) { return true; } case 1: - if (gSaveContext.save.weekEventReg[0xD] & 0x4) { + if (gSaveContext.save.weekEventReg[13] & 4) { return true; } } @@ -1404,15 +1404,15 @@ s32 EnMaYto_HasSpokeToPlayer(void) { void EnMaYto_SetTalkedFlag(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.save.weekEventReg[0xD] |= 0x4; + gSaveContext.save.weekEventReg[13] |= 4; break; case 2: - gSaveContext.save.weekEventReg[0xD] |= 0x8; + gSaveContext.save.weekEventReg[13] |= 8; break; case 3: - gSaveContext.save.weekEventReg[0xD] |= 0x10; + gSaveContext.save.weekEventReg[13] |= 0x10; break; } } @@ -1464,7 +1464,7 @@ void EnMaYto_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; OPEN_DISPS(globalCtx->state.gfxCtx); - if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.save.weekEventReg[0x16] & 1)) { // Alieans defeated + if (this->type == MA_YTO_TYPE_BARN && (gSaveContext.save.weekEventReg[22] & 1)) { // Aliens defeated gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gCremiaWoodenBox); } 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 0929b31cf..29eb6cdcc 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 @@ -7,7 +7,7 @@ #include "z_en_ma_yts.h" #include "objects/object_ma1/object_ma1.h" -#define FLAGS 0x02100009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnMaYts*)thisx) @@ -78,29 +78,29 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static struct_80B8E1A8 sAnimationInfo[] = { - { &object_ma1_Anim_009E58, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_009E58, 1.0f, 0, -6.0f }, // Idle anim - { &object_ma1_Anim_018948, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_018948, 1.0f, 2, -6.0f }, // Starts holding hands anim - { &object_ma1_Anim_01B76C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_01B76C, 1.0f, 0, -6.0f }, // Holnding hands anim - { &object_ma1_Anim_007328, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007328, 1.0f, 0, -6.0f }, // Walking anim - { &object_ma1_Anim_014088, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_014088, 1.0f, 0, -6.0f }, // - { &object_ma1_Anim_002A8C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_002A8C, 1.0f, 0, -6.0f }, // Looking around anim - { &object_ma1_Anim_015B7C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_015B7C, 1.0f, 0, -6.0f }, // Shoot arrow anim - { &object_ma1_Anim_007D98, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_007D98, 1.0f, 0, -6.0f }, // Sitting anim - { &object_ma1_Anim_00852C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_00852C, 1.0f, 0, -6.0f }, // Sitting traumatized anim - { &object_ma1_Anim_008F6C, 1.0f, 0, 0.0f }, - { &object_ma1_Anim_008F6C, 1.0f, 0, -6.0f }, // Sitting sad anim - { &object_ma1_Anim_0180DC, 1.0f, 2, 0.0f }, - { &object_ma1_Anim_0180DC, 1.0f, 2, -6.0f }, // Turns around anim +static AnimationSpeedInfo sAnimationInfo[] = { + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_009E58, 1.0f, ANIMMODE_LOOP, -6.0f }, // Idle anim + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_018948, 1.0f, ANIMMODE_ONCE, -6.0f }, // Starts holding hands anim + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_01B76C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Holnding hands anim + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007328, 1.0f, ANIMMODE_LOOP, -6.0f }, // Walking anim + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_014088, 1.0f, ANIMMODE_LOOP, -6.0f }, // + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_002A8C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Looking around anim + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_015B7C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Shoot arrow anim + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_007D98, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting anim + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_00852C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting traumatized anim + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_ma1_Anim_008F6C, 1.0f, ANIMMODE_LOOP, -6.0f }, // Sitting sad anim + { &object_ma1_Anim_0180DC, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_ma1_Anim_0180DC, 1.0f, ANIMMODE_ONCE, -6.0f }, // Turns around anim }; static TexturePtr sMouthTextures[] = { @@ -115,9 +115,9 @@ static TexturePtr sEyeTextures[] = { }; void EnMaYts_ChangeAnim(EnMaYts* this, s32 index) { - Animation_Change(&this->skelAnime, sAnimationInfo[index].animationSeg, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimationInfo[index].animationSeg), sAnimationInfo[index].mode, - sAnimationInfo[index].transitionRate); + Animation_Change(&this->skelAnime, sAnimationInfo[index].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimationInfo[index].animation), sAnimationInfo[index].mode, + sAnimationInfo[index].morphFrames); } void func_80B8D12C(EnMaYts* this, GlobalContext* globalCtx) { @@ -145,7 +145,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SITTING: this->actor.targetMode = 6; // Day 1 or "Winning" the alien invasion - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_ChangeAnim(this, 14); } else { EnMaYts_ChangeAnim(this, 18); @@ -178,14 +178,14 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case 2: // Failing the alien invasion - if (!(gSaveContext.save.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; } break; case 3: // "Winning" the alien invasion - if (gSaveContext.save.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -194,7 +194,7 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_BARN: // Failing the alien invasion - if (!(gSaveContext.save.weekEventReg[0x16] & 1)) { + if (!(gSaveContext.save.weekEventReg[22] & 1)) { return false; } else if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; @@ -203,7 +203,7 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SLEEPING: // "Winning" the alien invasion - if (gSaveContext.save.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { return false; } break; @@ -250,7 +250,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[0x16] & 1)) { + if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -268,7 +268,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->mouthTexIndex = 0; this->unk_32C = 2; EnMaYts_SetupEndCreditsHandler(this); - } else if (CURRENT_DAY == 2 && gSaveContext.save.isNight == 1 && (gSaveContext.save.weekEventReg[0x16] & 1)) { + } else if (CURRENT_DAY == 2 && gSaveContext.save.isNight == 1 && (gSaveContext.save.weekEventReg[22] & 1)) { EnMaYts_SetupStartDialogue(this); } else { EnMaYts_SetupDoNothing(this); @@ -298,46 +298,46 @@ void EnMaYts_StartDialogue(EnMaYts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (!(gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { - if (!(gSaveContext.save.weekEventReg[0x41] & 0x80)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x80)) { // Saying to non-human Link: "Cremia went to town." - gSaveContext.save.weekEventReg[0x41] |= 0x80; + gSaveContext.save.weekEventReg[65] |= 0x80; EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x335F, &this->actor); + Message_StartTextbox(globalCtx, 0x335F, &this->actor); this->textId = 0x335F; } else { // Saying to non-human Link: "Pretend you did not hear that." EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3362, &this->actor); + Message_StartTextbox(globalCtx, 0x3362, &this->actor); this->textId = 0x3362; func_80151BB4(globalCtx, 5); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_NONE) { - if (!(gSaveContext.save.weekEventReg[0x41] & 0x40)) { - gSaveContext.save.weekEventReg[0x41] |= 0x40; + if (!(gSaveContext.save.weekEventReg[65] & 0x40)) { + gSaveContext.save.weekEventReg[65] |= 0x40; EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3363, &this->actor); + Message_StartTextbox(globalCtx, 0x3363, &this->actor); this->textId = 0x3363; } else { EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3366, &this->actor); + Message_StartTextbox(globalCtx, 0x3366, &this->actor); this->textId = 0x3366; func_80151BB4(globalCtx, 5); } - } else if (!(gSaveContext.save.weekEventReg[0x15] & 0x20)) { + } else if (!(gSaveContext.save.weekEventReg[21] & 0x20)) { EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x3367, &this->actor); + Message_StartTextbox(globalCtx, 0x3367, &this->actor); this->textId = 0x3367; } else { - if (!(gSaveContext.save.weekEventReg[0x41] & 0x20)) { + if (!(gSaveContext.save.weekEventReg[65] & 0x20)) { // Saying to Grasshopper: "Cremia went to town." - gSaveContext.save.weekEventReg[0x41] |= 0x20; + gSaveContext.save.weekEventReg[65] |= 0x20; EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3369, &this->actor); + Message_StartTextbox(globalCtx, 0x3369, &this->actor); this->textId = 0x3369; } else { // Saying to Grasshopper: "You're our bodyguard." EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336C, &this->actor); + Message_StartTextbox(globalCtx, 0x336C, &this->actor); this->textId = 0x336C; func_80151BB4(globalCtx, 5); } @@ -359,7 +359,7 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { break; case 6: // End conversation - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { EnMaYts_SetupStartDialogue(this); } break; @@ -374,21 +374,21 @@ void EnMaYts_DialogueHandler(EnMaYts* this, GlobalContext* globalCtx) { } void EnMaYts_SetupEndCreditsHandler(EnMaYts* this) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; EnMaYts_SetFaceExpression(this, 0, 0); this->actionFunc = EnMaYts_EndCreditsHandler; } static u16 D_80B8E32C = 99; void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x78) != 0) { - u32 actionIndex = func_800EE200(globalCtx, 0x78); + if (Cutscene_CheckActorAction(globalCtx, 120)) { + s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 120); - if (globalCtx->csCtx.frames == globalCtx->csCtx.npcActions[actionIndex]->startFrame) { - if (globalCtx->csCtx.npcActions[actionIndex]->unk0 != D_80B8E32C) { - D_80B8E32C = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (globalCtx->csCtx.frames == globalCtx->csCtx.actorActions[actionIndex]->startFrame) { + if (globalCtx->csCtx.actorActions[actionIndex]->action != D_80B8E32C) { + D_80B8E32C = globalCtx->csCtx.actorActions[actionIndex]->action; this->endCreditsFlag = 0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: this->hasBow = true; EnMaYts_ChangeAnim(this, 0); @@ -412,9 +412,9 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); if ((D_80B8E32C == 2) && (this->endCreditsFlag == 0) && - (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) != 0)) { + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->endCreditsFlag++; EnMaYts_ChangeAnim(this, 5); } @@ -426,50 +426,50 @@ void EnMaYts_EndCreditsHandler(EnMaYts* this, GlobalContext* globalCtx) { // Select the following dialogue based on the current one, and an appropiate face expression void EnMaYts_ChooseNextDialogue(EnMaYts* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (this->textId) { case 0x335F: EnMaYts_SetFaceExpression(this, 0, 2); - func_801518B0(globalCtx, 0x3360, &this->actor); + Message_StartTextbox(globalCtx, 0x3360, &this->actor); this->textId = 0x3360; break; case 0x3360: EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3361, &this->actor); + Message_StartTextbox(globalCtx, 0x3361, &this->actor); this->textId = 0x3361; func_80151BB4(globalCtx, 5); break; case 0x3363: EnMaYts_SetFaceExpression(this, 1, 1); - func_801518B0(globalCtx, 0x3364, &this->actor); + Message_StartTextbox(globalCtx, 0x3364, &this->actor); this->textId = 0x3364; break; case 0x3364: EnMaYts_SetFaceExpression(this, 4, 2); - func_801518B0(globalCtx, 0x3365, &this->actor); + Message_StartTextbox(globalCtx, 0x3365, &this->actor); this->textId = 0x3365; func_80151BB4(globalCtx, 5); break; case 0x3367: EnMaYts_SetFaceExpression(this, 4, 3); - func_801518B0(globalCtx, 0x3368, &this->actor); + Message_StartTextbox(globalCtx, 0x3368, &this->actor); this->textId = 0x3368; func_80151BB4(globalCtx, 5); break; case 0x3369: EnMaYts_SetFaceExpression(this, 0, 0); - func_801518B0(globalCtx, 0x336A, &this->actor); + Message_StartTextbox(globalCtx, 0x336A, &this->actor); this->textId = 0x336A; break; case 0x336A: EnMaYts_SetFaceExpression(this, 3, 3); - func_801518B0(globalCtx, 0x336B, &this->actor); + Message_StartTextbox(globalCtx, 0x336B, &this->actor); this->textId = 0x336B; func_80151BB4(globalCtx, 5); break; 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 0da65401e..907ba619b 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -7,7 +7,7 @@ #include "z_en_mag.h" #include "objects/object_mag/object_mag.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnMag*)thisx) @@ -382,7 +382,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_A) || CHECK_BTN_ALL(CONTROLLER1(globalCtx)->press.button, BTN_B)) { if (globalCtx->sceneLoadFlag != 0x14) { - func_801A3F54(false); + Audio_SetCutsceneFlag(false); D_801BB12C++; if (D_801BB12C >= 2) { D_801BB12C = 0; 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 7d379c08d..9d6f6312e 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -5,8 +5,10 @@ */ #include "z_en_maruta.h" +#include "overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h" +#include "objects/object_maruta/object_maruta.h" -#define FLAGS 0x00000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10) #define THIS ((EnMaruta*)thisx) @@ -15,16 +17,25 @@ void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx); void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B372B8(EnMaruta* this); void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37364(EnMaruta* this); void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx); +void func_80B373F4(EnMaruta* this); void func_80B37428(EnMaruta* this, GlobalContext* globalCtx); void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx); void func_80B37950(EnMaruta* this, GlobalContext* globalCtx); void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37A14(EnMaruta* this); void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx); void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B37C04(s16* arg0); +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx); +void func_80B38060(EnMaruta* this, Vec3f* arg1); +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4); +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1); -#if 0 const ActorInit En_Maruta_InitVars = { ACTOR_EN_MARUTA, ACTORCAT_PROP, @@ -37,15 +48,94 @@ const ActorInit En_Maruta_InitVars = { (ActorFunc)EnMaruta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B38AFC = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +Gfx* D_80B386A0[] = { + object_maruta_DL_002220, object_maruta_DL_0023D0, object_maruta_DL_002568, object_maruta_DL_002660, + object_maruta_DL_002758, object_maruta_DL_002850, object_maruta_DL_002948, object_maruta_DL_002AE0, +}; + +u8 D_80B386C0[] = { + 0xFF, 0x2B, 0xD4, 0x17, 0xE8, 0x55, 0xAA, 0x0F, 0xF0, +}; + +s32 D_80B386CC[] = { + 5, 5, 3, 3, 7, 7, 7, 7, 3, 3, 3, 3, 7, 7, 3, 3, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, +}; + +Vec3f D_80B38754 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B38760 = { -2.0f, 3.0f, 0.0f }; +Vec3f D_80B3876C = { 2.0f, 3.0f, 0.0f }; +Vec3f D_80B38778 = { -2.0f, 10.0f, 0.0f }; +Vec3f D_80B38784 = { -2.5f, 5.0f, 0.0f }; +Vec3f D_80B38790 = { -3.0f, 10.0f, 0.0f }; +Vec3f D_80B3879C = { 2.5f, 5.0f, 0.0f }; +Vec3f D_80B387A8 = { 3.0f, 10.0f, 0.0f }; +Vec3f D_80B387B4 = { -1.0f, 7.0f, -1.0f }; +Vec3f D_80B387C0 = { 1.0f, 7.0f, -1.0f }; +Vec3f D_80B387CC = { 0.0f, 8.0f, -1.5f }; +Vec3f D_80B387D8 = { 0.0f, 8.0f, -1.5f }; + +Vec3f D_80B387E4[] = { + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -10.0f, 460.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, { 10.0f, 460.0f, 0.0f }, { -40.0f, 315.0f, 0.0f }, + { 40.0f, 315.0f, 0.0f }, { 0.0f, 140.0f, 0.0f }, { 0.0f, 445.0f, 0.0f }, +}; + +Vec3f D_80B38850[] = { + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, -1.0f }, { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f }, + { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, -1.0f }, { -1.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, +}; + +Vec3f D_80B388BC[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 350.0f, -78.0f }, { -90.0f, 170.0f, -78.0f }, { -90.0f, 170.0f, 78.0f }, { 90.0f, 350.0f, 78.0f }, +}; + +Vec3f D_80B3891C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 170.0f, -78.0f }, { -90.0f, 350.0f, -78.0f }, { -90.0f, 350.0f, 78.0f }, { 90.0f, 170.0f, 78.0f }, +}; + +Vec3f D_80B3897C[] = { + { 0.0f, 630.0f, -104.0f }, { -90.0f, 630.0f, -52.0f }, { -90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { -90.0f, 0.0f, -52.0f }, { -90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B389DC[] = { + { 0.0f, 630.0f, -104.0f }, { 90.0f, 630.0f, -52.0f }, { 90.0f, 630.0f, 52.0f }, { 0.0f, 630.0f, 104.0f }, + { 0.0f, 0.0f, -104.0f }, { 90.0f, 0.0f, -52.0f }, { 90.0f, 0.0f, 52.0f }, { 0.0f, 0.0f, 104.0f }, +}; + +Vec3f D_80B38A3C[] = { + { 90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, -78.0f }, { -90.0f, 630.0f, 78.0f }, { 90.0f, 630.0f, 78.0f }, + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, +}; + +Vec3f D_80B38A9C[] = { + { 90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, -78.0f }, { -90.0f, 260.0f, 78.0f }, { 90.0f, 260.0f, 78.0f }, + { 90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, -78.0f }, { -90.0f, 20.0f, 78.0f }, { 90.0f, 20.0f, 78.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 12, 65, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B38B28 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -80,71 +170,530 @@ static DamageTable D_80B38B28 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B38B48 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B38B54 = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80B38AFC; -extern DamageTable D_80B38B28; -extern CollisionCheckInfoInit2 D_80B38B48; +void EnMaruta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMaruta* this = THIS; + s32 i; -extern UNK_TYPE D_06002EC0; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Init.s") + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Destroy.s") + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372B8.s") + this->actor.colChkInfo.health = 1; + this->actor.world.pos.y -= 4.0f; + this->actor.home.pos.y -= 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B372CC.s") + this->unk_210 = ENMARUTA_GET_FF00(&this->actor); + this->unk_218 = 0; + this->unk_21A = 0; + this->unk_1A0 = NULL; + this->unk_21C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37364.s") + this->unk_194.x = 0.0f; + this->unk_194.y = 0.0f; + this->unk_194.z = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3738C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + this->unk_1A4[i] = D_80B38B54; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B373F4.s") + this->unk_214 = -1; + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37428.s") + if (this->unk_210 == 0) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374B8.s") + if (this->unk_210 == 0) { + if (ENMARUTA_GET_FF(&this->actor) == 0xFF) { + func_80B372B8(this); + } else { + func_80B37364(this); + } + } else { + func_80B37590(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B374FC.s") +void EnMaruta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37590.s") + if (this->unk_210 == 0) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37950.s") +void func_80B372B8(EnMaruta* this) { + this->actionFunc = func_80B372CC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37998.s") +void func_80B372CC(EnMaruta* this, GlobalContext* globalCtx) { + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B379C0.s") + if (temp_v1 > 0x1555) { + this->actor.shape.rot.y += 0x2AAA; + } else if (temp_v1 < -0x1555) { + this->actor.shape.rot.y -= 0x2AAA; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A14.s") + if (this->unk_220 == 1) { + func_80B373F4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A64.s") + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37A8C.s") + kendoJs->unk_292 = this->actor.isTargeted; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37AA0.s") +void func_80B37364(EnMaruta* this) { + this->actor.world.pos.y = this->actor.home.pos.y - 630.0f; + this->actionFunc = func_80B3738C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37B78.s") +void func_80B3738C(EnMaruta* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.4f, 100.0f, 10.0f) == 0.0f) { + func_80B372B8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C04.s") +void func_80B373F4(EnMaruta* this) { + this->collider.base.acFlags |= AC_HIT; + this->actor.velocity.y = 0.0f; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B37428; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37C60.s") +void func_80B37428(EnMaruta* this, GlobalContext* globalCtx) { + if ((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } else { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37CA0.s") + kendoJs->unk_28C--; + } + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B37EC0.s") +void func_80B374B8(EnMaruta* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->actionFunc != func_80B37428) { + this->unk_21E = 0; + this->actor.gravity = -2.0f; + this->actionFunc = func_80B374FC; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38028.s") +void func_80B374FC(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B38060.s") + if (((this->actor.floorHeight - 630.0f) < this->actor.world.pos.y) && (this->unk_21E > 30)) { + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B3828C.s") + this->unk_21E++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/func_80B382E4.s") +void func_80B37590(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp48; + s16 sp46; + Vec3f sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Update.s") + this->unk_21E = 0; + this->unk_21C = 0; + this->actor.gravity = -2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Maruta/EnMaruta_Draw.s") + switch (this->unk_210) { + case 2: + sp48 = D_80B38754; + this->unk_1A0 = D_80B388BC; + break; + + case 4: + if (player->swordAnimation == 8) { + sp48 = D_80B3876C; + } else { + sp48 = D_80B38778; + } + this->unk_1A0 = D_80B3891C; + break; + + case 5: + if (player->swordAnimation == 0) { + sp48 = D_80B38784; + } else { + sp48 = D_80B38790; + } + this->unk_1A0 = D_80B3897C; + break; + + case 6: + if (player->swordAnimation == 0) { + sp48 = D_80B3879C; + } else { + sp48 = D_80B387A8; + } + this->unk_1A0 = D_80B389DC; + break; + + case 8: + if (player->swordAnimation == 4) { + sp48 = D_80B387B4; + } else { + sp48 = D_80B387C0; + } + this->unk_1A0 = D_80B38A3C; + break; + + case 7: + sp48 = D_80B387CC; + this->unk_1A0 = D_80B38A9C; + break; + + default: + sp48 = D_80B38B54; + break; + } + + sp46 = this->actor.shape.rot.y; + this->actor.velocity.x = (sp48.x * Math_CosS(sp46) + (Math_SinS(sp46) * sp48.z)); + this->actor.velocity.y = sp48.y; + this->actor.velocity.z = (-sp48.x * Math_SinS(sp46) + (Math_CosS(sp46) * sp48.z)); + + sp38 = D_80B38850[this->unk_210]; + + func_80B3828C(&sp38, &this->unk_194, Rand_Next() & 0xFFF, Rand_Next() & 0xFFF, 0); + this->unk_21A = Rand_Next() & 0x7FF; + + if (this->unk_210 == 7) { + this->unk_21A |= 0x3F; + } else { + this->unk_21A |= 0xFF; + } + + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80B37950; +} + +void func_80B37950(EnMaruta* this, GlobalContext* globalCtx) { + this->unk_218 += this->unk_21A; + this->actor.velocity.y += this->actor.gravity; + func_80B37EC0(this, globalCtx); + Actor_UpdatePos(&this->actor); +} + +void func_80B37998(EnMaruta* this) { + this->unk_21E = 0; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + this->unk_21A = 0; + this->actionFunc = func_80B379C0; +} + +void func_80B379C0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E == 40) { + func_80B37A14(this); + } else { + this->unk_21E++; + } + func_80B37C04(&this->unk_218); +} + +void func_80B37A14(EnMaruta* this) { + s16 temp = this->unk_218 & 0x7FFF; + + if (((this->unk_210 == 5) || (this->unk_210 == 6)) && !temp) { + this->unk_21E = 100; + } else { + this->unk_21E = 0; + } + this->actionFunc = func_80B37A64; +} + +void func_80B37A64(EnMaruta* this, GlobalContext* globalCtx) { + if (this->unk_21E > 100) { + this->actor.colChkInfo.health = 0; + } else { + this->unk_21E++; + } +} + +void func_80B37A8C(EnMaruta* this) { + this->actionFunc = func_80B37AA0; +} + +void func_80B37AA0(EnMaruta* this, GlobalContext* globalCtx) { + if (this->actor.scale.y == 0.0f) { + if (this->actor.scale.x == 0.0f) { + Actor_MarkForDeath(&this->actor); + return; + } + Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 0.2f, 0.01f, 0.001f); + Math_SmoothStepToF(&this->actor.scale.z, 0.0f, 0.2f, 0.01f, 0.001f); + } else { + Math_SmoothStepToF(&this->actor.scale.y, 0.0f, 0.2f, 0.003f, 0.001f); + } +} + +s32 func_80B37B78(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, 0x8000); + + temp_v1 = BINANG_SUB(temp_v1, player->actor.shape.rot.y); + if ((ABS_ALT(temp_v1) < 0x1555) || + ((player->swordState != 0) && ((player->swordAnimation == 4) || (player->swordAnimation == 6) || + (player->swordAnimation == 0x1E) || (player->swordAnimation == 0x20)))) { + return true; + } + return false; +} + +void func_80B37C04(s16* arg0) { + s16 temp_a1 = *arg0 & 0xC000; + s16 temp = *arg0 & 0x3FFF; + + if (temp > 0x2000) { + temp_a1 += 0x4000; + } + Math_SmoothStepToS(arg0, temp_a1, 1, 0xAAA, 0xB6); +} + +void func_80B37C60(EnMaruta* this) { + if ((this->actionFunc != func_80B37AA0) && (this->actor.colChkInfo.health == 0)) { + func_80B37A8C(this); + } +} + +void func_80B37CA0(EnMaruta* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->actionFunc == func_80B372CC) || (this->actionFunc == func_80B3738C) || + (this->actionFunc == func_80B374FC) || (this->actionFunc == func_80B37AA0) || + ((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); + + if (D_80B386CC[player->swordAnimation] != 0) { + s32 temp = D_80B386CC[player->swordAnimation] + 1; + + temp = (temp << 8) & 0xFF00; + this->unk_210 = D_80B386CC[player->swordAnimation]; + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MARUTA, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, + this->actor.shape.rot.y, 0, temp); + this->actor.world.rot.y = this->actor.shape.rot.y; + if ((this->unk_210 == 5) || ((this->unk_210 == 7) && (player->swordAnimation == 0xC))) { + func_80B37590(this, globalCtx); + } else { + func_80B374B8(this); + } + + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_KENDO_JS)) { + EnKendoJs* kendoJs = (EnKendoJs*)this->actor.parent; + + kendoJs->unk_28E = 1; + kendoJs->unk_28C--; + } + return; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (func_80B37B78(this, globalCtx) && (this->actionFunc == func_80B372CC)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_80B37EC0(EnMaruta* this, GlobalContext* globalCtx) { + Vec3f sp34 = this->unk_204; + s32 phi_a2 = -1; + s32 i; + f32 temp; + + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + if (this->unk_1A4[i].y < sp34.y) { + sp34 = this->unk_1A4[i]; + phi_a2 = i; + } + this->unk_214 = phi_a2; + } + + if (sp34.y < this->actor.floorHeight) { + this->unk_218 -= this->unk_21A; + + temp = this->actor.floorHeight - sp34.y; + this->actor.velocity.y -= this->actor.gravity; + this->actor.velocity.x *= 0.6f; + this->actor.velocity.z *= 0.6f; + this->actor.world.pos.y += temp; + + if (this->actor.velocity.y < -this->actor.gravity) { + func_80B382E4(globalCtx, sp34); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_LOG_BOUND); + this->actor.velocity.y *= -0.6f; + func_80B38060(this, &sp34); + } + } +} + +f32 func_80B38028(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2) { + f32 x0 = arg0->x; + f32 z0 = arg0->z; + f32 dx = arg2->x - arg1->x; + f32 dz = arg2->z - arg1->z; + + return z0 * dx - x0 * dz; +} + +void func_80B38060(EnMaruta* this, Vec3f* arg1) { + Vec3f sp44; + s32 pad; + f32 temp_f0; + f32 phi_f2; + + func_80B3828C(&this->unk_194, &sp44, 0, this->actor.shape.rot.y, 0); + temp_f0 = func_80B38028(&sp44, &this->unk_204, arg1); + + if ((this->unk_210 == 5) || (this->unk_210 == 6)) { + phi_f2 = 8.0f; + } else if (this->unk_210 == 4) { + phi_f2 = 5.0f; + } else { + phi_f2 = 2.0f; + } + + if ((temp_f0 < phi_f2) && (-phi_f2 < temp_f0)) { + phi_f2 = 3.0f; + } else { + phi_f2 = 1.2f; + } + + if (temp_f0 > 0.0f) { + if (this->unk_21A > 0) { + this->unk_21A *= phi_f2; + } else { + this->unk_21A *= -0.8f; + } + } else { + if (this->unk_21A > 0) { + this->unk_21A *= -0.8f; + } else { + this->unk_21A *= phi_f2; + } + } + + if ((ABS_ALT(this->unk_21A) < 0x38E) && + (((this->unk_218 & 0x3FFF) < 0x71C) || ((this->unk_218 & 0x3FFF) >= 0x38E4))) { + this->actor.gravity *= 0.8f; + this->unk_21C++; + if (this->unk_21C == 2) { + func_80B37998(this); + } + } else if (ABS_ALT(this->unk_21A) > 0x38E) { + if (this->unk_21A < 0) { + this->unk_21A = -0x38E; + } else { + this->unk_21A = 0x38E; + } + } +} + +void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { + Matrix_StatePush(); + Matrix_InsertRotation(arg2, arg3, arg4, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(arg0, arg1); + Matrix_StatePop(); +} + +void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { + Vec3f sp84 = arg1; + Vec3f sp78; + Vec3f sp6C; + Color_RGBA8 sp68 = { 170, 130, 90, 255 }; + Color_RGBA8 sp64 = { 100, 60, 20, 255 }; + s32 i; + + sp6C.y = 0.0f; + sp84.y += 15.0f; + + for (i = 0; i < 10; i++) { + sp78.x = Rand_Centered() * 10.0f; + sp78.y = 2.0f * Rand_ZeroOne(); + sp78.z = Rand_Centered() * 10.0f; + sp6C.x = -0.2f * sp78.x; + sp6C.z = -0.2f * sp78.z; + func_800B0EB0(globalCtx, &sp84, &sp78, &sp6C, &sp68, &sp64, 60, 20, 10); + } +} + +void EnMaruta_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B37CA0(this, globalCtx); + func_80B37C60(this); +} + +void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMaruta* this = THIS; + Vec3f sp50; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_210 == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_maruta_DL_002EC0); + } else { + sp50 = D_80B387E4[this->unk_210]; + + Matrix_StatePush(); + Matrix_InsertTranslation(sp50.x, sp50.y, sp50.z, MTXMODE_APPLY); + Matrix_InsertRotationAroundUnitVector_s(this->unk_218, &this->unk_194, MTXMODE_APPLY); + Matrix_InsertTranslation(-sp50.x, -sp50.y, -sp50.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + for (i = 0; i < 8; i++) { + if (D_80B386C0[this->unk_210] & (1 << i)) { + gSPDisplayList(POLY_OPA_DISP++, D_80B386A0[i]); + } + } + + if (this->unk_1A0 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_1A4); i++) { + Matrix_MultiplyVector3fByState(&this->unk_1A0[i], &this->unk_1A4[i]); + } + Matrix_MultiplyVector3fByState(&sp50, &this->unk_204); + } + + Matrix_StatePop(); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h index df53fbe49..162618fc6 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -7,10 +7,24 @@ struct EnMaruta; typedef void (*EnMarutaActionFunc)(struct EnMaruta*, GlobalContext*); +#define ENMARUTA_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENMARUTA_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct EnMaruta { /* 0x0000 */ Actor actor; /* 0x0144 */ EnMarutaActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xDC]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ Vec3f unk_194; + /* 0x01A0 */ Vec3f* unk_1A0; + /* 0x01A4 */ Vec3f unk_1A4[8]; + /* 0x0204 */ Vec3f unk_204; + /* 0x0210 */ s32 unk_210; + /* 0x0214 */ s32 unk_214; + /* 0x0218 */ s16 unk_218; + /* 0x021A */ s16 unk_21A; + /* 0x021C */ s16 unk_21C; + /* 0x021E */ s16 unk_21E; + /* 0x0220 */ s16 unk_220; } EnMaruta; // size = 0x224 extern const ActorInit En_Maruta_InitVars; diff --git a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c index 6750c81da..d5e15c04d 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -6,7 +6,7 @@ #include "z_en_minideath.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnMinideath*)thisx) 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 9b395b55e..27192800e 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -8,7 +8,7 @@ #include "objects/object_fr/object_fr.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMinifrog*)thisx) @@ -130,14 +130,14 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { // Not spoken to MINIFROG_YELLOW if (!(gSaveContext.save.weekEventReg[34] & 1)) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; } this->actor.home.rot.x = this->actor.home.rot.z = 0; this->frog = NULL; } else { this->frog = EnMinifrog_GetFrog(globalCtx); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; // Frog has been returned if ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & @@ -224,22 +224,22 @@ void EnMinifrog_TurnToMissingFrog(EnMinifrog* this) { static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; static Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -void EnMinifrog_SetCamera(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SpawnDust(EnMinifrog* this, GlobalContext* globalCtx) { Vec3f pos; Vec3f vec5; Vec3f vel; Vec3f accel; s16 yaw; s16 pitch; - Vec3f eye; + Vec3f eye = GET_ACTIVE_CAM(globalCtx)->eye; s32 i; - eye = GET_ACTIVE_CAM(globalCtx)->eye; yaw = Math_Vec3f_Yaw(&eye, &this->actor.world.pos); pitch = -Math_Vec3f_Pitch(&eye, &this->actor.world.pos); vec5.x = this->actor.world.pos.x - (5.0f * Math_SinS(yaw) * Math_CosS(pitch)); vec5.y = this->actor.world.pos.y - (5.0f * Math_SinS(pitch)); vec5.z = this->actor.world.pos.z - (5.0f * Math_CosS(yaw) * Math_CosS(pitch)); + for (i = 0; i < 5; i++) { vel.x = randPlusMinusPoint5Scaled(4.0f); vel.y = randPlusMinusPoint5Scaled(4.0f); @@ -259,16 +259,16 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->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(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xD82: // "What has brought you all this way?" if (gSaveContext.save.weekEventReg[33] & 0x80) { // Mountain village is unfrozen @@ -284,7 +284,7 @@ void EnMinifrog_ReturnFrogCutscene(EnMinifrog* this, GlobalContext* globalCtx) { case 0xD85: // "I understand. I shall head for the mountains immediately." default: func_801477B4(globalCtx); - EnMinifrog_SetCamera(this, globalCtx); + EnMinifrog_SpawnDust(this, globalCtx); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_NPC_FADEAWAY); if (this->actor.cutscene != -1) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { @@ -471,7 +471,7 @@ void EnMinifrog_EndChoir(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_TurnToPlayer(this); EnMinifrog_Jump(this); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." + Message_StartTextbox(globalCtx, 0xD7E, &this->actor); // "Let us do it again sometime." this->actionFunc = EnMinifrog_YellowFrogDialog; } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); @@ -484,7 +484,7 @@ void EnMinifrog_GetFrogHP(EnMinifrog* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = EnMinifrog_EndChoir; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_NONE); } else { Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 10000.0f, 50.0f); @@ -496,7 +496,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { EnMinifrog_Jump(this); switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // Yes func_8019F208(); @@ -511,13 +511,13 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { } break; case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnMinifrog_SetJumpState(this); - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->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(globalCtx, globalCtx->msgCtx.unk11F04 + 1); - this->actor.flags &= ~0x10000; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + this->actor.flags &= ~ACTOR_FLAG_10000; gSaveContext.save.weekEventReg[34] |= 1; // Spoken to MINIFROG_YELLOW break; case 0xD78: // "Unfortunately, it seems not all of our members have gathered." @@ -525,7 +525,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { // 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(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0xD77: // "Let us begin our chorus" this->actionFunc = EnMinifrog_BeginChoirCutscene; @@ -549,7 +549,7 @@ void EnMinifrog_YellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx) { default: func_801477B4(globalCtx); this->actionFunc = EnMinifrog_SetupYellowFrogDialog; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; break; } } @@ -565,14 +565,15 @@ void EnMinifrog_SetupYellowFrogDialog(EnMinifrog* this, GlobalContext* globalCtx if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = EnMinifrog_YellowFrogDialog; if (!(gSaveContext.save.weekEventReg[34] & 1)) { // Not spoken with MINIFROG_YELLOW - func_801518B0(globalCtx, 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(globalCtx, 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..." } else { - func_801518B0(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." + Message_StartTextbox(globalCtx, 0xD7F, &this->actor); // "Well, if it isn't the great Don Gero." } } else if ((this->actor.xzDistToPlayer < 150.0f) && - (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || ((this->actor.flags & 0x10000) == 0x10000)) && + (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) || + CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) && Player_GetMask(globalCtx) == PLAYER_MASK_DON_GERO) { func_800B8614(&this->actor, globalCtx, 160.0f); } 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 b2b8dd5ba..4efc18714 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -7,7 +7,7 @@ #include "z_en_minislime.h" #include "overlays/actors/ovl_En_Bigslime/z_en_bigslime.h" -#define FLAGS 0x00000235 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200) #define THIS ((EnMinislime*)thisx) @@ -121,7 +121,7 @@ static DamageTable sDamageTable = { void EnMinislime_Init(Actor* thisx, GlobalContext* globalCtx) { EnMinislime* this = THIS; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->id = this->actor.params; @@ -506,8 +506,8 @@ void EnMinislime_SetupMoveToBigslime(EnMinislime* this) { } this->frozenAlpha = 0; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToBigslime; } @@ -562,8 +562,8 @@ void EnMinislime_SetupDefeatIdle(EnMinislime* this) { } this->frozenAlpha = 0; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actor.shape.rot.x = 0; @@ -630,8 +630,8 @@ void EnMinislime_SetupMoveToGekko(EnMinislime* this) { this->actor.velocity.y = 0.0f; this->collider.base.acFlags &= ~AC_ON; this->collider.base.ocFlags1 &= ~OC1_ON; - if ((this->actor.flags & 0x2000) == 0x2000) { - this->actor.flags &= ~0x2000; + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { + this->actor.flags &= ~ACTOR_FLAG_2000; } this->actionFunc = EnMinislime_MoveToGekko; @@ -720,7 +720,7 @@ void EnMinislime_Update(Actor* thisx, GlobalContext* globalCtx) { } else if ((this->actor.params == MINISLIME_FORM_BIGSLIME) && (this->actionFunc != EnMinislime_MoveToBigslime)) { EnMinislime_SetupMoveToBigslime(this); } else { - if ((this->actor.flags & 0x2000) == 0x2000) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000)) { this->collider.base.acFlags &= ~AC_HIT; return; } 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 514816f10..8c20b4106 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -6,7 +6,7 @@ #include "z_en_mk.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMk*)thisx) @@ -15,6 +15,7 @@ void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMk_Update(Actor* thisx, GlobalContext* globalCtx); void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx); +s32 func_80959524(GlobalContext* globalCtx); void func_809596A0(EnMk* this, GlobalContext* globalCtx); void func_80959774(EnMk* this, GlobalContext* globalCtx); void func_80959A24(EnMk* this, GlobalContext* globalCtx); @@ -22,7 +23,6 @@ void func_80959C94(EnMk* this, GlobalContext* globalCtx); void func_80959D28(EnMk* this, GlobalContext* globalCtx); void func_80959E18(EnMk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Mk_InitVars = { ACTOR_EN_MK, ACTORCAT_NPC, @@ -35,49 +35,453 @@ const ActorInit En_Mk_InitVars = { (ActorFunc)EnMk_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8095A260 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +s32 func_809592E0(EnMk* this, s16 index) { + AnimationHeader* sAnimations[] = { + &object_mk_Anim_001C38, &object_mk_Anim_000438, &object_mk_Anim_0007D8, + &object_mk_Anim_0010F4, &object_mk_Anim_001964, + }; -extern ColliderCylinderInit D_8095A260; + if (index == this->unk_27C) { + return false; + } -extern UNK_TYPE D_06001C38; + if ((index < 0) || (index >= 5)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809592E0.s") + Animation_PlayLoop(&this->skelAnime, sAnimations[index]); + this->unk_27C = index; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Init.s") +void EnMk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + s16 cs; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Destroy.s") + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -1.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mk_Skel_006CA0, &object_mk_Anim_001C38, this->jointTable, + this->morphTable, OBJECT_MK_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959524.s") + this->unk_27C = -1; + func_809592E0(this, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095954C.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959624.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_809596A0.s") + this->actionFunc = func_80959E18; + this->unk_27A = 0; + this->actor.targetMode = 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959774.s") + if (func_80959524(globalCtx) < 7) { + this->unk_27A |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959844.s") + 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); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959A24.s") + this->actor.cutscene = this->unk_276[0]; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959C94.s") +void EnMk_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959D28.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_80959E18.s") +s32 func_80959524(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Update.s") +void func_8095954C(EnMk* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, 0x7F)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 0x7F)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A150.s") + switch (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action) { + case 1: + case 2: + case 3: + case 4: + case 5: + func_809592E0(this, + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7F)]->action - 1); + break; + } + } else { + func_809592E0(this, 0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/func_8095A198.s") +void func_80959624(EnMk* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mk/EnMk_Draw.s") + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (this->unk_27A & 4) { + textId = 0xFB9; + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFBC; + } else { + textId = 0xFBB; + } + } else { + textId = 0xFBA; + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_809596A0(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->msgCtx.currentTextId == 0xFB9) || (globalCtx->msgCtx.currentTextId == 0xFBB) || + (globalCtx->msgCtx.currentTextId == 0xFBC)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80959774; + } + break; + + case 2: + this->actionFunc = func_80959774; + break; + } +} + +void func_80959774(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 3, 0x400, 0x80); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959624(this, globalCtx); + this->actionFunc = func_809596A0; + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 130.0f); + } + + func_8095954C(this, globalCtx); +} + +void func_80959844(EnMk* this, GlobalContext* globalCtx) { + u16 textId; + + if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + textId = 0xFB3; + } else if (gSaveContext.save.weekEventReg[20] & 0x40) { + textId = 0xFB9; + } else if (gSaveContext.save.weekEventReg[19] & 0x40) { + textId = 0xFB5; + } else if (func_80959524(globalCtx) >= 7) { + textId = 0xFB3; + } else { + switch (gSaveContext.save.playerForm) { + case PLAYER_FORM_DEKU: + if (gSaveContext.save.weekEventReg[19] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFAF; + } else { + textId = 0xFAE; + } + } else { + textId = 0xFAC; + } + break; + + case PLAYER_FORM_GORON: + if (gSaveContext.save.weekEventReg[19] & 8) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFAB; + } else { + textId = 0xFAA; + } + } else { + textId = 0xFA8; + } + break; + + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_HUMAN: + if (func_80959524(globalCtx) > 0) { + textId = 0xFA7; + } else if (gSaveContext.save.weekEventReg[19] & 4) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + textId = 0xFBF; + } else { + textId = 0xFA6; + } + } else { + textId = 0xFA0; + } + break; + + default: + if (func_80959524(globalCtx) > 0) { + textId = 0xFB0; + } else if (gSaveContext.save.weekEventReg[19] & 0x20) { + textId = 0xFB2; + } else { + textId = 0xFB1; + } + break; + } + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80959A24(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + this->unk_27A |= 1; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0xFA1: + case 0xFA3: + case 0xFA4: + case 0xFAA: + case 0xFAE: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0xFA2: + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0xFA5: + case 0xFA6: + case 0xFA7: + case 0xFA9: + case 0xFAB: + case 0xFAD: + case 0xFAF: + case 0xFB0: + case 0xFB2: + case 0xFBD: + case 0xFBE: + case 0xFBF: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFA0: + gSaveContext.save.weekEventReg[19] |= 4; + func_80151938(globalCtx, 0xFA1); + break; + + case 0xFA8: + gSaveContext.save.weekEventReg[19] |= 8; + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBD); + break; + } + func_80151938(globalCtx, 0xFA9); + break; + + case 0xFAC: + gSaveContext.save.weekEventReg[19] |= 0x10; + if (gSaveContext.save.weekEventReg[55] & 0x80) { + func_80151938(globalCtx, 0xFBE); + break; + } + func_80151938(globalCtx, 0xFAD); + break; + + case 0xFB1: + gSaveContext.save.weekEventReg[19] |= 0x20; + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + case 0xFB3: + case 0xFB4: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + this->actor.flags &= ~ACTOR_FLAG_10000; + break; + + case 0xFB5: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80959E18; + break; + } + } + break; + } +} + +void func_80959C94(EnMk* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80959A24; + this->unk_27A &= ~2; + Message_StartTextbox(globalCtx, 0xFB3, &this->actor); + } else { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 350.0f, 1000.0f, -1); + } +} + +void func_80959D28(EnMk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((globalCtx->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if (gSaveContext.save.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + this->unk_27A |= 4; + } else { + this->actionFunc = func_80959E18; + } + this->actor.cutscene = this->unk_276[0]; + } else { + if (this->actor.cutscene != -1) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actor.cutscene = -1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + func_8095954C(this, globalCtx); + } +} + +void func_80959E18(EnMk* this, GlobalContext* globalCtx) { + s32 pad; + s16 sp22 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + SkelAnime_Update(&this->skelAnime); + + if (gSaveContext.save.weekEventReg[20] & 0x40) { + this->unk_27A &= ~1; + this->actionFunc = func_80959774; + this->actor.home.rot.y += 0x4E20; + return; + } + + if (func_800B8718(&this->actor, &globalCtx->state)) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = func_80959D28; + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + this->actor.cutscene = this->unk_276[0]; + gSaveContext.save.weekEventReg[20] |= 0x40; + Item_Give(globalCtx, ITEM_SONG_NOVA); + } else { + this->actor.cutscene = this->unk_276[1]; + } + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80959844(this, globalCtx); + this->actionFunc = func_80959A24; + this->unk_27A |= 1; + } else if ((this->unk_27A & 2) && (func_80959524(globalCtx) >= 7)) { + this->actionFunc = func_80959C94; + } else if ((this->actor.xzDistToPlayer < 120.0f) && (ABS_ALT(sp22) <= 0x4300)) { + this->unk_27A |= 1; + func_800B8614(&this->actor, globalCtx, 200.0f); + if (!(gSaveContext.save.weekEventReg[20] & 0x40) && (gSaveContext.save.weekEventReg[19] & 0x40)) { + func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); + } + } else { + this->unk_27A &= ~1; + } + func_8095954C(this, globalCtx); +} + +void EnMk_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMk* this = THIS; + Vec3s sp38; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if ((this->unk_27A & 1) && !Cutscene_CheckActorAction(globalCtx, 0x7F)) { + func_800E9250(globalCtx, &this->actor, &this->unk_270, &sp38, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_270.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_270.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnMk_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + rot->y -= this->unk_270.y; + rot->z += this->unk_270.x; + } + return false; +} + +Vec3f D_8095A2A0 = { 1000.0f, -100.0f, 0.0f }; + +void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMk* this = THIS; + + if (limbIndex == OBJECT_MK_LIMB_0B) { + Matrix_MultiplyVector3fByState(&D_8095A2A0, &this->actor.focus.pos); + } +} + +void EnMk_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMk* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMk_OverrideLimbDraw, EnMk_PostLimbDraw, &this->actor); +} 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 715a07c84..fee132ccd 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -2,6 +2,7 @@ #define Z_EN_MK_H #include "global.h" +#include "objects/object_mk/object_mk.h" struct EnMk; @@ -9,7 +10,14 @@ typedef void (*EnMkActionFunc)(struct EnMk*, GlobalContext*); typedef struct EnMk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; + /* 0x01D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; + /* 0x0222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x0270 */ Vec3s unk_270; + /* 0x0276 */ s16 unk_276[2]; + /* 0x027A */ u16 unk_27A; + /* 0x027C */ s16 unk_27C; /* 0x0280 */ EnMkActionFunc actionFunc; } EnMk; // size = 0x284 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 019e7a848..45eff8050 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -6,7 +6,7 @@ #include "z_en_mkk.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnMkk*)thisx) 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 f72ceaf9b..5f79cf9e4 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -7,7 +7,7 @@ #include "z_en_mm.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMm*)thisx) 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 94507b001..79b4987e9 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -6,7 +6,7 @@ #include "z_en_mm2.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMm2*)thisx) @@ -49,7 +49,7 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState != 2) { - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = EnMm2_WaitForRead; } @@ -64,7 +64,7 @@ void EnMm2_Reading(EnMm2* this, GlobalContext* globalCtx) { */ void EnMm2_WaitForRead(EnMm2* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x277B, &this->actor); + Message_StartTextbox(globalCtx, 0x277B, &this->actor); this->actionFunc = EnMm2_Reading; } else if ((this->actor.xzDistToPlayer < 60.0f) && (Player_IsFacingActor(&this->actor, 0x3000, globalCtx))) { func_800B8614(&this->actor, globalCtx, 110.0f); 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 3c9719008..0a4fb551f 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -5,8 +5,9 @@ */ #include "z_en_mm3.h" +#include "objects/object_mm/object_mm.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMm3*)thisx) @@ -15,7 +16,19 @@ void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx); void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A6F270(EnMm3* this); +void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx); +void func_80A6F9C8(EnMm3* this); +void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FBA0(EnMm3* this); +void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FE1C(EnMm3* this); +void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx); +void func_80A6FED8(EnMm3* this); +void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx); +s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx); +void func_80A70084(EnMm3* this, GlobalContext* globalCtx); + const ActorInit En_Mm3_InitVars = { ACTOR_EN_MM3, ACTORCAT_NPC, @@ -28,61 +41,532 @@ const ActorInit En_Mm3_InitVars = { (ActorFunc)EnMm3_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A703F0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +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 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 63, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80A7041C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfo sAnimations[] = { + { &object_mm_Anim_002238, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00A4E0, -1.0f, 0.0f, 0.0f, 2, -7.0f }, + { &object_mm_Anim_00C640, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00A4E0, 1.0f, 0.0f, 0.0f, 2, -7.0f }, + { &object_mm_Anim_000468, 1.0f, 0.0f, 0.0f, 0, -7.0f }, { &object_mm_Anim_00CD90, 1.0f, 0.0f, 0.0f, 0, -12.0f }, + { &object_mm_Anim_00DA50, 1.0f, 0.0f, 0.0f, 0, -12.0f }, { &object_mm_Anim_00DA50, 1.0f, 0.0f, 10.0f, 2, -10.0f }, +}; -extern ColliderCylinderInit D_80A703F0; -extern CollisionCheckInfoInit2 D_80A7041C; +#include "overlays/ovl_En_Mm3/ovl_En_Mm3.c" -extern UNK_TYPE D_0600A4E0; +Vec3f D_80A704F0 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Init.s") +TexturePtr D_80A704FC[] = { object_mm_Tex_002950, object_mm_Tex_002750 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Destroy.s") +void EnMm3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMm3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F22C.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 21.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_mm_Skel_0096E8, &object_mm_Anim_00A4E0, this->jointTable, + this->morphTable, 16); + Animation_Change(&this->skelAnime, &object_mm_Anim_00A4E0, -1.0f, Animation_GetLastFrame(&object_mm_Anim_00A4E0), + 0.0f, 2, 0.0f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + this->actor.parent = NULL; + this->actor.targetMode = 0; + this->unk_1DC = 1; + this->unk_2B4 = 0; + this->unk_2AE = 0; + this->unk_2B0 &= ~1; + this->actor.world.pos.y = this->actor.floorHeight; + func_80A6F270(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F270.s") +void EnMm3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMm3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F2C8.s") + gSaveContext.save.weekEventReg[63] &= (u8)~1; + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F3B4.s") +s32 func_80A6F22C(EnMm3* this) { + s16 abs = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F5E4.s") + abs = ABS_ALT(abs); + if (abs < 0x4000) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F9C8.s") +void func_80A6F270(EnMm3* this) { + this->unk_1DC = 1; + this->unk_2B0 &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->actionFunc = func_80A6F2C8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6F9DC.s") +void func_80A6F2C8(EnMm3* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + Message_StartTextbox(globalCtx, 0x278A, &this->actor); + this->unk_2B4 = 0x278A; + func_80A6F9C8(this); + } else if (func_80A6F22C(this)) { + func_800B8614(&this->actor, globalCtx, 100.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FBA0.s") + Math_SmoothStepToS(&this->unk_2A0.x, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A0.y, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A6.x, 0, 5, 0x1000, 0x100); + Math_SmoothStepToS(&this->unk_2A6.y, 0, 5, 0x1000, 0x100); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FBFC.s") +void func_80A6F3B4(EnMm3* this, GlobalContext* globalCtx) { + if (Message_ShouldAdvance(globalCtx)) { + switch (this->unk_2B4) { + case 0x278E: + if (globalCtx->msgCtx.choiceIndex == 0) { + if (this->unk_2B2 & 0x20) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + Rupees_ChangeBy(-globalCtx->msgCtx.unk1206C); + } else { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x279C, &this->actor); + this->unk_2B4 = 0x279C; + func_80151BB4(globalCtx, 0xB); + } + } else { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + } + } else { + func_8019F230(); + Message_StartTextbox(globalCtx, 0x278F, &this->actor); + this->unk_2B4 = 0x278F; + func_80151BB4(globalCtx, 0xB); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FE1C.s") + case 0x279A: + if (globalCtx->msgCtx.choiceIndex == 0) { + if (gSaveContext.save.playerData.rupees >= globalCtx->msgCtx.unk1206C) { + func_8019F208(); + Message_StartTextbox(globalCtx, 0x2790, &this->actor); + this->unk_2B4 = 0x2790; + Rupees_ChangeBy(-globalCtx->msgCtx.unk1206C); + } else { + play_sound(NA_SE_SY_ERROR); + Message_StartTextbox(globalCtx, 0x279C, &this->actor); + this->unk_2B4 = 0x279C; + func_80151BB4(globalCtx, 0xB); + } + } else { + func_8019F230(); + Message_StartTextbox(globalCtx, 0x279B, &this->actor); + this->unk_2B4 = 0x279B; + func_80151BB4(globalCtx, 0xB); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FE30.s") +void func_80A6F5E4(EnMm3* this, GlobalContext* globalCtx) { + if (((this->unk_2B4 != 0x2791) || (this->unk_2AC == 0)) && Message_ShouldAdvance(globalCtx)) { + switch (this->unk_2B4) { + case 0x278A: + if (func_80A6FFAC(this, globalCtx)) { + Message_StartTextbox(globalCtx, 0x279D, &this->actor); + this->unk_2B4 = 0x279D; + } else { + func_80A70084(this, globalCtx); + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + Message_StartTextbox(globalCtx, 0x27A0, &this->actor); + this->unk_2B4 = 0x27A0; + } else { + Message_StartTextbox(globalCtx, 0x278B, &this->actor); + this->unk_2B4 = 0x278B; + } + } + this->unk_1DC = 0; + this->unk_2B0 |= 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FED8.s") + case 0x278B: + case 0x27A0: + this->unk_2AE = 0; + Message_StartTextbox(globalCtx, 0x278C, &this->actor); + this->unk_2B4 = 0x278C; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FEEC.s") + case 0x278C: + Message_StartTextbox(globalCtx, 0x278D, &this->actor); + this->unk_2B4 = 0x278D; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A6FFAC.s") + case 0x279D: + this->unk_2AE = 0; + Message_StartTextbox(globalCtx, 0x279E, &this->actor); + this->unk_2B4 = 0x279E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A70084.s") + case 0x279E: + this->unk_2B2 |= 0x20; + Message_StartTextbox(globalCtx, 0x279F, &this->actor); + this->unk_2B4 = 0x279F; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Update.s") + case 0x278D: + case 0x279F: + Message_StartTextbox(globalCtx, 0x278E, &this->actor); + this->unk_2B4 = 0x278E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A701E0.s") + case 0x2791: + if (gSaveContext.unk_3DE0[0] == 1000) { + Message_StartTextbox(globalCtx, 0x2792, &this->actor); + this->unk_2B4 = 0x2792; + } else if ((gSaveContext.unk_3DE0[0] >= 1500)) { + Message_StartTextbox(globalCtx, 0x2797, &this->actor); + this->unk_2B4 = 0x2797; + } else if ((gSaveContext.unk_3DE0[0] <= 1050) && (gSaveContext.unk_3DE0[0] >= 950)) { + Message_StartTextbox(globalCtx, 0x2795, &this->actor); + this->unk_2B4 = 0x2795; + } else { + Message_StartTextbox(globalCtx, 0x2796, &this->actor); + this->unk_2B4 = 0x2796; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/func_80A702B0.s") + case 0x2792: + Message_StartTextbox(globalCtx, 0x2793, &this->actor); + this->unk_2B4 = 0x2793; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm3/EnMm3_Draw.s") + case 0x2793: + func_801477B4(globalCtx); + func_80A6FE1C(this); + func_80A6FE30(this, globalCtx); + break; + + case 0x2795: + case 0x2796: + case 0x2797: + if (gSaveContext.save.weekEventReg[63] & 2) { + Message_StartTextbox(globalCtx, 0x279B, &this->actor); + this->unk_2B4 = 0x279B; + func_80151BB4(globalCtx, 0xB); + } else { + Message_StartTextbox(globalCtx, 0x2798, &this->actor); + this->unk_2B4 = 0x2798; + } + break; + + case 0x2798: + Message_StartTextbox(globalCtx, 0x2799, &this->actor); + this->unk_2B4 = 0x2799; + break; + + case 0x2799: + Message_StartTextbox(globalCtx, 0x279A, &this->actor); + this->unk_2B4 = 0x279A; + break; + } + } else if ((this->unk_2AC > 0) && (this->unk_2B4 == 0x2791)) { + this->unk_2AC--; + if (this->unk_2AC == 0) { + if (gSaveContext.unk_3DE0[0] == 1000) { + func_801A3098(0x922); + } else { + play_sound(NA_SE_SY_ERROR); + } + } + } +} + +void func_80A6F9C8(EnMm3* this) { + this->actionFunc = func_80A6F9DC; +} + +void func_80A6F9DC(EnMm3* this, GlobalContext* globalCtx) { + this->unk_2B0 &= ~2; + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 0: + case 1: + case 2: + break; + + case 3: + this->unk_2B0 |= 2; + break; + + case 4: + func_80A6F3B4(this, globalCtx); + break; + + case 5: + func_80A6F5E4(this, globalCtx); + break; + + case 6: + if (Message_ShouldAdvance(globalCtx)) { + if (this->unk_2B4 == 0x2790) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags1 |= 0x20; + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + func_8010EA9C(0, 2); + } else { + func_8010EA9C(0, 0); + } + func_801477B4(globalCtx); + play_sound(NA_SE_SY_START_SHOT); + func_80A6FBA0(this); + } else { + gSaveContext.save.weekEventReg[63] &= (u8)~1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; + func_80A6F270(this); + } + } + break; + } + + if ((this->skelAnime.mode == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + } + + 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); + this->unk_2AE = 1; + } +} + +void func_80A6FBA0(EnMm3* this) { + func_801A5BD0(0x6F); + func_801A0238(0, 5); + gSaveContext.save.weekEventReg[63] |= 1; + gSaveContext.save.weekEventReg[63] &= (u8)~2; + this->actionFunc = func_80A6FBFC; +} + +void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + OSTime a; + OSTime b; + + if (gSaveContext.unk_3DD0[0] == 0x10) { + player->stateFlags1 &= ~0x20; + this->actor.flags |= ACTOR_FLAG_10000; + if (gSaveContext.unk_3DE0[0] >= 0x5DD) { + gSaveContext.unk_3DE0[0] = 0x5DC; + } else { + a = gSaveContext.unk_3DE0[0]; + if (a >= (OSTime)(995 - XREG(16))) { + b = gSaveContext.unk_3DE0[0]; + if ((OSTime)(XREG(17) + 1005) >= b) { + gSaveContext.unk_3DE0[0] = 1000; + } + } + } + } else if (gSaveContext.unk_3DE0[0] >= 0x5DD) { + gSaveContext.unk_3DD0[0] = 15; + gSaveContext.unk_3DC8 = osGetTime(); + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_801A5BD0(0); + func_801A0238(0x7F, 5); + Message_StartTextbox(globalCtx, 0x2791, &this->actor); + this->unk_2B4 = 0x2791; + this->unk_2AC = 7; + gSaveContext.unk_3DD0[0] = 0; + this->actor.flags &= ~ACTOR_FLAG_10000; + play_sound(NA_SE_SY_START_SHOT); + func_80A6F9C8(this); + } else { + func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer + 10.0f); + func_80123E90(globalCtx, &this->actor); + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + play_sound(NA_SE_SY_STOPWATCH_TIMER_INF - SFX_FLAG); + } else { + play_sound(NA_SE_SY_STOPWATCH_TIMER_3 - SFX_FLAG); + } + } +} + +void func_80A6FE1C(EnMm3* this) { + this->actionFunc = func_80A6FE30; +} + +void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + if (!(gSaveContext.save.weekEventReg[77] & 1)) { + gSaveContext.save.weekEventReg[77] |= 1; + } + this->actor.parent = NULL; + func_80A6FED8(this); + } else if (gSaveContext.save.weekEventReg[77] & 1) { + Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + } +} + +void func_80A6FED8(EnMm3* this) { + this->actionFunc = func_80A6FEEC; +} + +void func_80A6FEEC(EnMm3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + player->stateFlags1 &= ~0x20; + Message_StartTextbox(globalCtx, 0x2794, &this->actor); + this->unk_2B4 = 0x2794; + func_80151BB4(globalCtx, 0xB); + func_80151BB4(globalCtx, 0x2B); + this->actor.flags &= ~ACTOR_FLAG_10000; + func_80A6F9C8(this); + } else { + func_800B85E0(&this->actor, globalCtx, 200.0f, -1); + } +} + +s32 func_80A6FFAC(EnMm3* this, GlobalContext* globalCtx) { + switch (gSaveContext.save.playerForm) { + case 4: + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + if (this->unk_2B2 & 0x10) { + return true; + } + } else if (this->unk_2B2 & 1) { + return true; + } + break; + + case 3: + if (this->unk_2B2 & 2) { + return true; + } + break; + + case 2: + if (this->unk_2B2 & 4) { + return true; + } + break; + + case 1: + if (this->unk_2B2 & 8) { + return true; + } + break; + } + + return false; +} + +void func_80A70084(EnMm3* this, GlobalContext* globalCtx) { + switch (gSaveContext.save.playerForm) { + case 4: + if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + this->unk_2B2 |= 0x10; + this->unk_2B2 |= 1; + } else { + this->unk_2B2 |= 1; + } + break; + + case 3: + this->unk_2B2 |= 2; + break; + + case 2: + this->unk_2B2 |= 4; + break; + + case 1: + this->unk_2B2 |= 8; + break; + } +} + +void EnMm3_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMm3* this = THIS; + + this->actionFunc(this, globalCtx); + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_2B0 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_2A0, &this->unk_2A6, this->actor.focus.pos); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 EnMm3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnMm3* this = THIS; + + if (limbIndex == 8) { + rot->x += this->unk_2A6.y; + rot->y -= this->unk_2A6.x; + } else if (limbIndex == 15) { + rot->x += this->unk_2A0.y; + rot->z += this->unk_2A0.x; + if ((this->unk_2B0 & 2) && ((globalCtx->gameplayFrames % 3) == 0)) { + Matrix_InsertTranslation(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); + } + } + return false; +} + +void EnMm3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnMm3* this = THIS; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_80A704F0, &this->actor.focus.pos); + } +} + +void EnMm3_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMm3* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A704FC[this->unk_1DC])); + gSPSegment(POLY_OPA_DISP++, 0x0C, sEnMm3DL); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnMm3_OverrideLimbDraw, EnMm3_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h index b3a8c2893..fe2e7ba06 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h @@ -9,9 +9,20 @@ typedef void (*EnMm3ActionFunc)(struct EnMm3*, GlobalContext*); typedef struct EnMm3 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; /* 0x01D4 */ EnMm3ActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0xE0]; + /* 0x01D8 */ UNK_TYPE1 unk1D8[4]; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Vec3s jointTable[16]; + /* 0x0240 */ Vec3s morphTable[16]; + /* 0x02A0 */ Vec3s unk_2A0; + /* 0x02A6 */ Vec3s unk_2A6; + /* 0x02AC */ s16 unk_2AC; + /* 0x02AE */ s16 unk_2AE; + /* 0x02B0 */ u16 unk_2B0; + /* 0x02B2 */ u16 unk_2B2; + /* 0x02B4 */ u16 unk_2B4; } EnMm3; // size = 0x2B8 extern const ActorInit En_Mm3_InitVars; diff --git a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c index cf9d23cb0..85996fe6c 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c @@ -6,7 +6,7 @@ #include "z_en_mnk.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnMnk*)thisx) 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 8782ea67c..0c16e9b03 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -7,7 +7,7 @@ #include "z_en_ms.h" #include "objects/object_ms/object_ms.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnMs*)thisx) @@ -99,13 +99,13 @@ void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 6: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { this->actionFunc = EnMs_Wait; } break; case 5: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { func_801477B4(globalCtx); Actor_PickUp(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); @@ -114,7 +114,7 @@ void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { break; case 4: - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: // yes func_801477B4(globalCtx); 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 789f308ca..8dfdeaeb8 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 @@ -6,7 +6,7 @@ #include "z_en_mt_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMttag*)thisx) @@ -14,15 +14,20 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx); -void func_809CF9A0(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA00(EnMttag* this, GlobalContext* globalCtx); -void func_809CFA54(EnMttag* this, GlobalContext* globalCtx); -void func_809CFC38(EnMttag* this, GlobalContext* globalCtx); -void func_809CFD98(EnMttag* this, GlobalContext* globalCtx); -void func_809CFE28(EnMttag* this, GlobalContext* globalCtx); -void func_809CFF94(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx); +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx); + +typedef enum { + GORON_RACE_CHEAT_NO_CHEATING, + GORON_RACE_CHEAT_FALSE_START, + GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND, +} PlayerCheatStatus; -#if 0 const ActorInit En_Mt_tag_InitVars = { ACTOR_EN_MT_TAG, ACTORCAT_BG, @@ -35,42 +40,475 @@ const ActorInit En_Mt_tag_InitVars = { (ActorFunc)NULL, }; -#endif +static s32 sStartingCheckpointPerSceneExitIndex[] = { + 0, 0, 0, 0, 1, 9, 12, 16, 19, 22, 26, 29, 30, 32, 34, 36, 39, 42, 45, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF350.s") +// The Y-positions here are never used by any part of this actor. +static Vec3f sCheckpointPositions[] = { + { -105.0f, 1000.0f, -240.0f }, { -1751.0f, 1000.0f, -240.0f }, { -3138.0f, 1000.0f, -74.0f }, + { -4617.0f, 1000.0f, 277.0f }, { -5060.0f, 1000.0f, 388.0f }, { -5412.0f, 1000.0f, 573.0f }, + { -5523.0f, 1000.0f, 1035.0f }, { -5393.0f, 1000.0f, 1405.0f }, { -5060.0f, 1000.0f, 1553.0f }, + { -3933.0f, 1000.0f, 1479.0f }, { -3212.0f, 1000.0f, 1461.0f }, { -2805.0f, 1000.0f, 1645.0f }, + { -2638.0f, 1000.0f, 2071.0f }, { -2823.0f, 1000.0f, 2422.0f }, { -3212.0f, 1000.0f, 2607.0f }, + { -3785.0f, 1000.0f, 2977.0f }, { -4321.0f, 1000.0f, 3501.0f }, { -4654.0f, 1000.0f, 4185.0f }, + { -4802.0f, 1000.0f, 4779.0f }, { -4672.0f, 1000.0f, 5426.0f }, { -4339.0f, 1000.0f, 6037.0f }, + { -3748.0f, 1000.0f, 6314.0f }, { -2749.0f, 1000.0f, 6478.0f }, { -2453.0f, 1000.0f, 6922.0f }, + { -2269.0f, 1000.0f, 7754.0f }, { -2453.0f, 1000.0f, 8309.0f }, { -3008.0f, 1000.0f, 8438.0f }, + { -3304.0f, 1000.0f, 8179.0f }, { -3600.0f, 1000.0f, 7606.0f }, { -3600.0f, 1000.0f, 6885.0f }, + { -3618.0f, 1000.0f, 4392.0f }, { -3600.0f, 1000.0f, 3855.0f }, { -3396.0f, 1000.0f, 3189.0f }, + { -3396.0f, 1000.0f, 2283.0f }, { -3600.0f, 1000.0f, 818.0f }, { -3803.0f, 1000.0f, -88.0f }, + { -4543.0f, 1000.0f, -2457.0f }, { -4543.0f, 1000.0f, -2938.0f }, { -4543.0f, 1000.0f, -3530.0f }, + { -4284.0f, 1000.0f, -4333.0f }, { -3581.0f, 1000.0f, -4795.0f }, { -2805.0f, 1000.0f, -4850.0f }, + { -1825.0f, 1000.0f, -4703.0f }, { -1326.0f, 1000.0f, -4166.0f }, { -1122.0f, 1000.0f, -3186.0f }, + { -1085.0f, 1000.0f, -2059.0f }, { -1067.0f, 1000.0f, -912.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF394.s") +/** + * Returns true if the specified position is in the finish line. + * The range extends a little bit beyond the finish line's in-game visual. + */ +s32 EnMttag_IsInFinishLine(Vec3f* pos) { + return Math3D_XZBoundCheck(-1261.0f, -901.0f, -1600.0f, -1520.0f, pos->x, pos->z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF444.s") +/** + * Returns a value in PlayerCheatStatus that indicates if the player is cheating + * and, if so, what kind of cheating the player is performing. + */ +s32 EnMttag_CheckPlayerCheatStatus(Vec3f* pos) { + if (!(gSaveContext.eventInf[1] & 1)) { + if (Math3D_XZBoundCheck(-466.0f, -386.0f, -687.0f, 193.0f, pos->x, pos->z)) { + // The race hasn't started yet, but the player is beyond the starting line. + return GORON_RACE_CHEAT_FALSE_START; + } + } else if (Math3D_XZBoundCheck(-1127.0f, -1007.0f, -867.0f, -787.0f, pos->x, pos->z)) { + // The goal is actually quite close to the start, just behind a large wall. + // This checks if the player is in an area "behind" the goal that is not accessible + // in normal play; it can only be reached by climbing the wall somehow. Perhaps they + // were worried that players would find a way to climb the wall with a glitch, or + // perhaps they just wanted to punish people using cheat codes. + return GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND; + } + return GORON_RACE_CHEAT_NO_CHEATING; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF4EC.s") +/** + * This function tries to find all four Race Gorons present in the racetrack. + * If it finds them, it stores a pointer to each one in the actor's struct. + * Returns true if all four Race Gorons are found. + */ +s32 EnMttag_AreFourRaceGoronsPresent(EnMttag* this, GlobalContext* globalCtx) { + Actor* actor = NULL; + s32 i = 0; + s32 areGoronsPresent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF67C.s") + do { + actor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_RG); + if (actor != NULL) { + this->raceGorons[i] = (EnRg*)actor; + i++; + } else if ((actor == NULL) || (actor->next == NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF848.s") + actor = actor->next; + } while (i < ARRAY_COUNT(this->raceGorons)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF8EC.s") + if (i < ARRAY_COUNT(this->raceGorons)) { + areGoronsPresent = false; + } else { + areGoronsPresent = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF950.s") + return areGoronsPresent; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CF9A0.s") +/** + * Returns the checkpoint number for the supplied actor. + * At the start of the race, all race entrants are at checkpoint 1, and their + * checkpoint number gradually increases as they move forward through the racetrack. + * The player can have a checkpoint number of -1 if they move far enough backwards + * from the starting line. + */ +s32 EnMttag_GetCurrentCheckpoint(Actor* actor, GlobalContext* globalCtx, s32* upcomingCheckpoint, + f32* outPerpendicularPointX, f32* outPerpendicularPointZ) { + s32 curentCheckpoint = -1; + s32 hasSetCurrentCheckpointOnce = false; + f32 minLineLengthSq = 0.0f; + s32 sceneExitIndex; + f32 perpendicularPointX; + f32 perpendicularPointZ; + f32 lineLenSq; + s32 checkpointIterator; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA00.s") + // The Goron Racetrack is configured such that the sceneExitIndex for any given floor polygon + // gradually increases as you move forward through the racetrack. + sceneExitIndex = SurfaceType_GetSceneExitIndex(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + if ((sceneExitIndex < 4) || (sceneExitIndex >= 19)) { + //! @bug - upcomingCheckpoint is not initialized here + return -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFA54.s") + checkpointIterator = sStartingCheckpointPerSceneExitIndex[sceneExitIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFBC4.s") + // Iterates through all possible checkpoints that are associated with this sceneExitIndex. + do { + if ((Math3D_PointDistToLine2D( + actor->world.pos.x, actor->world.pos.z, (&sCheckpointPositions[checkpointIterator])[-1].x, + (&sCheckpointPositions[checkpointIterator])[-1].z, (&sCheckpointPositions[checkpointIterator])[1].x, + (&sCheckpointPositions[checkpointIterator])[1].z, &perpendicularPointX, &perpendicularPointZ, + &lineLenSq)) && + (!hasSetCurrentCheckpointOnce || ((curentCheckpoint + 1) == checkpointIterator) || + (lineLenSq < minLineLengthSq))) { + minLineLengthSq = lineLenSq; + curentCheckpoint = checkpointIterator; + *outPerpendicularPointX = perpendicularPointX; + *outPerpendicularPointZ = perpendicularPointZ; + hasSetCurrentCheckpointOnce = true; + } + checkpointIterator++; + } while (checkpointIterator < sStartingCheckpointPerSceneExitIndex[sceneExitIndex + 1]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFC38.s") + *upcomingCheckpoint = curentCheckpoint + 1; + return curentCheckpoint; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFD98.s") +/** + * Returns true if the player is almost certainly going to lose the race. + * Specifically, it checks if the player's current checkpoint is 24 or more + * checkpoints behind the leading racer. This value was probably chosen because + * falling off the wooden bridge in the middle of the track can set the player + * back up to 23 checkpoints. + * + * This function also has the side effect of updating the number of checkpoints + * ahead of the player each Race Goron is. + */ +s32 EnMttag_UpdateCheckpoints(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnRg* rg; + s32 currentCheckpoints[5]; + s32 upcomingCheckpoints[5]; + f32 perpendicularPointsX[5]; + f32 perpendicularPointsZ[5]; + s32 highestCurrentCheckpoint; + s32 i; + s32 playerIsLikelyToLose = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFE28.s") + highestCurrentCheckpoint = -1; + currentCheckpoints[0] = EnMttag_GetCurrentCheckpoint(&player->actor, globalCtx, &upcomingCheckpoints[0], + &perpendicularPointsX[0], &perpendicularPointsZ[0]); + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + currentCheckpoints[i] = + EnMttag_GetCurrentCheckpoint(&this->raceGorons[i - 1]->actor, globalCtx, &upcomingCheckpoints[i], + &perpendicularPointsX[i], &perpendicularPointsZ[i]); + if (highestCurrentCheckpoint < currentCheckpoints[i]) { + highestCurrentCheckpoint = currentCheckpoints[i]; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/func_809CFF94.s") + for (i = 1; i < ARRAY_COUNT(this->raceGorons) + 1; i++) { + rg = this->raceGorons[i - 1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Init.s") + // Because of the bug described in EnMttag_GetCurrentCheckpoint, these values may not be initialized. + //! @bug When initialized, this check is pointless because upcomingCheckpoint is always 0 or higher. + if ((upcomingCheckpoints[i] != -1) && (upcomingCheckpoints[0] != -1)) { + rg->numCheckpointsAheadOfPlayer = (upcomingCheckpoints[i] - upcomingCheckpoints[0]); + } else { + rg->numCheckpointsAheadOfPlayer = 0; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Destroy.s") + if ((currentCheckpoints[0] > 0) && (currentCheckpoints[0] < highestCurrentCheckpoint) && + (player->actor.bgCheckFlags & 1) && ((highestCurrentCheckpoint - currentCheckpoints[0]) >= 24)) { + playerIsLikelyToLose = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mt_tag/EnMttag_Update.s") + return playerIsLikelyToLose; +} + +/** + * Exits the race and returns the player back to "normal" gameplay. + * Whether the player won or lost the race is determined by arg1 and nextTransition. + */ +s32 EnMttag_ExitRace(GlobalContext* globalCtx, s32 arg1, s32 nextTransition) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + globalCtx->nextEntranceIndex = 0xD020; + if ((gSaveContext.save.weekEventReg[33] & 0x80)) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = arg1; + gSaveContext.nextTransition = nextTransition; + func_801477B4(globalCtx); + return 1; +} + +/** + * Displays the text which says that the player has made a false start. + */ +void EnMttag_ShowFalseStartMessage(EnMttag* this, GlobalContext* globalCtx) { + gSaveContext.unk_3DD0[4] = 0; + Message_StartTextbox(globalCtx, 0xE95, NULL); // An entrant made a false start + func_800B7298(globalCtx, &this->actor, 7); + Audio_QueueSeqCmd(0x101400FF); + this->actionFunc = EnMttag_PotentiallyRestartRace; +} + +/** + * Displays the text from the Goron Elder's child which tells the player that + * they probably can't win the race. + */ +void EnMttag_ShowCantWinMessage(EnMttag* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0xE97, NULL); // You can't win now... + func_800B7298(globalCtx, &this->actor, 7); + this->actionFunc = EnMttag_HandleCantWinChoice; +} + +/** + * Shows the cutscene that pans over the race track and shows all five race entrants. + */ +void EnMttag_ShowIntroCutscene(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->actionFunc = EnMttag_WaitForIntroCutsceneToEnd; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +/** + * When the intro cutscene concludes, this sets the weekEventReg to prevent it + * from showing again and starts the race. + */ +void EnMttag_WaitForIntroCutsceneToEnd(EnMttag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + gSaveContext.save.weekEventReg[12] |= 2; + this->actionFunc = EnMttag_RaceStart; + } +} + +/** + * Handles the race from when the Gorons are first lined up at the + * starting block to when the countdown finishes. + */ +void EnMttag_RaceStart(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 playerCheatStatus; + + if (this->raceInitialized == true) { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(&player->actor.world.pos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else { + if (DECR(this->timer) == 60) { + func_8010E9F0(4, 0); + globalCtx->interfaceCtx.unk_280 = 1; + Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); + globalCtx->envCtx.unk_E4 = 0xFE; + player->stateFlags1 &= ~0x20; + } else if ((this->timer < 60) && (globalCtx->interfaceCtx.unk_280 == 8)) { + this->timer = 0; + gSaveContext.eventInf[1] |= 1; + this->actionFunc = EnMttag_Race; + } + } + } else { + if (EnMttag_AreFourRaceGoronsPresent(this, globalCtx)) { + this->raceInitialized = true; + } + } +} + +/** + * Returns true if any Race Goron is over the finish line. + */ +s32 EnMttag_IsAnyRaceGoronOverFinishLine(EnMttag* this) { + s32 isAnyRaceGoronOverFinishLine = false; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->raceGorons); i++) { + if ((EnMttag_IsInFinishLine(&this->raceGorons[i]->actor.world.pos)) && + (this->raceGorons[i]->actor.update != NULL)) { + isAnyRaceGoronOverFinishLine = true; + break; + } + } + return isAnyRaceGoronOverFinishLine; +} + +/** + * Handles the race from when the countdown finishes to when + * any race entrant crosses the finish line. + */ +void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; + s32 playerCheatStatus; + + if (EnMttag_IsInFinishLine(playerPos)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 2; + this->actionFunc = EnMttag_RaceFinish; + } else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) { + gSaveContext.unk_3DD0[4] = 6; + play_sound(NA_SE_SY_START_SHOT); + Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); + this->timer = 55; + gSaveContext.eventInf[1] |= 4; + this->actionFunc = EnMttag_RaceFinish; + } else { + playerCheatStatus = EnMttag_CheckPlayerCheatStatus(playerPos); + if (playerCheatStatus != GORON_RACE_CHEAT_NO_CHEATING) { + if (playerCheatStatus == GORON_RACE_CHEAT_FALSE_START) { + this->shouldRestartRace = true; + } else { + this->shouldRestartRace = false; + } + + EnMttag_ShowFalseStartMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } else if ((EnMttag_UpdateCheckpoints(this, globalCtx)) && (this->timer == 0)) { + EnMttag_ShowCantWinMessage(this, globalCtx); + gSaveContext.eventInf[1] |= 8; + } + } +} + +/** + * Handles the race after any race entrant crosses the finish line. + * This function simply waits for a bit before exiting the race. + */ +void EnMttag_RaceFinish(EnMttag* this, GlobalContext* globalCtx) { + if (DECR(this->timer) == 0) { + if ((gSaveContext.eventInf[1] & 2)) { + // Player won + EnMttag_ExitRace(globalCtx, 3, 3); + } else { + // A non-player Goron won + EnMttag_ExitRace(globalCtx, 2, 2); + } + + Actor_MarkForDeath(&this->actor); + } +} + +/** + * Restarts the race if this->shouldRestartRace is true. Otherwise, it exits the race. + * In practice, the only time this exits the race is if the player tries to cheat by + * reaching the goal from behind. + */ +void EnMttag_PotentiallyRestartRace(EnMttag* this, GlobalContext* globalCtx) { + u8 talkState = Message_GetState(&globalCtx->msgCtx); + + if (((talkState == 5 && Message_ShouldAdvance(globalCtx)) || talkState == 2)) { + if (this->shouldRestartRace) { + globalCtx->nextEntranceIndex = 0xD010; + + if (gSaveContext.save.weekEventReg[33] & 0x80) { + // Spring + gSaveContext.nextCutsceneIndex = 0xFFF0; + } else { + // Winter + gSaveContext.nextCutsceneIndex = 0; + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.nextTransition = 2; + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 7); + Interface_AddMagic(globalCtx, + ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[2] = ((gSaveContext.eventInf[2] & 0xF) + 1) | (gSaveContext.eventInf[2] & 0xF0); + } else { + EnMttag_ExitRace(globalCtx, 2, 2); + } + Actor_MarkForDeath(&this->actor); + } +} + +/** + * This function either exits the race or resumes it based on how the player + * responded to the Goron Elder's son's question. + */ +void EnMttag_HandleCantWinChoice(EnMttag* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { + if (globalCtx->msgCtx.choiceIndex != 0) { + // Exit the race + func_8019F230(); + gSaveContext.unk_3DD0[4] = 0; + EnMttag_ExitRace(globalCtx, 2, 2); + gSaveContext.eventInf[1] &= (u8)~8; + gSaveContext.eventInf[1] |= 4; + Actor_MarkForDeath(&this->actor); + } else { + // Keep racing + func_8019F208(); + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 6); + gSaveContext.eventInf[1] &= (u8)~8; + this->timer = 100; + this->actionFunc = EnMttag_Race; + } + } +} + +void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { + Player* player; + EnMttag* this = THIS; + + if (gSaveContext.save.entranceIndex == 0xD010) { + player = GET_PLAYER(globalCtx); + player->stateFlags1 |= 0x20; + this->raceInitialized = false; + this->timer = 100; + + gSaveContext.eventInf[1] &= (u8)~1; + gSaveContext.eventInf[1] &= (u8)~2; + gSaveContext.eventInf[1] &= (u8)~4; + gSaveContext.eventInf[1] &= (u8)~8; + + if (!(gSaveContext.save.weekEventReg[12] & 2)) { + this->actionFunc = EnMttag_ShowIntroCutscene; + } else { + s32 requiredScopeTemp; + + this->actionFunc = EnMttag_RaceStart; + } + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnMttag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + if (gSaveContext.unk_3DD0[4] != 6) { + gSaveContext.unk_3DD0[4] = 5; + } +} + +void EnMttag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMttag* this = THIS; + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h index 796482b14..796dff17a 100644 --- a/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h +++ b/src/overlays/actors/ovl_En_Mt_tag/z_en_mt_tag.h @@ -2,15 +2,20 @@ #define Z_EN_MT_TAG_H #include "global.h" +#include "overlays/actors/ovl_En_Rg/z_en_rg.h" struct EnMttag; typedef void (*EnMttagActionFunc)(struct EnMttag*, GlobalContext*); typedef struct EnMttag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnMttagActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x20]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnMttagActionFunc actionFunc; + /* 0x148 */ EnRg* raceGorons[4]; + /* 0x158 */ u16 raceInitialized; + /* 0x15A */ s16 timer; + /* 0x15C */ UNK_TYPE1 unk_15C[0x8]; + /* 0x164 */ s32 shouldRestartRace; } EnMttag; // size = 0x168 extern const ActorInit En_Mt_tag_InitVars; 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 afb1a80c7..60de87422 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -8,7 +8,7 @@ #include "z_en_mushi2.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnMushi2*)thisx) @@ -991,7 +991,7 @@ void func_80A6AB08(EnMushi2* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.world.rot.z, 0, 0xBB8); this->actor.shape.rot.z = this->actor.world.rot.z; - if ((this->actor.flags & 0x40) && (Rand_ZeroOne() < 0.03f)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (Rand_ZeroOne() < 0.03f)) { Vec3f sp3C; sp3C.x = this->actor.world.pos.x; @@ -1033,8 +1033,8 @@ void func_80A6AE7C(EnMushi2* this, GlobalContext* globalCtx) { func_80A69424(this, globalCtx); temp_f2 = this->actor.scale.x - (1.0f / 20000.0f); Actor_SetScale(&this->actor, CLAMP_MIN(temp_f2, 0.001f)); - if ((this->actor.flags & 0x40) && (this->actor.depthInWater > 5.0f) && (this->actor.depthInWater < 30.0f) && - ((Rand_Next() & 0x1FF) < this->unk_368)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.depthInWater > 5.0f) && + (this->actor.depthInWater < 30.0f) && ((Rand_Next() & 0x1FF) < this->unk_368)) { EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, -5.0f, 5.0f, 5.0f, ((Rand_ZeroOne() * 4.0f) + 2.0f) * this->actor.scale.x); } @@ -1082,7 +1082,7 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { this->actor.velocity.z = (this->actor.speedXZ * this->unk_328.z) + (-0.01f * this->unk_31C.z) + (this->unk_310.z * temp_f2); - if ((this->actor.flags & 0x40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->unk_368 > 20) && (Rand_ZeroOne() < 0.15f)) { Vec3f sp48; s32 sp44 = 0; @@ -1195,7 +1195,7 @@ void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { if ((this->actionFunc != func_80A6AE7C) && (this->actionFunc != func_80A6B0D8) && ((this->actionFunc != func_80A6A36C) || (this->unk_36A < 0xDD)) && (((this->actionFunc != func_80A6A5C0) && (this->actionFunc != func_80A6A824) && 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 99092b53a..4aed3132f 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -7,7 +7,7 @@ #include "z_en_muto.h" #include "objects/object_toryo/object_toryo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnMuto*)thisx) @@ -101,7 +101,7 @@ void EnMuto_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnMuto_ChangeAnim(EnMuto* this, s32 animIndex) { static AnimationHeader* sAnimations[] = { &object_toryo_Anim_000E50, &object_toryo_Anim_000E50 }; - static u8 sAnimationModes[] = { 0, 2 }; + static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_ONCE }; this->animIndex = animIndex; this->frameIndex = Animation_GetLastFrame(&sAnimations[animIndex]->common); @@ -134,7 +134,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { this->actor.textId = sTextIds[this->textIdIndex]; if (!this->isInMayorsRoom && (player = GET_PLAYER(globalCtx))->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.save.weekEventReg[0x58] & 8)) { + if (!(gSaveContext.save.weekEventReg[88] & 8)) { this->actor.textId = 0x62C; } else { this->actor.textId = 0x62B; @@ -161,7 +161,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { } } else { this->textIdIndex = 0; - if (gSaveContext.save.weekEventReg[0x3C] & 8) { + if (gSaveContext.save.weekEventReg[60] & 8) { this->textIdIndex = 1; } if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLE) { @@ -195,7 +195,7 @@ void EnMuto_SetupDialogue(EnMuto* this, GlobalContext* globalCtx) { void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { if (!this->isInMayorsRoom) { this->yawTowardsTarget = this->actor.yawTowardsPlayer; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); if (this->actor.textId == 0x62C) { @@ -226,13 +226,13 @@ void EnMuto_InDialogue(EnMuto* this, GlobalContext* globalCtx) { } } - if (globalCtx->msgCtx.unk11F04 == 0x2AC6 || globalCtx->msgCtx.unk11F04 == 0x2AC7 || - globalCtx->msgCtx.unk11F04 == 0x2AC8) { + if (globalCtx->msgCtx.currentTextId == 0x2AC6 || globalCtx->msgCtx.currentTextId == 0x2AC7 || + globalCtx->msgCtx.currentTextId == 0x2AC8) { this->skelAnime.playSpeed = 0.0f; this->yawTowardsTarget = this->actor.yawTowardsPlayer; this->skelAnime.curFrame = 30.0f; } - if (globalCtx->msgCtx.unk11F04 == 0x2ACF) { + if (globalCtx->msgCtx.currentTextId == 0x2ACF) { this->skelAnime.playSpeed = 0.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 ffd002a40..5f24e5b01 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -6,7 +6,7 @@ #include "z_en_nb.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnNb*)thisx) 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 4c3859efd..591d4ddcb 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 @@ -5,8 +5,9 @@ */ #include "z_en_neo_reeba.h" +#include "objects/object_rb/object_rb.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnNeoReeba*)thisx) @@ -15,7 +16,26 @@ void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx); void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this); +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupSink(EnNeoReeba* this); +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupRise(EnNeoReeba* this); +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupMove(EnNeoReeba* this); +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this); +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this); +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this); +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx); +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx); + const ActorInit En_Neo_Reeba_InitVars = { ACTOR_EN_NEO_REEBA, ACTORCAT_ENEMY, @@ -28,118 +48,701 @@ const ActorInit En_Neo_Reeba_InitVars = { (ActorFunc)EnNeoReeba_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7E500 = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(1, 0xE), - /* Horse trample */ DMG_ENTRY(1, 0xF), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xE), - /* Normal arrow */ DMG_ENTRY(1, 0xE), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xC), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0xE), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xD), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* 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, 0xF), +typedef enum { + /* 0x0 */ EN_NEO_REEBA_DMGEFF_IMMUNE, // No effect on the leever + /* 0x1 */ EN_NEO_REEBA_DMGEFF_STUN, // Turns blue, frozen in place + /* 0x2 */ EN_NEO_REEBA_DMGEFF_FIRE, + /* 0x3 */ EN_NEO_REEBA_DMGEFF_FREEZE, // Ice effects, frozen in place + /* 0x4 */ EN_NEO_REEBA_DMGEFF_LIGHT, + /* 0xC */ EN_NEO_REEBA_DMGEFF_HOOKSHOT = 0xC, // No damage, used only for hookshot + /* 0xD */ EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN, // Electric effects, frozen in place + /* 0xE */ EN_NEO_REEBA_DMGEFF_NONE, // Normal hit + /* 0xF */ EN_NEO_REEBA_DMGEFF_SHATTER, // Normal hit that can break ice if leever is frozen +} EnNeoReebaDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Deku Stick */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Explosives */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora boomerang */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Hookshot */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Goron pound */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Fire arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_LIGHT), + /* Goron spikes */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Deku spin */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_NEO_REEBA_DMGEFF_SHATTER), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Zora barrier */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Zora punch */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Spin attack */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), + /* Sword beam */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_NEO_REEBA_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_NEO_REEBA_DMGEFF_SHATTER), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B7E520 = { - { COLTYPE_HIT5, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 18, 30, 0, { 0, 0, 0 } }, }; -#endif +void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -extern DamageTable D_80B7E500; -extern ColliderCylinderInit D_80B7E520; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &gLeeverSkel, &gLeeverSpinAnim, this->jointTable, this->morphTable, + LEEVER_LIMB_MAX); -extern UNK_TYPE D_060001E4; + if (!EN_NEO_REEBA_IS_LARGE(&this->actor)) { + Actor_SetScale(&this->actor, 0.04f); + this->actor.colChkInfo.mass = 90; + this->actor.colChkInfo.health = 1; + } else { + Actor_SetScale(&this->actor, 0.05f); + this->actor.colChkInfo.mass = 180; + this->actor.colChkInfo.health = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Init.s") + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 2; + this->actor.hintId = 0x47; + this->actor.gravity = -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Destroy.s") + this->targetPos = gZeroVec3f; + this->velToTarget = gZeroVec3f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA34.s") + this->rotationAngle = 0; + this->sfxTimer = 0; + this->stunTimer = 0; + this->actionTimer = 0; + this->sinkRiseRate = 0.0f; + this->rotationSpeed = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CA70.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB3C.s") + EnNeoReeba_SetupWaitUnderground(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CB88.s") +void EnNeoReeba_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CCE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CD28.s") +void EnNeoReeba_SetupWaitUnderground(EnNeoReeba* this) { + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.draw = NULL; + this->actionTimer = 10; + this->actionFunc = EnNeoReeba_WaitUnderground; + this->actor.shape.yOffset = -2000.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE34.s") +void EnNeoReeba_WaitUnderground(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CE94.s") + if ((Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) < 200.0f) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + EnNeoReeba_SetupRise(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFA0.s") + if (this->actionTimer == 0) { + this->actor.world.pos = this->actor.home.pos; + this->actionTimer = -1; + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7CFFC.s") +void EnNeoReeba_SetupChooseAction(EnNeoReeba* this) { + this->actor.shape.yOffset = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D130.s") + if (this->actionFunc == EnNeoReeba_Move) { + this->actionTimer = 20; + } else { + this->actionTimer = 10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D150.s") + this->actionFunc = EnNeoReeba_ChooseAction; + this->skelAnime.playSpeed = 1.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D254.s") +void EnNeoReeba_ChooseAction(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 distToPlayer = Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D2E4.s") + if ((distToPlayer > 200.0f) || (fabsf(this->actor.playerHeightRel) > 100.0f)) { + EnNeoReeba_SetupSink(this); + } else { + 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); + EnNeoReeba_SetupMove(this); + } else { + EnNeoReeba_SetupReturnHome(this); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D360.s") + if (this->actionTimer != 0) { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D398.s") +void EnNeoReeba_SetupSink(EnNeoReeba* this) { + this->sinkRiseRate = 0.0f; + this->skelAnime.playSpeed = 2.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = EnNeoReeba_Sink; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D3EC.s") +void EnNeoReeba_Sink(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, -2000.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupWaitUnderground(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D47C.s") + if (this->sinkRiseRate < 300.0f) { + this->sinkRiseRate += 20.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D4FC.s") + Math_ApproachF(&this->actor.shape.shadowScale, 0.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D5A4.s") +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); + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnNeoReeba_RiseOutOfGround; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D6D0.s") +void EnNeoReeba_RiseOutOfGround(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 0.5f, this->sinkRiseRate, 10.0f) == 0.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (globalCtx->gameplayFrames % 4 == 0) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 8.0f, 500, 10, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D788.s") + if (this->sinkRiseRate > 20.0f) { + this->sinkRiseRate -= 10.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7D9B8.s") + Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 1.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DC80.s") +void EnNeoReeba_SetupMove(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&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; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DD7C.s") +void EnNeoReeba_Move(EnNeoReeba* this, GlobalContext* globalCtx) { + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7DF34.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, 4.0f, + 0xFA, 0xA, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E0BC.s") + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E260.s") + if (this->sfxTimer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_MOVE); + this->sfxTimer = 10; + } else { + this->sfxTimer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Update.s") + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/func_80B7E378.s") +void EnNeoReeba_SetupReturnHome(EnNeoReeba* this) { + this->actionFunc = EnNeoReeba_ReturnHome; + this->actor.speedXZ = 6.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Neo_Reeba/EnNeoReeba_Draw.s") +void EnNeoReeba_ReturnHome(EnNeoReeba* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; + f32 remainingDist = Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ); + + if (remainingDist < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } else if (remainingDist < 40.0f && this->actor.speedXZ > 3.0f) { + this->actor.speedXZ -= 1.0f; + } + + if (Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) > 200.0f || + fabsf(this->actor.playerHeightRel) > 100.0f) { + EnNeoReeba_SetupSink(this); + } +} + +void EnNeoReeba_SetupBounce(EnNeoReeba* this) { + this->actionTimer = 60; + this->targetPos = this->actor.world.pos; + this->targetPos.x -= 20.0f * Math_SinS(this->actor.yawTowardsPlayer); + this->targetPos.z -= 20.0f * Math_CosS(this->actor.yawTowardsPlayer); + this->actionFunc = EnNeoReeba_Bounce; +} + +void EnNeoReeba_Bounce(EnNeoReeba* this, GlobalContext* globalCtx) { + if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->targetPos, this->actor.speedXZ) < 2.0f) { + EnNeoReeba_SetupChooseAction(this); + } + + if (this->actionTimer == 0) { + EnNeoReeba_SetupChooseAction(this); + } else { + this->actionTimer--; + } +} + +void EnNeoReeba_SetupStun(EnNeoReeba* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Stunned; +} + +void EnNeoReeba_Stunned(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer > 0) { + this->stunTimer--; + } else { + this->drawEffectAlpha = 0.0f; + this->drawEffectScale = 0.0f; + } + + if (this->actor.colorFilterTimer == 0) { + this->stunTimer = 0; + EnNeoReeba_SetupChooseAction(this); + } +} + +void EnNeoReeba_SetupFrozen(EnNeoReeba* this) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawEffectScale = 0.5f; + this->drawEffectAlpha = 1.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->drawEffectScale *= 1.5f; + } + + if (this->actor.colChkInfo.health != 0) { + this->stunTimer = 80; + } else { + this->stunTimer = 12; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = EnNeoReeba_Frozen; +} + +void EnNeoReeba_Frozen(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->stunTimer == 0) { + this->stunTimer = 0; + this->drawEffectScale = 0.0f; + this->drawEffectAlpha = 0.0f; + + if (this->actor.colChkInfo.health != 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + EnNeoReeba_SetupDeathEffects(this); + } + } else if (this->stunTimer == 1) { + this->stunTimer--; + EnNeoReeba_SpawnIce(this, globalCtx); + } else { + this->stunTimer--; + } +} + +void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this) { + this->actionTimer = 10; + this->skelAnime.playSpeed = 1.0f; + 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); + this->actionFunc = EnNeoReeba_DamageAnim; +} + +static f32 sDamageAnimXZScales[] = { 0.04, 0.04, 0.039, 0.042, 0.045, 0.043, 0.04, 0.035, 0.03, 0.033, 0.04 }; +static f32 sDamageAnimYScales[] = { 0.04f, 0.04f, 0.041f, 0.038f, 0.035f, 0.037f, 0.04f, 0.045f, 0.05f, 0.047f, 0.04f }; + +void EnNeoReeba_DamageAnim(EnNeoReeba* this, GlobalContext* globalCtx) { + if (this->actionTimer == 0) { + this->rotationSpeed = 0.0f; + EnNeoReeba_SetupChooseAction(this); + } else { + this->rotationAngle -= 0x1F40; + Math_SmoothStepToF(&this->rotationSpeed, 0.0f, 0.5f, 182.0f, 18.0f); + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale, 1, + 4.0f, 250, 10, 1); + this->actionTimer--; + } +} + +void EnNeoReeba_SetupDeathEffects(EnNeoReeba* this) { + this->actionTimer = 10; + + this->velToTarget.x = Math_SinS(this->actor.yawTowardsPlayer) * -12.0f; + 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; + this->actor.flags &= ~ACTOR_FLAG_1; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIVA_DEAD); + this->actionFunc = EnNeoReeba_PlayDeathEffects; +} + +void EnNeoReeba_PlayDeathEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + static Vec3f sDeadDbVel = { 0.0f, 0.0f, 0.0f }; + static Vec3f sDeadDbAccel = { 0.0f, 4.0f, 0.0f }; + + if (this->actionTimer == 0) { + Math_ApproachZeroF(&this->actor.scale.x, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.y, 0.1f, 0.01f); + Math_ApproachZeroF(&this->actor.scale.z, 0.1f, 0.01f); + Math_ApproachZeroF(&this->drawEffectAlpha, 0.1f, 0.1f); + Math_ApproachZeroF(&this->drawEffectScale, 0.1f, 0.1f); + + if (this->actor.scale.x < 0.01f) { + func_800B3030(globalCtx, &this->actor.world.pos, &sDeadDbAccel, &sDeadDbVel, 120, 0, 0); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + Actor_MarkForDeath(&this->actor); + } + } else { + if (this->actionTimer <= 10) { + this->rotationAngle -= 0x1388; + this->actor.scale.x = this->actor.scale.z = sDamageAnimXZScales[this->actionTimer]; + this->actor.scale.y = sDamageAnimYScales[this->actionTimer]; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->actor.scale.x *= 1.5f; + this->actor.scale.y *= 1.5f; + this->actor.scale.z *= 1.5f; + } + } + + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) { + f32 target = 1.2f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } else { + f32 target = 1.6f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + target *= 1.5f; + } + + Math_SmoothStepToF(&this->drawEffectScale, target, 0.5f, 0.3f, 0.0f); + } + this->actionTimer--; + } +} + +void EnNeoReeba_HandleHit(EnNeoReeba* this, GlobalContext* globalCtx) { + Actor_SetFocus(&this->actor, 20.0f); + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actionFunc == EnNeoReeba_Frozen) { + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_STUN: + case EN_NEO_REEBA_DMGEFF_FREEZE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + case EN_NEO_REEBA_DMGEFF_NONE: + return; + default: + if (this->stunTimer >= 2) { + EnNeoReeba_SpawnIce(this, globalCtx); + } + this->stunTimer = 0; + } + } + + Actor_ApplyDamage(&this->actor); + + switch (this->actor.colChkInfo.damageEffect) { + case EN_NEO_REEBA_DMGEFF_FREEZE: + EnNeoReeba_SetupFrozen(this); + break; + + case EN_NEO_REEBA_DMGEFF_FIRE: + case EN_NEO_REEBA_DMGEFF_LIGHT: + if (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_FIRE) { + this->drawEffectType = ACTOR_DRAW_DMGEFF_FIRE; + this->stunTimer = 80; + } else { + this->drawEffectType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->stunTimer = 40; + } + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 0.0f; + /* fallthrough */ + case EN_NEO_REEBA_DMGEFF_NONE: + case EN_NEO_REEBA_DMGEFF_SHATTER: + if ((this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_SHATTER) || + (this->actor.colChkInfo.damageEffect == EN_NEO_REEBA_DMGEFF_NONE)) { + this->stunTimer = 0; + } + if (this->actor.colChkInfo.health > 0) { + EnNeoReeba_SetupDamageAnim(this); + } else { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + EnNeoReeba_SetupDeathEffects(this); + } + break; + + case EN_NEO_REEBA_DMGEFF_ELECTRIC_STUN: + this->drawEffectType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->stunTimer = 40; + this->drawEffectAlpha = 1.0f; + this->drawEffectScale = 2.0f; + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + + case EN_NEO_REEBA_DMGEFF_STUN: + Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); + EnNeoReeba_SetupStun(this); + break; + } + } else { + if (((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.atFlags & AT_BOUNCED)) && + (this->actionFunc == EnNeoReeba_Move)) { + EnNeoReeba_SetupBounce(this); + } + } + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround) && (this->actionFunc != EnNeoReeba_DamageAnim) && + (this->actionFunc != EnNeoReeba_PlayDeathEffects)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actionFunc != EnNeoReeba_Stunned) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void EnNeoReeba_UpdatePosition(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Sink) && + (this->actionFunc != EnNeoReeba_RiseOutOfGround)) { + this->actor.velocity.y += this->actor.gravity; + + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.world.pos.x += this->actor.colChkInfo.displacement.x; + this->actor.world.pos.z += this->actor.colChkInfo.displacement.z; + + this->actor.world.pos.x += this->velToTarget.x; + this->actor.world.pos.z += this->velToTarget.z; + + Math_ApproachZeroF(&this->velToTarget.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->velToTarget.z, 1.0f, 2.0f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 40.0f, 40.0f, 5); + } +} + +void EnNeoReeba_DrawFrozenEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 limbPosScale = 10.0f; + f32 phi_f2 = 20.0f; + f32 drawEffectScale = 0.8f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + limbPosScale *= 1.5f; + phi_f2 *= 1.5f; + drawEffectScale *= 1.5f; + } + + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + + this->limbPos[i].x += limbPosScale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += limbPosScale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += 5.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + this->limbPos[ARRAY_COUNT(this->limbPos) - 1].y += phi_f2; + + this->drawEffectScale = drawEffectScale; + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); +} + +void EnNeoReeba_DrawEffects(EnNeoReeba* this, GlobalContext* globalCtx) { + s32 i; + f32 scale = 15.0f; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + scale *= 1.5f; + } + + if ((this->drawEffectType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawEffectType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS) || + (this->drawEffectType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL)) { + for (i = 0; i < ARRAY_COUNT(this->limbPos) - 1; i++) { + this->limbPos[i] = this->actor.world.pos; + this->limbPos[i].x += scale * Math_SinS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].z += scale * Math_CosS(BINANG_ADD(this->actor.shape.rot.y, i * 0x5555)); + this->limbPos[i].y += -20.0f; + } + + this->limbPos[ARRAY_COUNT(this->limbPos) - 1] = this->actor.world.pos; + Actor_DrawDamageEffects(globalCtx, NULL, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawEffectScale, 0.5f, + this->drawEffectAlpha, this->drawEffectType); + } +} + +void EnNeoReeba_SpawnIce(EnNeoReeba* this, GlobalContext* globalCtx) { + static Color_RGBA8 sIcePrimColor = { 170, 255, 255, 255 }; + static Color_RGBA8 sIceEnvColor = { 200, 200, 255, 255 }; + static Vec3f sIceAccel = { 0.0f, -1.0f, 0.0f }; + Vec3f iceVel; + f32 xVel; + f32 zVel; + s32 i; + s16 yaw; + s32 j; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); + + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); + xVel = Math_SinS(yaw) * 3.0f; + zVel = Math_CosS(yaw) * 3.0f; + + for (j = 0; j < 4; j++) { + iceVel.x = (Rand_Centered() * 3.0f) + xVel; + iceVel.z = (Rand_Centered() * 3.0f) + zVel; + iceVel.y = (Rand_ZeroOne() * 6.0f) + 4.0f; + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.7f, &iceVel, &sIceAccel, &sIcePrimColor, &sIceEnvColor, + 30); + } + } +} + +void EnNeoReeba_SinkIfStoneMask(EnNeoReeba* this, GlobalContext* globalCtx) { + if ((this->actionFunc == EnNeoReeba_ChooseAction) || (this->actionFunc == EnNeoReeba_Move) || + (this->actionFunc == EnNeoReeba_ReturnHome)) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) { + EnNeoReeba_SetupSink(this); + } + } +} + +void EnNeoReeba_Update(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + if (EN_NEO_REEBA_IS_LARGE(&this->actor)) { + this->collider.dim.radius = 27; + this->collider.dim.height = 45; + } + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnNeoReeba_WaitUnderground) && (this->actionFunc != EnNeoReeba_Stunned) && + (this->actionFunc != EnNeoReeba_Frozen)) { + SkelAnime_Update(&this->skelAnime); + } + + EnNeoReeba_HandleHit(this, globalCtx); + EnNeoReeba_UpdatePosition(this, globalCtx); + EnNeoReeba_SinkIfStoneMask(this, globalCtx); +} + +s32 EnNeoReeba_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnNeoReeba* this = THIS; + + if ((limbIndex == OBJECT_RB_LIMB_03) && (this->rotationSpeed != 0.0f)) { + rot->y += (s16)(this->rotationSpeed * Math_SinS(this->rotationAngle)); + rot->z += (s16)(this->rotationSpeed * Math_CosS(this->rotationAngle)); + } + + return false; +} + +void EnNeoReeba_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnNeoReeba* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(globalCtx->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x01, 255, 255, 255, 255); + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnNeoReeba_OverrideLimbDraw, + NULL, &this->actor); + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stunTimer > 0) { + if (this->drawEffectType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { + EnNeoReeba_DrawFrozenEffects(this, globalCtx); + } else { + EnNeoReeba_DrawEffects(this, globalCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h index 8d1091dfc..df6aaab1d 100644 --- a/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h +++ b/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.h @@ -2,16 +2,33 @@ #define Z_EN_NEO_REEBA_H #include "global.h" +#include "objects/object_rb/object_rb.h" + +#define EN_NEO_REEBA_IS_LARGE(thisx) ((thisx)->params & 0x8000) struct EnNeoReeba; typedef void (*EnNeoReebaActionFunc)(struct EnNeoReeba*, GlobalContext*); typedef struct EnNeoReeba { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x168]; - /* 0x02AC */ EnNeoReebaActionFunc actionFunc; - /* 0x02B0 */ char unk_2B0[0x64]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[LEEVER_LIMB_MAX]; + /* 0x240 */ Vec3s morphTable[LEEVER_LIMB_MAX]; + /* 0x2AC */ EnNeoReebaActionFunc actionFunc; + /* 0x2B0 */ Vec3f targetPos; + /* 0x2BC */ Vec3f velToTarget; + /* 0x2C8 */ Vec3f limbPos[4]; + /* 0x2F8 */ f32 sinkRiseRate; + /* 0x2FC */ f32 rotationSpeed; + /* 0x300 */ f32 drawEffectAlpha; + /* 0x304 */ f32 drawEffectScale; + /* 0x308 */ s16 rotationAngle; + /* 0x30A */ s16 actionTimer; + /* 0x30C */ s16 sfxTimer; + /* 0x30E */ s16 stunTimer; + /* 0x310 */ u8 drawEffectType; } EnNeoReeba; // size = 0x314 extern const ActorInit En_Neo_Reeba_InitVars; 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 050d22dac..779de0b8a 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -6,7 +6,7 @@ #include "z_en_nimotsu.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNimotsu*)thisx) 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 fa560f013..f6e398a33 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -7,7 +7,7 @@ #include "z_en_niw.h" #include "objects/object_niw/object_niw.h" -#define FLAGS 0x00800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000) #define THIS ((EnNiw*)thisx) @@ -118,7 +118,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { this->niwType = this->actor.params; Actor_ProcessInitChain(&this->actor, sInitChain); - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); @@ -146,7 +146,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 4; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; @@ -342,7 +342,7 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 4; this->actor.speedXZ = 0.0f; this->actionFunc = EnNiw_Held; @@ -438,7 +438,7 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; this->unknownState28E = 5; - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; this->actor.shape.rot.y = rotZ; this->actor.shape.rot.x = rotZ; @@ -456,7 +456,7 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = rotZ; Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); Math_Vec3f_Copy(&this->unk2BC, &vec3fcopy); - this->actor.flags |= 0x1; // targetable ON + this->actor.flags |= ACTOR_FLAG_1; // targetable ON this->actionFunc = EnNiw_Thrown; } func_80891320(this, globalCtx, 2); @@ -494,7 +494,7 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { this->sfxTimer1 = 30; this->unk2EC = 0; this->unkTimer250 = 30; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 4; this->actionFunc = EnNiw_Held; this->actor.speedXZ = 0.0f; @@ -605,7 +605,7 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { if (this->unkTimer252 == 0) { this->unkTimer252 = 10; this->yawTowardsPlayer = this->actor.yawTowardsPlayer; - this->actor.flags &= ~0x1; // targetable OFF + this->actor.flags &= ~ACTOR_FLAG_1; // targetable OFF this->unknownState28E = 3; this->actionFunc = EnNiw_CuccoStorm; } @@ -742,7 +742,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad2[9]; s16 temp29C; f32 featherScale; - f32 camResult; + f32 viewAtToEyeNormY; f32 floorHeight; f32 dist = 20.0f; s32 pad3; @@ -808,17 +808,19 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 0x1F); + // if cucco is off the map? if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= BGCHECK_Y_MAX) { - // if cucco is off the map? - Vec3f camera; - camera.x = globalCtx->view.at.x - globalCtx->view.eye.x; - camera.y = globalCtx->view.at.y - globalCtx->view.eye.y; - camera.z = globalCtx->view.at.z - globalCtx->view.eye.z; - camResult = camera.y / sqrtf(SQXYZ(camera)); + Vec3f viewAtToEye; + + // Direction vector for the direction the camera is facing + viewAtToEye.x = globalCtx->view.at.x - globalCtx->view.eye.x; + viewAtToEye.y = globalCtx->view.at.y - globalCtx->view.eye.y; + viewAtToEye.z = globalCtx->view.at.z - globalCtx->view.eye.z; + viewAtToEyeNormY = viewAtToEye.y / sqrtf(SQXYZ(viewAtToEye)); 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 + globalCtx->view.eye.y) + (camResult * 160.0f); + this->actor.world.pos.y = (this->actor.home.pos.y + globalCtx->view.eye.y) + (viewAtToEyeNormY * 160.0f); if (this->actor.world.pos.y < this->actor.home.pos.y) { this->actor.world.pos.y = this->actor.home.pos.y + 300.0f; diff --git a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c index c7e0d5dac..1400e3c06 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -7,7 +7,7 @@ #include "z_en_nnh.h" #include "objects/object_nnh/object_nnh.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnNnh*)thisx) @@ -77,7 +77,7 @@ void func_80C08828(EnNnh* this) { void func_80C0883C(EnNnh* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x228U, &this->actor); + Message_StartTextbox(globalCtx, 0x228U, &this->actor); func_80C088A4(this); return; } 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 4c2cec3fa..3eed47b71 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -8,7 +8,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNutsball*)thisx) @@ -155,7 +155,7 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { } Collider_UpdateCylinder(&this->actor, &this->collider); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); 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 53c38ab6b..4c0fdce1e 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -6,7 +6,7 @@ #include "z_en_nwc.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnNwc*)thisx) diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 9b0d89cdd..c87e30329 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -6,7 +6,7 @@ #include "z_en_okarina_effect.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnOkarinaEffect*)thisx) @@ -58,7 +58,7 @@ void func_8096B104(EnOkarinaEffect* this, GlobalContext* globalCtx) { void func_8096B174(EnOkarinaEffect* this, GlobalContext* globalCtx) { DECR(this->unk144); if (!globalCtx->pauseCtx.state && !globalCtx->gameOverCtx.state && !globalCtx->msgCtx.unk11F10 && - !FrameAdvance_IsEnabled(globalCtx) && this->unk144 == 0) { + !FrameAdvance_IsEnabled(&globalCtx->state) && this->unk144 == 0) { EnOkarinaEffect_SetupAction(this, func_8096B1FC); } } 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 096fd9421..5a54da7b1 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 0x0A000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnOkarinaTag*)thisx) diff --git a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c index 251f23a30..b11997b82 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -6,7 +6,7 @@ #include "z_en_okuta.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnOkuta*)thisx) 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 1f93a9786..c904cdd42 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -6,7 +6,7 @@ #include "z_en_onpuman.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnOnpuman*)thisx) 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 c71650ef1..30d9a1666 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -5,8 +5,10 @@ */ #include "z_en_osk.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_ikn_demo/object_ikn_demo.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnOsk*)thisx) @@ -20,7 +22,6 @@ void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx); void func_80BF656C(EnOsk* this, GlobalContext* globalCtx); void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Osk_InitVars = { ACTOR_EN_OSK, ACTORCAT_NPC, @@ -33,42 +34,533 @@ const ActorInit En_Osk_InitVars = { (ActorFunc)EnOsk_Draw, }; -#endif +AnimationHeader* D_80BF6FA0[] = { + &object_ikn_demo_Anim_003CAC, &object_ikn_demo_Anim_004208, &object_ikn_demo_Anim_004514, + &object_ikn_demo_Anim_004A58, &object_ikn_demo_Anim_0065D8, +}; -extern UNK_TYPE D_06006808; +AnimationHeader* D_80BF6FB4[] = { + &object_ikn_demo_Anim_0067B8, &object_ikn_demo_Anim_0083F4, &object_ikn_demo_Anim_0081A8, + &object_ikn_demo_Anim_008AF4, &object_ikn_demo_Anim_008724, &object_ikn_demo_Anim_008F1C, + &object_ikn_demo_Anim_008CEC, &object_ikn_demo_Anim_009254, &object_ikn_demo_Anim_009044, + &object_ikn_demo_Anim_0098E4, &object_ikn_demo_Anim_009CC8, &object_ikn_demo_Anim_009A44, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Init.s") +AnimationHeader* D_80BF6FE4[] = { + &object_ikn_demo_Anim_009EA8, &object_ikn_demo_Anim_00B8C0, &object_ikn_demo_Anim_00B704, + &object_ikn_demo_Anim_00BDB4, &object_ikn_demo_Anim_00B9E4, &object_ikn_demo_Anim_00C154, + &object_ikn_demo_Anim_00BF04, &object_ikn_demo_Anim_00CA74, &object_ikn_demo_Anim_00C804, + &object_ikn_demo_Anim_00D044, &object_ikn_demo_Anim_00CD28, &object_ikn_demo_Anim_00C59C, + &object_ikn_demo_Anim_00C2C4, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Destroy.s") +Vec3f D_80BF7018 = { 0.0f, 0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E00.s") +Vec3f D_80BF7024 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5E68.s") +void EnOsk_Init(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5EBC.s") + Actor_SetScale(&this->actor, 0.013f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F60.s") + this->actionFunc = func_80BF5F60; + this->unk_254 = -1; + this->unk_256 = -1; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF5F70.s") + switch (ENOSK_GET_F(&this->actor)) { + case ENOSK_1: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_007B48, &object_ikn_demo_Anim_006808, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF656C; + this->unk_258 = 0x210; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF609C.s") + case ENOSK_2: + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_00B490, &object_ikn_demo_Anim_009F00, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_006808); + this->actionFunc = func_80BF6A20; + this->unk_258 = 0x211; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF61EC.s") + default: + Actor_SetScale(&this->actor, 0.017f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ikn_demo_Skel_0038F0, &object_ikn_demo_Anim_0000B8, + this->jointTable, this->morphTable, 17); + Animation_PlayLoop(&this->skelAnime, &object_ikn_demo_Anim_0000B8); + this->actionFunc = func_80BF61EC; + this->unk_258 = 0x212; + this->actor.home.rot.z = 0; + this->unk_25C = 0.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6314.s") +void EnOsk_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6478.s") +void func_80BF5E00(EnOsk* this, AnimationHeader** animations, s16 index, f32 morphFrame) { + if (index == this->unk_254) { + return; + } + Animation_MorphToLoop(&this->skelAnime, animations[index], morphFrame); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF656C.s") +void func_80BF5E68(EnOsk* this, AnimationHeader** animations, s16 index, f32 playSpeed) { + Animation_MorphToPlayOnce(&this->skelAnime, animations[index], playSpeed); + this->unk_254 = index; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF67A8.s") +void func_80BF5EBC(EnOsk* this, GlobalContext* globalCtx) { + Vec3f sp2C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF68E0.s") + sp2C.x = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.x; + sp2C.z = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.z; + sp2C.y = randPlusMinusPoint5Scaled(30.0f) + this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6A20.s") + func_800B3030(globalCtx, &sp2C, &D_80BF7018, &D_80BF7018, 100, 0, 2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Update.s") +void func_80BF5F60(EnOsk* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/func_80BF6C54.s") +void func_80BF5F70(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 6)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.017f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osk/EnOsk_Draw.s") + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FA0, 3, -5.0f); + break; + + case 3: + func_80BF5E00(this, D_80BF6FA0, 2, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 5: + func_80BF5E00(this, D_80BF6FA0, 0, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FA0, 1, -5.0f); + break; + + case 7: + func_80BF5E00(this, D_80BF6FA0, 4, -5.0f); + this->actor.home.rot.z = 1; + break; + } +} + +void func_80BF609C(EnOsk* this, GlobalContext* globalCtx) { + if (this->actor.draw != NULL) { + if (this->actor.home.rot.z != 0) { + if (globalCtx->msgCtx.currentTextId == 0x1531) { + this->actor.home.rot.z = 0; + } + } else { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + this->unk_25C = Rand_ZeroFloat(3.0f); + } + + switch (this->unk_254) { + 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); + } + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->unk_25C)) { + Actor_PlaySfxAtPos(&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); + } + break; + } + } + } +} + +void func_80BF61EC(EnOsk* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF5F70(this); + } + func_80BF609C(this, globalCtx); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 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); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF6314(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 9)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E00(this, D_80BF6FB4, 9, -5.0f); + Actor_SetScale(&this->actor, 0.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FB4, 2, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FB4, 4, 0); + break; + + case 5: + func_80BF5E68(this, D_80BF6FB4, 8, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FB4, 11, -5.0f); + break; + + case 7: + func_80BF5E68(this, D_80BF6FB4, 6, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + + case 9: + func_80BF5E00(this, D_80BF6FB4, 0, -5.0f); + break; + } +} + +void func_80BF6478(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + 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); + } + break; + + case 3: + if (Animation_OnFrame(&this->skelAnime, 11.0f)) { + Actor_PlaySfxAtPos(&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); + } + break; + + case 10: + case 11: + func_800B9010(&this->actor, NA_SE_EN_YASE_LAUGH_K - SFX_FLAG); + break; + } + } +} + +void func_80BF656C(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FB4, 1, 0.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FB4, 3, 0.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FB4, 7, -5.0f); + break; + + case 11: + func_80BF5E00(this, D_80BF6FB4, 10, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FB4, 5, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF6314(this); + } + func_80BF6478(this); + } else { + this->actor.draw = NULL; + } + + if ((this->unk_256 == 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->actor.scale.x > 0.65f * 0.001f) { + this->actor.scale.x -= 0.65f * 0.001f; + Actor_SetScale(&this->actor, this->actor.scale.x); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void func_80BF67A8(EnOsk* this) { + if ((this->unk_256 != 1) && (this->unk_256 != 8)) { + this->actor.draw = EnOsk_Draw; + Actor_SetScale(&this->actor, 0.013f); + } + + switch (this->unk_256) { + case 1: + this->actor.draw = NULL; + break; + + case 2: + func_80BF5E68(this, D_80BF6FE4, 2, -5.0f); + break; + + case 3: + func_80BF5E68(this, D_80BF6FE4, 8, -5.0f); + break; + + case 4: + func_80BF5E68(this, D_80BF6FE4, 4, -5.0f); + break; + + case 5: + func_80BF5E68(this, D_80BF6FE4, 6, -5.0f); + break; + + case 6: + func_80BF5E68(this, D_80BF6FE4, 10, -5.0f); + break; + + case 7: + case 8: + func_80BF5E00(this, D_80BF6FE4, 0, -5.0f); + break; + + case 9: + func_80BF5E68(this, D_80BF6FE4, 12, -5.0f); + break; + } +} + +void func_80BF68E0(EnOsk* this) { + if (this->actor.draw != NULL) { + switch (this->unk_254) { + case 1: + 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); + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&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); + } + 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); + } + break; + + case 8: + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEBU_HEAD_UP); + } + break; + } + } +} + +void func_80BF6A20(EnOsk* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_254) { + case 2: + func_80BF5E00(this, D_80BF6FE4, 1, -5.0f); + break; + + case 8: + func_80BF5E00(this, D_80BF6FE4, 7, -5.0f); + break; + + case 4: + func_80BF5E00(this, D_80BF6FE4, 3, -5.0f); + break; + + case 6: + func_80BF5E00(this, D_80BF6FE4, 5, -5.0f); + break; + + case 10: + func_80BF5E00(this, D_80BF6FE4, 9, -5.0f); + break; + + case 12: + func_80BF5E00(this, D_80BF6FE4, 11, -5.0f); + break; + } + } + + if (Cutscene_CheckActorAction(globalCtx, this->unk_258)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, this->unk_258)); + if (this->unk_256 != + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action) { + this->unk_256 = + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->unk_258)]->action; + func_80BF67A8(this); + } + func_80BF68E0(this); + } else { + this->actor.draw = NULL; + } + + if (this->unk_256 == 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); + func_80BF5EBC(this, globalCtx); + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + } else { + this->actor.draw = NULL; + } + } +} + +void EnOsk_Update(Actor* thisx, GlobalContext* globalCtx) { + EnOsk* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnOsk* this = THIS; + + if (limbIndex == 1) { + Matrix_MultiplyVector3fByState(&D_80BF7024, &this->actor.focus.pos); + } +} + +void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsk* this = THIS; + Gfx* gfx; + Vec3f sp80; + s32 pad2[4]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_PrimColor(globalCtx->state.gfxCtx, 0x80, 255, 255, 255, 255)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, func_80BF6C54, &this->actor); + + { + s16 sp62; + s16 sp60; + Vec3f sp54; + + sp54 = GET_ACTIVE_CAM(globalCtx)->eye; + + sp62 = Math_Vec3f_Yaw(&sp54, &this->actor.focus.pos); + sp60 = -Math_Vec3f_Pitch(&sp54, &this->actor.focus.pos); + + sp80.x = -(15.0f * (Math_SinS(sp62)) * Math_CosS(sp60)); + sp80.y = -(Math_SinS(sp60) * 15.0f); + sp80.z = -(15.0f * (Math_CosS(sp62)) * Math_CosS(sp60)); + + Matrix_InsertTranslation(this->actor.focus.pos.x + sp80.x, this->actor.focus.pos.y + sp80.y, + sp80.z = this->actor.focus.pos.z + sp80.z, MTXMODE_NEW); + + sp80.z = Math_SinS(globalCtx->gameplayFrames << 0xE); + sp80.z = ((sp80.z + 1.0f) * 0.1f) + 2.0f; + Matrix_Scale(this->actor.scale.x * sp80.z, this->actor.scale.y * sp80.z, this->actor.scale.z * sp80.z, + MTXMODE_APPLY); + } + + gfx = func_8012C868(POLY_XLU_DISP); + + gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + if (1) {} + if (1) {} + if (1) {} + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); + gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); + gDPSetPrimColor(gfx++, 0, 0, 130, 0, 255, 100); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 f98437897..9515e9705 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.h +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.h @@ -7,9 +7,20 @@ struct EnOsk; typedef void (*EnOskActionFunc)(struct EnOsk*, GlobalContext*); +#define ENOSK_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENOSK_1 1 +#define ENOSK_2 2 + typedef struct EnOsk { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x11C]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[17]; + /* 0x01EE */ Vec3s morphTable[17]; + /* 0x0254 */ s16 unk_254; + /* 0x0256 */ s16 unk_256; + /* 0x0258 */ u16 unk_258; + /* 0x025C */ f32 unk_25C; /* 0x0260 */ 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 758da16f4..48a87b30e 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -5,8 +5,9 @@ */ #include "z_en_osn.h" +#include "objects/object_osn/object_osn.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOsn*)thisx) @@ -15,7 +16,6 @@ void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Osn_InitVars = { ACTOR_EN_OSN, ACTORCAT_NPC, @@ -28,18 +28,45 @@ const ActorInit En_Osn_InitVars = { (ActorFunc)EnOsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AD2518 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_osn_Anim_0201BC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_002F74, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_0037C4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_004320, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_004C8C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0094E4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_009BB8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00AC60, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_001614, 1.0f, 1.0f, 39.0f, 0, 0.0f }, { &object_osn_Anim_001034, 1.0f, 1.0f, 70.0f, 0, 0.0f }, + { &object_osn_Anim_00AE9C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_003A1C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_0055F8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_007220, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_0000C4, 0.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_osn_Anim_0000C4, 0.0f, 1.0f, 1.0f, 2, 0.0f }, { &object_osn_Anim_006D48, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_001D6C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_002634, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_008D80, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_osn_Anim_005D78, 1.0f, 0.0f, 0.0f, 2, 0.0f }, + { &object_osn_Anim_006564, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, 0, 0.0f }, + { &object_osn_Anim_008D80, 0.0f, 77.0f, 0.0f, 2, 0.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80AD2544 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80AD2550 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -74,59 +101,827 @@ static DamageTable D_80AD2550 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AD2570[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -#endif +void func_80AD1634(EnOsn*, GlobalContext*); +void func_80AD16A8(EnOsn*, GlobalContext*); +void func_80AD14C8(EnOsn*, GlobalContext*); +void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx); -extern ColliderCylinderInit D_80AD2518; -extern CollisionCheckInfoInit2 D_80AD2544; -extern DamageTable D_80AD2550; -extern InitChainEntry D_80AD2570[]; +void func_80AD0830(EnOsn* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -extern UNK_TYPE D_060192A0; -extern UNK_TYPE D_060201BC; +s32 func_80AD08B0(GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GREAT_FAIRY: + return 0x1FD6; + case PLAYER_MASK_GIBDO: + return 0x1FD8; + case PLAYER_MASK_TRUTH: + return 0x1FDA; + case PLAYER_MASK_GIANT: + return 0x1FDC; + case PLAYER_MASK_KAFEIS_MASK: + return 0x1FDE; + case PLAYER_MASK_DON_GERO: + return 0x1FE0; + case PLAYER_MASK_BLAST: + return 0x1FE2; + case PLAYER_MASK_COUPLE: + return 0x1FE4; + case PLAYER_MASK_SCENTS: + return 0x1FE6; + case PLAYER_MASK_KAMARO: + return 0x1FE8; + case PLAYER_MASK_STONE: + return 0x1FEA; + case PLAYER_MASK_POSTMAN: + return 0x1FEC; + case PLAYER_MASK_BUNNY: + return 0x1FEE; + case PLAYER_MASK_CAPTAIN: + return 0x1FF0; + case PLAYER_MASK_BREMEN: + return 0x1FF2; + case PLAYER_MASK_CIRCUS_LEADER: + return 0x1FF4; + case PLAYER_MASK_KEATON: + return 0x1FF6; + case PLAYER_MASK_GARO: + return 0x1FF8; + case PLAYER_MASK_ALL_NIGHT: + return 0x1FFA; + case PLAYER_MASK_ROMANI: + return 0x1FFC; + default: + return 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0830.s") +void func_80AD0998(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD08B0.s") + if (this->unk_1EC == 0x12 && curFrame == lastFrame) { + this->unk_1EC = 0x13; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x13); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0998.s") +void func_80AD0A24(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0A24.s") + if (this->unk_1EC == 0x15 && curFrame == lastFrame) { + this->unk_1EC = 0x16; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x16); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0AB0.s") +void func_80AD0AB0(EnOsn* this) { + s16 curFrame = this->skelAnime.curFrame; + s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0B38.s") + if (curFrame == lastFrame) { + this->unk_1FA -= 8; + if (this->unk_1FA < 8) { + this->unk_1FA = 0; + Actor_MarkForDeath(&this->actor); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD0E10.s") +s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { + switch (Player_GetMask(globalCtx)) { + case PLAYER_MASK_GREAT_FAIRY: + if (!(this->unk_1F6 & 1)) { + this->unk_1F6 |= 1; + return 0x1FD1; + } + break; + case PLAYER_MASK_GIBDO: + if (!(this->unk_1F6 & 2)) { + this->unk_1F6 |= 2; + return 0x1FD1; + } + break; + case PLAYER_MASK_TRUTH: + if (!(this->unk_1F6 & 4)) { + this->unk_1F6 |= 4; + return 0x1FD1; + } + break; + case PLAYER_MASK_GIANT: + if (!(this->unk_1F6 & 8)) { + this->unk_1F6 |= 8; + return 0x1FD1; + } + break; + case PLAYER_MASK_KAFEIS_MASK: + if (!(this->unk_1F6 & 0x10)) { + this->unk_1F6 |= 0x10; + return 0x1FD1; + } + break; + case PLAYER_MASK_DON_GERO: + if (!(this->unk_1F6 & 0x20)) { + this->unk_1F6 |= 0x20; + return 0x1FD1; + } + break; + case PLAYER_MASK_BLAST: + if (!(this->unk_1F6 & 0x40)) { + this->unk_1F6 |= 0x40; + return 0x1FD1; + } + break; + case PLAYER_MASK_COUPLE: + if (!(this->unk_1F6 & 0x80)) { + this->unk_1F6 |= 0x80; + return 0x1FD1; + } + break; + case PLAYER_MASK_SCENTS: + if (!(this->unk_1F6 & 0x100)) { + this->unk_1F6 |= 0x100; + return 0x1FD1; + } + break; + case PLAYER_MASK_KAMARO: + if (!(this->unk_1F6 & 0x200)) { + this->unk_1F6 |= 0x200; + return 0x1FD1; + } + break; + case PLAYER_MASK_STONE: + if (!(this->unk_1F6 & 0x400)) { + this->unk_1F6 |= 0x400; + return 0x1FD1; + } + break; + case PLAYER_MASK_POSTMAN: + if (!(this->unk_1F6 & 0x800)) { + this->unk_1F6 |= 0x800; + return 0x1FD2; + } + break; + case PLAYER_MASK_BUNNY: + if (!(this->unk_1F6 & 0x1000)) { + this->unk_1F6 |= 0x1000; + return 0x1FD2; + } + break; + case PLAYER_MASK_CAPTAIN: + if (!(this->unk_1F6 & 0x2000)) { + this->unk_1F6 |= 0x2000; + return 0x1FD1; + } + break; + case PLAYER_MASK_BREMEN: + if (!(this->unk_1F6 & 0x4000)) { + this->unk_1F6 |= 0x4000; + return 0x1FD1; + } + break; + case PLAYER_MASK_CIRCUS_LEADER: + if (!(this->unk_1F6 & 0x8000)) { + this->unk_1F6 |= 0x8000; + return 0x1FD1; + } + break; + case PLAYER_MASK_KEATON: + if (!(this->unk_1F6 & 0x10000)) { + this->unk_1F6 |= 0x10000; + return 0x1FD1; + } + break; + case PLAYER_MASK_GARO: + if (!(this->unk_1F6 & 0x20000)) { + this->unk_1F6 |= 0x20000; + return 0x1FD1; + } + break; + case PLAYER_MASK_ALL_NIGHT: + if (!(this->unk_1F6 & 0x40000)) { + this->unk_1F6 |= 0x40000; + return 0x1FD1; + } + break; + case PLAYER_MASK_ROMANI: + if (!(this->unk_1F6 & 0x80000)) { + this->unk_1F6 |= 0x80000; + return 0x1FD1; + } + break; + default: + break; + } + this->unk_1EA |= 0x20; + if (gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { + return 0x2006; + } + return 0x1FCD; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD10FC.s") +s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1398.s") + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (this->unk_1EA & 1) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.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))) { + return 0x2006; + } + return 0x1FCD; + } + return 0x1FAF; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD144C.s") + if (player->transformation == PLAYER_FORM_DEKU) { + if (this->unk_1EA & 4) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 4; + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD14C8.s") + if (player->transformation == PLAYER_FORM_GORON) { + if (this->unk_1EA & 8) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 8; + if (gSaveContext.save.weekEventReg[76] & 0x20) { + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1634.s") + gSaveContext.save.weekEventReg[76] |= 0x20; + return 0x1FCE; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD16A8.s") + if (player->transformation == PLAYER_FORM_ZORA) { + if (this->unk_1EA & 0x10) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 0x10; + if (gSaveContext.save.weekEventReg[76] & 0x40) { + return 0x1FC8; + } + gSaveContext.save.weekEventReg[76] |= 0x40; + return 0x1FD0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD19A0.s") + if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { + if (this->unk_1EA & 2) { + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2006; + } + return 0x1FCD; + } + this->unk_1EA |= 2; + return 0x1FC8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1A4C.s") + return func_80AD0B38(this, globalCtx); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Init.s") + this->unk_1EA |= 0x20; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + return 0x2004; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Destroy.s") + return 0x1FAE; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Update.s") +void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { + switch (this->unk_1F4) { + case 0x1FC8: + this->unk_1F4 = 0x1FC9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1DA8.s") + case 0x1FC9: + this->unk_1F4 = 0x1FCA; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/func_80AD1E28.s") + case 0x1FCA: + if ((gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + gSaveContext.save.time < CLOCK_TIME(6, 0)) { + this->unk_1F4 = 0x2007; + } else { + this->unk_1F4 = 0x1FCB; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Osn/EnOsn_Draw.s") + case 0x1FCB: + case 0x2007: + this->unk_1F4 = 0x1FCC; + this->unk_1EA |= 0x20; + break; + + case 0x1FCE: + case 0x1FD0: + this->unk_1F4 = 0x1FCF; + break; + + case 0x1FCF: + this->unk_1F4 = 0x1FCA; + break; + + case 0x1FD1: + case 0x1FD2: + this->unk_1F4 = func_80AD08B0(globalCtx); + break; + + case 0x1FD6: + this->unk_1F4 = 0x1FD7; + break; + + case 0x1FD8: + this->unk_1F4 = 0x1FD9; + break; + + case 0x1FDA: + this->unk_1F4 = 0x1FDB; + break; + + case 0x1FDC: + this->unk_1F4 = 0x1FDD; + break; + + case 0x1FDE: + this->unk_1F4 = 0x1FDF; + break; + + case 0x1FE0: + this->unk_1F4 = 0x1FE1; + break; + + case 0x1FE2: + this->unk_1F4 = 0x1FE3; + break; + + case 0x1FE4: + this->unk_1F4 = 0x1FE5; + break; + + case 0x1FE6: + this->unk_1F4 = 0x1FE7; + break; + + case 0x1FE8: + this->unk_1F4 = 0x1FE9; + break; + + case 0x1FEA: + this->unk_1F4 = 0x1FEB; + break; + + case 0x1FEC: + this->unk_1F4 = 0x1FED; + break; + + case 0x1FEE: + this->unk_1F4 = 0x1FEF; + break; + + case 0x1FF0: + this->unk_1F4 = 0x1FF1; + break; + + case 0x1FF2: + this->unk_1F4 = 0x1FF3; + break; + + case 0x1FF4: + this->unk_1F4 = 0x1FF5; + break; + + case 0x1FF6: + this->unk_1F4 = 0x1FF7; + break; + + case 0x1FF8: + this->unk_1F4 = 0x1FF9; + break; + + case 0x1FFA: + this->unk_1F4 = 0x1FFB; + break; + + case 0x1FFC: + this->unk_1F4 = 0x1FFD; + break; + + case 0x1FD7: + case 0x1FDB: + case 0x1FDD: + case 0x1FDF: + case 0x1FE1: + case 0x1FE7: + case 0x1FF1: + case 0x1FF3: + case 0x1FF7: + case 0x1FF9: + case 0x1FFB: + this->unk_1F4 = 0x1FD3; + break; + + case 0x1FD9: + case 0x1FE3: + case 0x1FE9: + case 0x1FEB: + case 0x1FED: + case 0x1FEF: + case 0x1FF5: + case 0x1FFD: + this->unk_1F4 = 0x1FD4; + break; + + case 0x1FE5: + this->unk_1F4 = 0x1FFE; + break; + + case 0x1FD3: + case 0x1FD4: + case 0x1FFE: + this->unk_1F4 = 0x1FD5; + this->unk_1EA |= 0x20; + } + + Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); +} + +void func_80AD1398(EnOsn* this) { + this->cutscene = this->actor.cutscene; + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) || + (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { + this->cutscene = ActorCutscene_GetAdditionalCutscene(this->cutscene); + } + } +} + +void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { + u32 sp1C = Flags_GetSwitch(globalCtx, 0); + this->cutscene = this->actor.cutscene; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + if (sp1C == 0) { + this->actionFunc = func_80AD16A8; + } else { + this->actionFunc = func_80AD14C8; + } +} + +void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { + s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + if (gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AD1634; + } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && + (temp_v1 > -0x4000)) { + func_800B863C(&this->actor, globalCtx); + this->actor.textId = 0xFFFF; + } + } else { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1F4 = func_80AD0E10(this, globalCtx); + Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); + this->actionFunc = func_80AD19A0; + } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && + (temp_v1 > -0x4000)) { + func_800B863C(&this->actor, globalCtx); + } + } +} + +void func_80AD1634(EnOsn* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Start(this->cutscene, &this->actor); + this->actionFunc = func_80AD16A8; + return; + } + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); +} + +void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { + u8 pad; + s32 actionIndex; + + if (Cutscene_CheckActorAction(globalCtx, 130)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 130); + this->unk_1F0 = 0; + if (this->unk_1ED != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_1ED = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + case 1: + this->unk_1EC = 2; + break; + case 2: + this->unk_1EC = 1; + break; + case 3: + this->unk_1EC = 7; + break; + case 4: + this->unk_1EC = 3; + break; + case 5: + this->unk_1EC = 6; + break; + case 6: + this->unk_1EC = 5; + break; + case 7: + this->unk_1EC = 4; + break; + case 8: + this->unk_1EC = 0; + break; + case 10: + this->unk_1EC = 8; + break; + case 11: + this->unk_1EC = 9; + break; + case 13: + this->unk_1EC = 0xA; + break; + case 15: + this->unk_1EC = 0xB; + break; + case 16: + this->unk_1EC = 0xC; + break; + case 17: + this->unk_1EC = 0xD; + break; + case 18: + this->unk_1EC = 0xE; + break; + case 19: + this->unk_1EC = 0x11; + break; + case 20: + this->unk_1EC = 0x12; + break; + case 21: + this->unk_1EC = 0x14; + break; + case 22: + this->unk_1EC = 0x15; + break; + case 23: + this->unk_1EC = 0x17; + break; + case 24: + this->unk_1EC = 0x18; + break; + default: + this->unk_1EC = 0; + break; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + } + + if ((this->unk_1EC == 5) && (globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && + (globalCtx->csCtx.frames == 400)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); + } + if (this->unk_1EC == 0x12) { + func_80AD0998(this); + } + if (this->unk_1EC == 0x15) { + func_80AD0A24(this); + } + if (this->unk_1EC == 0x18) { + func_80AD0AB0(this); + } + if ((this->unk_1EC == 0x14) && + (((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); + } + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + } else { + this->unk_1F0 = 1; + this->unk_1ED = 0x63; + func_80AD144C(this, globalCtx); + } +} + +void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx) { + u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); + + if ((temp_v0 == 6 || temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { + if (this->unk_1EA & 0x20) { + this->unk_1EA &= ~0x20; + globalCtx->msgCtx.msgMode = 0x43; + globalCtx->msgCtx.unk12023 = 4; + this->actionFunc = func_80AD14C8; + } else { + func_80AD10FC(this, globalCtx); + } + } +} + +void EnOsn_Idle(EnOsn* this, GlobalContext* globalCtx) { +} + +void EnOsn_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsn* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_osn_Skel_0202F0, &object_osn_Anim_0201BC, 0, 0, 0); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->unk_1FA = 255; + switch (ENOSN_GET_3(&this->actor)) { + case 0: + if (((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC030)) || + (gSaveContext.save.entranceIndex == 0xC060)) { + this->unk_1EA |= 1; + } + this->unk_1F0 = 1; + if (globalCtx->sceneNum == SCENE_INSIDETOWER) { + if ((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC060)) { + this->actionFunc = func_80AD16A8; + return; + } + if (gSaveContext.save.entranceIndex == 0xC030) { + func_80AD1398(this); + this->actionFunc = func_80AD1634; + return; + } + func_80AD144C(this, globalCtx); + return; + } + func_80AD144C(this, globalCtx); + break; + + case 1: + this->unk_1EC = 0xF; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + this->actionFunc = EnOsn_Idle; + break; + + case 2: + this->unk_1EC = 0x10; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + this->actionFunc = EnOsn_Idle; + break; + + case 3: + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80AD16A8; + break; + + default: + Actor_MarkForDeath(&this->actor); + } +} + +void EnOsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnOsn* this = THIS; + + SkelAnime_Free(&this->skelAnime, globalCtx); + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnOsn_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnOsn* this = THIS; + u32 sp34; + + sp34 = Flags_GetSwitch(globalCtx, 0); + this->actionFunc(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + if (!(ENOSN_GET_3(&this->actor))) { + if (sp34 != 0) { + this->actor.flags |= ACTOR_FLAG_1; + func_80AD0830(this, globalCtx); + this->actor.draw = EnOsn_Draw; + } else { + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + } + } + func_800E9250(globalCtx, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); +} + +s32 EnOsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnOsn* this = (EnOsn*)thisx; + + if (this->unk_1F0 && limbIndex == 11) { + Matrix_InsertXRotation_s(this->unk_1D8.y, MTXMODE_APPLY); + } + if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { + *dList = NULL; + } + return false; +} + +void EnOsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnOsn* this = (EnOsn*)thisx; + Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; + Vec3s sp28 = { 0x9920, -0x384, -0x320 }; + + if (limbIndex == 11) { + Matrix_MultiplyVector3fByState(&sp30, &thisx->focus.pos); + } + if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { + Matrix_StatePush(); + Matrix_InsertTranslation(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(sp28.x, MTXMODE_APPLY); + Matrix_RotateY(sp28.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp28.z, MTXMODE_APPLY); + + gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); + Matrix_StatePop(); + } +} + +void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr D_80AD2588 = object_osn_Tex_0166F8; + static TexturePtr D_80AD258C = object_osn_Tex_016EF8; + static TexturePtr D_80AD2590 = object_osn_Tex_0176F8; + static TexturePtr D_80AD2594 = object_osn_Tex_017EF8; + static TexturePtr D_80AD2598 = object_osn_Tex_0182F8; + s32 pad; + EnOsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_1FA == 0xFF) { + func_8012C28C(globalCtx->state.gfxCtx); + if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || + (globalCtx->msgCtx.currentTextId == 0x1FCA)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD258C)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + } else if ((this->unk_1EC == 7) || (this->unk_1EC == 3) || (this->unk_1EC == 0xD)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2590)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2598)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + } + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, + &this->actor, POLY_OPA_DISP); + } else { + func_8012C2DC(globalCtx->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_1FA); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, + &this->actor, POLY_XLU_DISP); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} 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 112a73e47..4cb99b925 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -9,11 +9,25 @@ typedef void (*EnOsnActionFunc)(struct EnOsn*, GlobalContext*); typedef struct EnOsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0X0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnOsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x28]; -} EnOsn; // size = 0x200 + /* 0x01D8 */ Vec3s unk_1D8; + /* 0x01DE */ Vec3s unk_1DE; + /* 0x01E4 */ UNK_TYPE1 unk_1E4[0x6]; + /* 0x01EA */ u16 unk_1EA; + /* 0x01EC */ u8 unk_1EC; + /* 0x01ED */ u8 unk_1ED; + /* 0x01EE */ s16 cutscene; + /* 0x01F0 */ u8 unk_1F0; + /* 0x01F1 */ UNK_TYPE1 unk_1F1[0x3]; + /* 0x01F4 */ u16 unk_1F4; + /* 0x01F6 */ s32 unk_1F6; + /* 0x01FA */ u8 unk_1FA; +} EnOsn; // size = 0x1FB extern const ActorInit En_Osn_InitVars; +#define ENOSN_GET_3(this) ((thisx)->params & 3) + #endif // Z_EN_OSN_H 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 54ca45a58..1bc38b877 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -6,10 +6,8 @@ #include "z_en_ossan.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_fsn/object_fsn.h" -#include "objects/object_ani/object_ani.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOssan*)thisx) @@ -20,17 +18,19 @@ void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx); -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx); + +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx); +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx); void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx); void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx); void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx); -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx); void EnOssan_SetHaveMet(EnOssan* this); void EnOssan_StartShopping(GlobalContext* globalCtx, EnOssan* this); void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx); @@ -53,6 +53,45 @@ void EnOssan_GetCutscenes(EnOssan* this, GlobalContext* globalCtx); s32 EnOssan_ReturnItemToShelf(EnOssan* this); s32 EnOssan_TakeItemOffShelf(EnOssan* this); +typedef enum { + /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, + /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, + /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING +} EnOssanCutsceneState; + +typedef enum { + /* 00 */ FSN_ANIMATION_IDLE, + /* 01 */ FSN_ANIMATION_SCRATCH_BACK, + /* 02 */ FSN_ANIMATION_TURN_AROUND_FORWARD, + /* 03 */ FSN_ANIMATION_TURN_AROUND_REVERSE, + /* 04 */ FSN_ANIMATION_HANDS_ON_COUNTER_START, + /* 05 */ FSN_ANIMATION_HANDS_ON_COUNTER_LOOP, + /* 06 */ FSN_ANIMATION_HAND_ON_FACE_START, + /* 07 */ FSN_ANIMATION_HAND_ON_FACE_LOOP, + /* 08 */ FSN_ANIMATION_LEAN_FORWARD_START, + /* 09 */ FSN_ANIMATION_LEAN_FORWARD_LOOP, + /* 10 */ FSN_ANIMATION_SLAM_COUNTER_START, + /* 11 */ FSN_ANIMATION_SLAM_COUNTER_LOOP, + /* 12 */ FSN_ANIMATION_MAKE_OFFER, + /* 13 */ FSN_ANIMATION_MAX +} FsnAnimation; + +typedef enum { + /* 00 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_1, + /* 01 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_2, + /* 02 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_1, + /* 03 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_REVERSE, + /* 04 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_2, + /* 05 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_3, + /* 06 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_3, + /* 07 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_4, + /* 08 */ ANI_ANIMATION_APOLOGY_START, + /* 09 */ ANI_ANIMATION_APOLOGY_LOOP, + /* 10 */ ANI_ANIMATION_STANDING_NORMAL_ONCE_FORWARD_4, + /* 11 */ ANI_ANIMATION_STANDING_NORMAL_LOOP_5, + /* 12 */ ANI_ANIMATION_MAX +} AniAnimation; + const ActorInit En_Ossan_InitVars = { ACTOR_EN_OSSAN, ACTORCAT_NPC, @@ -65,28 +104,40 @@ const ActorInit En_Ossan_InitVars = { (ActorFunc)NULL, }; -static ActorAnimationEntryS sAnimationsCuriosityShopMan[] = { - { &object_fsn_Anim_012C34, 1.0f, 0, -1, 0, 0 }, { &object_fsn_Anim_0131FC, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00C58C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C58C, -1.0f, 0, -1, 2, 0 }, - { &object_fsn_Anim_00E3EC, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00F00C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00CB3C, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00D354, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_0138B0, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_01430C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00B9D8, 1.0f, 0, -1, 2, 0 }, { &object_fsn_Anim_00C26C, 1.0f, 0, -1, 0, 0 }, - { &object_fsn_Anim_00DE34, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimationsCuriosityShopMan[] = { + { &gFsnIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnScratchBackAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnTurnAroundAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandsOnCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnHandOnFaceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnHandOnFaceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnLeanForwardStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnLeanForwardLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnSlamCounterStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gFsnSlamCounterLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gFsnMakeOfferAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -static ActorAnimationEntryS sAnimationsPartTimeWorker[] = { - { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, -10 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, -10 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, -1.0f, 0, -1, 2, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, - { &object_ani_Anim_00A460, 1.0f, 0, -1, 2, -5 }, { &object_ani_Anim_00A460, 1.0f, 0, -1, 0, -5 }, - { &object_ani_Anim_009D34, 1.0f, 0, -1, 2, 0 }, { &object_ani_Anim_009D34, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimationsPartTimeWorker[] = { + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAniHandBehindHeadApologyAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -5 }, + { &gAniHandBehindHeadApologyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -5 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gAniStandingNormalAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static s16 sObjectIds[] = { OBJECT_FSN, OBJECT_ANI }; -static ActorAnimationEntryS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; +static AnimationInfoS* sAnimations[] = { sAnimationsCuriosityShopMan, sAnimationsPartTimeWorker }; static f32 sActorScales[] = { 0.01f, 0.01f }; @@ -313,7 +364,7 @@ void EnOssan_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnOssan* t void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - func_8013D9C8(globalCtx, this->limbRotTableY, this->limbRotTableZ, 19); + SubS_FillLimbRotTables(globalCtx, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->stateFlags2 |= 0x20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); @@ -338,11 +389,11 @@ void EnOssan_Idle(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(animations[this->animationIdx].animationSeg); + s16 frameCount = Animation_GetLastFrame(animations[this->animationIndex].animation); - if (this->animationIdx == 3) { + if (this->animationIndex == FSN_ANIMATION_TURN_AROUND_REVERSE) { frameCount = 0; } if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_WAITING) { @@ -355,48 +406,48 @@ void EnOssan_BeginInteraction(EnOssan* this, GlobalContext* globalCtx) { } if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { if (curFrame == frameCount) { - switch (this->animationIdx) { - case 1: - this->animationIdx = 2; - func_8013BC6C(&this->skelAnime, animations, 2); + switch (this->animationIndex) { + case FSN_ANIMATION_SCRATCH_BACK: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_FORWARD; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_FORWARD); break; - case 2: + case FSN_ANIMATION_TURN_AROUND_FORWARD: EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomeCuriosityShopMan(this, globalCtx); - func_8013BC6C(&this->skelAnime, animations, this->animationIdx); + this->textId = EnOssan_CuriosityShopMan_GetWelcome(this, globalCtx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); break; - case 4: - case 6: - case 8: - case 10: - this->animationIdx++; - func_8013BC6C(&this->skelAnime, animations, this->animationIdx); - func_801518B0(globalCtx, this->textId, &this->actor); + case FSN_ANIMATION_HANDS_ON_COUNTER_START: + case FSN_ANIMATION_HAND_ON_FACE_START: + case FSN_ANIMATION_LEAN_FORWARD_START: + case FSN_ANIMATION_SLAM_COUNTER_START: + this->animationIndex++; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, this->animationIndex); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); break; - case 5: - case 7: - case 9: - case 11: - this->animationIdx = 3; - func_8013BC6C(&this->skelAnime, animations, 3); + case FSN_ANIMATION_HANDS_ON_COUNTER_LOOP: + case FSN_ANIMATION_HAND_ON_FACE_LOOP: + case FSN_ANIMATION_LEAN_FORWARD_LOOP: + case FSN_ANIMATION_SLAM_COUNTER_LOOP: + this->animationIndex = FSN_ANIMATION_TURN_AROUND_REVERSE; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_TURN_AROUND_REVERSE); break; - case 3: - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + case FSN_ANIMATION_TURN_AROUND_REVERSE: + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; default: - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + this->animationIndex = FSN_ANIMATION_SCRATCH_BACK; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, FSN_ANIMATION_SCRATCH_BACK); EnOssan_SetupAction(this, EnOssan_Idle); break; } } } else { EnOssan_SetHaveMet(this); - this->textId = EnOssan_GetWelcomePartTimeWorker(this, globalCtx); - func_801518B0(globalCtx, this->textId, &this->actor); + this->textId = EnOssan_PartTimerWorker_GetWelcome(this, globalCtx); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, false); } } @@ -506,16 +557,16 @@ u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { } void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; u8 talkState = Message_GetState(&globalCtx->msgCtx); s32 pad; Player* player = GET_PLAYER(globalCtx); EnOssan_RotateHead(this, globalCtx); - if (talkState == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } this->flags &= ~LOOKED_AT_PLAYER; if (player->transformation == PLAYER_FORM_DEKU) { @@ -529,26 +580,26 @@ void EnOssan_Hello(EnOssan* this, GlobalContext* globalCtx) { return; } } - if (talkState == 10 && this->actor.params == ENOSSAN_PART_TIME_WORKER && - player->transformation == PLAYER_FORM_ZORA && func_80147624(globalCtx)) { - this->animationIdx = 9; - func_8013BC6C(&this->skelAnime, animations, 9); + if ((talkState == 10) && (this->actor.params == ENOSSAN_PART_TIME_WORKER) && + (player->transformation == PLAYER_FORM_ZORA) && Message_ShouldAdvance(globalCtx)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, ANI_ANIMATION_APOLOGY_LOOP); } - if (this->animationIdx == 11 && Animation_OnFrame(&this->skelAnime, 18.0f)) { + if ((this->animationIndex == FSN_ANIMATION_SLAM_COUNTER_LOOP) && Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } } s32 EnOssan_FacingShopkeeperDialogResult(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; Player* player = GET_PLAYER(globalCtx); switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); - if (this->actor.params == ENOSSAN_PART_TIME_WORKER && player->transformation == PLAYER_FORM_ZORA) { - this->animationIdx = 9; - func_8013BC6C(&this->skelAnime, animations, 9); + if ((this->actor.params == ENOSSAN_PART_TIME_WORKER) && (player->transformation == PLAYER_FORM_ZORA)) { + this->animationIndex = ANI_ANIMATION_APOLOGY_LOOP; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 9); } EnOssan_SetupAction(this, EnOssan_TalkToShopkeeper); func_80151938(globalCtx, sTalkOptionTextIds[this->actor.params]); @@ -581,7 +632,7 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); if (!EnOssan_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)) && - (!func_80147624(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { + (!Message_ShouldAdvance(globalCtx) || !EnOssan_FacingShopkeeperDialogResult(this, globalCtx))) { if (this->stickAccumX < 0) { cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 4); if (cursorIdx != CURSOR_INVALID) { @@ -612,12 +663,12 @@ void EnOssan_FaceShopkeeper(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_TalkToShopkeeper(EnOssan* this, GlobalContext* globalCtx) { - ActorAnimationEntryS* animations = sAnimations[this->actor.params]; + AnimationInfoS* animations = sAnimations[this->actor.params]; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { - if (this->animationIdx == 9 && this->actor.params == ENOSSAN_PART_TIME_WORKER) { - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, animations, 1); + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { + if ((this->animationIndex == ANI_ANIMATION_APOLOGY_LOOP) && (this->actor.params == ENOSSAN_PART_TIME_WORKER)) { + this->animationIndex = ANI_ANIMATION_STANDING_NORMAL_LOOP_2; + SubS_ChangeAnimationByInfoS(&this->skelAnime, animations, 1); } EnOssan_StartShopping(globalCtx, this); } @@ -1002,7 +1053,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { if (EnOssan_TakeItemOffShelf(this) && talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnOssan_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnOssan_HandleCanBuyItem(globalCtx, this); @@ -1018,7 +1069,7 @@ void EnOssan_SelectItem(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1027,7 +1078,7 @@ void EnOssan_CannotBuy(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_CanBuy(EnOssan* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1047,7 +1098,7 @@ void EnOssan_BuyItemWithFanfare(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_SetupItemPurchased(EnOssan* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnOssan_SetupAction(this, EnOssan_ItemPurchased); @@ -1069,7 +1120,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1079,7 +1130,7 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); break; @@ -1091,13 +1142,13 @@ void EnOssan_ContinueShopping(EnOssan* this, GlobalContext* globalCtx) { } } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { EnOssan_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnOssan_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 100.0f, EXCH_ITEM_MINUS1); } @@ -1226,10 +1277,7 @@ void EnOssan_UpdateCursorAnim(EnOssan* this) { void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possibly Fake - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1256,31 +1304,33 @@ void EnOssan_UpdateStickDirectionPromptAnim(EnOssan* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnOssan_WaitForBlink(EnOssan* this) { @@ -1312,52 +1362,52 @@ void EnOssan_Blink(EnOssan* this) { } } -void EnOssan_InitCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_fsn_Skel_013320, &object_fsn_Anim_012C34, this->jointTable, - this->morphTable, 19); - this->actor.draw = EnOssan_DrawCuriosityShopMan; +void EnOssan_CuriosityShopMan_Init(EnOssan* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, + ENOSSAN_LIMB_MAX); + this->actor.draw = EnOssan_CuriosityShopMan_Draw; } -void EnOssan_InitPartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ani_Skel_0028A0, &object_ani_Anim_009D34, this->jointTable, +void EnOssan_PartTimeWorker_Init(EnOssan* this, GlobalContext* globalCtx) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gAniSkeleton, &gAniStandingNormalAnim, this->jointTable, this->morphTable, 16); - this->actor.draw = EnOssan_DrawPartTimeWorker; + this->actor.draw = EnOssan_PartTimeWorker_Draw; } -u16 EnOssan_GetWelcomeCuriosityShopMan(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_CuriosityShopMan_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x2F); if (textId != 0) { - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; this->flags |= END_INTERACTION; return textId; } switch (player->transformation) { case PLAYER_FORM_DEKU: - this->animationIdx = 10; - if (gSaveContext.save.weekEventReg[0x12] & 0x10) { + this->animationIndex = FSN_ANIMATION_SLAM_COUNTER_START; + if (gSaveContext.save.weekEventReg[18] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_ZORA: - this->animationIdx = 8; - if (gSaveContext.save.weekEventReg[0x12] & 8) { + this->animationIndex = FSN_ANIMATION_LEAN_FORWARD_START; + if (gSaveContext.save.weekEventReg[18] & 8) { return sWelcomeZoraTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_GORON: - this->animationIdx = 6; - if (gSaveContext.save.weekEventReg[0x12] & 4) { + this->animationIndex = FSN_ANIMATION_HAND_ON_FACE_START; + if (gSaveContext.save.weekEventReg[18] & 4) { return sWelcomeGoronTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } - this->animationIdx = 4; + this->animationIndex = FSN_ANIMATION_HANDS_ON_COUNTER_START; return sWelcomeHumanTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } -u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { +u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); u16 textId = Text_GetFaceReaction(globalCtx, 0x36); @@ -1367,17 +1417,17 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { } switch (player->transformation) { case PLAYER_FORM_DEKU: - if (gSaveContext.save.weekEventReg[0x37] & 0x10) { + if (gSaveContext.save.weekEventReg[55] & 0x10) { return sWelcomeDekuTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_ZORA: - if (gSaveContext.save.weekEventReg[0x37] & 8) { + if (gSaveContext.save.weekEventReg[55] & 8) { return sWelcomeZoraTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_GORON: - if (gSaveContext.save.weekEventReg[0x37] & 4) { + if (gSaveContext.save.weekEventReg[55] & 4) { return sWelcomeGoronTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; @@ -1388,32 +1438,32 @@ u16 EnOssan_GetWelcomePartTimeWorker(EnOssan* this, GlobalContext* globalCtx) { void EnOssan_SetHaveMet(EnOssan* this) { switch (this->textId) { case 0x06A9: - gSaveContext.save.weekEventReg[0x12] |= 0x10; + gSaveContext.save.weekEventReg[18] |= 0x10; break; case 0x06C6: - gSaveContext.save.weekEventReg[0x37] |= 0x10; + gSaveContext.save.weekEventReg[55] |= 0x10; break; case 0x06A7: - gSaveContext.save.weekEventReg[0x12] |= 8; + gSaveContext.save.weekEventReg[18] |= 8; break; case 0x06C4: - gSaveContext.save.weekEventReg[0x37] |= 8; + gSaveContext.save.weekEventReg[55] |= 8; break; case 0x06A5: - gSaveContext.save.weekEventReg[0x12] |= 4; + gSaveContext.save.weekEventReg[18] |= 4; break; case 0x06C2: - gSaveContext.save.weekEventReg[0x37] |= 4; + gSaveContext.save.weekEventReg[55] |= 4; break; } } void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { - static EnOssanActionFunc sInitFuncs[] = { EnOssan_InitCuriosityShopMan, EnOssan_InitPartTimeWorker }; + static EnOssanActionFunc sInitFuncs[] = { EnOssan_CuriosityShopMan_Init, EnOssan_PartTimeWorker_Init }; ShopItem* shopItems; if (Object_IsLoaded(&globalCtx->objectCtx, this->objIndex)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndex; Actor_SetObjectDependency(globalCtx, &this->actor); shopItems = sShops[this->actor.params]; @@ -1474,14 +1524,15 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->arrowAnimTween = 0.0f; this->stickAnimTween = 0.0f; this->shopItemSelectedTween = 0.0f; + Actor_SetScale(&this->actor, sActorScales[this->actor.params]); - this->animationIdx = 1; - func_8013BC6C(&this->skelAnime, sAnimations[this->actor.params], 1); + this->animationIndex = 1; // FSN_ANIMATION_SCRATCH_BACK and ANI_ANIMATION_STANDING_NORMAL_LOOP_2 + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations[this->actor.params], 1); EnOssan_SpawnShopItems(this, globalCtx, shopItems); this->blinkTimer = 20; this->eyeTexIndex = 0; this->blinkFunc = EnOssan_WaitForBlink; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnOssan_SetupAction(this, EnOssan_Idle); } } @@ -1512,19 +1563,22 @@ void EnOssan_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawCursor != 0) { func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w) * 4.0f; @@ -1539,11 +1593,16 @@ void EnOssan_DrawCursor(GlobalContext* globalCtx, EnOssan* this, f32 x, f32 y, f void EnOssan_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1569,21 +1628,15 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_oB1.c"); // Unreferenced + (void)"../z_en_oB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1596,15 +1649,9 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnOssan_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1621,72 +1668,73 @@ void EnOssan_DrawStickDirectionPrompts(GlobalContext* globalCtx, EnOssan* this) CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnOssan_OverrideLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, Actor* thisx) { +s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, + Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 16) { + if (limbIndex == FSN_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRot.y, MTXMODE_APPLY); } return false; } -s32 EnOssan_OverrideLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnOssan_PartTimeWorker_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, + Vec3s* rot, Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ANI_LIMB_HEAD) { Matrix_InsertXRotation_s(this->headRotPartTimeWorker.y, MTXMODE_APPLY); Matrix_InsertZRotation_s(this->headRotPartTimeWorker.x, MTXMODE_APPLY); } return false; } -void EnOssan_PostLimbDrawCuriosityShopMan(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_CuriosityShopMan_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { EnOssan* this = THIS; - if (limbIndex == 1 || limbIndex == 9 || limbIndex == 12) { + if (limbIndex == FSN_LIMB_PELVIS || limbIndex == FSN_LIMB_LEFT_UPPER_ARM || limbIndex == FSN_LIMB_RIGHT_UPPER_ARM) { rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 200; } } -void EnOssan_PostLimbDrawPartTimeWorker(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, - Actor* thisx) { +void EnOssan_PartTimeWorker_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { static Vec3f sPartTimeWorkerFocusOffset = { 800.0f, 500.0f, 0.0f }; EnOssan* this = THIS; - if (limbIndex == 15) { + if (limbIndex == ANI_LIMB_HEAD) { Matrix_MultiplyVector3fByState(&sPartTimeWorkerFocusOffset, &this->actor.focus.pos); } } -void EnOssan_DrawCuriosityShopMan(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_fsn_Tex_005BC0, object_fsn_Tex_006D40, object_fsn_Tex_007140 }; - EnOssan* this = THIS; +void EnOssan_CuriosityShopMan_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gFsnEyeOpenTex, gFsnEyeHalfTex, gFsnEyeClosedTex }; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawCuriosityShopMan, EnOssan_PostLimbDrawCuriosityShopMan, &this->actor); + EnOssan_CuriosityShopMan_OverrideLimbDraw, EnOssan_CuriosityShopMan_PostLimbDraw, + &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnOssan_DrawPartTimeWorker(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_ani_Tex_006498, object_ani_Tex_006B18, object_ani_Tex_006F18 }; - EnOssan* this = THIS; +void EnOssan_PartTimeWorker_Draw(Actor* thisx, GlobalContext* globalCtx) { + static TexturePtr sEyeTextures[] = { gAniOpenEyeTex, gAniClosingEyeTex, gAniClosedEyeTex }; s32 pad; + EnOssan* this = THIS; OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnOssan_OverrideLimbDrawPartTimeWorker, EnOssan_PostLimbDrawPartTimeWorker, &this->actor); + EnOssan_PartTimeWorker_OverrideLimbDraw, EnOssan_PartTimeWorker_PostLimbDraw, &this->actor); EnOssan_DrawCursor(globalCtx, this, this->cursorPos.x, this->cursorPos.y, this->cursorPos.z, this->drawCursor); EnOssan_DrawStickDirectionPrompts(globalCtx, this); CLOSE_DISPS(globalCtx->state.gfxCtx); 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 53f8b8f39..58c638d8e 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.h @@ -2,8 +2,11 @@ #define Z_EN_OSSAN_H #include "global.h" - #include "overlays/actors/ovl_En_GirlA/z_en_girla.h" +#include "objects/object_ani/object_ani.h" +#include "objects/object_fsn/object_fsn.h" + +#define ENOSSAN_LIMB_MAX MAX(FSN_LIMB_MAX + 1, ANI_LIMB_MAX) struct EnOssan; @@ -50,9 +53,9 @@ typedef struct EnOssan { /* 0x2CC */ Vec3s unk2CC; // Set but never used /* 0x2D2 */ s16 limbRotTableY[19]; /* 0x2F8 */ s16 limbRotTableZ[19]; - /* 0x31E */ Vec3s jointTable[19]; - /* 0x390 */ Vec3s morphTable[19]; - /* 0x402 */ s16 animationIdx; + /* 0x31E */ Vec3s jointTable[ENOSSAN_LIMB_MAX]; + /* 0x390 */ Vec3s morphTable[ENOSSAN_LIMB_MAX]; + /* 0x402 */ s16 animationIndex; /* 0x404 */ Vec3s headRotPartTimeWorker; /* 0x40A */ u16 flags; } EnOssan; // size = 0x40C @@ -68,12 +71,6 @@ typedef enum { /* 1 */ ENOSSAN_PART_TIME_WORKER } EnOssanWorker; -typedef enum { - /* 0 */ ENOSSAN_CUTSCENESTATE_STOPPED, - /* 1 */ ENOSSAN_CUTSCENESTATE_WAITING, - /* 2 */ ENOSSAN_CUTSCENESTATE_PLAYING -} EnOssanCutsceneState; - extern const ActorInit En_Ossan_InitVars; #endif // Z_EN_OSSAN_H 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 89b1362e1..7573947e6 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -9,7 +9,7 @@ #include "objects/object_ot/object_ot.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOt*)thisx) @@ -95,10 +95,10 @@ static ColliderCylinderInit sCylinderInit = { { 5, 33, -20, { 0, 0, 0 } }, }; -static struct_80B8E1A8 sAnimations[] = { - { &object_ot_Anim_004B30, 1.0f, 0, -5.0f }, - { &object_ot_Anim_0008D8, 1.0f, 0, -5.0f }, - { &object_ot_Anim_000420, 1.0f, 0, 0.0f }, +static AnimationSpeedInfo sAnimations[] = { + { &object_ot_Anim_004B30, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_ot_Anim_0008D8, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &object_ot_Anim_000420, 1.0f, ANIMMODE_LOOP, 0.0f }, }; static InitChainEntry sInitChain[] = { @@ -141,8 +141,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_33C = ENOT_GET_C000(&this->actor); if (this->unk_33C == 0) { D_80B5E880 = this; - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.update = func_80B5DB6C; this->actor.draw = NULL; return; @@ -152,18 +152,18 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_ot_Skel_004800, &object_ot_Anim_0008D8, this->jointTable, this->morphTable, 19); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Animation_Change(&this->skelAnime, sAnimations[0].animationSeg, 1.0f, - Animation_GetLastFrame(&sAnimations[0].animationSeg->common) * Rand_ZeroOne(), - Animation_GetLastFrame(&sAnimations[0].animationSeg->common), sAnimations[0].mode, - sAnimations[0].transitionRate); + Animation_Change(&this->skelAnime, sAnimations[0].animation, 1.0f, + Animation_GetLastFrame(&sAnimations[0].animation->common) * Rand_ZeroOne(), + Animation_GetLastFrame(&sAnimations[0].animation->common), sAnimations[0].mode, + sAnimations[0].morphFrames); this->unk_346 = ENOT_GET_7F(&this->actor); this->unk_344 = this->actor.world.rot.z; this->actor.world.rot.z = 0; this->actor.shape.rot.z = 0; this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.gravity = 0.0f; - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); this->unk_744.r = 255; @@ -265,8 +265,8 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { case 3: if (!(gSaveContext.save.weekEventReg[26] & 8)) { - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Actor_SetScale(&this->actor, 0.0064999997f); this->collider.dim.radius *= 0.5f; this->collider.dim.height *= 0.5f; @@ -300,21 +300,21 @@ void func_80B5BB38(Color_RGB8* arg0, Color_RGB8* arg1, f32 arg2) { } void func_80B5BDA8(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); this->actionFunc = func_80B5BE04; } void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { switch (this->unk_388) { case 0: - if (func_8013E2D4(&this->actor, this->cutscenes[2], -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[2], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80B5BF60(this, globalCtx); } break; case 1: - if (func_8013E2D4(&this->actor, this->cutscenes[3], -1, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[3], -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80B5BF60(this, globalCtx); } break; @@ -322,7 +322,7 @@ void func_80B5BE04(EnOt* this, GlobalContext* globalCtx) { } void func_80B5BE88(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); this->actionFunc = func_80B5BED4; } @@ -337,7 +337,7 @@ void func_80B5BED4(EnOt* this, GlobalContext* globalCtx) { void func_80B5BF60(EnOt* this, GlobalContext* globalCtx) { this->unk_32C |= 0x40; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5BFB8; } @@ -410,12 +410,12 @@ void func_80B5C25C(EnOt* this, GlobalContext* globalCtx) { if ((this->unk_33C == 2) && (this->unk_32C & 0x80) && (this->unk_360->unk_32C & 0x80)) { this->unk_32C |= 0x100; this->unk_360->unk_32C |= 0x100; - func_8013E1C8(&this->skelAnime, sAnimations, 2, &this->animIdx); - func_8013E1C8(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); - this->unk_360->actor.flags |= 0x8000000; - this->unk_360->actor.flags &= ~(0x8 | 0x1); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 2, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->unk_360->skelAnime, sAnimations, 2, &this->unk_360->animIdx); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_360->actor.flags |= ACTOR_FLAG_8000000; + this->unk_360->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B5C9A8(this->unk_360, globalCtx); func_80B5C3B8(this, globalCtx); } @@ -437,7 +437,7 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { Vec3f sp38; this->unk_3A0 += 0x2D8; - Matrix_RotateY(this->unk_3A0, 0); + Matrix_RotateY(this->unk_3A0, MTXMODE_NEW); Matrix_GetStateTranslationAndScaledZ(26.259998f, &sp5C); Matrix_GetStateTranslationAndScaledZ(-26.259998f, &sp50); this->unk_348.x = this->unk_394.x + sp5C.x; @@ -461,7 +461,7 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateY(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)), 0); + Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_NEW); sp38.x = 1.0f; sp38.y = 8.1f; sp38.z = 0.0f; @@ -489,7 +489,7 @@ void func_80B5C64C(EnOt* this, GlobalContext* globalCtx) { void func_80B5C684(EnOt* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5C6DC; } @@ -591,7 +591,7 @@ void func_80B5CA30(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CAD0(EnOt* this, GlobalContext* globalCtx) { - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes) / 2); this->actionFunc = func_80B5CB0C; } @@ -605,14 +605,14 @@ void func_80B5CB0C(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CBA0(EnOt* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); this->actionFunc = func_80B5CBEC; } void func_80B5CBEC(EnOt* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80B5CC88(this, globalCtx); } else { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); @@ -626,7 +626,7 @@ void func_80B5CC88(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 1)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { Player* player = GET_PLAYER(globalCtx); player->stateFlags2 |= 0x20000000; @@ -635,7 +635,7 @@ void func_80B5CCA0(EnOt* this, GlobalContext* globalCtx) { } void func_80B5CCF4(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5CD40; } @@ -645,13 +645,13 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: - temp = Math_SmoothStepToS(&this->actor.shape.rot.y, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), - 3, 0xE38, 0x38E); + temp = Math_SmoothStepToS(&this->actor.shape.rot.y, + BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 3, 0xE38, 0x38E); this->actor.world.rot.y = this->actor.shape.rot.y; if (1) {} if (!temp) { gSaveContext.save.weekEventReg[23] |= 0x10; - func_801518B0(globalCtx, 0x1069, NULL); + Message_StartTextbox(globalCtx, 0x1069, NULL); } break; @@ -663,7 +663,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1069)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1069)) { this->unk_32C |= 4; ActorCutscene_Stop(this->cutscenes[0]); player->stateFlags2 &= ~0x20000000; @@ -676,7 +676,7 @@ void func_80B5CD40(EnOt* this, GlobalContext* globalCtx) { void func_80B5CE6C(EnOt* this, GlobalContext* globalCtx) { this->unk_384 = 0; this->unk_32C |= 0x20; - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5CEC8; } @@ -692,10 +692,10 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); if (this->unk_32C & 0x800) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; if ((player->actor.bgCheckFlags & 1) && !func_801242B4(player) && (this->actor.xzDistToPlayer < 130.0f)) { func_800B8614(&this->actor, globalCtx, 130.0f); } @@ -731,7 +731,7 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { } void func_80B5D114(EnOt* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, sAnimations, 0, &this->animIdx); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->animIdx); this->actionFunc = func_80B5D160; } @@ -765,12 +765,12 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x10A5; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); func_80B5D114(this, globalCtx); break; case 1: - func_801518B0(globalCtx, 0x106D, &this->actor); + Message_StartTextbox(globalCtx, 0x106D, &this->actor); func_80B5D114(this, globalCtx); break; } @@ -786,8 +786,8 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { default: case 0x1068: case 0x106B: @@ -817,31 +817,27 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 func_80B5D37C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - s32 pad; - EnOt* temp_s0 = (EnOt*)arg1->actor; - f32 sp24; - f32 sp20; +s32 EnOt_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnOt* this = (EnOt*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; + f32 sp20 = gFramerateDivisorHalf; - sp24 = Math_CosS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - 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.z = Math_CosS(thisx->world.rot.y) * sp24; - temp_s0->actor.velocity.x = Math_SinS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->actor.velocity.y = Math_SinS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - do { - temp_s0->actor.velocity.z = Math_CosS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->unk_330.x += (temp_s0->actor.velocity.x * sp20) + temp_s0->actor.colChkInfo.displacement.x; - temp_s0->unk_330.y += (temp_s0->actor.velocity.y * sp20) + temp_s0->actor.colChkInfo.displacement.y; - } while (0); - temp_s0->unk_330.z += (temp_s0->actor.velocity.z * sp20) + temp_s0->actor.colChkInfo.displacement.z; + this->unk_330.x += (thisx->velocity.x * sp20) + thisx->colChkInfo.displacement.x; + this->unk_330.y += (thisx->velocity.y * sp20) + thisx->colChkInfo.displacement.y; + this->unk_330.z += (thisx->velocity.z * sp20) + thisx->colChkInfo.displacement.z; return false; } -s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { +s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + s32 ret = false; s32 pad; - s32 ret; - Actor* temp_s1 = arg1->actor; Vec3f sp50; Vec3f sp44; f32 temp; @@ -849,32 +845,31 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 sp30; s32 sp34; - ret = false; - temp_s1->gravity = 0.0f; - Math_SmoothStepToF(&temp_s1->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); + thisx->gravity = 0.0f; + Math_SmoothStepToF(&thisx->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); - sp50.x = arg1->unk_20.x - temp_s1->world.pos.x; - sp50.y = arg1->unk_20.y - temp_s1->world.pos.y; - sp50.z = arg1->unk_20.z - temp_s1->world.pos.z; + sp50.x = actorPath->curPoint.x - thisx->world.pos.x; + sp50.y = actorPath->curPoint.y - thisx->world.pos.y; + sp50.z = actorPath->curPoint.z - thisx->world.pos.z; - sp44.x = arg1->unk_20.x - arg1->unk_38.x; - sp44.y = arg1->unk_20.y - arg1->unk_38.y; - sp44.z = arg1->unk_20.z - arg1->unk_38.z; + sp44.x = actorPath->curPoint.x - actorPath->prevPoint.x; + sp44.y = actorPath->curPoint.y - actorPath->prevPoint.y; + sp44.z = actorPath->curPoint.z - actorPath->prevPoint.z; temp = Math3D_Parallel(&sp50, &sp44); - if ((arg1->unk_4C < SQ(temp_s1->speedXZ)) || (temp <= 0.0f)) { + if ((actorPath->distSqToCurPointXZ < SQ(thisx->speedXZ)) || (temp <= 0.0f)) { ret = true; } else { - temp = SQ(temp_s1->speedXZ) / arg1->unk_50; - sp34 = ABS(arg1->unk_54.x - temp_s1->world.rot.x); + temp = SQ(thisx->speedXZ) / actorPath->distSqToCurPoint; + sp34 = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; - sp34 = ABS(arg1->unk_54.y - temp_s1->world.rot.y); + sp34 = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54.x, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, 1, sp2C, 0); sp2C = (s32)(sp34 * temp) + 0xAAA; - Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_54.y, 1, sp2C, 0); - Math_SmoothStepToS(&temp_s1->shape.rot.y, temp_s1->world.rot.y, 2, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->shape.rot.y, thisx->world.rot.y, 2, sp2C, 0); } return ret; @@ -883,33 +878,35 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { func_80B5B2E0(globalCtx, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); Math_Vec3f_Copy(&this->unk_330, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_330, &this->actor, &this->unk_2C0, globalCtx->setupPathList, this->unk_346, 0, - 0, this->unk_340, 0); + SubS_ActorPathing_Init(globalCtx, &this->unk_330, &this->actor, &this->actorPath, globalCtx->setupPathList, + this->unk_346, 0, 0, this->unk_340, 0); this->unk_32C = 0; - this->unk_2C0.unk_2C.x = 0.0f; - this->unk_2C0.unk_2C.y = 0.0f; - this->unk_2C0.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, sAnimations, 1, &this->animIdx); - this->actor.flags |= 0x8000000; - this->actor.flags &= ~(0x8 | 0x1); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Flags_SetSwitch(globalCtx, ENOT_GET_3F80(&this->actor)); this->actionFunc = func_80B5D750; } void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { if (!(this->unk_32C & 1) && !(this->unk_32C & 2)) { - func_8013DE04(globalCtx, &this->unk_2C0, func_8013DF3C, func_80B5D470, func_80B5D37C, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnOt_ActorPathing_UpdateActorInfo, EnOt_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); } Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_330); - if (this->unk_2C0.unk_1C & 0x40) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_POINT_TEMPORARY) { this->unk_32C |= 2; } - if (this->unk_2C0.unk_1C & 0x80) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) { this->unk_32C |= 1; } @@ -918,8 +915,8 @@ void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { } if ((this->unk_32C & 1) && (this->actor.xzDistToPlayer <= 180.0f)) { - this->actor.flags &= ~0x8000000; - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); if (D_80B5E884 != 0) { func_80B5C9A8(this, globalCtx); } else { @@ -939,7 +936,7 @@ void EnOt_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); if (this->actor.bgCheckFlags & 0x20) { if (DECR(this->unk_354) == 0) { - if (this->actor.flags & 0x40) { + if (this->actor.flags & ACTOR_FLAG_40) { s32 i; for (i = 0; i < 2; i++) { @@ -1038,7 +1035,7 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, (AnimatedMaterial*)Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ot_Matanimheader_0005F8)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnOt_PostLimbDraw, &this->actor); Matrix_InsertTranslation(this->unk_378.x, this->unk_378.y, this->unk_378.z, MTXMODE_NEW); @@ -1048,7 +1045,7 @@ void EnOt_Draw(Actor* thisx, GlobalContext* globalCtx) { gfx = func_8012C7FC(POLY_XLU_DISP); - gSPSetOtherMode(&gfx[0], G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetDither(&gfx[0], G_CD_NOISE); gDPSetCombineLERP(&gfx[1], 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); gSPDisplayList(&gfx[2], gameplay_keep_DL_029CB0); @@ -1112,7 +1109,7 @@ EnOtUnkStruct* func_80B5DF58(EnOtUnkStruct* arg0, u8 arg1, Vec3f* arg2, Vec3s* a void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { Vec3f sp54; s32 i; - s16 temp = func_800DFC68(GET_ACTIVE_CAM(globalCtx)); + s16 temp = Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)); for (i = 0; i < arg2; i++, arg1++) { if ((arg1->unk_00 == 1) || (arg1->unk_00 == 2)) { @@ -1152,7 +1149,7 @@ void func_80B5E1D8(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { } Matrix_InsertTranslation(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); Matrix_Scale(arg1->unk_04, arg1->unk_04, arg1->unk_04, MTXMODE_APPLY); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gameplay_keep_Tex_05E6F0)); 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 3a52b48c6..902cbecd7 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -36,7 +36,7 @@ typedef struct EnOt { /* 0x01D8 */ Vec3s jointTable[19]; /* 0x024A */ Vec3s morphTable[19]; /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ struct_8013DF3C_arg1 unk_2C0; + /* 0x02C0 */ ActorPathing actorPath; /* 0x032C */ u16 unk_32C; /* 0x0330 */ Vec3f unk_330; /* 0x033C */ s32 unk_33C; 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 9ed5c9a3e..ab8f721ae 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -7,7 +7,7 @@ #include "z_en_owl.h" #include "objects/object_owl/object_owl.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnOwl*)thisx) @@ -41,7 +41,7 @@ void func_8095C484(EnOwl* this); void func_8095CCF4(Actor* thisx, GlobalContext* globalCtx); void func_8095D074(Actor* thisx, GlobalContext* globalCtx); void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, - AnimationHeader* animationSeg, f32 transitionRate); + AnimationHeader* animation, f32 morphFrames); typedef enum { /* 0x00 */ OWL_REPEAT, @@ -120,7 +120,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.1f); this->actor.update = func_8095CCF4; this->actor.draw = func_8095D074; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D8 = 0; this->unk_3DA = 0x320; this->unk_3DC = 0x12C; @@ -157,7 +157,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENOWL_GET_TYPE_2: - if (gSaveContext.save.inventory.items[SLOT_LENS] == ITEM_LENS) { + if (gSaveContext.save.inventory.items[ITEM_LENS] == ITEM_LENS) { Actor_MarkForDeath(&this->actor); return; } @@ -228,7 +228,7 @@ s32 func_8095A978(EnOwl* this, GlobalContext* globalCtx, u16 textId, f32 targetD this->actor.textId = textId; if (this->actor.xzDistToPlayer < targetDist) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, targetDist, arg4, EXCH_ITEM_NONE); } @@ -294,7 +294,7 @@ void func_8095ABF0(EnOwl* this, GlobalContext* globalCtx) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { Audio_QueueSeqCmd(0x110000FF); func_8095AAD0(this, globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -309,7 +309,7 @@ void func_8095AC50(EnOwl* this, GlobalContext* globalCtx) { func_8095ABA8(this); this->actionFunc = func_8095AB1C; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -324,7 +324,7 @@ void func_8095ACEC(EnOwl* this) { } void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 4) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case OWL_REPEAT: func_80151938(globalCtx, 0x7D1); @@ -340,14 +340,14 @@ void func_8095AD54(EnOwl* this, GlobalContext* globalCtx) { } void func_8095AE00(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D2); this->actionFunc = func_8095AD54; } } void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_80151938(globalCtx, 0x7D1); this->actionFunc = func_8095AE00; } @@ -364,13 +364,13 @@ void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - if (globalCtx->msgCtx.unk11F04 == 0xBFE) { + if (Message_ShouldAdvance(globalCtx)) { + if (globalCtx->msgCtx.currentTextId == 0xBFE) { func_8095ACEC(this); func_801477B4(globalCtx); this->actionFunc = func_8095ABF0; } else { - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); } } break; @@ -408,7 +408,7 @@ s32 func_8095B06C(EnOwl* this) { void func_8095B0C8(EnOwl* this) { s32 pad; - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + Vec3s* points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; this->unk_3EC = Math_FAtan2F(points->z - this->actor.world.pos.z, points->x - this->actor.world.pos.x); @@ -441,7 +441,7 @@ void func_8095B254(EnOwl* this, GlobalContext* globalCtx) { if (this->actionFlags & 1) { EnOwl_ChangeMode(this, func_8095B1E4, func_8095C328, &this->skelAnime1, &object_owl_Anim_001ADC, 0.0f); this->unk_3EA = 6; - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; } func_8095B158(this); @@ -504,10 +504,10 @@ void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 200.0f, 400.0f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } func_8095B480(this, globalCtx); } @@ -542,7 +542,7 @@ void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if (sp44 < SQ(this->actor.speedXZ)) { this->actor.speedXZ = 0.0f; - points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; do { @@ -607,8 +607,8 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEC: switch (globalCtx->msgCtx.choiceIndex) { case 0: @@ -646,8 +646,8 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0xBEA: gSaveContext.save.weekEventReg[9] |= 0x20; func_80151938(globalCtx, 0xBEB); @@ -671,7 +671,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { this->eyeTexIndex = 0; this->blinkTimer = Rand_S16Offset(60, 60); this->actionFlags |= 8; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.home.rot.x = 0; func_8095ACEC(this); this->unk_406 = 0; @@ -683,7 +683,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { func_801477B4(globalCtx); Audio_QueueSeqCmd(0x110000FF); func_8095ACEC(this); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0xBF0; this->actionFunc = func_8095BE0C; break; @@ -695,7 +695,7 @@ void func_8095BA84(EnOwl* this, GlobalContext* globalCtx) { case 0xBF5: func_801477B4(globalCtx); Audio_QueueSeqCmd(0x110000FF); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; EnOwl_ChangeMode(this, func_8095B3DC, func_8095C484, &this->skelAnime1, &object_owl_Anim_00CB94, 0.0f); this->eyeTexIndex = 0; @@ -721,10 +721,10 @@ void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } } else if (this->actor.xzDistToPlayer < 200.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 200.0f, 200.0f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; } } @@ -738,7 +738,7 @@ void func_8095BF58(EnOwl* this, GlobalContext* globalCtx) { } void func_8095BF78(EnOwl* this, GlobalContext* globalCtx) { - this->actor.flags |= 0x20; + this->actor.flags |= ACTOR_FLAG_20; if (this->actor.xzDistToPlayer > 6000.0f) { Actor_MarkForDeath(&this->actor); } @@ -1191,10 +1191,9 @@ void func_8095D074(Actor* thisx, GlobalContext* globalCtx) { } void EnOwl_ChangeMode(EnOwl* this, EnOwlActionFunc actionFunc, EnOwlFunc unkFunc, SkelAnime* skelAnime, - AnimationHeader* animationSeg, f32 transitionRate) { + AnimationHeader* animation, f32 morphFrames) { this->skelAnime3 = skelAnime; - Animation_Change(this->skelAnime3, animationSeg, 1.0f, 0.0f, Animation_GetLastFrame(animationSeg), 2, - transitionRate); + Animation_Change(this->skelAnime3, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), 2, morphFrames); this->actionFunc = actionFunc; this->unk_414 = unkFunc; } 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 9f2277b08..06cf9b22d 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -9,7 +9,7 @@ #include "../ovl_En_Door/z_en_door.h" #include "objects/object_pamera/object_pamera.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnPamera*)thisx) @@ -106,14 +106,20 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, MASS_IMMOVABLE, }; -static ActorAnimationEntry sAnimations[] = { - { &object_pamera_Anim_0005BC, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_008AE0, 1.0f, 0, 0.0f, 0, -4.0f }, - { &object_pamera_Anim_008E38, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_00A844, 1.0f, 0, 0.0f, 0, -4.0f }, - { &object_pamera_Anim_00B0C4, 1.0f, 0, 0.0f, 0, -4.0f }, { &object_pamera_Anim_009870, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_009F54, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00B5B0, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_00BCC4, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00D9DC, 1.0f, 0, 0.0f, 0, 0.0f }, - { &object_pamera_Anim_00E16C, 1.0f, 0, 0.0f, 0, 0.0f }, { &object_pamera_Anim_00C9F4, 1.0f, 0, 0.0f, 2, 0.0f }, - { &object_pamera_Anim_00D0F0, 1.0f, 0, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_pamera_Anim_0005BC, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_008AE0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_008E38, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_00A844, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_00B0C4, 1.0f, 0, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_pamera_Anim_009870, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_009F54, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00B5B0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00BCC4, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00D9DC, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00E16C, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_pamera_Anim_00C9F4, 1.0f, 0, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_pamera_Anim_00D0F0, 1.0f, 0, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static Vec3f D_80BDA5F0 = { 1000.0f, 0.0f, 0.0f }; @@ -226,8 +232,8 @@ void EnPamera_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BD8700(EnPamera* this) { this->hideInisdeTimer = 0; - this->actor.flags &= ~1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80BD8758; } @@ -235,9 +241,10 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 1800) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0]) && (this->cutscenes[0] != -1)) { ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); - func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), &this->actor); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[0])), + &this->actor); this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -246,7 +253,7 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } else { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actor.shape.rot.y = this->actor.home.rot.y; this->actor.world.rot.y = this->actor.home.rot.y; func_80BD9338(this, globalCtx); @@ -267,8 +274,8 @@ void func_80BD8758(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8908(EnPamera* this) { this->actor.draw = EnPamera_Draw; - this->actor.flags |= 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + this->actor.flags |= ACTOR_FLAG_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8964; } @@ -281,14 +288,14 @@ void func_80BD8964(EnPamera* this, GlobalContext* globalCtx) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &vec, 1.0f) < 5.0f) { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); gSaveContext.save.weekEventReg[59] |= 1; func_80BD8B50(this); } } void func_80BD8A38(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80BD8A7C; } @@ -335,14 +342,14 @@ void func_80BD8B70(EnPamera* this, GlobalContext* globalCtx) { void func_80BD8CCC(EnPamera* this) { this->hideInisdeTimer = 0; this->actor.speedXZ = 0.0f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD8D1C; } void func_80BD8D1C(EnPamera* this, GlobalContext* globalCtx) { if (this->hideInisdeTimer++ > 200) { this->actor.speedXZ = 1.5f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); func_80BD8D80(this); } } @@ -378,14 +385,14 @@ void func_80BD8DB0(EnPamera* this, GlobalContext* globalCtx) { void EnPamera_LookDownWell(EnPamera* this) { func_80BD93CC(this, 1, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BD8F60; } void func_80BD8F60(EnPamera* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x3000, 0x1000); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actor.speedXZ = 3.0f; func_80BD93CC(this, 0, 0); func_80BD8D80(this); @@ -402,7 +409,7 @@ void func_80BD8FF0(EnPamera* this) { pameraYaw = Math_Vec3f_Yaw(&pameraPos, &this->actor.world.pos); this->actor.shape.rot.y = pameraYaw; this->actor.world.rot.y = pameraYaw; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->actionFunc = func_80BD909C; } @@ -421,7 +428,8 @@ void func_80BD90AC(EnPamera* this, GlobalContext* globalCtx) { (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); - func_800E02AC(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), &this->actor); + Camera_SetToTrackActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(this->cutscenes[1])), + &this->actor); EnPamera_LookDownWell(this); } else if (this->cutscenes[1] != -1) { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -557,8 +565,8 @@ void EnPamera_Draw(Actor* thisx, GlobalContext* globalCtx) { void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { this->actor.update = func_80BDA344; - this->actor.flags |= 0x2000000; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_2000000; + this->actor.flags |= ACTOR_FLAG_100000; if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { func_80BD9E60(this); func_80BD9938(this); @@ -575,7 +583,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9904(EnPamera* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = &func_80BD9928; } @@ -591,21 +599,21 @@ void func_80BD994C(EnPamera* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { if (1) {} func_80BD93CC(this, 0, 1); - func_801518B0(globalCtx, 0x15A8, &this->actor); + Message_StartTextbox(globalCtx, 0x15A8, &this->actor); this->unk_324 = 0x15A8; } else if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || ((gSaveContext.save.weekEventReg[52] & 0x20) && (!(gSaveContext.save.weekEventReg[75] & 0x20)))) { func_80BD93CC(this, 1, 0); - func_801518B0(globalCtx, 0x158E, &this->actor); + Message_StartTextbox(globalCtx, 0x158E, &this->actor); this->unk_324 = 0x158E; } else { if (!(this->unk_322 & 1)) { this->unk_322 |= 1; - func_801518B0(globalCtx, 0x1587, &this->actor); + Message_StartTextbox(globalCtx, 0x1587, &this->actor); this->unk_324 = 0x1587; } else { - func_801518B0(globalCtx, 0x158C, &this->actor); + Message_StartTextbox(globalCtx, 0x158C, &this->actor); this->unk_324 = 0x158C; } } @@ -631,7 +639,7 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { func_80BD9B4C(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BD9938(this); } break; @@ -643,26 +651,26 @@ void EnPamera_HandleDialogue(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9B4C(EnPamera* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_324) { case 0x1587: - func_801518B0(globalCtx, 0x1588, &this->actor); + Message_StartTextbox(globalCtx, 0x1588, &this->actor); this->unk_324 = 0x1588; break; case 0x1588: - func_801518B0(globalCtx, 0x1589, &this->actor); + Message_StartTextbox(globalCtx, 0x1589, &this->actor); this->unk_324 = 0x1589; break; case 0x1589: - func_801518B0(globalCtx, 0x158A, &this->actor); + Message_StartTextbox(globalCtx, 0x158A, &this->actor); this->unk_324 = 0x158A; break; case 0x158A: - func_801518B0(globalCtx, 0x158B, &this->actor); + Message_StartTextbox(globalCtx, 0x158B, &this->actor); this->unk_324 = 0x158B; break; case 0x158C: - func_801518B0(globalCtx, 0x158D, &this->actor); + Message_StartTextbox(globalCtx, 0x158D, &this->actor); this->unk_324 = 0x158D; break; case 0x158E: @@ -682,21 +690,21 @@ void func_80BD9C70(EnPamera* this, GlobalContext* globalCtx) { } s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E5)) { - actionIndex = func_800EE200(globalCtx, 0x1E5); - if (this->unk_326 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk_326 = globalCtx->csCtx.npcActions[actionIndex]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 0x1E5)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x1E5); + if (this->unk_326 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk_326 = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: func_80BD9E88(this); break; case 2: if (this->actor.draw == NULL) { this->actor.draw = EnPamera_Draw; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } func_80BD9EE0(this); break; @@ -714,7 +722,7 @@ s32 func_80BD9CB8(EnPamera* this, GlobalContext* globalCtx) { break; } } - func_800EDF24(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); this->setupFunc(this, globalCtx); return 1; } @@ -738,7 +746,7 @@ void func_80BD9E78(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9E88(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->unk_31E = 0; this->setupFunc = func_80BD9ED0; } @@ -747,7 +755,7 @@ void func_80BD9ED0(EnPamera* this, GlobalContext* globalCtx) { } void func_80BD9EE0(EnPamera* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); func_80BD93CC(this, 1, 0); this->unk_31E = 1; this->setupFunc = func_80BD9F3C; @@ -764,14 +772,14 @@ void func_80BD9F3C(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } } void func_80BDA038(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); this->unk_31E = 0; this->setupFunc = func_80BDA090; } @@ -781,7 +789,7 @@ void func_80BDA090(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA0A0(EnPamera* this) { func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->unk_31E = 1; this->setupFunc = func_80BDA0FC; } @@ -791,7 +799,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); } } } @@ -799,7 +807,7 @@ void func_80BDA0FC(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA170(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 1); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->setupFunc = func_80BDA1C8; } @@ -812,7 +820,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); } } } @@ -820,7 +828,7 @@ void func_80BDA1C8(EnPamera* this, GlobalContext* globalCtx) { void func_80BDA288(EnPamera* this) { this->unk_31E = 1; func_80BD93CC(this, 0, 0); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); this->setupFunc = func_80BDA2E0; } @@ -828,7 +836,7 @@ void func_80BDA2E0(EnPamera* this, GlobalContext* globalCtx) { if (this->unk_31E == 1) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_31E = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); } } } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 79069bb97..542238a17 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -9,7 +9,7 @@ #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_bigslime/object_bigslime.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnPametfrog*)thisx) @@ -231,21 +231,21 @@ u8 EnPametfrog_Vec3fNormalize(Vec3f* vec) { } void EnPametfrog_Freeze(EnPametfrog* this) { - this->drawEffect = GEKKO_DRAW_EFFECT_FROZEN; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->collider.elements->info.elemType = ELEMTYPE_UNK0; - this->unk_2C8 = 0.75f; - this->unk_2CC = 1.125f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; } void EnPametfrog_Thaw(EnPametfrog* this, GlobalContext* globalCtx) { this->freezeTimer = 0; - if (this->drawEffect == GEKKO_DRAW_EFFECT_FROZEN) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; this->collider.elements->info.elemType = ELEMTYPE_UNK1; - this->unk_2C4 = 0.0f; + this->drawDmgEffAlpha = 0.0f; Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.3f, 0.2f); } } @@ -325,24 +325,24 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) { } void EnPametfrog_ShakeCamera(EnPametfrog* this, GlobalContext* globalCtx, f32 magShakeXZ, f32 magShakeY) { - Camera* camera = Play_GetCamera(globalCtx, this->camId); - s16 y; - Vec3f eye; + Camera* subCam = Play_GetCamera(globalCtx, this->subCamId); + s16 subCamYaw; + Vec3f subCamEye; - y = BINANG_ROT180(func_800DFCDC(camera)); - eye.x = (Math_SinS(y) * magShakeXZ) + camera->at.x; - eye.y = camera->at.y + magShakeY; - eye.z = (Math_CosS(y) * magShakeXZ) + camera->at.z; - Play_CameraSetAtEye(globalCtx, this->camId, &camera->at, &eye); + subCamYaw = BINANG_ROT180(Camera_GetCamDirYaw(subCam)); + subCamEye.x = (Math_SinS(subCamYaw) * magShakeXZ) + subCam->at.x; + subCamEye.y = subCam->at.y + magShakeY; + subCamEye.z = (Math_CosS(subCamYaw) * magShakeXZ) + subCam->at.z; + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCam->at, &subCamEye); } void EnPametfrog_StopCutscene(EnPametfrog* this, GlobalContext* globalCtx) { - Camera* camera; + Camera* subCam; - if (this->camId != 0) { - camera = Play_GetCamera(globalCtx, this->camId); - Play_CameraSetAtEye(globalCtx, 0, &camera->at, &camera->eye); - this->camId = 0; + if (this->subCamId != CAM_ID_MAIN) { + subCam = Play_GetCamera(globalCtx, this->subCamId); + Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &subCam->at, &subCam->eye); + this->subCamId = CAM_ID_MAIN; ActorCutscene_Stop(this->cutscene); func_800B724C(globalCtx, &this->actor, 6); } @@ -387,13 +387,13 @@ void EnPametfrog_JumpOnGround(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_ApplyMagicArrowEffects(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C4 = 3.0f; - this->unk_2C8 = 0.75f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 3.0f; + this->drawDmgEffScale = 0.75f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 3.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 3.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, this->collider.elements[0].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -406,9 +406,9 @@ 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); - this->drawEffect = GEKKO_DRAW_EFFECT_ELECTRIC_STUN; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 2.0f; } void EnPametfrog_ApplyStun(EnPametfrog* this) { @@ -426,7 +426,7 @@ void EnPametfrog_SetupRearOnSnapper(EnPametfrog* this) { Animation_PlayOnce(&this->skelAnime, &gGekkoStandingIdleAnim); } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.params = GEKKO_ON_SNAPPER; this->actionFunc = EnPametfrog_RearOnSnapper; } @@ -494,7 +494,7 @@ void EnPametfrog_RearOnSnapperRise(EnPametfrog* this, GlobalContext* globalCtx) } void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw; Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); @@ -503,14 +503,14 @@ void EnPametfrog_SetupFallOffSnapper(EnPametfrog* this, GlobalContext* globalCtx 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 |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->timer = 30; this->collider.base.ocFlags1 |= OC1_ON; yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); - eye.x = (Math_SinS(yaw) * 300.0f) + this->actor.focus.pos.x; - eye.y = this->actor.focus.pos.y + 100.0f; - eye.z = (Math_CosS(yaw) * 300.0f) + this->actor.focus.pos.z; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.focus.pos, &eye); + 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_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.focus.pos, &subCamEye); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_DAMAGE); this->actionFunc = EnPametfrog_FallOffSnapper; } @@ -683,7 +683,7 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { } else { SkelAnime_Update(&this->skelAnime); this->timer--; - Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, 0); + Matrix_InsertRotationAroundUnitVector_f(this->wallRotation, &this->unk_2DC, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&this->unk_2D0, &vec); Math_Vec3f_Copy(&this->unk_2D0, &vec); Math3D_CrossProduct(&this->unk_2DC, &this->unk_2D0, &this->unk_2E8); @@ -806,7 +806,7 @@ void EnPametfrog_LandOnSnapper(EnPametfrog* this, GlobalContext* globalCtx) { void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { s16 yaw; - Vec3f eye; + Vec3f subCamEye; f32 xzDist; Animation_PlayOnce(&this->skelAnime, &gGekkoFallInAirAnim); @@ -828,7 +828,7 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); this->actor.world.pos.x += 30.0f * Math_SinS(yaw); this->actor.world.pos.z += 30.0f * Math_CosS(yaw); - if (this->camId != 0) { + if (this->subCamId != CAM_ID_MAIN) { xzDist = sqrtf(SQXZ(this->unk_2DC)); if (xzDist > 0.001f) { xzDist = 200.0f / xzDist; @@ -838,10 +838,10 @@ void EnPametfrog_SetupFallInAir(EnPametfrog* this, GlobalContext* globalCtx) { this->unk_2DC.z = 0.0f; } - eye.x = this->actor.world.pos.x + (xzDist * this->unk_2DC.x); - eye.y = (this->actor.world.pos.y + this->actor.home.pos.y) * 0.5f; - eye.z = this->actor.world.pos.z + (xzDist * this->unk_2DC.z); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, &eye); + subCamEye.x = this->actor.world.pos.x + (xzDist * this->unk_2DC.x); + subCamEye.y = (this->actor.world.pos.y + this->actor.home.pos.y) * 0.5f; + subCamEye.z = this->actor.world.pos.z + (xzDist * this->unk_2DC.z); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, &subCamEye); } this->actionFunc = EnPametfrog_FallInAir; @@ -858,9 +858,9 @@ void EnPametfrog_FallInAir(EnPametfrog* this, GlobalContext* globalCtx) { } } else { this->spinYaw += 0xF00; - if (this->camId != 0) { - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, - &Play_GetCamera(globalCtx, this->camId)->eye); + if (this->subCamId != CAM_ID_MAIN) { + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, + &Play_GetCamera(globalCtx, this->subCamId)->eye); } if (this->actor.bgCheckFlags & 1) { @@ -900,15 +900,15 @@ void EnPametfrog_FallOnGround(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw = Actor_YawToPoint(this->actor.child, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; - eye.x = this->actor.child->focus.pos.x + 150.0f * Math_SinS(yaw); - eye.y = this->actor.child->focus.pos.y + 20.0f; - eye.z = this->actor.child->focus.pos.z + 150.0f * Math_CosS(yaw); - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.child->focus.pos, &eye); + subCamEye.x = this->actor.child->focus.pos.x + 150.0f * Math_SinS(yaw); + subCamEye.y = this->actor.child->focus.pos.y + 20.0f; + subCamEye.z = this->actor.child->focus.pos.z + 150.0f * Math_CosS(yaw); + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.child->focus.pos, &subCamEye); this->actor.params = GEKKO_DEFEAT; this->timer = 38; this->actionFunc = EnPametfrog_DefeatGekko; @@ -925,15 +925,15 @@ void EnPametfrog_DefeatGekko(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupDefeatSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; + Vec3f subCamEye; s16 yaw = Actor_YawToPoint(&this->actor, &this->actor.home.pos); s16 yawDiff = this->actor.yawTowardsPlayer - yaw; yaw = yawDiff > 0 ? yaw - 0x2000 : yaw + 0x2000; - eye.x = this->actor.world.pos.x + Math_SinS(yaw) * 150.0f; - eye.y = this->actor.world.pos.y + 20.0f; - eye.z = this->actor.world.pos.z + Math_CosS(yaw) * 150.0f; - Play_CameraSetAtEye(globalCtx, this->camId, &this->actor.world.pos, &eye); + subCamEye.x = this->actor.world.pos.x + Math_SinS(yaw) * 150.0f; + subCamEye.y = this->actor.world.pos.y + 20.0f; + subCamEye.z = this->actor.world.pos.z + Math_CosS(yaw) * 150.0f; + Play_CameraSetAtEye(globalCtx, this->subCamId, &this->actor.world.pos, &subCamEye); this->timer = 20; this->actionFunc = EnPametfrog_DefeatSnapper; } @@ -952,7 +952,7 @@ void EnPametfrog_SetupSpawnFrog(EnPametfrog* this, GlobalContext* globalCtx) { static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; static Color_RGBA8 primColor = { 250, 250, 250, 255 }; static Color_RGBA8 envColor = { 180, 180, 180, 255 }; - s16 yaw = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + s16 yaw = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); Vec3f vec1; Vec3f vel; s32 i; @@ -1007,7 +1007,7 @@ void EnPametfrog_SetupCutscene(EnPametfrog* this) { void EnPametfrog_PlayCutscene(EnPametfrog* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->camId = ActorCutscene_GetCurrentCamera(this->cutscene); + this->subCamId = ActorCutscene_GetCurrentCamera(this->cutscene); func_800B724C(globalCtx, &this->actor, 7); if (this->actor.colChkInfo.health == 0) { if (this->actor.params == GEKKO_PRE_SNAPPER) { @@ -1035,7 +1035,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { EnPametfrog_IdleWaterEffects(this, globalCtx); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 5, 0x400, 0x80); this->actor.shape.rot.y = this->actor.world.rot.y; - if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { + if (SkelAnime_Update(&this->skelAnime) && !Play_InCsMode(globalCtx)) { if (!this->unk_2AE) { func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; @@ -1166,13 +1166,13 @@ void EnPametfrog_Stun(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f eye; - Vec3f at; + Vec3f subCamEye; + Vec3f subCamAt; s16 yawDiff; Animation_MorphToPlayOnce(&this->skelAnime, &gGekkoCallAnim, 3.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FROG_GREET); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.colChkInfo.health = 6; this->actor.world.rot.y = Actor_YawToPoint(&this->actor, &this->actor.home.pos); yawDiff = this->actor.yawTowardsPlayer - this->actor.world.rot.y; @@ -1183,15 +1183,15 @@ void EnPametfrog_SetupCallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } this->actor.shape.rot.y = this->actor.world.rot.y; - at.x = this->actor.world.pos.x; - at.z = this->actor.world.pos.z; - at.y = this->actor.world.pos.y + 45.0f; - eye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + at.x; - eye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + at.z; - eye.y = at.y + 4.0f; + subCamAt.x = this->actor.world.pos.x; + subCamAt.z = this->actor.world.pos.z; + subCamAt.y = this->actor.world.pos.y + 45.0f; + subCamEye.x = (Math_SinS(this->actor.shape.rot.y) * 90.0f) + subCamAt.x; + subCamEye.z = (Math_CosS(this->actor.shape.rot.y) * 90.0f) + subCamAt.z; + subCamEye.y = subCamAt.y + 4.0f; // Zooms in on Gekko - Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); this->timer = 0; this->actor.hintId = 0x5F; this->actionFunc = EnPametfrog_CallSnapper; @@ -1204,26 +1204,26 @@ void EnPametfrog_CallSnapper(EnPametfrog* this, GlobalContext* globalCtx) { } void EnPametfrog_SetupSnapperSpawn(EnPametfrog* this, GlobalContext* globalCtx) { - Vec3f at; - Vec3f eye; + Vec3f subCamAt; + Vec3f subCamEye; s16 yaw; EnPametfrog_PlaceSnapper(this, globalCtx); - at.x = this->actor.child->world.pos.x; - at.z = this->actor.child->world.pos.z; - at.y = this->actor.child->floorHeight + 50.0f; + 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) { yaw = this->actor.child->shape.rot.y - 0x1000; } else { yaw = this->actor.child->shape.rot.y + 0x1000; } - eye.x = (Math_SinS(yaw) * 500.0f) + at.x; - eye.y = at.y + 55.0f; - eye.z = (Math_CosS(yaw) * 500.0f) + at.z; + subCamEye.x = (Math_SinS(yaw) * 500.0f) + subCamAt.x; + subCamEye.y = subCamAt.y + 55.0f; + subCamEye.z = (Math_CosS(yaw) * 500.0f) + subCamAt.z; // Zooms in on Snapper spawn point - Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + Play_CameraSetAtEye(globalCtx, this->subCamId, &subCamAt, &subCamEye); this->quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); Quake_SetSpeed(this->quake, 18000); Quake_SetQuakeValues(this->quake, 2, 0, 0, 0); @@ -1265,7 +1265,7 @@ void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* global void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) || + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.params == GEKKO_PRE_SNAPPER) { if (Actor_ApplyDamage(&this->actor) == 0) { @@ -1286,13 +1286,13 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) } else { EnPametfrog_Thaw(this, globalCtx); if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_FIRE) { - this->drawEffect = GEKKO_DRAW_EFFECT_THAW; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_LIGHT) { - this->drawEffect = GEKKO_DRAW_EFFECT_LIGHT_ORBS; - this->unk_2C8 = 0.75f; - this->unk_2C4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.elements[0].info.bumper.hitPos.x, this->collider.elements[0].info.bumper.hitPos.y, @@ -1305,7 +1305,7 @@ void EnPametfrog_ApplyDamageEffect(EnPametfrog* this, GlobalContext* globalCtx) this->collider.base.acFlags &= ~AC_ON; EnPametfrog_ApplyMagicArrowEffects(this, globalCtx); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_801A2ED8(); EnPametfrog_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { @@ -1357,13 +1357,14 @@ void EnPametfrog_Update(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } - if (this->unk_2C4 > 0.0f) { - if ((this->drawEffect != GEKKO_DRAW_EFFECT_FROZEN) && (this->actionFunc != EnPametfrog_PlayCutscene)) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - unk2C4 = ((this->unk_2C4 + 1.0f) * 0.375f); - this->unk_2C8 = unk2C4; - this->unk_2C8 = unk2C4 > 0.75f ? 0.75f : this->unk_2C8; - } else if (!Math_StepToF(&this->unk_2CC, 0.75f, (3.0f / 160.0f))) { + if (this->drawDmgEffAlpha > 0.0f) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->actionFunc != EnPametfrog_PlayCutscene)) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + unk2C4 = ((this->drawDmgEffAlpha + 1.0f) * 0.375f); + this->drawDmgEffScale = unk2C4; + this->drawDmgEffScale = unk2C4 > 0.75f ? 0.75f : this->drawDmgEffScale; + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, (3.0f / 160.0f))) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1420,6 +1421,6 @@ void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateY(this->spinYaw, MTXMODE_APPLY); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnPametfrog_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->drawEffect); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h index 957a46cfc..2b21f3ea3 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.h @@ -20,13 +20,6 @@ typedef enum { /* 0x9 */ GEKKO_DEFEAT, } EnPametfrogState; -typedef enum { - /* 00 */ GEKKO_DRAW_EFFECT_THAW, - /* 10 */ GEKKO_DRAW_EFFECT_FROZEN = 10, - /* 20 */ GEKKO_DRAW_EFFECT_LIGHT_ORBS = 20, - /* 30 */ GEKKO_DRAW_EFFECT_ELECTRIC_STUN = 30, -} EnPametfrogDrawEffectType; - typedef enum { /* 0x00 */ GEKKO_LIMB_NONE, /* 0x01 */ GEKKO_LIMB_ROOT, @@ -61,7 +54,7 @@ typedef struct EnPametfrog { /* 0x188 */ Vec3s jointTable[GEKKO_LIMB_MAX]; /* 0x218 */ Vec3s morphTable[GEKKO_LIMB_MAX]; /* 0x2A8 */ EnPametfrogActionFunc actionFunc; - /* 0x2AC */ u8 drawEffect; + /* 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; @@ -69,12 +62,12 @@ typedef struct EnPametfrog { /* 0x2B4 */ s16 quake; /* 0x2B6 */ s16 timer; /* 0x2B8 */ s16 spinYaw; - /* 0x2BA */ s16 camId; + /* 0x2BA */ s16 subCamId; /* 0x2BC */ s16 freezeTimer; /* 0x2C0 */ f32 wallRotation; - /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; + /* 0x2C4 */ f32 drawDmgEffAlpha; + /* 0x2C8 */ f32 drawDmgEffScale; + /* 0x2CC */ f32 drawDmgEffFrozenSteamScale; /* 0x2D0 */ Vec3f unk_2D0; // MtxF zx/zy/zz /* 0x2DC */ Vec3f unk_2DC; // MtxF yx/yy/yz: wallNorm/floorNorm/Base of Gekko walking??? /* 0x2E8 */ Vec3f unk_2E8; // MtxF xx/xy/xz 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 e629ebf9a..50e364529 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -6,7 +6,7 @@ #include "z_en_paper.h" -#define FLAGS 0x02100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnPaper*)thisx) 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 4f9a7e64f..bbf098c92 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -6,7 +6,7 @@ #include "z_en_part.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnPart*)thisx) 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 a54e9243d..a5321bf26 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_ph/object_ph.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPeehat*)thisx) @@ -227,21 +227,21 @@ void EnPeehat_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_80897170(EnPeehat* this) { - this->unk_2AE = 10; - this->unk_2CC = 1.1f; - this->unk_2D0 = 1.6500001f; - this->unk_2C8 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffFrozenSteamScale = 1.6500001f; + this->drawDmgEffAlpha = 1.0f; this->colliderSphere.base.colType = COLTYPE_HIT3; this->unk_2B0 = 80; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808971DC(EnPeehat* this, GlobalContext* globalCtx) { - if (this->unk_2AE == 10) { - this->unk_2AE = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->colliderSphere.base.colType = COLTYPE_HIT6; - this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), 2, 0.5f, 0.35f); + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 2, 0.5f, 0.35f); } } @@ -297,7 +297,7 @@ void func_80897498(EnPeehat* this) { void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { if (!gSaveContext.save.isNight) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->colliderSphere.base.acFlags |= AC_ON; if (this->actor.xzDistToPlayer < 740.0f) { func_80897648(this); @@ -305,7 +305,7 @@ void func_80897520(EnPeehat* this, GlobalContext* globalCtx) { Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 10.0f); } } else { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->colliderSphere.base.acFlags &= ~AC_ON; Math_StepToF(&this->actor.shape.yOffset, -1000.0f, 50.0f); if (this->unk_2B0 != 0) { @@ -685,7 +685,8 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { if (this->colliderSphere.base.acFlags & AC_HIT) { this->colliderSphere.base.acFlags &= ~AC_HIT; - if ((this->unk_2AE != 10) || !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderSphere.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (!Actor_ApplyDamage(&this->actor)) { Enemy_StartFinishingBlow(globalCtx, &this->actor); } @@ -698,9 +699,9 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { this->unk_2B0 = 40; Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2CC = 1.1f; - this->unk_2C8 = 2.0f; - this->unk_2AE = 32; + 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; @@ -716,13 +717,13 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_80898414(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 2.1f; - this->unk_2AE = 0; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 2.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2C8 = 4.0f; - this->unk_2CC = 1.1f; - this->unk_2AE = 20; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 1.1f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderSphere.info.bumper.hitPos.x, this->colliderSphere.info.bumper.hitPos.y, this->colliderSphere.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -731,8 +732,10 @@ void func_8089874C(EnPeehat* this, GlobalContext* globalCtx) { func_808984E0(this); } } - } else if ((this->unk_2AE == 10) && (this->colliderCylinder.base.acFlags & AC_HIT) && - ((this->unk_2AE != 10) || !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + } else if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (this->colliderCylinder.base.acFlags & AC_HIT) && + ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { func_808971DC(this, globalCtx); this->actor.colorFilterTimer = 0; func_80897648(this); @@ -797,8 +800,8 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); for (i = 1; i >= 0; i--) { - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, 1, - 1, 0, 1, &sp6C)) { + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &thisx->world.pos, &this->unk_2D4[i], &sp74, &sp70, + true, true, false, true, &sp6C)) { func_800BBFB0(globalCtx, &sp74, 0.0f, 1, 300, 150, 1); func_80897258(globalCtx, this, &sp74, 0.0f, 1.5f); } @@ -812,17 +815,17 @@ void EnPeehat_Update(Actor* thisx, GlobalContext* globalCtx2) { Math_StepToF(&this->unk_2C4, 0.0f, 0.001f); } - if (this->unk_2C8 > 0.0f) { - if (this->unk_2AE != 10) { - Math_StepToF(&this->unk_2C8, 0.0f, 0.05f); - if (this->unk_2AE == 0) { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 1.05f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 2.1f); + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 1.05f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 2.1f); } else { - this->unk_2CC = (this->unk_2C8 + 1.0f) * 0.55f; - this->unk_2CC = CLAMP_MAX(this->unk_2CC, 1.1f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.55f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 1.1f); } - } else if (!Math_StepToF(&this->unk_2D0, 1.1f, 0.0275f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 1.1f, 0.0275f)) { func_800B9010(thisx, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -879,8 +882,8 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Gfx* gfx; if (index != -1) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2EC[index]); - Matrix_GetStateTranslationAndScaledX(4000.0f, &this->unk_2EC[index + 1]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[index]); + Matrix_GetStateTranslationAndScaledX(4000.0f, &this->limbPos[index + 1]); } if (limbIndex == 4) { @@ -888,7 +891,7 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList Matrix_GetStateTranslationAndScaledZ(-5500.0f, &this->unk_2D4[1]); } else if ((limbIndex == 3) && (thisx->params == 0)) { Vec3f* vec = &D_80899570[0]; - Vec3f* vec2 = &this->unk_2EC[12]; + Vec3f* vec2 = &this->limbPos[12]; for (i = 0; i < ARRAY_COUNT(D_80899570); i++, vec++, vec2++) { Matrix_MultiplyVector3fByState(vec, vec2); @@ -937,12 +940,12 @@ void EnPeehat_Draw(Actor* thisx, GlobalContext* globalCtx) { Collider_SetTrisVertices(&this->colliderTris, 1, &sp40, &sp58, &sp4C); } - if (this->unk_2AE == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2EC); i++) { - this->unk_2EC[i].y -= 50.0f; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) { + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + this->limbPos[i].y -= 50.0f; } } - func_800BE680(globalCtx, &this->actor, this->unk_2EC, ARRAY_COUNT(this->unk_2EC), this->unk_2CC, this->unk_2D0, - this->unk_2C8, this->unk_2AE); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); } diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h index 0aee3a742..a7bda3577 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.h @@ -15,7 +15,7 @@ typedef struct EnPeehat { /* 0x2A8 */ EnPeehatActionFunc actionFunc; /* 0x2AC */ u8 unk_2AC; /* 0x2AD */ s8 unk_2AD; - /* 0x2AE */ u8 unk_2AE; + /* 0x2AE */ u8 drawDmgEffType; /* 0x2B0 */ s16 unk_2B0; /* 0x2B2 */ s16 unk_2B2; /* 0x2B4 */ s16 unk_2B4; @@ -24,11 +24,11 @@ typedef struct EnPeehat { /* 0x2BC */ f32 unk_2BC; /* 0x2C0 */ f32 unk_2C0; /* 0x2C4 */ f32 unk_2C4; - /* 0x2C8 */ f32 unk_2C8; - /* 0x2CC */ f32 unk_2CC; - /* 0x2D0 */ f32 unk_2D0; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; /* 0x2D4 */ Vec3f unk_2D4[2]; - /* 0x2EC */ Vec3f unk_2EC[18]; + /* 0x2EC */ Vec3f limbPos[18]; /* 0x3C4 */ ColliderCylinder colliderCylinder; /* 0x410 */ ColliderSphere colliderSphere; /* 0x468 */ ColliderTris colliderTris; 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 f2d1b9d34..2736fc71a 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_mm/object_mm.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnPm*)thisx) @@ -230,14 +230,21 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS sAnimations[] = { - { &object_mm_Anim_002238, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_002238, 1.0f, 0, -1, 0, -4 }, - { &object_mm_Anim_00A4E0, 1.0f, 0, -1, 2, 0 }, { &object_mm_Anim_00B09C, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_00B09C, 1.0f, 0, -1, 0, -4 }, { &object_mm_Anim_00BA78, 1.0f, 0, -1, 2, 0 }, - { &object_mm_Anim_00C32C, 1.0f, 0, -1, 0, -4 }, { &object_mm_Anim_0099B4, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_000FC4, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_00A8D8, 1.0f, 0, -1, 0, 0 }, - { &object_mm_Anim_00099C, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_001F84, 1.0f, 0, -1, 2, 0 }, - { &object_mm_Anim_000468, 1.0f, 0, -1, 0, 0 }, { &object_mm_Anim_00C640, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_mm_Anim_002238, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_002238, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_00A4E0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_00B09C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00B09C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_00BA78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_00C32C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_mm_Anim_0099B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_000FC4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00A8D8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00099C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_001F84, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_mm_Anim_000468, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_mm_Anim_00C640, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; s32 func_80AF7B40(void) { @@ -415,7 +422,7 @@ s32 func_80AF7E98(EnPm* this, s32 arg1) { if (phi_v1) { this->unk_384 = arg1; - ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); this->unk_35C = this->skelAnime.playSpeed; } @@ -530,7 +537,8 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_378++; ret = true; @@ -542,7 +550,7 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[86] & 8) && (this->unk_378 == 3)) { ActorCutscene_Stop(sp2A); } else { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); } this->unk_378++; ret = true; @@ -572,7 +580,7 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 4: case 6: case 8: - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), &this->actor); this->unk_378++; ret = true; break; @@ -582,7 +590,8 @@ s32 func_80AF8348(EnPm* this, GlobalContext* globalCtx) { case 5: case 7: if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - func_800E0308(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), this->actor.child); + Camera_SetTargetActor(Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(sp2A)), + this->actor.child); } this->unk_378++; ret = true; @@ -695,7 +704,7 @@ s32 func_80AF86F0(EnPm* this, GlobalContext* globalCtx) { s32 ret = false; if ((this->unk_356 & 7) && Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_8013AED4(&this->unk_356, 0, 7); + SubS_UpdateFlags(&this->unk_356, 0, 7); this->unk_398 = 0; this->unk_378 = 0; this->unk_37C = NULL; @@ -808,7 +817,8 @@ void func_80AF8BA8(s32 arg0) { s32 temp; if (!(gSaveContext.save.weekEventReg[88] & 2)) { - if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & (D_80AFB8D4[arg0] & 0xFF)) { + if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & + (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { switch (gSaveContext.save.day) { case 2: gSaveContext.save.weekEventReg[28] |= 8; @@ -824,13 +834,14 @@ void func_80AF8BA8(s32 arg0) { } temp = gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]; - gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = temp | (D_80AFB8E0[arg0] & 0xFF); + gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = + temp | (D_80AFB8E0[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80)); } void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 sp28 = Message_GetState(&globalCtx->msgCtx); - u16 temp_a0 = globalCtx->msgCtx.unk11F04; + u16 temp_a0 = globalCtx->msgCtx.currentTextId; if ((player->targetActor == &this->actor) && ((temp_a0 < 255) || (temp_a0 > 512)) && (sp28 == 3) && (this->unk_388 == 3)) { @@ -864,7 +875,7 @@ s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - u16 temp = globalCtx->msgCtx.unk11F04; + u16 temp = globalCtx->msgCtx.currentTextId; s32 pad; if (player->stateFlags1 & (0x400 | 0x40)) { @@ -905,12 +916,12 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { if (this->unk_234 != NULL) { - sp48 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp48 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); this->actor.shape.shadowDraw = NULL; @@ -926,7 +937,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { u16 sp56 = gSaveContext.save.time - 0x3FFC; u8 sp55 = this->actor.params & 0xFF; - EnDoor* sp50; + EnDoor* door; Vec3s* sp4C; Vec3f sp40; Vec3f sp34; @@ -934,21 +945,21 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - sp50 = func_80AF7D60(globalCtx, arg2->unk0); + door = func_80AF7D60(globalCtx, arg2->unk0); if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp55, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->unk0]); } - if ((sp50 != NULL) && (sp50->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (this->unk_234 != 0) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp4C = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_26C, &sp40); Math_Vec3f_Copy(&this->unk_278, &sp34); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - temp = this->actor.world.rot.y - sp50->actor.shape.rot.y; + temp = this->actor.world.rot.y - door->dyna.actor.shape.rot.y; if (ABS_ALT(temp) <= 0x4000) { this->unk_260 = -0x4B; } else { @@ -957,7 +968,7 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_36C = arg2->unk8 - arg2->unk4; this->unk_36E = sp56 - arg2->unk4; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; } @@ -981,7 +992,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->unk0]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1034,7 +1045,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar break; default: - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 0); if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; @@ -1061,11 +1072,11 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp30 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp30[0]); Math_Vec3s_ToVec3f(&sp34, &sp30[1]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); @@ -1114,11 +1125,11 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; phi_a3 = D_80AFB430[arg2->unk0]; if (phi_a3 >= 0) { - this->unk_234 = func_8013BB34(globalCtx, sp4F, phi_a3); + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_234->points); + sp30 = Lib_SegmentedToVirtual(this->unk_234->points); Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); @@ -1131,7 +1142,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(globalCtx, 0); this->unk_36C = 20; - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 3); break; @@ -1161,7 +1172,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if (arg2->unk0 == 0x1D) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; func_80AF7E98(this, 3); break; @@ -1190,7 +1201,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &D_80AFB8EC); Math_Vec3s_Copy(&this->actor.world.rot, &D_80AFB8F8); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; @@ -1208,7 +1219,7 @@ s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; if (this->unk_258 != 0) { @@ -1226,7 +1237,7 @@ s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x20; this->unk_356 |= 0x9000; if (this->unk_258 != 0) { @@ -1244,7 +1255,7 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 |= 0x9000; this->unk_356 |= 0x20; if (this->unk_258 != 0) { @@ -1261,7 +1272,7 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { s32 ret; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetMode = 0; this->unk_394 = 0; this->unk_356 = 0; @@ -1393,17 +1404,17 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { - EnDoor* sp44 = func_80AF7D60(globalCtx, this->unk_258); + EnDoor* door = (EnDoor*)func_80AF7D60(globalCtx, this->unk_258); Vec3f sp38; Vec3f* sp28; f32 temp; if (!func_8013AD6C(globalCtx) && (this->unk_374 != 0)) { - if ((sp44 != NULL) && (sp44->actor.update != NULL)) { + if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { - sp44->unk_1A7 = this->unk_260; + door->unk_1A7 = this->unk_260; } else { - sp44->unk_1A7 = 0; + door->unk_1A7 = 0; } } this->unk_36E = CLAMP(this->unk_36E, 0, this->unk_36C); @@ -1545,9 +1556,9 @@ s32 func_80AFA334(EnPm* this, GlobalContext* globalCtx) { case 24: temp_v0 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if (ABS_ALT(temp_v0) < 0x4000) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); } else { - func_8013AED4(&this->unk_356, 0, 7); + SubS_UpdateFlags(&this->unk_356, 0, 7); } break; @@ -1695,11 +1706,11 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || ((this->unk_258 != sp2C.unk0) && !func_80AF9BF8(this, globalCtx, &sp2C))) { this->actor.shape.shadowDraw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; sp2C.unk0 = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk_258 = sp2C.unk0; @@ -1716,7 +1727,7 @@ void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx) { Vec3f sp2C; if (func_8010BF58(&this->actor, globalCtx, this->unk_25C, this->unk_37C, &this->unk_264)) { - func_8013AED4(&this->unk_356, 3, 7); + SubS_UpdateFlags(&this->unk_356, 3, 7); this->unk_356 &= ~0x20; this->unk_356 |= 0x200; this->actor.child = NULL; diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index dce3a55fd..744644e58 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -6,7 +6,7 @@ #include "z_en_po_composer.h" -#define FLAGS 0x02100019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((EnPoComposer*)thisx) 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 5641c83e7..d6c9d7065 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 @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_En_Ma4/z_en_ma4.h" #include "objects/object_po_fusen/object_po_fusen.h" -#define FLAGS 0x80100030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_80000000) #define THIS ((EnPoFusen*)thisx) @@ -147,7 +147,7 @@ void EnPoFusen_Destroy(Actor* thisx, GlobalContext* globalCtx) { } u16 EnPoFusen_CheckParent(EnPoFusen* this, GlobalContext* globalCtx) { - struct Actor* actorPtr; + Actor* actorPtr; actorPtr = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; if (GET_IS_FUSE_TYPE_PARAM(this)) { 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 af8e0f11b..1cd7a4f83 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 @@ -8,7 +8,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_po_sisters/object_po_sisters.h" -#define FLAGS 0x00005015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_1000 | ACTOR_FLAG_4000) #define THIS ((EnPoSisters*)thisx) @@ -173,7 +173,7 @@ void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { func_80B1BCF0(this, globalCtx); func_80B1C2E8(this); } else { - this->actor.flags &= ~(0x4000 | 0x200); + this->actor.flags &= ~(ACTOR_FLAG_200 | ACTOR_FLAG_4000); this->collider.info.elemType = ELEMTYPE_UNK4; this->collider.info.bumper.dmgFlags |= (0x40000 | 0x1); this->collider.base.ocFlags1 = OC1_NONE; @@ -481,7 +481,7 @@ void func_80B1B3A8(EnPoSisters* this) { void func_80B1B444(EnPoSisters* this, GlobalContext* globalCtx) { s32 temp_f18; - if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & 0x8000)) { + if (SkelAnime_Update(&this->skelAnime) && !(this->actor.flags & ACTOR_FLAG_8000)) { if (this->actor.colChkInfo.health != 0) { if (this->unk_18C != 0) { func_80B1B5B4(this); @@ -611,7 +611,7 @@ void func_80B1BA3C(EnPoSisters* this) { this->actor.speedXZ = 0.0f; this->actor.world.pos.y += 42.0f; this->actor.shape.yOffset = -6000.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_191 = 0; this->actionFunc = func_80B1BA90; } @@ -703,7 +703,7 @@ void func_80B1BE4C(EnPoSisters* this, s32 arg1) { Vec3f sp34; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_194 = 100; this->unk_191 = 0x20; this->collider.base.colType = COLTYPE_HIT3; @@ -749,7 +749,7 @@ void func_80B1C030(EnPoSisters* this) { this->unk_192 = 300; this->unk_194 = 3; this->unk_191 |= (0x8 | 0x1); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80B1C0A4; } @@ -821,7 +821,7 @@ void func_80B1C2E8(EnPoSisters* this) { void func_80B1C340(EnPoSisters* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_229 = 255; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_191 |= (0x10 | 0x8); if (this->unk_18C == 0) { func_80B1BE4C(this, globalCtx); @@ -872,8 +872,8 @@ void func_80B1C408(EnPoSisters* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2F0 = 4.0f; - this->unk_2F4 = 0.5f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -922,17 +922,17 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowAlpha = this->unk_229; Actor_SetFocus(&this->actor, 40.0f); - if (this->unk_2F0 > 0.0f) { - Math_StepToF(&this->unk_2F0, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_229 != 255) { temp_f2 = this->unk_229 * (1.0f / 255); if (temp_f2 < this->unk_229) { - this->unk_2F0 = temp_f2; + this->drawDmgEffAlpha = temp_f2; } } - this->unk_2F4 = (this->unk_2F0 + 1.0f) * 0.25f; - this->unk_2F4 = CLAMP_MAX(this->unk_2F4, 0.5f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); } if (this->unk_191 & (0x10 | 0x8 | 0x4 | 0x2 | 0x1)) { @@ -945,7 +945,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actionFunc == func_80B1B168) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } @@ -1057,14 +1057,14 @@ void EnPoSisters_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi f32 temp_f2; if (D_80B1DB08[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_28C[D_80B1DB08[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80B1DB08[limbIndex]]); } else if (limbIndex == 9) { - Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->unk_28C[4]); - Matrix_GetStateTranslationAndScaledY(3000.0f, &this->unk_28C[5]); + Matrix_GetStateTranslationAndScaledY(-2500.0f, &this->limbPos[4]); + Matrix_GetStateTranslationAndScaledY(3000.0f, &this->limbPos[5]); } else if (limbIndex == 10) { - Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->unk_28C[6]); + Matrix_GetStateTranslationAndScaledY(-4000.0f, &this->limbPos[6]); } else if (limbIndex == 11) { - Matrix_GetStateTranslationAndScaledX(3000.0f, &this->unk_28C[7]); + Matrix_GetStateTranslationAndScaledX(3000.0f, &this->limbPos[7]); } if ((this->actionFunc == func_80B1BA90) && (this->unk_192 >= 8) && (limbIndex == 9)) { @@ -1164,7 +1164,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); Matrix_InsertTranslation(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); - Matrix_InsertRotation(0, BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + Matrix_InsertRotation(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); if (this->actionFunc == func_80B1BA90) { f32 phi_f0; @@ -1179,8 +1179,9 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); } - func_800BE680(globalCtx, &this->actor, this->unk_28C, ARRAY_COUNT(this->unk_28C), - this->actor.scale.x * 142.857131958f * this->unk_2F4, 0.0f, this->unk_2F0, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 142.857131958f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 741ebbcce..3350f8f03 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 @@ -30,10 +30,10 @@ typedef struct EnPoSisters { /* 0x0228 */ u8 unk_228; /* 0x0229 */ u8 unk_229; /* 0x022C */ Vec3f unk_22C[8]; - /* 0x028C */ Vec3f unk_28C[8]; + /* 0x028C */ Vec3f limbPos[8]; /* 0x02EC */ f32 unk_2EC; - /* 0x02F0 */ f32 unk_2F0; - /* 0x02F4 */ f32 unk_2F4; + /* 0x02F0 */ f32 drawDmgEffAlpha; + /* 0x02F4 */ f32 drawDmgEffScale; /* 0x02F8 */ LightNode* lightNode; /* 0x02FC */ LightInfo lightInfo; /* 0x030C */ ColliderCylinder collider; 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 a5b377ecb..22f590c44 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -7,7 +7,7 @@ #include "z_en_poh.h" #include "objects/object_po/object_po.h" -#define FLAGS 0x00001205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000) #define THIS ((EnPoh*)thisx) @@ -363,7 +363,7 @@ void func_80B2D07C(EnPoh* this, GlobalContext* globalCtx) { void func_80B2D0E8(EnPoh* this) { this->unk_197 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; Animation_PlayOnceSetSpeed(&this->skelAnime, &object_po_Anim_0011C4, 0.0f); this->actionFunc = func_80B2D140; } @@ -372,7 +372,7 @@ void func_80B2D140(EnPoh* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { this->unk_197 = 255; this->unk_190 = Rand_S16Offset(700, 300); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; func_80B2CB60(this); } else if (this->skelAnime.curFrame > 10.0f) { this->unk_197 = (this->skelAnime.curFrame - 10.0f) * 0.05f * 255.0f; @@ -389,7 +389,7 @@ void func_80B2D2C0(EnPoh* this) { this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_18E = 0; this->actor.hintId = 0xFF; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80B2D300; } @@ -404,7 +404,7 @@ void func_80B2D300(EnPoh* this, GlobalContext* globalCtx) { this->unk_18E++; if (this->unk_18E < 8) { - sp38 = func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x4800; + sp38 = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x4800; if (this->unk_18E < 5) { sp3A = (this->unk_18E * 0x1000) - 0x4000; sp44.y = (Math_SinS(sp3A) * 23.0f) + (this->actor.world.pos.y + 40.0f); @@ -571,13 +571,13 @@ void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { this->actor.world.pos.y = this->unk_3D8.wy; this->actor.world.pos.z = this->unk_3D8.wz; Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actor.gravity = -1.0f; this->actor.shape.yOffset = 1500.0f; this->actor.world.pos.y -= 15.0f; this->actor.shape.rot.x = -0x8000; func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 8); - this->actor.flags &= ~(0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actionFunc = func_80B2DD2C; } @@ -647,7 +647,7 @@ void func_80B2E1D8(EnPoh* this) { Actor_SetFocus(&this->actor, -10.0f); this->unk_18E = 200; this->unk_18D = 32; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80B2E230; } @@ -707,8 +707,8 @@ void func_80B2E438(EnPoh* this, GlobalContext* globalCtx) { func_80B2D924(this); } else { if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_298 = 4.0f; - this->unk_29C = 0.45f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.45f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->colliderCylinder.info.bumper.hitPos.x, this->colliderCylinder.info.bumper.hitPos.y, @@ -811,7 +811,7 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc(this, globalCtx); Actor_MoveWithGravity(&this->actor); if ((this->actionFunc == func_80B2CF28) && (this->unk_18E < 10)) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderSph.base); } @@ -834,16 +834,16 @@ void EnPoh_Update(Actor* thisx, GlobalContext* globalCtx2) { func_80B2E8E0(this); this->actor.shape.shadowAlpha = this->unk_197; - if (this->unk_298 > 0.0f) { - Math_StepToF(&this->unk_298, 0.0f, 0.05f); + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); if (this->unk_197 != 255) { if (this->unk_197 * (1.0f / 255.0f) < this->unk_197) { - this->unk_298 = this->unk_197 * (1.0f / 255.0f); + this->drawDmgEffAlpha = this->unk_197 * (1.0f / 255.0f); } } - this->unk_29C = (this->unk_298 + 1.0f) * (9.0f / 40.0f); - this->unk_29C = CLAMP_MAX(this->unk_29C, 0.45f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * (9.0f / 40.0f); + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.45f); } } @@ -899,18 +899,18 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve temp_s3 = D_80B2F71C[limbIndex]; if (temp_s3 != -1) { if (temp_s3 < 4) { - Matrix_GetStateTranslation(&this->unk_2A0[temp_s3]); + Matrix_GetStateTranslation(&this->limbPos[temp_s3]); } else if (temp_s3 == 4) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_2A0[temp_s3]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[temp_s3]); } else { s32 i; - Vec3f* vec = &this->unk_2A0[temp_s3 + 2]; + Vec3f* vec = &this->limbPos[temp_s3 + 2]; Vec3f* vec2 = &D_80B2F734[0]; - Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->unk_2A0[temp_s3]); - Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->unk_2A0[temp_s3 + 1]); + Matrix_GetStateTranslationAndScaledX(-2000.0f, &this->limbPos[temp_s3]); + Matrix_GetStateTranslationAndScaledY(-2000.0f, &this->limbPos[temp_s3 + 1]); - for (i = temp_s3 + 2; i < ARRAY_COUNT(this->unk_2A0); i++, vec++, vec2++) { + for (i = temp_s3 + 2; i < ARRAY_COUNT(this->limbPos); i++, vec++, vec2++) { Matrix_MultiplyVector3fByState(vec2, vec); } } @@ -958,8 +958,9 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(&gfx[3], object_po_DL_002D28); POLY_OPA_DISP = &gfx[4]; - func_800BE680(globalCtx, &this->actor, this->unk_2A0, 10, this->actor.scale.x * 100.0f * this->unk_29C, 0.0f, - this->unk_298, 20); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.x * 100.0f * this->drawDmgEffScale, 0.0f, this->drawDmgEffAlpha, + ACTOR_DRAW_DMGEFF_LIGHT_ORBS); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -1006,7 +1007,8 @@ void func_80B2F37C(Actor* thisx, GlobalContext* globalCtx) { 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_InsertYRotation_f((func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), MTXMODE_APPLY); + Matrix_InsertYRotation_f((Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 32768), + MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_po_DL_003850); diff --git a/src/overlays/actors/ovl_En_Poh/z_en_poh.h b/src/overlays/actors/ovl_En_Poh/z_en_poh.h index fe579e027..f4787b357 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -26,9 +26,9 @@ typedef struct EnPoh { /* 0x019B */ u8 unk_19B; /* 0x019C */ Vec3s jointTable[21]; /* 0x021A */ Vec3s morphTable[21]; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ f32 unk_29C; - /* 0x02A0 */ Vec3f unk_2A0[10]; + /* 0x0298 */ f32 drawDmgEffAlpha; + /* 0x029C */ f32 drawDmgEffScale; + /* 0x02A0 */ Vec3f limbPos[10]; /* 0x0318 */ LightNode* lightNode; /* 0x031C */ LightInfo lightInfo; /* 0x032C */ ColliderCylinder colliderCylinder; 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 0fb1e08d0..67f951299 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -6,7 +6,7 @@ #include "z_en_pp.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnPp*)thisx) 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 696abb358..8c5d417f3 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.c +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.c @@ -5,8 +5,10 @@ */ #include "z_en_pr.h" +#include "overlays/actors/ovl_En_Prz/z_en_prz.h" +#include "objects/object_pr/object_pr.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPr*)thisx) @@ -15,18 +17,21 @@ void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPr_Update(Actor* thisx, GlobalContext* globalCtx); void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A326F0(EnPr* this); void func_80A32740(EnPr* this, GlobalContext* globalCtx); +void func_80A32854(EnPr* this); void func_80A3289C(EnPr* this, GlobalContext* globalCtx); +void func_80A3295C(EnPr* this); void func_80A32984(EnPr* this, GlobalContext* globalCtx); void func_80A32A40(EnPr* this, GlobalContext* globalCtx); +void func_80A32AF8(EnPr* this); void func_80A32B20(EnPr* this, GlobalContext* globalCtx); +void func_80A32CDC(EnPr* this); void func_80A32D28(EnPr* this, GlobalContext* globalCtx); void func_80A32EA4(EnPr* this, GlobalContext* globalCtx); void func_80A32F48(EnPr* this, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A338A0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -61,6 +66,8 @@ static DamageTable D_80A338A0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; +f32 D_80A338C0[PLAYER_FORM_MAX] = { 30.0f, 30.0f, 30.0f, 15.0f, 15.0f }; + const ActorInit En_Pr_InitVars = { ACTOR_EN_PR, ACTORCAT_ENEMY, @@ -73,64 +80,547 @@ const ActorInit En_Pr_InitVars = { (ActorFunc)EnPr_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A338F4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 18, 20, 5, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_pr_Anim_0021E8, &object_pr_Anim_001E10, &object_pr_Anim_0021E8, + &object_pr_Anim_000740, &object_pr_Anim_000268, +}; -extern DamageTable D_80A338A0; -extern ColliderCylinderInit D_80A338F4; +u8 D_80A33934[] = { + 0, 2, 0, 0, 2, +}; -extern UNK_TYPE D_060021E8; +void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnPr* this = THIS; + EnPrz* prz; + s32 i; + s32 temp_s4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Init.s") + this->actor.colChkInfo.health = 3; + this->actor.colChkInfo.mass = 50; + this->actor.hintId = 0x5C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Destroy.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3242C.s") + this->unk_208 = 255; + this->unk_2CC = 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A324E0.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A325E4.s") + this->actor.targetMode = 3; + this->unk_2B8 = this->actor.world.pos.y; + this->actor.shape.yOffset = 1500.0f; + this->actor.colChkInfo.damageTable = &sDamageTable; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A326F0.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_0038B8, &object_pr_Anim_0021E8, this->jointTable, + this->morphTable, 10); + this->unk_2C8 = this->actor.world.rot.z * 20.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32740.s") + if (this->unk_2C8 < 80.0f) { + this->unk_2C8 = 80.0f; + } + this->actor.world.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32854.s") + temp_s4 = ENPR_GET_FF00(&this->actor); + if (temp_s4 > ENPR_FF00_MAX) { + temp_s4 = ENPR_FF00_MAX; + } else if (temp_s4 < ENPR_FF00_MIN) { + temp_s4 = ENPR_FF00_MIN; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3289C.s") + this->unk_2F8 = &this->actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3295C.s") + for (i = 0; i < temp_s4; i++) { + prz = (EnPrz*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_PRZ, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, + this->actor.world.rot.y, 0, i + 1); + if (prz != NULL) { + prz->unk_220 = this->unk_2F8; + this->unk_2F8 = &prz->actor; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32984.s") + this->unk_2D0 = 255; + this->unk_20E = 30; + this->unk_216 = this->actor.world.rot.y; + this->unk_214 = this->actor.world.rot.y; + this->unk_2B4 = this->actor.world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32A40.s") + func_80A326F0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32AF8.s") +void EnPr_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPr* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32B20.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32CDC.s") +void func_80A3242C(EnPr* this, s32 arg0) { + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32D28.s") + this->unk_21C = arg0; + sp34 = 1.0f; + this->unk_2BC = Animation_GetLastFrame(sAnimations[arg0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32E60.s") + if (this->unk_21C == 2) { + sp34 = 2.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32EA4.s") + Animation_Change(&this->skelAnime, sAnimations[this->unk_21C], sp34, 0.0f, this->unk_2BC, D_80A33934[this->unk_21C], + -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A32F48.s") +s32 func_80A324E0(EnPr* this, GlobalContext* globalCtx) { + CollisionPoly* sp54; + Vec3f sp48; + s32 sp44; + WaterBox* sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A33098.s") + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &this->unk_2E0, &sp48, &sp54, 1, 0, 0, 1, + &sp44)) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Update.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp40)) { + if ((this->unk_2B4 - 30.0f) < this->actor.world.pos.y) { + this->unk_2B8 = this->unk_2B4 - 30.0f; + return 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A3357C.s") + if (this->actor.world.pos.y < (this->actor.floorHeight + 20.0f)) { + this->unk_2B8 = this->actor.floorHeight + 20.0f; + return 2; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/func_80A335B4.s") +s32 func_80A325E4(EnPr* this) { + s16 temp = this->unk_214 * 0.2f; + s32 abs = ABS_ALT(temp) & 0xFFFF; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr/EnPr_Draw.s") + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_22C, 1, abs + 1, 0); + this->unk_216 = this->actor.world.rot.y - this->unk_22C; + + if (this->unk_216 > 10000) { + this->unk_216 = 10000; + } else if (this->unk_216 < -10000) { + this->unk_216 = -10000; + } + + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_22C)) > 0x100) { + return true; + } + this->unk_216 = 0; + return false; +} + +void func_80A326F0(EnPr* this) { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 0; + this->actor.speedXZ = 1.0f; + this->actionFunc = func_80A32740; +} + +void func_80A32740(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + switch (func_80A324E0(this, globalCtx)) { + case 1: + func_80A3295C(this); + return; + + case 2: + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + break; + } + + if (this->unk_2C8 < sqrtf(SQ(this->actor.world.pos.x - this->actor.home.pos.x) + + SQ(this->actor.world.pos.z - this->actor.home.pos.z))) { + func_80A32854(this); + } else if ((this->unk_20E == 0) && (player->stateFlags1 & 0x8000000)) { + if (sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.home.pos.z)) < this->unk_2C8) { + func_80A32AF8(this); + } + } +} + +void func_80A32854(EnPr* this) { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 1; + this->actionFunc = func_80A3289C; +} + +void func_80A3289C(EnPr* this, GlobalContext* globalCtx) { + this->unk_22C = Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos); + func_80A325E4(this); + + if (sqrtf(SQ(this->actor.world.pos.x - this->actor.home.pos.x) + + SQ(this->actor.world.pos.z - this->actor.home.pos.z)) < (((BREG(53) * 0.1f) + 0.5f) * this->unk_2C8)) { + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + } +} + +void func_80A3295C(EnPr* this) { + this->unk_22C = BINANG_ADD(this->actor.world.rot.y, 0x4000); + this->unk_206 = 2; + this->actionFunc = func_80A32984; +} + +void func_80A32984(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((player->stateFlags1 & 0x8000000) && (this->unk_20E == 0)) { + this->unk_22C = this->actor.world.rot.y; + func_80A32AF8(this); + } else if (!func_80A325E4(this)) { + if (func_80A324E0(this, globalCtx)) { + this->unk_22C += 0x1000; + } else { + if (this->unk_21C != 0) { + func_80A3242C(this, 0); + } + this->unk_206 = 3; + this->actionFunc = func_80A32A40; + } + } +} + +void func_80A32A40(EnPr* this, GlobalContext* globalCtx) { + Vec3f sp34; + WaterBox* sp30; + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp34.y = randPlusMinusPoint5Scaled(50.0f) + this->actor.home.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp30)) { + if (sp34.y < (this->unk_2B4 - 30.0f)) { + this->unk_2B8 = sp34.y; + } else { + this->unk_2B8 = this->unk_2B4 - 30.0f; + } + } + + this->unk_206 = 0; + this->actionFunc = func_80A32740; +} + +void func_80A32AF8(EnPr* this) { + this->unk_206 = 4; + this->skelAnime.playSpeed = 2.0f; + this->actionFunc = func_80A32B20; +} + +void func_80A32B20(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->actor.speedXZ = 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[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; + func_80A324E0(this, globalCtx); + + if (!(player->stateFlags1 & 0x8000000)) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 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; + 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)) { + this->skelAnime.playSpeed = 1.0f; + func_80A32CDC(this); + } +} + +void func_80A32CDC(EnPr* this) { + func_80A3242C(this, 3); + this->unk_206 = 5; + this->unk_20A = 400; + this->unk_2C0 = 0.0f; + this->actionFunc = func_80A32D28; +} + +void func_80A32D28(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (!(player->stateFlags1 & 0x8000000)) { + this->skelAnime.playSpeed = 1.0f; + this->actor.speedXZ = 1.0f; + func_80A32854(this); + } else { + Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); + func_80A325E4(this); + this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; + func_80A324E0(this, globalCtx); + 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; + func_80A32854(this); + } + } +} + +void func_80A32E60(EnPr* this) { + func_80A3242C(this, 4); + this->unk_206 = 6; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80A32EA4; +} + +void func_80A32EA4(EnPr* this, GlobalContext* globalCtx) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_2BC <= curFrame) { + if (this->actor.colChkInfo.health <= 0) { + this->unk_206 = 7; + this->unk_20A = 50; + this->actor.flags |= ACTOR_FLAG_8000000; + this->unk_2C4 = 0.0f; + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + this->unk_216 = 0; + this->actionFunc = func_80A32F48; + } else { + func_80A326F0(this); + } + } +} + +void func_80A32F48(EnPr* this, GlobalContext* globalCtx) { + WaterBox* sp2C; + + if (this->unk_208 > 0) { + this->unk_208 -= 2; + } else { + this->unk_208 = 0; + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_2B4, &sp2C)) { + if ((this->unk_2B4 - 100.0f) < this->actor.world.pos.y) { + this->unk_212 += 0xBB8; + this->unk_2C4 = 2.0f * Math_SinS(this->unk_212); + } + Math_ApproachF(&this->actor.world.pos.y, (this->unk_2B4 - 16.0f) + this->unk_2C4, 0.5f, 2.0f); + Math_SmoothStepToS(&this->actor.world.rot.z, 0x7700, 0x12C, 0x3E8, 0x3E8); + } + + if ((this->unk_20A == 0) && (this->unk_208 == 0)) { + this->unk_2D2 = 1; + } + + if (this->unk_2D2 != 0) { + Math_SmoothStepToS(&this->unk_2D0, 0, 1, 15, 50); + if (this->unk_2D0 < 2) { + Actor_MarkForDeath(&this->actor); + } + } +} + +void func_80A33098(EnPr* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if ((this->unk_206 != 7) && (this->unk_206 != 6)) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->actor.colChkInfo.damageEffect == 4) { + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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); + } + + if ((player->stateFlags1 & 0x8000000) && (this->actor.colChkInfo.damageEffect == 5)) { + this->drawDmgEffAlpha = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + } + + 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); + func_80A32E60(this); + } + } + } +} + +void EnPr_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPr* this = THIS; + s32 i; + + SkelAnime_Update(&this->skelAnime); + + if (this->unk_20A != 0) { + this->unk_20A--; + } + + if (this->unk_20E != 0) { + this->unk_20E--; + } + + if (this->unk_20C != 0) { + this->unk_20C--; + } + + if (this->unk_210 != 0) { + this->unk_210--; + } + + this->actionFunc(this, globalCtx); + + Actor_SetFocus(&this->actor, 20.0f); + func_80A33098(this, globalCtx); + Math_Vec3f_Copy(&this->unk_2E0, &this->actor.world.pos); + + this->unk_2E0.x += (Math_SinS(this->actor.world.rot.y) * 70.0f); + this->unk_2E0.y = this->unk_2D4.y - 10.0f; + this->unk_2E0.z += Math_CosS(this->actor.world.rot.y) * 70.0f; + + Math_SmoothStepToS(&this->unk_214, this->unk_216, 1, 0x7D0, 0); + + if (this->unk_210 == 0) { + this->unk_210 = Rand_S16Offset(10, 30); + this->unk_204 = 1; + } + + Actor_MoveWithGravity(&this->actor); + + if (this->unk_206 != 7) { + Vec3f sp50; + s16 pitch; + + Math_ApproachF(&this->actor.world.pos.y, this->unk_2B8, 0.3f, BREG(11) + 1.0f); + Math_Vec3f_Copy(&sp50, &this->actor.world.pos); + sp50.y = this->unk_2B8; + pitch = Math_Vec3f_Pitch(&this->actor.world.pos, &sp50) * 0.3f; + + if (fabsf(this->actor.world.pos.y - this->unk_2B8) > 8.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, pitch, 1, BREG(48) + 500, 0); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 1, BREG(52) + 500, 0); + } + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 30.0f, 20.0f, 0x1D); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + + if (this->unk_206 != 7) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_204 != 0) { + Vec3f sp40; + + Math_Vec3f_Copy(&sp40, &this->unk_2D4); + this->unk_204 = 0; + sp40.x += randPlusMinusPoint5Scaled(20.0f); + sp40.y += randPlusMinusPoint5Scaled(5.0f); + sp40.z += randPlusMinusPoint5Scaled(20.0f); + + for (i = 0; i < (s32)Rand_ZeroFloat(5.0f) + 5; i++) { + EffectSsBubble_Spawn(globalCtx, &sp40, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + } + } +} + +s32 EnPr_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPr* this = THIS; + + if (limbIndex == 2) { + rot->y += this->unk_214; + } + return false; +} + +void EnPr_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; + EnPr* this = THIS; + + if (limbIndex == 2) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&sp24, &this->unk_2D4); + } + + if ((limbIndex == 0) || (limbIndex == 1) || (limbIndex == 2) || (limbIndex == 3) || (limbIndex == 4) || + (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9)) { + Matrix_GetStateTranslation(&this->limbPos[this->unk_228]); + this->unk_228++; + if (this->unk_228 >= ARRAY_COUNT(this->limbPos)) { + this->unk_228 = 0; + } + } +} + +void EnPr_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPr* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + if (this->unk_2D2 == 0) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_208, this->unk_208, this->unk_208, this->unk_2D0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_2D0); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnPr_OverrideLimbDraw, EnPr_PostLimbDraw, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_2D0); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + } + + if (this->drawDmgEffAlpha != 0) { + f32 drawDmgEffAlpha = this->drawDmgEffAlpha * 0.05f; + + this->unk_238 = 0.8f; + this->unk_234 = 0.8f; + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0.8f, 0.8f, + drawDmgEffAlpha, this->drawDmgEffType); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Pr/z_en_pr.h b/src/overlays/actors/ovl_En_Pr/z_en_pr.h index fb2a1c8a2..18123e119 100644 --- a/src/overlays/actors/ovl_En_Pr/z_en_pr.h +++ b/src/overlays/actors/ovl_En_Pr/z_en_pr.h @@ -7,11 +7,51 @@ struct EnPr; typedef void (*EnPrActionFunc)(struct EnPr*, GlobalContext*); +#define ENPR_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENPR_FF00_MAX 20 +#define ENPR_FF00_MIN 0 + typedef struct EnPr { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[10]; + /* 0x01C4 */ Vec3s morphTable[10]; /* 0x0200 */ EnPrActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x144]; + /* 0x0204 */ u8 unk_204; + /* 0x0206 */ s16 unk_206; + /* 0x0208 */ s16 unk_208; + /* 0x020A */ s16 unk_20A; + /* 0x020C */ s16 unk_20C; + /* 0x020E */ s16 unk_20E; + /* 0x0210 */ s16 unk_210; + /* 0x0212 */ s16 unk_212; + /* 0x0214 */ s16 unk_214; + /* 0x0216 */ s16 unk_216; + /* 0x0218 */ UNK_TYPE1 unk218[4]; + /* 0x021C */ s32 unk_21C; + /* 0x0220 */ UNK_TYPE1 unk220[0x8]; + /* 0x0228 */ s32 unk_228; + /* 0x022C */ s16 unk_22C; + /* 0x022E */ s16 drawDmgEffAlpha; + /* 0x0230 */ s16 drawDmgEffType; + /* 0x0234 */ f32 unk_234; + /* 0x0238 */ f32 unk_238; + /* 0x023C */ Vec3f limbPos[10]; + /* 0x02B4 */ f32 unk_2B4; + /* 0x02B8 */ f32 unk_2B8; + /* 0x02BC */ f32 unk_2BC; + /* 0x02C0 */ f32 unk_2C0; + /* 0x02C4 */ f32 unk_2C4; + /* 0x02C8 */ f32 unk_2C8; + /* 0x02CC */ f32 unk_2CC; + /* 0x02D0 */ s16 unk_2D0; + /* 0x02D2 */ s16 unk_2D2; + /* 0x02D4 */ Vec3f unk_2D4; + /* 0x02E0 */ Vec3f unk_2E0; + /* 0x02EC */ UNK_TYPE1 unk2EC[0xC]; + /* 0x02F8 */ Actor* unk_2F8; + /* 0x02FC */ ColliderCylinder collider; } EnPr; // size = 0x348 extern const ActorInit En_Pr_InitVars; 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 b1ef7eaca..6bb60f174 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -5,8 +5,10 @@ */ #include "z_en_pr2.h" +#include "objects/object_pr/object_pr.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPr2*)thisx) @@ -15,9 +17,16 @@ void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx); void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A75BC0 = { +void func_80A745C4(EnPr2* this); +void func_80A745FC(EnPr2* this, GlobalContext* globalCtx); +void func_80A74888(EnPr2* this); +void func_80A748E8(EnPr2* this, GlobalContext* globalCtx); +void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx); +void func_80A74E90(EnPr2* this, GlobalContext* globalCtx); +void func_80A751B4(EnPr2* this); +void func_80A75310(EnPr2* this, GlobalContext* globalCtx); + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -52,10 +61,23 @@ static DamageTable D_80A75BC0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A75BE0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, 32, -10, { 0, 0, 0 } }, }; @@ -71,48 +93,668 @@ const ActorInit En_Pr2_InitVars = { (ActorFunc)EnPr2_Draw, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_pr_Anim_004340, + &object_pr_Anim_004274, + &object_pr_Anim_003904, +}; -extern DamageTable D_80A75BC0; -extern ColliderCylinderInit D_80A75BE0; +u8 D_80A75C38[] = { 0, 0, 2, 0 }; -extern UNK_TYPE D_06003904; -extern UNK_TYPE D_06004340; +s16 D_80A75C3C[] = { + 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Init.s") +void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Destroy.s") + this->actor.targetMode = 3; + this->actor.hintId = 0x5B; + this->unk_1EC = 255; + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A7429C.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + this->morphtable, 5); + this->unk_1E0 = ENPR2_GET_F(&this->actor); + this->actor.colChkInfo.mass = 10; + Math_Vec3f_Copy(&this->unk_228, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A7436C.s") + if (this->unk_1E0 == 2) { + this->unk_208 = ENPR2_GET_FF0(&this->actor) * 20.0f; + } + this->unk_1F4 = 255; + this->actor.shape.yOffset = 500.0f; + this->actor.shape.shadowScale = 12.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74510.s") + if (this->unk_1E0 < 10) { + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_218 = -1; + this->unk_204 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A745C4.s") + if (this->actor.parent != NULL) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A745FC.s") + if (parent->update != NULL) { + if (parent->world.rot.y != 0) { + this->unk_218 = parent->world.rot.y - 1; + } + } + } else if (this->actor.world.rot.z != 0) { + this->unk_218 = this->actor.world.rot.z - 1; + this->actor.world.rot.z = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74888.s") + if (this->unk_1E0 == 3) { + if (this->actor.parent != NULL) { + Actor* parent = this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A748E8.s") + if (parent->update != NULL) { + this->unk_1C8 = ((EnEncount1*)parent)->unk_15A; + this->path = SubS_GetPathByIndex(globalCtx, this->unk_1C8, 0x3F); + this->unk_208 = parent->world.rot.z * 20.0f; + if (this->unk_208 < 20.0f) { + this->unk_208 = 20.0f; + } + } + func_80A745C4(this); + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } else { + func_80A74888(this); + } + } else { + this->unk_204 = 0.02f; + func_80A751B4(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74DEC.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 20.0f, 20.0f, 0x1D); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A74E90.s") + if (!(this->actor.bgCheckFlags & 0x60)) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A751B4.s") +void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A75310.s") + if (this->unk_1E0 < 10) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A755D8.s") + if (this->actor.parent != NULL) { + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Update.s") + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A758E8.s") +s32 func_80A7429C(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp1A; + s16 sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A75950.s") + Actor_GetScreenPos(globalCtx, &this->actor, &sp1A, &sp18); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/func_80A759D8.s") + if ((fabsf(player->actor.world.pos.y - this->actor.world.pos.y) > 160.0f) || + (this->actor.projectedPos.z < -40.0f) || (sp1A < 0) || (sp1A > 320) || (sp18 < 0) || (sp18 > 240)) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pr2/EnPr2_Draw.s") + if (!(player->stateFlags1 & 0x8000000)) { + return false; + } else { + return true; + } +} + +void func_80A7436C(EnPr2* this, s16 arg1) { + s16 sp2E = arg1 - this->actor.world.rot.y; + + if (sp2E > 10000) { + sp2E = 10000; + } else if (sp2E < -10000) { + sp2E = -10000; + } + + Math_ApproachF(&this->actor.world.pos.y, this->unk_21C.y, 0.3f, 5.0f); + + if (fabsf(this->actor.world.pos.y - this->unk_21C.y) > 10.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_21C) * 0.3f, + 20, 5000, 500); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 20, 5000, 500); + } + + if (fabsf(this->actor.world.rot.y - arg1) < 30.0f) { + Math_ApproachZeroF(&this->unk_1FC, 0.5f, 20.0f); + } else { + Math_ApproachF(&this->unk_1FC, sp2E, 0.5f, 3000.0f); + } + + Math_SmoothStepToS(&this->actor.world.rot.y, arg1, 1, 2000, 300); +} + +void func_80A74510(EnPr2* this, s32 arg0) { + f32 sp34 = 1.0f; + + this->unk_210 = arg0; + this->unk_1F8 = Animation_GetLastFrame(sAnimations[arg0]); + if (this->unk_210 == 3) { + sp34 = 0.0f; + } + Animation_Change(&this->skelAnime, sAnimations[arg0], sp34, 0.0f, this->unk_1F8, D_80A75C38[arg0], 0.0f); +} + +void func_80A745C4(EnPr2* this) { + func_80A74510(this, 0); + this->unk_1D4 = 0; + this->actionFunc = func_80A745FC; +} + +void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { + f32 x; + f32 y; + f32 z; + f32 sqrtXYZ; + + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f) { + SkelAnime_Update(&this->skelAnime); + } + + Actor_PlaySfxAtPos(&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); + } else { + Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.3f, 1.0f); + } + + if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_1D0, &this->unk_21C)) { + Actor_MarkForDeath(&this->actor); + } + + Math_ApproachF(&this->actor.world.pos.y, this->unk_21C.y, 0.3f, 5.0f); + + if (fabsf(this->actor.world.pos.y - this->unk_21C.y) > 10.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_21C) * 0.3f, + 20, 5000, 500); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 20, 5000, 500); + } + + x = this->actor.world.pos.x - this->unk_21C.x; + y = this->actor.world.pos.y - this->unk_21C.y; + z = this->actor.world.pos.z - this->unk_21C.z; + sqrtXYZ = sqrtf(SQ(x) + SQ(y) + SQ(z)); + + if (sqrtXYZ < (Rand_ZeroFloat(20.0f) + 15.0f)) { + this->unk_1D0++; + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + if (this->unk_1D0 >= this->path->count) { + this->unk_1E0 = 2; + func_80A74888(this); + } + } + + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + func_80A7436C(this, this->unk_1EE); +} + +void func_80A74888(EnPr2* this) { + func_80A74510(this, 0); + this->unk_1DA = 2; + this->unk_1D8 = 0; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + this->unk_1D4 = 1; + this->actionFunc = func_80A748E8; +} + +void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f12; + f32 temp_f2; + f32 sqrtXZ; + s32 sp4C = false; + s32 sp48 = false; + Vec3f sp3C; + + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_EXIST - SFX_FLAG); + + if (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f) { + sp48 = true; + SkelAnime_Update(&this->skelAnime); + } + + if (this->unk_1F4 != 255) { + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); + if (this->unk_1F4 < 2) { + Actor_MarkForDeath(&this->actor); + } + } else { + switch (this->unk_1E0) { + case 1: + if (this->unk_1DC == 0) { + sp4C = true; + func_80A74DEC(this, globalCtx); + } else if (!func_80A7429C(this, globalCtx) && (this->unk_1F4 == 255)) { + this->unk_1F4 = 254; + } + break; + + case 2: + if (this->unk_1DE == 0) { + temp_f2 = player->actor.world.pos.x - this->unk_228.x; + temp_f12 = player->actor.world.pos.z - this->unk_228.z; + sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (sp48 && (player->stateFlags1 & 0x8000000) && (sqrtXZ < this->unk_208)) { + sp4C = true; + func_80A74DEC(this, globalCtx); + } + } else { + temp_f2 = this->actor.world.pos.x - this->unk_228.x; + temp_f12 = this->actor.world.pos.z - this->unk_228.z; + sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (sqrtXZ > 20.0f) { + this->unk_1DE = 5; + 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); + } + } + break; + } + + if (!sp4C) { + this->unk_21C.y = this->actor.world.pos.y; + if (this->unk_1DA != 0) { + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + } + + Math_ApproachZeroF(&this->actor.speedXZ, 0.1f, 0.2f); + + if (this->unk_1DA == 1) { + this->unk_1D8 = Rand_S16Offset(100, 100); + Math_Vec3f_Copy(&sp3C, &this->unk_228); + sp3C.x += randPlusMinusPoint5Scaled(300.0f); + sp3C.z += randPlusMinusPoint5Scaled(300.0f); + Math_Vec3f_Copy(&this->unk_21C, &sp3C); + } + } else { + Math_ApproachF(&this->actor.speedXZ, 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(&globalCtx->colCtx, &sp3C, 20.0f) || (this->actor.bgCheckFlags & 8)) { + this->unk_1DC = 0; + this->unk_1F2++; + Math_Vec3f_Copy(&this->unk_21C, &this->unk_228); + if (this->unk_1F2 > 10) { + this->unk_1F0 += 0x2000; + } + } else { + Math_SmoothStepToS(&this->unk_1F0, 0, 1, 1000, 100); + this->unk_1F2 = 0; + } + } + + if ((this->unk_1D8 == 0) || ((fabsf(this->unk_21C.x - this->actor.world.pos.x) < 10.0f) && + (fabsf(this->unk_21C.z - this->actor.world.pos.z) < 10.0f))) { + this->unk_1DA = Rand_S16Offset(20, 30); + } + } + } + + if (this->unk_1DA == 0) { + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C) + this->unk_1F0; + func_80A7436C(this, this->unk_1EE); + } + } +} + +void func_80A74DEC(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1F0 = 0; + func_80A74510(this, 1); + Actor_PlaySfxAtPos(&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); + this->unk_20C = Rand_ZeroFloat(30.0f); + this->unk_1DC = 0; + this->unk_1D8 = 70; + this->unk_1D4 = 2; + this->actionFunc = func_80A74E90; +} + +void func_80A74E90(EnPr2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + WaterBox* sp40; + + Math_ApproachF(&this->unk_204, 0.02f, 0.1f, 0.005f); + if ((this->unk_1D8 == 0) || !(player->stateFlags1 & 0x8000000) || (this->unk_1E0 == 0)) { + func_80A74888(this); + return; + } + + if (this->unk_1F4 != 255) { + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); + if (this->unk_1F4 < 2) { + Actor_MarkForDeath(&this->actor); + } + } else { + SkelAnime_Update(&this->skelAnime); + + if ((this->unk_1DC == 0) && (fabsf(this->actor.world.rot.y - this->unk_1EE) < 200.0f)) { + Math_Vec3f_Copy(&this->unk_21C, &player->actor.world.pos); + } + + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + this->unk_20C = Rand_ZeroFloat(30.0f); + } + + 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); + this->unk_1F0 = 0; + + if (this->unk_1E0 == 2) { + f32 temp_f2 = this->actor.world.pos.x - this->unk_228.x; + f32 temp_f12 = this->actor.world.pos.z - this->unk_228.z; + f32 sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); + + if (this->unk_208 < sqrtXZ) { + this->unk_1DE = 20; + func_80A74888(this); + return; + } + } else { + Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_200, &sp40)) { + if ((this->unk_200 - 40.0f) < this->unk_21C.y) { + this->unk_21C.y = this->unk_200 - 40.0f; + } + } + + if ((this->unk_1E0 == 1) && !func_80A7429C(this, globalCtx)) { + if (this->unk_1F4 == 255) { + this->unk_1F4 = 254; + } + } else { + if (this->collider.base.atFlags & AT_HIT) { + this->unk_1DC = Rand_S16Offset(30, 30); + this->unk_1D8 = 100; + if (this->unk_1E0 != 2) { + func_80A74888(this); + } + } + this->unk_1EE = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_21C); + func_80A7436C(this, this->unk_1EE); + } + } +} + +void func_80A751B4(EnPr2* this) { + this->unk_1EC = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + if (this->unk_1E0 < 10) { + func_80A74510(this, 2); + } else { + this->unk_1F8 = Animation_GetLastFrame(&object_pr_Anim_003904); + Animation_Change(&this->skelAnime, &object_pr_Anim_003904, 1.0f, this->unk_1F8, this->unk_1F8, 2, 0.0f); + this->unk_1D8 = Rand_S16Offset(20, 30); + this->unk_1E4 = 0x4000; + if (Rand_ZeroOne() < 0.5f) { + this->unk_1E4 = -0x4000; + } + this->unk_1E6 = this->actor.world.rot.y; + this->actor.shape.rot.x = this->actor.world.rot.x; + 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.world.rot.y = randPlusMinusPoint5Scaled(0x8000); + } + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 10); + this->unk_1D4 = 3; + this->actionFunc = func_80A75310; +} + +void func_80A75310(EnPr2* this, GlobalContext* globalCtx) { + s32 temp; + f32 frame; + WaterBox* sp74; + + SkelAnime_Update(&this->skelAnime); + if (this->unk_1E0 < 10) { + s32 i; + + frame = this->skelAnime.curFrame; + + if (this->unk_1F8 <= frame) { + for (i = 0; i < ARRAY_COUNT(this->unk_234); i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PR2, this->unk_234[i].x, this->unk_234[i].y, + this->unk_234[i].z, this->actor.world.rot.x, this->actor.world.rot.y, + this->actor.world.rot.z, i + 10); + } + + Actor_MarkForDeath(&this->actor); + return; + } + } else { + Vec3f sp64; + + temp = false; + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 5, 10000, 1000); + Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1E4, 5, 10000, 1000); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_1E6, 5, 10000, 1000); + + if ((Rand_ZeroOne() < 0.3f) && !this->unk_1D6) { + this->unk_1D6 = true; + } + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_200, &sp74)) { + frame = this->unk_200 - 15.0f; + + if (frame <= this->actor.world.pos.y) { + temp = true; + } else { + Math_ApproachF(&this->actor.world.pos.y, frame, 0.3f, 1.0f); + } + } + + if ((this->unk_1D8 == 0) || temp) { + s32 i; + + Math_SmoothStepToS(&this->unk_1F4, 0, 1, 15, 50); + + if (this->unk_1F4 < 2) { + for (i = 0; i < 10; i++) { + Math_Vec3f_Copy(&sp64, &this->actor.world.pos); + + sp64.x += randPlusMinusPoint5Scaled(20.0f); + sp64.y += randPlusMinusPoint5Scaled(5.0f); + sp64.z += randPlusMinusPoint5Scaled(20.0f); + frame = Rand_ZeroFloat(0.03f) + 0.07f; + + EffectSsBubble_Spawn(globalCtx, &sp64, 0.0f, 5.0f, 5.0f, frame); + } + + Actor_MarkForDeath(&this->actor); + } + } + } +} + +void func_80A755D8(EnPr2* this, GlobalContext* globalCtx) { + s32 temp_v0; + + if (this->collider.base.acFlags & AC_HIT) { + Actor_ApplyDamage(&this->actor); + if ((this->actor.colChkInfo.health <= 0) && (this->unk_1D4 != 3)) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + this->actor.speedXZ = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PIRANHA_DEAD); + + if (this->unk_218 >= 0) { + Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, D_80A75C3C[this->unk_218]); + } + + this->actor.colChkInfo.health = 0; + func_80A751B4(this); + } + } + + if (this->collider.base.atFlags & AT_BOUNCED) { + this->actor.speedXZ = -10.0f; + } +} + +void EnPr2_Update(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; + f32 rand; + + if (thisx) {} + + Actor_SetScale(&this->actor, this->unk_204); + + this->actionFunc(this, globalCtx); + + if (this->unk_1DA != 0) { + this->unk_1DA--; + } + + if (this->unk_1D8 != 0) { + this->unk_1D8--; + } + + if (this->unk_1DC != 0) { + this->unk_1DC--; + } + + if (this->unk_1DE != 0) { + this->unk_1DE--; + } + + Actor_SetFocus(&this->actor, 10.0f); + func_80A755D8(this, globalCtx); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0, 10.0f, 20.0f, 0x1F); + + if (this->unk_1D6) { + s32 i; + Vec3f sp58; + f32 rand; + + Math_Vec3f_Copy(&sp58, &this->unk_270); + this->unk_1D6 = false; + + sp58.x += randPlusMinusPoint5Scaled(20.0f); + sp58.y += randPlusMinusPoint5Scaled(5.0f); + sp58.z += randPlusMinusPoint5Scaled(20.0f); + + for (i = 0; i < 2; i++) { + rand = Rand_ZeroFloat(0.03f) + 0.07f; + EffectSsBubble_Spawn(globalCtx, &sp58, 0, 5.0f, 5.0f, rand); + } + } + + if ((this->unk_1F4 == 255) && (this->unk_1E0 < 10)) { + this->actor.shape.rot.x = this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + if (this->unk_1D4 != 3) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +s32 func_80A758E8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + rot->y += (s16)this->unk_1FC * -1; + } + } else if ((limbIndex + 10) != this->unk_1E0) { + *dList = NULL; + } + return false; +} + +void func_80A75950(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_GetStateTranslation(&this->unk_270); + } + Matrix_GetStateTranslation(&this->unk_234[limbIndex]); + } +} + +s32 func_80A759D8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnPr2* this = THIS; + + if (this->unk_1E0 < 10) { + if (limbIndex == 2) { + rot->y += (s16)this->unk_1FC * -1; + } + } else if ((limbIndex + 10) != this->unk_1E0) { + *dList = NULL; + } + return false; +} + +void EnPr2_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPr2* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_1F4 == 255) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1EC, this->unk_1EC, this->unk_1EC, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_1F4); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A758E8, func_80A75950, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1F4); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A759D8, NULL, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 68fb09b82..4ae14db77 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -7,11 +7,48 @@ struct EnPr2; typedef void (*EnPr2ActionFunc)(struct EnPr2*, GlobalContext*); +#define ENPR2_GET_F(thisx) ((thisx)->params & 0xF) +#define ENPR2_GET_FF0(thisx) (((thisx)->params >> 4) & 0xFF) + typedef struct EnPr2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x80]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[5]; + /* 0x01A6 */ Vec3s morphtable[5]; /* 0x01C4 */ EnPr2ActionFunc actionFunc; - /* 0x01C8 */ char unk_1C8[0x100]; + /* 0x01C8 */ s16 unk_1C8; + /* 0x01CC */ Path* path; + /* 0x01D0 */ s32 unk_1D0; + /* 0x01D4 */ s16 unk_1D4; + /* 0x01D6 */ s16 unk_1D6; + /* 0x01D8 */ s16 unk_1D8; + /* 0x01DA */ s16 unk_1DA; + /* 0x01DC */ s16 unk_1DC; + /* 0x01DE */ s16 unk_1DE; + /* 0x01E0 */ s16 unk_1E0; + /* 0x01E2 */ UNK_TYPE1 unk1E2[2]; + /* 0x01E4 */ s16 unk_1E4; + /* 0x01E6 */ s16 unk_1E6; + /* 0x01E8 */ UNK_TYPE1 unk1E8[4]; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ s16 unk_1F0; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ s16 unk_1F4; + /* 0x01F8 */ f32 unk_1F8; + /* 0x01FC */ f32 unk_1FC; + /* 0x0200 */ f32 unk_200; + /* 0x0204 */ f32 unk_204; + /* 0x0208 */ f32 unk_208; + /* 0x020C */ f32 unk_20C; + /* 0x0210 */ s32 unk_210; + /* 0x0214 */ UNK_TYPE1 unk214[4]; + /* 0x0218 */ s32 unk_218; + /* 0x021C */ Vec3f unk_21C; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ Vec3f unk_234[5]; + /* 0x0270 */ Vec3f unk_270; + /* 0x027C */ ColliderCylinder collider; } EnPr2; // size = 0x2C8 extern const ActorInit En_Pr2_InitVars; 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 960340d7e..29df2aa2c 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.c +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.c @@ -5,8 +5,10 @@ */ #include "z_en_prz.h" +#include "objects/object_pr/object_pr.h" +#include "overlays/actors/ovl_En_Pr/z_en_pr.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnPrz*)thisx) @@ -15,9 +17,15 @@ void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx); void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80A771C0 = { +void func_80A76388(EnPrz* this); +void func_80A763E8(EnPrz* this, GlobalContext* globalCtx); +void func_80A76604(EnPrz* this, GlobalContext* globalCtx); +void func_80A76634(EnPrz* this, GlobalContext* globalCtx); +void func_80A76748(EnPrz* this); +void func_80A767A8(EnPrz* this, GlobalContext* globalCtx); +void func_80A76B14(EnPrz* this, GlobalContext* globalCtx); + +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -52,10 +60,25 @@ static DamageTable D_80A771C0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A771F4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x20000000, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +f32 D_80A771E0[] = { 40.0f, 40.0f, 40.0f, 30.0f, 30.0f }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK4, + { 0x20000000, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 10, 0, { 0, 0, 0 } }, }; @@ -71,45 +94,436 @@ const ActorInit En_Prz_InitVars = { (ActorFunc)EnPrz_Draw, }; -#endif +AnimationHeader* D_80A77240[] = { &object_pr_Anim_004340, &object_pr_Anim_004274 }; -extern DamageTable D_80A771C0; -extern ColliderCylinderInit D_80A771F4; +u8 D_80A77248[] = { 0, 0 }; -extern UNK_TYPE D_06004340; +Vec3f D_80A7724C = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Init.s") +void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { + EnPrz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Destroy.s") + this->unk_20C = 0.01f; + this->unk_1E4 = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A75F18.s") + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A75FA4.s") + this->actor.targetMode = 3; + this->unk_1E8 = 255; + this->actor.hintId = 0x5B; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.colChkInfo.health = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76070.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, + this->morphTable, 5); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A762C0.s") + this->unk_1E6 = ENPRZ_GET(&this->actor); + this->actor.shape.yOffset = 500.0f; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76388.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Math_Vec3f_Copy(&this->unk_1D8, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A763E8.s") + this->unk_220 = &this->actor; + this->unk_1EC = 255; + this->unk_202 = randPlusMinusPoint5Scaled((this->unk_1E6 * 100.0f) + 1000.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76604.s") + func_80A76388(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76634.s") +void EnPrz_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76748.s") +void func_80A75F18(EnPrz* this, s32 arg1) { + this->unk_204 = arg1; + Animation_Change(&this->skelAnime, D_80A77240[arg1], 1.0f, 0.0f, Animation_GetLastFrame(D_80A77240[arg1]), + D_80A77248[arg1], -2.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A767A8.s") +s32 func_80A75FA4(EnPrz* this, GlobalContext* globalCtx) { + WaterBox* sp2C; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76A1C.s") + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &sp2C)) { + temp_f0 = BREG(10) + (this->unk_210 - 10.0f); + if (temp_f0 < this->actor.world.pos.y) { + this->unk_1D8.y = temp_f0; + return 1; + } + } else { + temp_f0 = this->actor.floorHeight + 35.0f; + if (this->actor.world.pos.y < temp_f0) { + this->unk_1D8.y = temp_f0; + return 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76B14.s") + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Update.s") +void func_80A76070(EnPrz* this, s16 arg1, GlobalContext* globalCtx) { + s16 temp_s0 = arg1 - this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76F70.s") + temp_s0 *= 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/func_80A76FCC.s") + if (temp_s0 > 100) { + temp_s0 = 100; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Prz/EnPrz_Draw.s") + if (temp_s0 < -100) { + temp_s0 = -100; + } + + if (fabsf(this->actor.world.rot.y - (f32)arg1) < (randPlusMinusPoint5Scaled(20.0f) + 100.0f)) { + Math_ApproachZeroF(&this->unk_218, 0.5f, 20.0f); + } else { + Math_ApproachF(&this->unk_218, temp_s0, 0.5f, 5.0f); + } + + temp_s0 = fabsf(this->unk_218) * 0.1f; + if (temp_s0 < 2) { + temp_s0 = 2; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, arg1, temp_s0, this->unk_202 + 0x1388, 0); + func_80A75FA4(this, globalCtx); + Math_ApproachF(&this->actor.world.pos.y, this->unk_1D8.y, 0.5f, 1.0f); + temp_s0 = Math_Vec3f_Pitch(&this->actor.world.pos, &this->unk_1D8) * 0.5f; + + if (fabsf(this->actor.world.pos.y - this->unk_208) > 4.0f) { + Math_SmoothStepToS(&this->actor.world.rot.x, temp_s0, 1, BREG(48) + 0x1F4, 0); + } else { + Math_SmoothStepToS(&this->actor.world.rot.x, 0, 1, BREG(52) + 0xBB8, 0); + } +} + +s32 func_80A762C0(EnPrz* this, GlobalContext* globalCtx) { + CollisionPoly* sp54; + Vec3f sp48; + s32 sp44; + Vec3f sp38; + + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + + sp38.x += Math_SinS(this->actor.world.rot.y) * 40.0f; + sp38.z += Math_CosS(this->actor.world.rot.y) * 40.0f; + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp38, &sp48, &sp54, true, false, false, + true, &sp44)) { + return true; + } + return false; +} + +void func_80A76388(EnPrz* this) { + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + func_80A75F18(this, 0); + this->unk_1EA = 1; + this->actionFunc = func_80A763E8; +} + +void func_80A763E8(EnPrz* this, GlobalContext* globalCtx) { + Actor* sp3C = this->actor.parent; + Player* player = GET_PLAYER(globalCtx); + s16 yaw; + s32 pad; + + if (&this->actor == this->unk_220) { + return; + } + + if ((player->stateFlags1 & 0x8000000) && (this->unk_1F2 == 0)) { + func_80A76748(this); + return; + } + + if (func_80A762C0(this, globalCtx)) { + func_80A76604(this, globalCtx); + return; + } + + if ((this->unk_220 != NULL) && (this->unk_220->update == NULL)) { + this->unk_220 = this->actor.parent; + } + + if ((this->unk_1EE == 0) && (this->unk_1F2 == 0)) { + s16 rot; + + this->unk_214 = randPlusMinusPoint5Scaled(40.0f); + + rot = BINANG_ROT180(this->unk_220->world.rot.y); + this->unk_1D8.x += Math_SinS(rot) * this->unk_214; + this->unk_1D8.y = randPlusMinusPoint5Scaled(40.0f) + (this->unk_220->world.pos.y + 40.0f); + rot = BINANG_ROT180(this->unk_220->world.rot.y); + this->unk_1D8.z += Math_CosS(rot) * this->unk_214; + + this->unk_1EE = Rand_S16Offset(20, 30); + } else if (sqrtf(SQ(this->actor.world.pos.x - sp3C->world.pos.x) + + SQ(this->actor.world.pos.z - sp3C->world.pos.z)) > 100.0f) { + Math_Vec3f_Copy(&this->unk_1D8, &sp3C->world.pos); + } + + if (1) {} + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_1C8 == 0)) { + this->unk_1C8 = 1; + } + + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8); + func_80A76070(this, yaw, globalCtx); +} + +void func_80A76604(EnPrz* this, GlobalContext* globalCtx) { + this->unk_1EE = 0; + this->unk_1E4 = BINANG_ADD(this->actor.world.rot.y, 0x4000); + this->unk_1EA = 2; + this->actionFunc = func_80A76634; +} + +void func_80A76634(EnPrz* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80A76070(this, this->unk_1E4, globalCtx); + + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->unk_1E4)) < 0x100) { + if (func_80A762C0(this, globalCtx) != 0) { + this->unk_1E4 += 0x1500; + this->unk_1E4 += (s16)Rand_ZeroFloat(5000.0f); + } else if ((player->stateFlags1 & 0x8000000) && (player->actor.floorHeight < 30.0f)) { + this->actionFunc = func_80A763E8; + } else { + this->unk_1EE = 10; + this->unk_1EA = 1; + this->actionFunc = func_80A763E8; + } + } +} + +void func_80A76748(EnPrz* this) { + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 3.0f; + this->unk_1EE = 0; + this->unk_1EA = 3; + this->skelAnime.playSpeed = 2.0f; + this->actionFunc = func_80A767A8; +} + +void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnPr* pr = (EnPr*)this->actor.parent; + f32 sqrt; + s32 pad[2]; + u8 playerForm; + + if (func_80A762C0(this, globalCtx)) { + func_80A75F18(this, 0); + this->actor.speedXZ = randPlusMinusPoint5Scaled(1.0f) + 4.0f; + func_80A76604(this, globalCtx); + return; + } + + sqrt = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + + SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); + + if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < sqrt)) { + this->unk_1F2 = 100; + this->skelAnime.playSpeed = 1.0f; + func_80A76388(this); + return; + } + + if ((this->actor.xzDistToPlayer < 200.0f) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { + if (this->unk_204 != 1) { + func_80A75F18(this, 1); + } + this->skelAnime.playSpeed = 1.0f; + } else { + if (this->unk_204 != 0) { + func_80A75F18(this, 0); + } + this->skelAnime.playSpeed = 2.0f; + } + + if (this->unk_1EE == 0) { + this->unk_1EE = Rand_S16Offset(2, 3); + Math_Vec3f_Copy(&this->unk_1D8, &player->actor.world.pos); + } + + if ((Rand_ZeroOne() < 0.1f) && (this->unk_1C8 == 0)) { + this->unk_1C8 = 1; + } + + playerForm = gSaveContext.save.playerForm; + this->unk_1D8.y = + (player->actor.world.pos.y + D_80A771E0[playerForm]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); + func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); +} + +void func_80A76A1C(EnPrz* this) { + this->unk_1E8 = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BUBLEWALK_DEAD); + + this->unk_1EE = Rand_S16Offset(100, 30); + this->unk_1FC = 0x4000; + + if (Rand_ZeroOne() < 0.5f) { + this->unk_1FC = -0x4000; + } + + this->unk_1FE = this->actor.world.rot.y; + this->actor.speedXZ = Rand_ZeroFloat(0.5f); + this->actor.world.rot.y = randPlusMinusPoint5Scaled(0x8000); + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 30); + this->unk_1EE = 50; + func_80A75F18(this, 0); + this->unk_1EA = 7; + this->actionFunc = func_80A76B14; +} + +void func_80A76B14(EnPrz* this, GlobalContext* globalCtx) { + WaterBox* sp7C; + s32 i; + Vec3f sp6C; + s32 phi_s0 = false; + + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 5, 0x2710, 0x3E8); + Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_1FC, 5, 0x2710, 0x3E8); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->unk_1FE, 5, 0x2710, 0x3E8); + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &this->unk_210, &sp7C)) { + if ((this->unk_210 - 15.0f) <= this->actor.world.pos.y) { + phi_s0 = true; + } else { + Math_ApproachF(&this->actor.world.pos.y, this->unk_210 - 14.0f, 0.3f, 1.0f); + } + } + + if ((this->unk_1EE == 0) || phi_s0) { + Math_SmoothStepToS(&this->unk_1EC, 0, 1, 15, 50); + + if (this->unk_1EC < 2) { + for (i = 0; i < 10; i++) { + Math_Vec3f_Copy(&sp6C, &this->actor.world.pos); + + sp6C.x += randPlusMinusPoint5Scaled(20.0f); + sp6C.y += randPlusMinusPoint5Scaled(5.0f); + sp6C.z += randPlusMinusPoint5Scaled(20.0f); + + EffectSsBubble_Spawn(globalCtx, &sp6C, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnPrz* this = THIS; + s32 sp44 = false; + Vec3f sp38; + + if (this->unk_1EA != 7) { + SkelAnime_Update(&this->skelAnime); + } + + this->actionFunc(this, globalCtx); + + if (this->unk_1EE != 0) { + this->unk_1EE--; + } + + if (this->unk_1F2 != 0) { + this->unk_1F2--; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 10.0f, 10.0f, 0x1D); + + if (this->unk_1EA != 7) { + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + } + + if (this->unk_1EA != 7) { + if (this->collider.base.acFlags & AC_HIT) { + Actor_ApplyDamage(&this->actor); + if (this->actor.colChkInfo.health <= 0) { + sp44 = true; + } + } + + if (sp44 || (this->actor.parent == NULL) || (this->actor.parent->colChkInfo.health <= 0)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_1EA != 7) { + func_80A76A1C(this); + return; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->unk_1C8 != 0) { + Math_Vec3f_Copy(&sp38, &this->unk_1CC); + this->unk_1C8 = 0; + + sp38.x += randPlusMinusPoint5Scaled(20.0f); + sp38.y += randPlusMinusPoint5Scaled(5.0f); + sp38.z += randPlusMinusPoint5Scaled(20.0f); + + EffectSsBubble_Spawn(globalCtx, &sp38, 0.0f, 5.0f, 5.0f, Rand_ZeroFloat(0.03f) + 0.07f); + } + } +} + +s32 func_80A76F70(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnPrz* this = THIS; + + if (limbIndex == 2) { + rot->y += (s16)this->unk_218 * -100; + } + return false; +} + +void func_80A76FCC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f sp1C = D_80A7724C; + EnPrz* this = THIS; + + if (limbIndex == 2) { + Matrix_InsertTranslation(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&sp1C, &this->unk_1CC); + } +} + +void EnPrz_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnPrz* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_1EC == 255) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->unk_1E8, this->unk_1E8, this->unk_1E8, this->unk_1EC); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_1EC); + + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, func_80A76F70, func_80A76FCC, &this->actor); + } else { + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1EC); + + Scene_SetRenderModeXlu(globalCtx, 1, 2); + POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Prz/z_en_prz.h b/src/overlays/actors/ovl_En_Prz/z_en_prz.h index 396ed84aa..28f8152a8 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.h +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.h @@ -7,11 +7,39 @@ struct EnPrz; typedef void (*EnPrzActionFunc)(struct EnPrz*, GlobalContext*); +#define ENPRZ_GET(thisx) ((thisx)->params & 0xFF) + typedef struct EnPrz { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x80]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[5]; + /* 0x01A6 */ Vec3s morphTable[5]; /* 0x01C4 */ EnPrzActionFunc actionFunc; - /* 0x01C8 */ char unk_1C8[0xA8]; + /* 0x01C8 */ u8 unk_1C8; + /* 0x01CC */ Vec3f unk_1CC; + /* 0x01D8 */ Vec3f unk_1D8; + /* 0x01E4 */ s16 unk_1E4; + /* 0x01E6 */ s16 unk_1E6; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ s16 unk_1EA; + /* 0x01EC */ s16 unk_1EC; + /* 0x01EE */ s16 unk_1EE; + /* 0x01F0 */ UNK_TYPE1 unk1F0[2]; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ UNK_TYPE1 unk1F4[8]; + /* 0x01FC */ s16 unk_1FC; + /* 0x01FE */ s16 unk_1FE; + /* 0x0200 */ UNK_TYPE1 unk200[2]; + /* 0x0202 */ s16 unk_202; + /* 0x0204 */ s32 unk_204; + /* 0x0208 */ f32 unk_208; + /* 0x020C */ f32 unk_20C; + /* 0x0210 */ f32 unk_210; + /* 0x0214 */ f32 unk_214; + /* 0x0218 */ f32 unk_218; + /* 0x021C */ UNK_TYPE1 unk21C[4]; + /* 0x0220 */ Actor* unk_220; + /* 0x0224 */ ColliderCylinder collider; } EnPrz; // size = 0x270 extern const ActorInit En_Prz_InitVars; 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 df0355ce9..02a9ea743 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.c +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.c @@ -6,7 +6,7 @@ #include "z_en_pst.h" -#define FLAGS 0x00000001 +#define FLAGS (ACTOR_FLAG_1) #define THIS ((EnPst*)thisx) 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 489fe63df..0166ed423 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -1,12 +1,16 @@ /* * File: z_en_racedog.c * Overlay: ovl_En_Racedog - * Description: Racetrack Dog + * Description: The dogs that run around the racetrack during the dog race. + * + * Note that the dogs milling about the Doggy Racetrack prior to and after the + * race are actually En_Dg. This actor is solely concerned with the dogs that + * actually perform the race by running around the track. */ #include "z_en_racedog.h" -#define FLAGS 0x80000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #define THIS ((EnRacedog*)thisx) @@ -17,8 +21,25 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx); void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx); +void func_80B24E14(EnRacedog* this); +void func_80B24F08(EnRacedog* this); +void func_80B251EC(EnRacedog* this); +void func_80B252F8(EnRacedog* this); +void func_80B2538C(EnRacedog* this); +void func_80B25448(EnRacedog* this); +s32 func_80B25490(EnRacedog* this, Vec2f* arg1); +void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx); +void func_80B256BC(EnRacedog* this); + +typedef struct { + f32 unk_00; + f32 unk_04; + s16 unk_08; + s16 unk_0A; + s16 unk_0C; + s16 unk_0E; +} UnkRacedogStruct; -#if 0 const ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, ACTORCAT_NPC, @@ -31,18 +52,60 @@ const ActorInit En_Racedog_InitVars = { (ActorFunc)EnRacedog_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B25E98 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static s16 D_80B25D40 = 0; + +static s16 D_80B25D44 = -1; + +static s16 D_80B25D48 = 0; + +static s16 D_80B25D4C = -1; + +static f32 D_80B25D50[][2] = { + { 0.0f, 0.0f }, { 5.0f, 5.5f }, { 5.0f, 5.0f }, { 5.5f, 5.0f }, { 4.5f, 5.5f }, { 6.0f, 4.0f }, { 4.0f, 6.0f }, +}; + +static UnkRacedogStruct D_80B25D88[] = { + { -1.0f, 1.20000004768f, 3, 0, 9, 0x3539 }, { -1.0f, 1.20000004768f, 1, 1, 9, 0x353A }, + { -1.0f, 1.20000004768f, 5, 2, 10, 0x353B }, { -1.0f, 1.20000004768f, 2, 3, 9, 0x353C }, + { -1.0f, 1.20000004768f, 4, 4, 8, 0x353D }, { -1.0f, 1.20000004768f, 2, 5, 9, 0x353E }, + { -1.0f, 1.20000004768f, 3, 6, 9, 0x353F }, { -1.0f, 1.20000004768f, 1, 7, 9, 0x3540 }, + { -1.0f, 1.20000004768f, 1, 8, 9, 0x3541 }, { -1.0f, 1.20000004768f, 6, 9, 8, 0x3542 }, + { -1.0f, 1.20000004768f, 2, 10, 9, 0x3543 }, { -1.0f, 1.20000004768f, 3, 11, 9, 0x3544 }, + { -1.0f, 1.20000004768f, 1, 12, 9, 0x3545 }, { -1.0f, 1.20000004768f, 4, 13, 8, 0x3546 }, +}; + +static UnkRacedogStruct D_80B25E68 = { -1.0f, 1.0, 0, -1, 0, 0x353E }; + +static Vec2f D_80B25E78[] = { + { -3914.0f, 1283.0f }, + { -3747.0f, 1104.0f }, + { -3717.0f, 1169.0f }, + { -3897.0f, 1308.0f }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 13, 19, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B25EC4 = { 0, 0, 0, 0, 1 }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, 1 }; -// static DamageTable sDamageTable = { -static DamageTable D_80B25ED0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -77,63 +140,523 @@ static DamageTable D_80B25ED0 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B25FF0[] = { +static AnimationInfoS D_80B25EF0[] = { + { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, { &gDogBarkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogSitAnim, 1.0f, 0, -1, ANIMMODE_LOOP_PARTIAL, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -6 }, { &gDogLyingDownLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -6 }, + { &gDogLyingDownAnim, 1.0f, 0, 27, ANIMMODE_ONCE, -6 }, { &gDogLyingDownAnim, 1.0f, 28, -1, ANIMMODE_ONCE, -6 }, + { &gDogLyingDownAnim, 1.0f, 54, 54, ANIMMODE_ONCE, -6 }, { &gDogWalkAnim, -1.5f, -1, 0, ANIMMODE_LOOP, -6 }, + { &gDogJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogLongJumpAnim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDogJump2Anim, 1.2f, 0, -1, ANIMMODE_ONCE, 0 }, { &gDogWalkAnim, 0.5f, 0, -1, ANIMMODE_LOOP, 0 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_STOP), }; -#endif +void func_80B24630(SkelAnime* skelAnime, AnimationInfoS arg1[], s32 arg2) { + f32 frameCount; -extern ColliderCylinderInit D_80B25E98; -extern CollisionCheckInfoInit2 D_80B25EC4; -extern DamageTable D_80B25ED0; -extern InitChainEntry D_80B25FF0[]; + arg1 += arg2; + if (arg1->frameCount < 0) { + frameCount = Animation_GetLastFrame(arg1->animation); + } else { + frameCount = arg1->frameCount; + } -extern UNK_TYPE D_06000618; -extern UNK_TYPE D_060080F0; + Animation_Change(skelAnime, arg1->animation, arg1->playSpeed + (BREG(88) * 0.1f), arg1->startFrame, frameCount, + arg1->mode, arg1->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24630.s") +void func_80B246F4(EnRacedog* this, GlobalContext* globalCtx) { + this->collider.dim.pos.x = this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 26.0f, 10.0f, 0.0f, 5); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B246F4.s") +s16 func_80B2478C(Path* path, s32 arg1, Vec3f* pos, f32* arg3) { + Vec3s* point; + f32 phi_f14; + f32 sp1C; + f32 xDiff; + f32 zDiff; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2478C.s") + if (path != NULL) { + point = Lib_SegmentedToVirtual(path->points); + point = &point[arg1]; + phi_f14 = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + sp1C = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + xDiff = point->x - pos->x; + zDiff = point->z - pos->z; + } else { + phi_f14 = 0.0f; + sp1C = 0.0f; + xDiff = 0.0f; + zDiff = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B248B8.s") + *arg3 = SQ(xDiff) + SQ(zDiff); + return RADF_TO_BINANG(Math_Acot2F(sp1C, phi_f14)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Init.s") +void func_80B248B8(EnRacedog* this, Vec3f* arg1) { + f32 sp20; + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Destroy.s") + if (this->actor.floorPoly != NULL) { + sp20 = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); + sp1C = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24C14.s") + arg1->x = -Math_Acot2F(1.0f, -sp1C * sp20); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24CB4.s") +void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; + ColliderCylinder* collider = &this->collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24E14.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gDogSkel, NULL, this->jointTable, this->morphTable, DOG_LIMB_MAX); + Collider_InitCylinder(globalCtx, collider); + Collider_SetCylinder(globalCtx, collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B24F08.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_1E0 = SubS_GetPathByIndex(globalCtx, ENRACEDOG_GET_PATH(&this->actor), 0x3F); + Actor_SetScale(&this->actor, 0.0075f); + this->actor.gravity = -3.0f; + if (ENRACEDOG_GET_3E0(&this->actor) < 14) { + this->unk_290 = ENRACEDOG_GET_3E0(&this->actor); + } else { + Actor_MarkForDeath(&this->actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B251EC.s") + this->unk_2BC = 0xFF; + this->unk_2C0 = 0x32; + this->unk_288 = 0xC; + this->unk_2A0.x = 0.0f; + this->unk_2A0.y = 0.0f; + this->unk_2A0.z = 0.0f; + this->unk_2C4 = 1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B252F8.s") + if ((D_80B25D88[this->unk_290].unk_0E >= 0x353F) && (this->unk_290 == (s16)Rand_ZeroFloat(20.0f))) { + this->unk_28C = 5; + } else { + this->unk_28C = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2538C.s") + this->unk_28A = 60; + this->unk_28A += this->unk_28C; + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + this->unk_29C = 0; + this->unk_2B8 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25448.s") + func_80B24E14(this); + this->actor.flags |= ACTOR_FLAG_10; + this->actor.flags |= ACTOR_FLAG_20; + D_80B25E68 = D_80B25D88[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; + this->unk_292 = D_80B25E68.unk_0A; + func_80B24630(&this->skelAnime, D_80B25EF0, 0); + D_80B25EF0->playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + this->actionFunc = func_80B24C14; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25490.s") +void EnRacedog_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B255AC.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B256BC.s") +void func_80B24C14(EnRacedog* this, GlobalContext* globalCtx) { + s16 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Update.s") + if (this->unk_28A == 0) { + phi_v1 = 0; + } else { + this->unk_28A--; + phi_v1 = this->unk_28A; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B2583C.s") + if (phi_v1 == 0) { + this->unk_28A = Rand_S16Offset(50, 50); + if (this->unk_28C == 0) { + play_sound(NA_SE_SY_START_SHOT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B258D8.s") + func_80B24630(&this->skelAnime, D_80B25EF0, 2); + this->actionFunc = func_80B24CB4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25A74.s") +void func_80B24CB4(EnRacedog* this, GlobalContext* globalCtx) { + s16 phi_a1; + f32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/func_80B25A90.s") + this->collider.dim.radius = 15; + if (this->unk_1E0 != 0) { + phi_a1 = func_80B2478C(this->unk_1E0, this->unk_1E8, &this->actor.world.pos, &sp30); + if (this->actor.bgCheckFlags & 8) { + phi_a1 = this->actor.wallYaw; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Racedog/EnRacedog_Draw.s") + Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + + if (sp30 <= 2500.0f) { + this->unk_1E8++; + if (this->unk_1E8 >= (this->unk_1E0->count - 1)) { + this->unk_1E8 = 0; + } + } + + func_80B24F08(this); + if ((this->unk_1E8 >= ((this->unk_1E0->count / 4) * 3)) && (this->unk_290 == D_80B25D4C)) { + D_80B25D48++; + } + + func_80B252F8(this); + func_80B2538C(this); + Actor_MoveWithGravity(&this->actor); + } + + func_80B25448(this); + func_80B256BC(this); + func_80B255AC(this, globalCtx); +} + +void func_80B24E14(EnRacedog* this) { + if (this->unk_290 % 2) { + D_80B25D88[this->unk_290].unk_0E = + (((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; + } else { + D_80B25D88[this->unk_290].unk_0E = + ((gSaveContext.save.weekEventReg[42 + (this->unk_290 / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + } + + if ((D_80B25D88[this->unk_290].unk_0E >= 0x3547) || (D_80B25D88[this->unk_290].unk_0E < 0x3539)) { + D_80B25D88[this->unk_290].unk_0E = 0x353E; + } + if (D_80B25D88[this->unk_290].unk_0E == 0x3547) { + D_80B25D88[this->unk_290].unk_0E = 0x3538; + } +} + +void func_80B24F08(EnRacedog* this) { + s32 temp_a0; + s32 temp_v1 = this->unk_1E0->count; + + if (this->unk_2B8 < this->unk_1E8) { + this->unk_2B8 = this->unk_1E8; + if (this->unk_1E8 == 0) { + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0]; + } else { + temp_a0 = temp_v1 / 4; + if (this->unk_1E8 < temp_a0) { + if (D_80B25D88[this->unk_290].unk_08 == 5) { + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][0] + randPlusMinusPoint5Scaled(1.0f); + } else { + this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } + + if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { + this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + } + } else if (this->unk_1E8 < (temp_a0 * 3)) { + if (this->unk_1E8 < D_80B25D88[this->unk_290].unk_0C) { + this->unk_298 = 5.0f + randPlusMinusPoint5Scaled(1.0f); + } else { + this->unk_298 = D_80B25D50[D_80B25D88[this->unk_290].unk_08][1] + randPlusMinusPoint5Scaled(1.0f); + + if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { + this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + } + } + } else if (this->unk_1E8 < temp_v1) { + func_80B251EC(this); + } else { + this->unk_298 = randPlusMinusPoint5Scaled(1.0f) + 5.0f; + } + } + } + + if ((this->unk_1E8 != 0) || (this->unk_29C != 0)) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } + + Math_ApproachF(&this->actor.speedXZ, this->unk_298, 0.5f, 3.0f); + + if (this->unk_290 == this->unk_292) { + if (this->actor.speedXZ > 7.5f) { + this->actor.speedXZ = 7.5f; + } + } else { + if (this->actor.speedXZ > 7.0f) { + this->actor.speedXZ = 7.0f; + } + } +} + +void func_80B251EC(EnRacedog* this) { + f32 temp; + + if (D_80B25D88[this->unk_290].unk_00 == -1.0f) { + if (D_80B25D48 < 100.0f) { + D_80B25D88[this->unk_290].unk_00 = 200.0f / (200.0f - D_80B25D48); + } else { + D_80B25D88[this->unk_290].unk_00 = 2.0f; + } + } + + if (D_80B25D88[this->unk_290].unk_0E < 0x3542) { + temp = D_80B25D88[this->unk_290].unk_00; + this->unk_298 = temp * D_80B25D50[D_80B25D88[this->unk_290].unk_08][1]; + } + + if ((D_80B25D88[this->unk_290].unk_0E < 0x353E) && (this->unk_290 != D_80B25D4C)) { + this->unk_298 *= D_80B25D88[this->unk_290].unk_04; + } +} + +void func_80B252F8(EnRacedog* this) { + if ((this->unk_1E8 >= 9) && (this->unk_29C == 0)) { + this->unk_29C = 1; + } + + if ((this->unk_1E8 >= 0xB) && (this->unk_29C == 1)) { + this->unk_29C = 2; + } + + if (((this->unk_1E8 >= D_80B25D44) || (this->unk_29C <= 0)) && (this->unk_1E8 > D_80B25D44)) { + D_80B25D44 = this->unk_1E8; + D_80B25D4C = this->unk_290; + } +} + +void func_80B2538C(EnRacedog* this) { + if (func_80B25490(this, D_80B25E78) && this->unk_29C == 2) { + D_80B25D40++; + if (D_80B25D40 == 1) { + Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); + play_sound(NA_SE_SY_START_SHOT); + } + + this->unk_29C = 3; + if (this->unk_290 == this->unk_292) { + gSaveContext.eventInf[0] = (gSaveContext.eventInf[0] & 7) | (D_80B25D40 * 8); + } + } +} + +void func_80B25448(EnRacedog* this) { + if (this->actor.speedXZ < 3.0f) { + D_80B25EF0[2].playSpeed = 0.9f; + } else { + D_80B25EF0[2].playSpeed = 1.0f; + } +} + +s32 func_80B25490(EnRacedog* this, Vec2f* arg1) { + f32 xDistToTopFront; + f32 zDistToTopFront; + f32 xDistToBottomFront; + f32 xDistToBottomBack; + f32 zDistToBottomBack; + f32 zDistToBottomFront; + f32 zDistToTopBack; + f32 xDistToTopBack; + f32 temp_f0; + f32 temp; + + xDistToTopFront = this->actor.world.pos.x - arg1[0].x; + zDistToTopFront = this->actor.world.pos.z - arg1[0].z; + xDistToBottomFront = this->actor.world.pos.x - arg1[1].x; + zDistToBottomFront = this->actor.world.pos.z - arg1[1].z; + xDistToBottomBack = this->actor.world.pos.x - arg1[2].x; + zDistToBottomBack = this->actor.world.pos.z - arg1[2].z; + xDistToTopBack = this->actor.world.pos.x - arg1[3].x; + zDistToTopBack = this->actor.world.pos.z - arg1[3].z; + + temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + temp = (((xDistToBottomFront * zDistToBottomBack) - (xDistToBottomBack * zDistToBottomFront))); + if (temp_f0 * temp < 0.0f) { + return false; + } + + temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + temp = ((xDistToBottomBack * zDistToTopBack) - (xDistToTopBack * zDistToBottomBack)); + if (temp_f0 * temp < 0.0f) { + return false; + } + + temp_f0 = ((xDistToTopFront * zDistToBottomFront) - (xDistToBottomFront * zDistToTopFront)); + temp = ((xDistToTopBack * zDistToTopFront) - (xDistToTopFront * zDistToTopBack)); + if (temp_f0 * temp < 0.0f) { + return false; + } + + return true; +} + +void func_80B255AC(EnRacedog* this, GlobalContext* globalCtx) { + s16 curFrame = this->skelAnime.curFrame; + s16 mod = (this->actor.speedXZ > 6.0f) ? 2 : 3; + Vec3f sp38; + + if (((this->unk_290 + curFrame) % mod) == 0) { + sp38.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + sp38.y = this->actor.world.pos.y; + sp38.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &sp38, 10.0f, 0, 2.0f, 300, 0, true); + } +} + +void func_80B256BC(EnRacedog* this) { + s16 curFrame = this->skelAnime.curFrame; + + if ((curFrame == 1) || (curFrame == 7)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MONKEY_WALK); + } +} + +void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRacedog* this = THIS; + Vec3f sp2C = { 0.0f, 0.0f, 0.0f }; + + this->unk_292 = D_80B25E68.unk_0A; + + this->actionFunc(this, globalCtx); + + func_80B246F4(this, globalCtx); + func_80B248B8(this, &sp2C); + Math_ApproachF(&this->unk_2AC.x, sp2C.x, 0.2f, 0.1f); + + if (this->unk_2A0.x > 0.0f) { + if ((this->unk_2AC.x < 0.0f) && (this->unk_2AC.x > -0.1f)) { + this->skelAnime.curFrame = 4.0f; + this->actor.velocity.y = 5.5f; + } + } + + if (!(this->actor.bgCheckFlags & 1)) { + this->skelAnime.curFrame = 0.0f; + } + + this->unk_2A0 = this->unk_2AC; + SkelAnime_Update(&this->skelAnime); +} + +void func_80B2583C(EnRacedog* this) { + s16 phi_v1; + + if (this->unk_288 >= 7) { + this->unk_2BC -= 0x10; + this->unk_2C0 += 8; + this->unk_2C4 += 0.05f; + } else { + this->unk_2BC += 0x10; + this->unk_2C0 -= 8; + this->unk_2C4 -= 0.05f; + } + + if (this->unk_288 == 0) { + phi_v1 = 0; + } else { + this->unk_288--; + phi_v1 = this->unk_288; + } + + if (phi_v1 == 0) { + this->unk_288 = 0xC; + } +} + +void func_80B258D8(EnRacedog* this, GlobalContext* globalCtx) { + Vec3s sp48 = gZeroVec3s; + s32 phi_v0 = (this->unk_290 == this->unk_292) ? true : false; + + if (phi_v0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + func_80B2583C(this); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, + this->actor.world.pos.z, &sp48); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 255, 255, this->unk_2BC, 0, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, this->unk_2C0, 0, 255); + Matrix_Scale(this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, this->unk_2C4 * 2.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowEmptyDL); + gSPDisplayList(POLY_OPA_DISP++, gDogSelectionArrowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnRacedog_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnRacedog* this = THIS; + Vec3f sp1C = { 0.0f, 20.0f, 0.0f }; + + if (limbIndex == DOG_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&sp1C, &this->actor.focus.pos); + } + + if (limbIndex == DOG_LIMB_TAIL) { + func_80B258D8(this, globalCtx); + } +} + +void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRacedog* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + switch (D_80B25D88[this->unk_290].unk_08) { + case 3: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); + break; + case 1: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 0); + break; + case 5: + gDPSetEnvColor(POLY_OPA_DISP++, 79, 79, 143, 0); + break; + case 6: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 207, 47, 0); + break; + case 4: + gDPSetEnvColor(POLY_OPA_DISP++, 143, 79, 47, 0); + break; + case 2: + gDPSetEnvColor(POLY_OPA_DISP++, 143, 143, 143, 0); + break; + default: + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 200, 0); + break; + } + + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(this->unk_2AC.x); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRacedog_OverrideLimbDraw, EnRacedog_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 4008ba4e1..19f7af7a5 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -2,22 +2,42 @@ #define Z_EN_RACEDOG_H #include "global.h" +#include "objects/object_dog/object_dog.h" + +#define ENRACEDOG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) +#define ENRACEDOG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) struct EnRacedog; typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); typedef struct EnRacedog { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnRacedogActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xA0]; - /* 0x01E8 */ s32 unk_1E8; - /* 0x01EC */ char unk_1EC[0xA4]; - /* 0x0290 */ s16 unk_290; - /* 0x0292 */ s16 unk_292; - /* 0x0294 */ char unk_294[0x8]; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ char unk_29E[0x2A]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnRacedogActionFunc actionFunc; + /* 0x148 */ UNK_TYPE1 unk_148[0x4]; + /* 0x14C */ SkelAnime skelAnime; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ UNK_TYPE1 unk_1DC[0x4]; + /* 0x1E0 */ Path* unk_1E0; + /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x4]; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ Vec3s jointTable[DOG_LIMB_MAX]; + /* 0x23A */ Vec3s morphTable[DOG_LIMB_MAX]; + /* 0x288 */ s16 unk_288; + /* 0x28A */ s16 unk_28A; + /* 0x28C */ s16 unk_28C; + /* 0x28A */ UNK_TYPE1 unk_28E[0x2]; + /* 0x290 */ s16 unk_290; + /* 0x292 */ s16 unk_292; + /* 0x294 */ UNK_TYPE1 unk_294[0x4]; + /* 0x298 */ f32 unk_298; + /* 0x29C */ s16 unk_29C; + /* 0x2A0 */ Vec3f unk_2A0; + /* 0x2AC */ Vec3f unk_2AC; + /* 0x2B8 */ s32 unk_2B8; + /* 0x2BC */ s32 unk_2BC; + /* 0x2C0 */ s32 unk_2C0; + /* 0x2C4 */ f32 unk_2C4; } EnRacedog; // size = 0x2C8 extern const ActorInit En_Racedog_InitVars; diff --git a/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/src/overlays/actors/ovl_En_Raf/z_en_raf.c index 38fb9e965..a32811620 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 0x08000000 +#define FLAGS (ACTOR_FLAG_8000000) #define THIS ((EnRaf*)thisx) 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 8f1500810..e1971c182 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 @@ -8,7 +8,7 @@ #include "z_en_rail_skb.h" #include "objects/object_skb/object_skb.h" -#define FLAGS 0x00000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10) #define THIS ((EnRailSkb*)thisx) @@ -62,14 +62,20 @@ const ActorInit En_Rail_Skb_InitVars = { (ActorFunc)EnRailSkb_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0f }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0f }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0f }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderJntSphElementInit sJntSphElementsInit[2] = { @@ -188,7 +194,7 @@ void func_80B708C0(EnRailSkb* this, GlobalContext* globalCtx) { s32 func_80B70AB4(Vec2f arg0, Vec2f arg1) { s32 phi_v1; - if ((arg1.x * arg0.y) < (arg0.x * arg1.y)) { + if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { phi_v1 = 1; } else { phi_v1 = -1; @@ -207,9 +213,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { s32 j; sp60.x = this->unk_230[0].z - pos.z; - sp60.y = this->unk_230[0].x - pos.x; + sp60.z = this->unk_230[0].x - pos.x; sp58.x = this->unk_230[1].z - pos.z; - sp58.y = this->unk_230[1].x - pos.x; + sp58.z = this->unk_230[1].x - pos.x; j = 1; temp_s3 = func_80B70AB4(sp60, sp58); @@ -223,9 +229,9 @@ s32 func_80B70B04(EnRailSkb* this, Vec3f pos) { } sp60.x = this->unk_230[i].z - pos.z; - sp60.y = this->unk_230[i].x - pos.x; + sp60.z = this->unk_230[i].x - pos.x; sp58.x = this->unk_230[j].z - pos.z; - sp58.y = this->unk_230[j].x - pos.x; + sp58.z = this->unk_230[j].x - pos.x; if (func_80B70AB4(sp60, sp58) != temp_s3) { ret = false; @@ -281,7 +287,7 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2E4 = -1; this->unk_3FC = 0; this->unk_3FA = 0; - this->unk_403 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_3FE = 0; if (this->actor.parent == NULL) { @@ -290,8 +296,9 @@ void EnRailSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3F8 = 0; } - if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { - this->actor.flags |= 0x100000; + if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 0)) { + this->actor.flags |= ACTOR_FLAG_100000; } func_80B70FA0(this); @@ -306,7 +313,7 @@ void EnRailSkb_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80B70FA0(EnRailSkb* this) { this->unk_3F2 = 0; if (this->actionFunc != func_80B716A8) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B70FF8; } @@ -344,13 +351,13 @@ void func_80B71114(EnRailSkb* this) { } void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); @@ -358,7 +365,7 @@ void func_80B7114C(EnRailSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); func_80B71488(this); } - } else if (this->unk_3F0 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80B726B4(this, globalCtx); } } @@ -368,13 +375,13 @@ void func_80B71228(EnRailSkb* this) { } void func_80B7123C(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 == 0) { - this->unk_3F0 = 0; - this->unk_2F0 = 0.0f; - this->unk_2EC = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_402 |= 1; func_80B712FC(this); @@ -400,7 +407,7 @@ void func_80B71314(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71354(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B713A4; } @@ -409,7 +416,7 @@ void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actor.xzDistToPlayer > 65.0f) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN)) { func_80B70FA0(this); } else { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); } } @@ -422,7 +429,7 @@ void func_80B713A4(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71488(EnRailSkb* this) { this->unk_402 |= 0x40; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (this->unk_2E0 != 0) { this->unk_2E4 = this->unk_2E0 - 1; } else { @@ -445,12 +452,12 @@ void func_80B7151C(EnRailSkb* this) { this->actor.shape.yOffset = -5000.0f; this->actor.colChkInfo.health = 2; this->unk_402 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); this->actionFunc = func_80B715AC; } @@ -473,7 +480,7 @@ void func_80B715AC(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71650(EnRailSkb* this) { this->unk_3FE = 0; if (this->actionFunc != func_80B70FF8) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } this->actionFunc = func_80B716A8; } @@ -483,14 +490,14 @@ void func_80B716A8(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3FE = 1; func_80B71D8C(this, globalCtx, func_80B723F8); if (!func_80B7285C(this)) { - func_801518B0(globalCtx, 0x13EC, &this->actor); + Message_StartTextbox(globalCtx, 0x13EC, &this->actor); this->unk_400 = 0x13EC; func_80B72830(this, 1); } else { - func_801518B0(globalCtx, 0x13F5, &this->actor); + Message_StartTextbox(globalCtx, 0x13F5, &this->actor); this->unk_400 = 0x13F5; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); func_80B717C8(this); } else if ((this->actor.xzDistToPlayer < 100.0f) && !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); @@ -527,7 +534,7 @@ void func_80B717E0(EnRailSkb* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80B71650(this); } break; @@ -552,13 +559,13 @@ void func_80B718C4(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B71910(EnRailSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71954; } void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { - s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); - f32 sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); + f32 sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); Math_SmoothStepToS(&this->actor.shape.rot.y, sp36, 1, 0x71C, 0xB6); this->actor.world.rot = this->actor.shape.rot; @@ -570,29 +577,29 @@ void func_80B71954(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71A08(EnRailSkb* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->actionFunc = func_80B71A58; } void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { - s16 sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + 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_ChangeAnimation(&this->skelAnime, sAnimations, 2); - if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { - this->unk_22C->actor.colChkInfo.health--; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { + this->unk_22C->dyna.actor.colChkInfo.health--; } else { - this->unk_22C->actor.colChkInfo.health--; + this->unk_22C->dyna.actor.colChkInfo.health--; func_80B71B6C(this); } } if (Animation_OnFrame(&this->skelAnime, 3.0f)) { - if (this->unk_2E8 < this->unk_22C->actor.colChkInfo.health) { - this->unk_22C->actor.colChkInfo.health--; + if (this->unk_2E8 < this->unk_22C->dyna.actor.colChkInfo.health) { + this->unk_22C->dyna.actor.colChkInfo.health--; } else { - this->unk_22C->actor.colChkInfo.health--; + this->unk_22C->dyna.actor.colChkInfo.health--; func_80B71B6C(this); } } @@ -602,14 +609,14 @@ void func_80B71A58(EnRailSkb* this, GlobalContext* globalCtx) { void func_80B71B6C(EnRailSkb* this) { this->unk_3F2 = 10; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80B71BB8; } void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { s32 pad; s32 i; - f32 sp34 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->actor.world.pos); + f32 sp34 = Math_Vec3f_DistXZ(&this->actor.world.pos, &this->unk_22C->dyna.actor.world.pos); if (this->unk_3F2 > 0) { this->unk_3F2--; @@ -617,15 +624,15 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.shape.rot.y, - Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_22C->actor.world.pos), 1, 0x71C, 0xB6); + 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->actor.colChkInfo.health == 0)) { + if ((this->actor.bgCheckFlags & 1) && (this->unk_22C->dyna.actor.colChkInfo.health == 0)) { Actor_MoveWithGravity(&this->actor); } else { this->actor.velocity.y += this->actor.gravity; this->actor.world.pos.y += this->actor.velocity.y; - Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_22C->actor.world.pos.x, 0.6f, 1.6f, 0.1f); - Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_22C->actor.world.pos.z, 0.6f, 1.6f, 0.1f); + Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_22C->dyna.actor.world.pos.x, 0.6f, 1.6f, 0.1f); + 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) { @@ -635,7 +642,7 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { if ((sp34 < 50.0f) && (this->actor.bgCheckFlags & 1)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_ATTACK); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.velocity.y = 10.0f; for (i = 0; i < 4; i++) { @@ -660,15 +667,15 @@ void func_80B71DF0(EnRailSkb* this) { this->actor.shape.yOffset = -5000.0f; this->actor.colChkInfo.health = 2; this->unk_402 = 0; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnRailSkb_Draw; this->actor.shape.shadowAlpha = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - } else if ((this->actionFunc == func_80B7114C) && (this->unk_3F0 >= 2)) { - this->unk_3F0 = 0; + } else if ((this->actionFunc == func_80B7114C) && (this->drawDmgEffTimer > 1)) { + this->drawDmgEffTimer = 0; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); this->actionFunc = func_80B71EA8; } @@ -693,37 +700,37 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { this->unk_3F2 = 1; } - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_400) { case 0x13EC: - func_801518B0(globalCtx, 0x13ED, &this->actor); + Message_StartTextbox(globalCtx, 0x13ED, &this->actor); this->unk_400 = 0x13ED; break; case 0x13ED: - func_801518B0(globalCtx, 0x13EE, &this->actor); + Message_StartTextbox(globalCtx, 0x13EE, &this->actor); this->unk_400 = 0x13EE; break; case 0x13EE: - func_801518B0(globalCtx, 0x13EF, &this->actor); + Message_StartTextbox(globalCtx, 0x13EF, &this->actor); this->unk_400 = 0x13EF; break; case 0x13EF: case 0x13F5: - func_801518B0(globalCtx, 0x13F0, &this->actor); + Message_StartTextbox(globalCtx, 0x13F0, &this->actor); this->unk_400 = 0x13F0; break; case 0x13F1: - func_801518B0(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(globalCtx, 0x13F2, &this->actor); this->unk_400 = 0x13F2; break; case 0x13F2: if (this->unk_3FC == 1) { - func_801518B0(globalCtx, 0x13F4, &this->actor); + Message_StartTextbox(globalCtx, 0x13F4, &this->actor); this->unk_400 = 0x13F4; } else { func_801477B4(globalCtx); @@ -732,7 +739,7 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { break; case 0x13F3: - func_801518B0(globalCtx, 0x13F2, &this->actor); + Message_StartTextbox(globalCtx, 0x13F2, &this->actor); this->unk_400 = 0x13F2; this->unk_3FC = 1; break; @@ -746,14 +753,14 @@ void func_80B71F3C(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B72100(EnRailSkb* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { func_8019F208(); - func_801518B0(globalCtx, 0x13F1, &this->actor); + Message_StartTextbox(globalCtx, 0x13F1, &this->actor); this->unk_400 = 0x13F1; } else { func_8019F208(); - func_801518B0(globalCtx, 0x13F3, &this->actor); + Message_StartTextbox(globalCtx, 0x13F3, &this->actor); this->unk_400 = 0x13F3; } } @@ -816,9 +823,9 @@ void func_80B72190(EnRailSkb* this, GlobalContext* globalCtx) { } void func_80B723F8(EnRailSkb* this) { - this->actor.flags &= ~(4 | 1); - this->actor.flags |= (8 | 1); - this->actor.flags |= 0x100000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= ACTOR_FLAG_100000; this->actor.hintId = 0xFF; this->actor.textId = 0; } @@ -848,20 +855,20 @@ void func_80B72430(EnRailSkb* this, GlobalContext* globalCtx, s32 arg2) { } void func_80B725C0(EnRailSkb* this, GlobalContext* globalCtx) { - if (this->unk_3F0 > 0) { - this->unk_3F0--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_80B7114C) { - if (this->unk_3F0 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_80B7123C) { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_2F0, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_2EC = this->unk_3F0 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2F0, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -876,21 +883,21 @@ void func_80B726B4(EnRailSkb* this, GlobalContext* globalCtx) { s16 yaw; if (this->unk_402 & 2) { - end = ARRAY_COUNT(this->unk_234) - 1; + end = ARRAY_COUNT(this->limbPos) - 1; } else { - end = ARRAY_COUNT(this->unk_234); + end = ARRAY_COUNT(this->limbPos); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80B734B8, &D_80B734B0, &D_80B734B4, 30); } } @@ -917,17 +924,17 @@ void func_80B72880(EnRailSkb* this, GlobalContext* globalCtx) { if ((this->actionFunc == func_80B70FF8) || (this->actionFunc == func_80B716A8)) { if (this->actionFunc != func_80B716A8) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(4 | 1); - this->actor.flags |= (8 | 1); - this->actor.flags |= 0x100000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= ACTOR_FLAG_100000; this->actor.hintId = 0xFF; this->actor.textId = 0; func_80B71650(this); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(8 | 1); - this->actor.flags &= ~0x100000; - this->actor.flags |= 5; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags &= ~ACTOR_FLAG_100000; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.hintId = 0x55; this->actor.textId = 0; func_80B70FA0(this); @@ -957,10 +964,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { return; default: - if (this->unk_3F0 >= 2) { + if (this->drawDmgEffTimer >= 2) { func_80B726B4(this, globalCtx); } - this->unk_3F0 = 0; + this->drawDmgEffTimer = 0; break; } } @@ -974,10 +981,10 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3F0 = 40; - this->unk_403 = 30; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 120, 0, 40); func_80B710AC(this); break; @@ -988,13 +995,13 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3F0 = 80; - this->unk_403 = 0; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.0f; + this->drawDmgEffTimer = 80; + 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_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_402 |= 1; func_80B712FC(this); break; @@ -1002,25 +1009,25 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3F0 = 80; + this->drawDmgEffTimer = 80; } else { - this->unk_3F0 = 3; + this->drawDmgEffTimer = 3; } - this->unk_403 = 11; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); func_80B71114(this); break; case 4: - this->unk_3F0 = 40; - this->unk_403 = 20; - this->unk_2EC = 1.0f; - this->unk_2F0 = 0.5f; + this->drawDmgEffTimer = 40; + 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_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80B71228(this); break; @@ -1037,7 +1044,7 @@ void func_80B72970(EnRailSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80B712FC(this); break; @@ -1118,15 +1125,15 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3F0 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_402 & 2)) { - Matrix_MultiplyVector3fByState(&D_80B734D0, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80B734D0, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1135,13 +1142,13 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList void EnRailSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnRailSkb_OverrideLimbDraw, EnRailSkb_PostLimbDraw, &this->actor); - if (this->unk_3F0 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_2F0, 0.5f, this->unk_2EC, - this->unk_403); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if ((this->unk_402 & 0x40) && !(this->unk_402 & 0x80)) { diff --git a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h index 23202ef19..6346eebe2 100644 --- a/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h +++ b/src/overlays/actors/ovl_En_Rail_Skb/z_en_rail_skb.h @@ -19,17 +19,17 @@ typedef struct EnRailSkb { /* 0x228 */ EnRailSkbActionFunc actionFunc; /* 0x22C */ ObjHakaisi* unk_22C; /* 0x230 */ Vec3s* unk_230; - /* 0x234 */ Vec3f unk_234[14]; - /* 0x2DC */ s32 unk_2DC; + /* 0x234 */ Vec3f limbPos[14]; + /* 0x2DC */ s32 limbCount; /* 0x2E0 */ s32 unk_2E0; /* 0x2E4 */ s32 unk_2E4; /* 0x2E8 */ s32 unk_2E8; - /* 0x2EC */ f32 unk_2EC; - /* 0x2F0 */ f32 unk_2F0; + /* 0x2EC */ f32 drawDmgEffAlpha; + /* 0x2F0 */ f32 drawDmgEffScale; /* 0x2F4 */ Vec3s jointTable[20]; /* 0x36C */ Vec3s morphTable[20]; /* 0x3E4 */ UNK_TYPE1 unk3E4[0xC]; - /* 0x3F0 */ s16 unk_3F0; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 unk_3F2; /* 0x3F4 */ s16 unk_3F4; /* 0x3F6 */ s16 unk_3F6; @@ -39,7 +39,7 @@ typedef struct EnRailSkb { /* 0x3FE */ s16 unk_3FE; /* 0x400 */ u16 unk_400; /* 0x402 */ u8 unk_402; - /* 0x403 */ u8 unk_403; + /* 0x403 */ u8 drawDmgEffType; } EnRailSkb; // size = 0x404 extern const ActorInit En_Rail_Skb_InitVars; 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 8e34372b7..70d9fb708 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -7,7 +7,7 @@ #include "z_en_railgibud.h" #include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRailgibud*)thisx) @@ -16,37 +16,71 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx); void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BA57A8(EnRailgibud* this); -void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA59F0(EnRailgibud* this); -void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA5AF0(EnRailgibud* this); -void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA5DBC(EnRailgibud* this); -void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6054(EnRailgibud* this); -void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6158(EnRailgibud* this); -void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6284(EnRailgibud* this); -void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6664(EnRailgibud* this); -void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA6974(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); -void func_80BA6B9C(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx); -s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7878(Actor* thisx, GlobalContext* globalCtx); -void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7C78(EnRailgibud* this); -void func_80BA7CF0(EnRailgibud* this); -void func_80BA7D04(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA7D30(EnRailgibud* this, GlobalContext* globalCtx); -void func_80BA8050(Actor* thisx, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkInCircles(EnRailgibud* this); +void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this); +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this); +void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupGrab(EnRailgibud* this); +void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupGrabFail(EnRailgibud* this); +void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this); +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupWalkToHome(EnRailgibud* this); +void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SetupDead(EnRailgibud* this); +void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5); +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, GlobalContext* globalCtx); +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, GlobalContext* globalCtx); +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_InitActorActionCommand(EnRailgibud* this); +void EnRailgibud_SetupDoNothing(EnRailgibud* this); +void EnRailgibud_DoNothing(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx); +void EnRailgibud_Cutscene_Update(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RAILGIBUD_ANIMATION_GRAB_ATTACK, + /* 1 */ EN_RAILGIBUD_ANIMATION_GRAB_END, + /* 2 */ EN_RAILGIBUD_ANIMATION_GRAB_START, + /* 3 */ EN_RAILGIBUD_ANIMATION_LOOK_BACK, + /* 4 */ EN_RAILGIBUD_ANIMATION_CROUCH_WIPING_TEARS, + /* 5 */ EN_RAILGIBUD_ANIMATION_CROUCH_CRYING, + /* 6 */ EN_RAILGIBUD_ANIMATION_DEATH, + /* 7 */ EN_RAILGIBUD_ANIMATION_DAMAGE, + /* 8 */ EN_RAILGIBUD_ANIMATION_CROUCH_END, + /* 9 */ EN_RAILGIBUD_ANIMATION_IDLE, + /* 10 */ EN_RAILGIBUD_ANIMATION_WALK, + /* 11 */ EN_RAILGIBUD_ANIMATION_DANCE_SQUAT, + /* 12 */ EN_RAILGIBUD_ANIMATION_DANCE_PIROUETTE, + /* 13 */ EN_RAILGIBUD_ANIMATION_DANCE_CLAP, + /* 14 */ EN_RAILGIBUD_ANIMATION_CROUCH_END_2, + /* 15 */ EN_RAILGIBUD_ANIMATION_SLUMP_START, + /* 16 */ EN_RAILGIBUD_ANIMATION_SLUMP_LOOP, + /* 17 */ EN_RAILGIBUD_ANIMATION_CONVULSION, + /* 18 */ EN_RAILGIBUD_ANIMATION_ARMS_UP_START, + /* 19 */ EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP, +} EnRailgibudAnimations; + +typedef enum { + /* 0 */ EN_RAILGIBUD_TYPE_GIBDO, + /* 1 */ EN_RAILGIBUD_TYPE_REDEAD, +} EnRailgibudType; + +typedef enum { + /* 0 */ EN_RAILGIBUD_GRAB_START, + /* 1 */ EN_RAILGIBUD_GRAB_ATTACK, + /* 2 */ EN_RAILGIBUD_GRAB_RELEASE, +} EnRailgibudGrabState; const ActorInit En_Railgibud_InitVars = { ACTOR_EN_RAILGIBUD, @@ -60,17 +94,27 @@ const ActorInit En_Railgibud_InitVars = { (ActorFunc)EnRailgibud_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, 3, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, 1, -8.0f }, { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_00A450, 3.0f, 0.0f, 0.0f, 2, -6.0f }, { &object_rd_Anim_005DF4, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_0061E4, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_001600, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0009C4, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_000F1C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &gGibdoRedeadGrabAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &gGibdoRedeadGrabStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadWipingTearsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSobbingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadDeathAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadStandUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadWalkAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &gGibdoRedeadSquattingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadPirouetteAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadClappingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadStandUpAnim, 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -6.0f }, + { &gGibdoRedeadSlumpStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSlumpLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadConvulsionAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadArmsUpStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadArmsUpLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -93,76 +137,98 @@ static ColliderCylinderInit sCylinderInit = { { 20, 70, 0, { 0, 0, 0 } }, }; +typedef enum { + /* 0x0 */ EN_RAILGIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_RAILGIBUD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_RAILGIBUD_DMGEFF_FIRE_ARROW, // Damages, applies a fire effect, and changes a Gibdo into a Redead + /* 0x4 */ EN_RAILGIBUD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect + /* 0xC */ EN_RAILGIBUD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect + /* 0xD */ EN_RAILGIBUD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation + /* 0xE */ EN_RAILGIBUD_DMGEFF_LIGHT_RAY, // Instantly kills a Redead on contact + /* 0xF */ EN_RAILGIBUD_DMGEFF_DAMAGE, // Deals damage and plays the damage animation +} EnRailgibudDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(0, 0xD), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xD), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(0, 0xD), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xC), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0xE), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* 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, 0xF), + /* Deku Nut */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Normal arrow */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Hookshot */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Goron punch */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Sword */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Fire arrow */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(2, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_LIGHT_RAY), + /* Thrown object */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_RAILGIBUD_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_RAILGIBUD_DMGEFF_DAMAGE), }; static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_IMMOVABLE }; -void func_80BA5400(EnRailgibud* this, GlobalContext* globalCtx) { - static s32 D_80BA82F8 = 0; - s32 phi_a3; - Vec3f sp70; - Path* path = &globalCtx->setupPathList[ENRAILGIBUD_GET_FF00(&this->actor)]; +/** + * The design behind this actor is that scene files should only spawn a single "main" Gibdo + * who then spawns all the other Gibdos. It spawns enough Gibdos for one to exist on every + * point along the path up to a maximum of nine additional Gibdos (not counting itself). + */ +void EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx) { + static s32 currentGibdoIndex = 0; + s32 nextPoint; + Vec3f targetPos; + Path* path = &globalCtx->setupPathList[ENRAILGIBUD_GET_PATH(&this->actor)]; - this->unk_294 = Lib_SegmentedToVirtual(path->points); - this->unk_298 = D_80BA82F8; - this->unk_29C = path->count; - if (D_80BA82F8 == 0) { + this->points = Lib_SegmentedToVirtual(path->points); + this->currentPoint = currentGibdoIndex; + this->pathCount = path->count; + + // This branch will only be taken for the first, "main" Gibdo. The subsequent + // Gibdos created by Actor_SpawnAsChild will go through this function to set + // their position and rotation, but they will not be able to spawn any more + // Gibdos themselves because currentGibdoIndex will be non-zero. + if (currentGibdoIndex == 0) { s32 i; - for (i = 1; i < this->unk_29C && i < 10; i++) { - D_80BA82F8++; + for (i = 1; i < this->pathCount && i < 10; i++) { + currentGibdoIndex++; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_RAILGIBUD, 0.0f, 0.0f, 0.0f, 0, 0, 0, this->actor.params); } - D_80BA82F8 = 0; + + currentGibdoIndex = 0; } - this->actor.world.pos.x = this->unk_294[this->unk_298].x; - this->actor.world.pos.y = this->unk_294[this->unk_298].y; - this->actor.world.pos.z = this->unk_294[this->unk_298].z; - if (this->unk_298 < (this->unk_29C - 1)) { - phi_a3 = this->unk_298 + 1; + this->actor.world.pos.x = this->points[this->currentPoint].x; + this->actor.world.pos.y = this->points[this->currentPoint].y; + this->actor.world.pos.z = this->points[this->currentPoint].z; + if (this->currentPoint < (this->pathCount - 1)) { + nextPoint = this->currentPoint + 1; } else { - phi_a3 = 0; + nextPoint = 0; } - sp70.x = this->unk_294[phi_a3].x; - sp70.y = this->unk_294[phi_a3].y; - sp70.z = this->unk_294[phi_a3].z; - this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &sp70); + targetPos.x = this->points[nextPoint].x; + targetPos.y = this->points[nextPoint].y; + targetPos.z = this->points[nextPoint].z; + this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); this->actor.home = this->actor.world; } @@ -181,26 +247,26 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.hintId = 0x2D; this->actor.textId = 0; - if (ENRAILGIBUD_GET_80(&this->actor)) { - func_80BA7B6C(this, globalCtx); + if (ENRAILGIBUD_IS_CUTSCENE_TYPE(&this->actor)) { + EnRailgibud_InitCutsceneGibdo(this, globalCtx); return; } - func_80BA5400(this, globalCtx); - this->unk_3F2 = 0; - this->unk_402 = gSaveContext.save.time; - this->unk_404 = 0; - this->unk_3F8 = 0; + EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation(this, globalCtx); + this->playerStunWaitTimer = 0; + this->timeInitialized = gSaveContext.save.time; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->type = EN_RAILGIBUD_TYPE_GIBDO; this->textId = 0; - this->unk_3FA = 0; + this->isInvincible = false; if (this->actor.parent == NULL) { - this->unk_3EC = 1; - this->unk_3EE = 1; + this->shouldWalkForward = true; + this->shouldWalkForwardNextFrame = true; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -208,7 +274,7 @@ void EnRailgibud_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); } - func_80BA57A8(this); + EnRailgibud_SetupWalkInCircles(this); } void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -217,63 +283,66 @@ void EnRailgibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80BA57A8(EnRailgibud* this) { +void EnRailgibud_SetupWalkInCircles(EnRailgibud* this) { this->actor.speedXZ = 0.6f; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); - this->actionFunc = func_80BA57F8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + this->actionFunc = EnRailgibud_WalkInCircles; } -void func_80BA57F8(EnRailgibud* this, GlobalContext* globalCtx) { - Vec3f sp3C; +void EnRailgibud_WalkInCircles(EnRailgibud* this, GlobalContext* globalCtx) { + Vec3f targetPos; s32 pad; - s16 sp36; + s16 yRotation; - sp3C.x = this->unk_294[this->unk_298].x; - sp3C.y = this->unk_294[this->unk_298].y; - sp3C.z = this->unk_294[this->unk_298].z; + targetPos.x = this->points[this->currentPoint].x; + targetPos.y = this->points[this->currentPoint].y; + targetPos.z = this->points[this->currentPoint].z; if ((this->actor.xzDistToPlayer <= 100.0f) && func_800B715C(globalCtx) && (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO)) { this->actor.home = this->actor.world; - func_80BA59F0(this); + EnRailgibud_SetupAttemptPlayerFreeze(this); } - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + // If we're not supposed to walk forward, then stop here; + // don't rotate the Gibdo or move it around. if (this->actor.parent == NULL) { - if (this->unk_3EC != 0) { + if (this->shouldWalkForward) { } else { return; } } else { EnRailgibud* parent = (EnRailgibud*)this->actor.parent; - if (parent->unk_3EC == 0) { + if (!parent->shouldWalkForward) { return; } } - sp36 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp3C); - if (Math_Vec3f_DistXZ(&this->actor.world.pos, &sp3C) > 60.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, sp36, 1, 0x190, 0xA); + yRotation = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); + if (Math_Vec3f_DistXZ(&this->actor.world.pos, &targetPos) > 60.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 1, 0x190, 0xA); this->actor.shape.rot.y = this->actor.world.rot.y; - } else if (this->unk_298 < (this->unk_29C - 1)) { - this->unk_298++; + } else if (this->currentPoint < (this->pathCount - 1)) { + this->currentPoint++; } else { - this->unk_298 = 0; + this->currentPoint = 0; } + Actor_MoveWithGravity(&this->actor); } -void func_80BA59F0(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); - this->actionFunc = func_80BA5A34; +void EnRailgibud_SetupAttemptPlayerFreeze(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); + this->actionFunc = EnRailgibud_AttemptPlayerFreeze; } -void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_AttemptPlayerFreeze(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s16 rot = this->actor.shape.rot.y + this->unk_3E2 + this->unk_3E8; + s16 rot = this->actor.shape.rot.y + this->headRotation.y + this->upperBodyRotation.y; s16 yaw = BINANG_SUB(this->actor.yawTowardsPlayer, rot); if (ABS_ALT(yaw) < 0x2008) { @@ -281,106 +350,112 @@ void func_80BA5A34(EnRailgibud* this, GlobalContext* globalCtx) { func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } - func_80BA6B9C(this, globalCtx); + + EnRailgibud_TurnTowardsPlayer(this, globalCtx); } -void func_80BA5AF0(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); +void EnRailgibud_SetupWalkToPlayer(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - if (this->actionFunc == func_80BA5A34) { - this->unk_3F2 = 80; + + if (this->actionFunc == EnRailgibud_AttemptPlayerFreeze) { + this->playerStunWaitTimer = 80; } else { - this->unk_3F2 = 20; + this->playerStunWaitTimer = 20; } - this->actionFunc = func_80BA5B64; + + this->actionFunc = EnRailgibud_WalkToPlayer; } -void func_80BA5B64(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_WalkToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); this->actor.world.rot = this->actor.shape.rot; - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x64, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x64, 0); - if (func_80BA6D10(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + + if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { + if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; if ((gSaveContext.save.playerForm == PLAYER_FORM_GORON) || (gSaveContext.save.playerForm == PLAYER_FORM_DEKU)) { - func_80BA6054(this); + // 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. + EnRailgibud_SetupGrabFail(this); } else if (globalCtx->grabPlayer(globalCtx, player)) { - func_80BA5DBC(this); + EnRailgibud_SetupGrab(this); } } else { - if (this->unk_3F2 == 0) { + if (this->playerStunWaitTimer == 0) { player->actor.freezeTimer = 40; - this->unk_3F2 = 60; + this->playerStunWaitTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } else { - this->unk_3F2--; + this->playerStunWaitTimer--; } } - } else if ((this->unk_3F4 == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { - func_80BA6284(this); - } else if (func_80BA6DAC(this, globalCtx)) { - func_80BA6284(this); + } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { + EnRailgibud_SetupWalkToHome(this); + } else if (EnRailgibud_PlayerOutOfRange(this, globalCtx)) { + EnRailgibud_SetupWalkToHome(this); } - if (this->unk_3F4 > 0) { - this->unk_3F4--; + if (this->grabWaitTimer > 0) { + this->grabWaitTimer--; } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); - } else if ((globalCtx->gameplayFrames & 95) == 0) { + } else if (!(globalCtx->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } -void func_80BA5DBC(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); - this->actor.flags &= ~1; - this->unk_3F2 = 0; - this->unk_3F0 = 0; - this->actionFunc = func_80BA5E18; +void EnRailgibud_SetupGrab(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_START); + this->grabDamageTimer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_START; + this->actionFunc = EnRailgibud_Grab; } -void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { Player* player2 = GET_PLAYER(globalCtx); Player* player = player2; - s32 sp34; - u16 sp32; + s32 inPositionToAttack; + u16 damageSfxId; - switch (this->unk_3F0) { - case 0: - sp34 = func_80BA7088(this, globalCtx); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (sp34 == 1)) { - this->unk_3F0 = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + switch (this->grabState) { + case EN_RAILGIBUD_GRAB_START: + inPositionToAttack = EnRailgibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (inPositionToAttack == true)) { + this->grabState = EN_RAILGIBUD_GRAB_ATTACK; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_ATTACK); } else if (!(player->stateFlags2 & 0x80)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); - this->actor.flags |= 1; - this->unk_3F0 = 2; - this->unk_3F2 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_RELEASE; + this->grabDamageTimer = 0; } break; - case 1: - if (this->unk_3F2 == 20) { + case EN_RAILGIBUD_GRAB_ATTACK: + if (this->grabDamageTimer == 20) { s16 requiredScopeTemp; - sp32 = player->ageProperties->unk_92 + 0x6805; + damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; globalCtx->damagePlayer(globalCtx, -8); - func_800B8E58(player, sp32); + func_800B8E58(player, damageSfxId); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); - this->unk_3F2 = 0; + this->grabDamageTimer = 0; } else { - this->unk_3F2++; + this->grabDamageTimer++; } if (Animation_OnFrame(&this->skelAnime, 0.0f)) { @@ -392,18 +467,19 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); - this->actor.flags |= 1; - this->unk_3F0 = 2; - this->unk_3F2 = 0; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; + this->grabState = EN_RAILGIBUD_GRAB_RELEASE; + this->grabDamageTimer = 0; } break; - case 2: + case EN_RAILGIBUD_GRAB_RELEASE: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_3F4 = 40; + this->grabWaitTimer = 40; this->actor.shape.yOffset = 0.0f; - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } else { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } @@ -411,88 +487,90 @@ void func_80BA5E18(EnRailgibud* this, GlobalContext* globalCtx) { } } -void func_80BA6054(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); +void EnRailgibud_SetupGrabFail(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->actor.speedXZ = -2.0f; - this->actionFunc = func_80BA60B0; + this->actionFunc = EnRailgibud_GrabFail; } -void func_80BA60B0(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_GrabFail(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 0x12C, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 0x12C, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x12C, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x12C, 0); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.world.rot.y = this->actor.shape.rot.y; - func_80BA6158(this); + EnRailgibud_SetupTurnAwayAndShakeHead(this); } } -void func_80BA6158(EnRailgibud* this) { - this->unk_3F2 = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); - this->actionFunc = func_80BA61A0; +void EnRailgibud_SetupTurnAwayAndShakeHead(EnRailgibud* this) { + this->headShakeTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); + this->actionFunc = EnRailgibud_TurnAwayAndShakeHead; } -void func_80BA61A0(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_TurnAwayAndShakeHead(EnRailgibud* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_3F2 > 60) { - func_80BA6284(this); - this->unk_3F2 = 0; + if (this->headShakeTimer > 60) { + EnRailgibud_SetupWalkToHome(this); + this->playerStunWaitTimer = 0; } else { - this->unk_3E2 = Math_SinS(this->unk_3F2 * 0xFA0) * (0x256F * ((60 - this->unk_3F2) / 60.0f)); - this->unk_3F2++; + this->headRotation.y = + Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); + this->headShakeTimer++; } } -void func_80BA6284(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); +void EnRailgibud_SetupWalkToHome(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - this->actionFunc = func_80BA62D4; + this->actionFunc = EnRailgibud_WalkToHome; } -void func_80BA62D4(EnRailgibud* this, GlobalContext* globalCtx) { - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 100, 0); +void EnRailgibud_WalkToHome(EnRailgibud* this, GlobalContext* globalCtx) { + 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; } else { this->actor.speedXZ = 0.0f; } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.world.rot.y == this->actor.home.rot.y) { - func_80BA57A8(this); + EnRailgibud_SetupWalkInCircles(this); } } else { Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 450); this->actor.world.rot = this->actor.shape.rot; } - if (func_80BA6D10(this, globalCtx)) { + if (EnRailgibud_PlayerInRangeWithCorrectState(this, globalCtx)) { if ((gSaveContext.save.playerForm != PLAYER_FORM_GORON) && (gSaveContext.save.playerForm != PLAYER_FORM_DEKU) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - func_80BA5AF0(this); + EnRailgibud_SetupWalkToPlayer(this); } } } -void func_80BA6440(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); +void EnRailgibud_SetupDamage(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3F2 = 0; - this->unk_3F4 = 0; + this->stunTimer = 0; + this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.speedXZ = -2.0f; - this->actionFunc = func_80BA64AC; + this->actionFunc = EnRailgibud_Damage; } -void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } @@ -500,58 +578,66 @@ void func_80BA64AC(EnRailgibud* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_405 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if ((this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, 26); - this->unk_3F8 = 1; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + this->type = EN_RAILGIBUD_TYPE_REDEAD; } - func_80BA6284(this); + + EnRailgibud_SetupWalkToHome(this); } } -void func_80BA6584(EnRailgibud* this) { +void EnRailgibud_SetupStunned(EnRailgibud* this) { this->actor.world.rot.y = this->actor.shape.rot.y; - this->unk_3F2 = 10; - if (this->unk_3F6 != 0) { + this->stunTimer = 10; + + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } - this->actionFunc = func_80BA6604; + + this->actionFunc = EnRailgibud_Stunned; } -void func_80BA6604(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_Stunned(EnRailgibud* this, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } } - if (this->unk_3F2 != 0) { - this->unk_3F2--; + if (this->stunTimer != 0) { + this->stunTimer--; } } -void func_80BA6664(EnRailgibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); - this->actor.flags &= ~1; +void EnRailgibud_SetupDead(EnRailgibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_DEATH); + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); - this->unk_3F2 = 0; - this->actionFunc = func_80BA66C8; + this->deathTimer = 0; + this->actionFunc = EnRailgibud_Dead; } -void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F2 > 300) { +void EnRailgibud_Dead(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->deathTimer > 300) { if (this->actor.shape.shadowAlpha == 0) { if (this->actor.parent != NULL) { Actor_MarkForDeath(&this->actor); } else { + // Don't delete the "main" Gibdo, since that will break the surviving + // Gibdos' ability to start and stop walking forward. Instead, just + // stop drawing it, and make its Update function only check to see if + // the Gibdos should move forward. this->actor.draw = NULL; - this->actor.flags &= ~1; - this->actor.update = func_80BA7878; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.update = EnRailgibud_MainGibdo_DeadUpdate; } } else { this->actor.shape.shadowAlpha -= 5; @@ -560,107 +646,124 @@ void func_80BA66C8(EnRailgibud* this, GlobalContext* globalCtx) { } } } else { - Math_SmoothStepToS(&this->unk_3E2, 0, 1, 250, 0); - Math_SmoothStepToS(&this->unk_3E8, 0, 1, 250, 0); - this->unk_3F2++; + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 250, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 250, 0); + this->deathTimer++; } - if ((this->unk_3F2 == 20) && (this->unk_3F6 > 0) && (this->unk_404 == 0) && (this->unk_3F8 == 0)) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, 26); - this->unk_3F8 = 1; + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); + this->type = EN_RAILGIBUD_TYPE_REDEAD; } } -void func_80BA6800(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { - Vec3f sp5C = this->actor.world.pos; - Vec3f sp50 = { 0.0f, 8.0f, 0.0f }; - Vec3f sp44 = { 0.0f, -1.5f, 0.0f }; +void EnRailgibud_SpawnEffectsForSinkingIntoTheGround(EnRailgibud* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f rockFragmentPos = this->actor.world.pos; + Vec3f rockFragmentVelocity = { 0.0f, 8.0f, 0.0f }; + Vec3f rockFragmentAccel = { 0.0f, -1.5f, 0.0f }; s16 rand; s32 pad; if ((globalCtx->gameplayFrames & arg2) == 0) { rand = Rand_Next(); - sp5C.x += 15.0f * Math_SinS(rand); - sp5C.z += 15.0f * Math_CosS(rand); - sp44.x = Rand_Centered(); - sp44.z = Rand_Centered(); - sp50.y += Rand_Centered() * 4.0f; - EffectSsHahen_Spawn(globalCtx, &sp5C, &sp50, &sp44, 0, (Rand_Next() & 7) + 10, -1, 10, NULL); - func_80BA6974(globalCtx, &sp5C, 10.0f, 10, 150, 0); + rockFragmentPos.x += 15.0f * Math_SinS(rand); + rockFragmentPos.z += 15.0f * Math_CosS(rand); + rockFragmentAccel.x = Rand_Centered(); + rockFragmentAccel.z = Rand_Centered(); + rockFragmentVelocity.y += Rand_Centered() * 4.0f; + EffectSsHahen_Spawn(globalCtx, &rockFragmentPos, &rockFragmentVelocity, &rockFragmentAccel, 0, + (Rand_Next() & 7) + 10, -1, 10, NULL); + EnRailgibud_SpawnDust(globalCtx, &rockFragmentPos, 10.0f, 10, 150, 0); } } -void func_80BA6974(GlobalContext* globalCtx, Vec3f* vec, f32 arg2, s32 arg3, s16 arg4, s16 arg5) { - Vec3f sp8C; - Vec3f sp80 = { 0.0f, 0.3f, 0.0f }; - Vec3f sp74 = gZeroVec3f; +void EnRailgibud_SpawnDust(GlobalContext* globalCtx, Vec3f* basePos, f32 randomnessScale, s32 dustCount, s16 dustScale, + s16 scaleStep) { + Vec3f dustPos; + Vec3f dustAccel = { 0.0f, 0.3f, 0.0f }; + Vec3f dustVelocity = gZeroVec3f; s32 i; s32 pad; - sp74.y = 2.5f; + dustVelocity.y = 2.5f; - for (i = arg3; i >= 0; i--) { - sp74.x = (Rand_ZeroOne() - 0.5f) * arg2; - sp74.z = (Rand_ZeroOne() - 0.5f) * arg2; + for (i = dustCount; i >= 0; i--) { + dustVelocity.x = (Rand_ZeroOne() - 0.5f) * randomnessScale; + dustVelocity.z = (Rand_ZeroOne() - 0.5f) * randomnessScale; - sp8C.x = vec->x + sp74.x; - sp8C.y = ((Rand_ZeroOne() - 0.5f) * arg2) + vec->y; - sp8C.z = vec->z + sp74.z; + dustPos.x = basePos->x + dustVelocity.x; + dustPos.y = ((Rand_ZeroOne() - 0.5f) * randomnessScale) + basePos->y; + dustPos.z = basePos->z + dustVelocity.z; - sp74.x *= 0.5f; - sp74.z *= 0.5f; - func_800B1210(globalCtx, &sp8C, &sp74, &sp80, (s16)(Rand_ZeroOne() * arg4 * 0.2f) + arg4, arg5); + dustVelocity.x *= 0.5f; + dustVelocity.z *= 0.5f; + func_800B1210(globalCtx, &dustPos, &dustVelocity, &dustAccel, + (s16)(Rand_ZeroOne() * dustScale * 0.2f) + dustScale, scaleStep); } } -void func_80BA6B30(EnRailgibud* this) { +/** + * If any Gibdo in the ring of Gibdos is doing any other action besides walking in + * circles or being dead, then this function will update the "main" Gibdo's + * walking forward variables such that all Gibdos in the ring will stop moving. + * Similarly, this will make all Gibdos in the ring start walking forward again + * if the Gibdos are all performing the appropriate action. + */ +void EnRailgibud_UpdateWalkForwardState(EnRailgibud* this) { if (this->actor.parent == NULL) { - this->unk_3EC = this->unk_3EE; - this->unk_3EE = 1; - if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA66C8)) { - this->unk_3EE = 0; + this->shouldWalkForward = this->shouldWalkForwardNextFrame; + this->shouldWalkForwardNextFrame = true; + if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_Dead)) { + this->shouldWalkForwardNextFrame = false; } - } else if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA66C8)) { - ((EnRailgibud*)this->actor.parent)->unk_3EE = 0; + } else if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_Dead)) { + ((EnRailgibud*)this->actor.parent)->shouldWalkForwardNextFrame = false; } } -void func_80BA6B9C(EnRailgibud* this, GlobalContext* globalCtx) { - s16 temp_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3E8; - s16 phi_a2 = CLAMP(temp_v0, -500, 500); +void EnRailgibud_TurnTowardsPlayer(EnRailgibud* this, GlobalContext* globalCtx) { + s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyRotation.y; + s16 upperBodyAngle = CLAMP(headAngle, -500, 500); - temp_v0 -= this->unk_3E2; - temp_v0 = CLAMP(temp_v0, -500, 500); + headAngle -= this->headRotation.y; + headAngle = CLAMP(headAngle, -500, 500); if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { - this->unk_3E8 += ABS_ALT(phi_a2); - this->unk_3E2 += ABS_ALT(temp_v0); + this->upperBodyRotation.y += ABS_ALT(upperBodyAngle); + this->headRotation.y += ABS_ALT(headAngle); } else { - this->unk_3E8 -= ABS_ALT(phi_a2); - this->unk_3E2 -= ABS_ALT(temp_v0); + this->upperBodyRotation.y -= ABS_ALT(upperBodyAngle); + this->headRotation.y -= ABS_ALT(headAngle); } - this->unk_3E8 = CLAMP(this->unk_3E8, -0x495F, 0x495F); - this->unk_3E2 = CLAMP(this->unk_3E2, -0x256F, 0x256F); + this->upperBodyRotation.y = CLAMP(this->upperBodyRotation.y, -0x495F, 0x495F); + this->headRotation.y = CLAMP(this->headRotation.y, -0x256F, 0x256F); } -s32 func_80BA6D10(EnRailgibud* this, GlobalContext* globalCtx) { +s32 EnRailgibud_PlayerInRangeWithCorrectState(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { return false; } - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f) && !(player->stateFlags1 & 0x2C6080) && - !(player->stateFlags2 & 0x4080)) { + if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f) && + !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & (0x4000 | 0x80))) { return true; } return false; } -s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * Gibdos/Redeads have a very short range around their home where they will + * engage with the player. If the player is out of this range, they will simply + * walk back to their home. + */ +s32 EnRailgibud_PlayerOutOfRange(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 100.0f) { @@ -670,196 +773,212 @@ s32 func_80BA6DAC(EnRailgibud* this, GlobalContext* globalCtx) { return false; } -void func_80BA6DF8(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_UpdateDamage(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->unk_3FA != 1) && (this->collider.base.acFlags & AC_HIT)) { - if (this->actionFunc == func_80BA57F8) { + if ((this->isInvincible != true) && (this->collider.base.acFlags & AC_HIT)) { + if (this->actionFunc == EnRailgibud_WalkInCircles) { this->actor.home = this->actor.world; } this->collider.base.acFlags &= ~AC_HIT; Actor_ApplyDamage(&this->actor); switch (this->actor.colChkInfo.damageEffect) { - case 15: + case EN_RAILGIBUD_DMGEFF_DAMAGE: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (player->unk_ADC != 0) { this->unk_405 = player->unk_ADD; } this->actor.shape.yOffset = 0.0f; if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } break; - case 14: - if (this->unk_3F8 == 1) { + case EN_RAILGIBUD_DMGEFF_LIGHT_RAY: + if (this->type == EN_RAILGIBUD_TYPE_REDEAD) { this->actor.colChkInfo.health = 0; this->actor.shape.yOffset = 0.0f; - func_80BA6664(this); + EnRailgibud_SetupDead(this); } break; - case 2: + case EN_RAILGIBUD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } - this->unk_404 = 0; - this->unk_3F6 = 180; - this->unk_2A0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffTimer = 180; + this->drawDmgEffAlpha = 1.0f; break; - case 4: + case EN_RAILGIBUD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); if (this->actor.colChkInfo.health == 0) { - func_80BA6664(this); + EnRailgibud_SetupDead(this); } else { - func_80BA6440(this); + EnRailgibud_SetupDamage(this); } - this->unk_404 = 20; - this->unk_3F6 = 60; - this->unk_2A0 = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffTimer = 60; + this->drawDmgEffAlpha = 1.0f; break; - case 12: - if ((this->actionFunc != func_80BA5E18) && - ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0))) { - this->unk_404 = 30; - this->unk_3F6 = 40; - this->unk_2A0 = 1.0f; - func_80BA6584(this); + case EN_RAILGIBUD_DMGEFF_ZORA_MAGIC: + if ((this->actionFunc != EnRailgibud_Grab) && + ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + EnRailgibud_SetupStunned(this); } break; - case 1: - if ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0)) { - func_80BA6584(this); + case EN_RAILGIBUD_DMGEFF_STUN: + if ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0)) { + EnRailgibud_SetupStunned(this); } break; } } } -s32 func_80BA7088(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * Returns true if the Gibdo is in the correct position and rotation to start + * performing its grab attack. Regardless of what this returns, the Gibdo is + * moved closer to this ideal position and rotation. + */ +s32 EnRailgibud_MoveToIdealGrabPositionAndRotation(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp40; - f32 sp3C; - f32 sp38 = 0.0f; - s16 temp_s0_2; + Vec3f targetPos; + f32 distanceFromTargetPos; + f32 distanceFromTargetYOffset = 0.0f; + s16 distanceFromTargetAngle; - sp40 = player->actor.world.pos; - - sp40.x -= 25.0f * Math_SinS(player->actor.shape.rot.y); - sp40.z -= 25.0f * Math_CosS(player->actor.shape.rot.y); - sp3C = Math_Vec3f_StepTo(&this->actor.world.pos, &sp40, 10.0f); - temp_s0_2 = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); + targetPos = player->actor.world.pos; + targetPos.x -= 25.0f * Math_SinS(player->actor.shape.rot.y); + targetPos.z -= 25.0f * Math_CosS(player->actor.shape.rot.y); + distanceFromTargetPos = Math_Vec3f_StepTo(&this->actor.world.pos, &targetPos, 10.0f); + distanceFromTargetAngle = Math_SmoothStepToS(&this->actor.shape.rot.y, player->actor.shape.rot.y, 1, 0x1770, 0x64); this->actor.world.rot.y = this->actor.shape.rot.y; if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - sp38 = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); + distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } - if ((sp3C == 0.0f) && (ABS_ALT(temp_s0_2) < 100) && (sp38 == 0.0f)) { + if ((distanceFromTargetPos == 0.0f) && (ABS_ALT(distanceFromTargetAngle) < 100) && + (distanceFromTargetYOffset == 0.0f)) { return true; } return false; } -void func_80BA71E4(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->actionFunc == func_80BA5B64) || (this->actionFunc == func_80BA62D4) || - (this->actionFunc == func_80BA64AC)) { +void EnRailgibud_MoveWithGravity(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->actionFunc == EnRailgibud_WalkToPlayer) || (this->actionFunc == EnRailgibud_WalkToHome) || + (this->actionFunc == EnRailgibud_Damage)) { Actor_MoveWithGravity(&this->actor); } } -void func_80BA7234(EnRailgibud* this, GlobalContext* globalCtx) { +/** + * If the Gibdo is starting a grab and is touching a wall, the player is moved + * away from that wall with this function. This can happen when the player's + * back is close to a wall before being grabbed. The Gibdo changes its own + * position to match the player's position at the start of a grab, so moving + * the player like this will help prevent the Gibdo from looking like it's + * clipping into the wall as it grabs onto the player. + */ +void EnRailgibud_MoveGrabbedPlayerAwayFromWall(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - Vec3f sp30; + Vec3f targetPos; - if ((this->actionFunc == func_80BA5E18) && (this->unk_3F0 != 2)) { + if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState != EN_RAILGIBUD_GRAB_RELEASE)) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 1); } else { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } - if ((this->actionFunc == func_80BA5E18) && (this->unk_3F0 == 0) && (this->actor.bgCheckFlags & 8)) { - sp30 = player->actor.world.pos; - sp30.x += 10.0f * Math_SinS(this->actor.wallYaw); - sp30.z += 10.0f * Math_CosS(this->actor.wallYaw); - Math_Vec3f_StepTo(&player->actor.world.pos, &sp30, 5.0f); + if ((this->actionFunc == EnRailgibud_Grab) && (this->grabState == EN_RAILGIBUD_GRAB_START) && + (this->actor.bgCheckFlags & 8)) { + targetPos = player->actor.world.pos; + targetPos.x += 10.0f * Math_SinS(this->actor.wallYaw); + targetPos.z += 10.0f * Math_CosS(this->actor.wallYaw); + Math_Vec3f_StepTo(&player->actor.world.pos, &targetPos, 5.0f); } } -void func_80BA7388(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F6 > 0) { - this->unk_3F6--; +void EnRailgibud_UpdateEffect(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_3F6 < 20) { - Math_SmoothStepToF(&this->unk_2A4, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_2A0 = this->unk_3F6 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_2A4, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } -void func_80BA7434(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->actionFunc != func_80BA5E18) && (this->actionFunc != func_80BA64AC) && - (this->actionFunc != func_80BA60B0) && (this->actionFunc != func_80BA61A0) && - (this->actionFunc != func_80BA66C8)) { - if ((this->actor.flags & 5) == 5) { +void EnRailgibud_CheckForGibdoMask(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->actionFunc != EnRailgibud_Grab) && (this->actionFunc != EnRailgibud_Damage) && + (this->actionFunc != EnRailgibud_GrabFail) && (this->actionFunc != EnRailgibud_TurnAwayAndShakeHead) && + (this->actionFunc != EnRailgibud_Dead)) { + if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_4))) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { - this->actor.flags &= ~5; - this->actor.flags |= 9; + this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.hintId = 0xFF; this->actor.textId = 0; - if ((this->actionFunc != func_80BA57F8) && (this->actionFunc != func_80BA62D4)) { - func_80BA6284(this); + if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_WalkToHome)) { + EnRailgibud_SetupWalkToHome(this); } } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); - if (this->unk_3F8 == 1) { + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); + if (this->type == EN_RAILGIBUD_TYPE_REDEAD) { this->actor.hintId = 0x2A; } else { this->actor.hintId = 0x2D; } this->actor.textId = 0; } - func_80BA7578(this, globalCtx); + + EnRailgibud_CheckIfTalkingToPlayer(this, globalCtx); } } -void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { - if ((this->textId == 0) && (this->unk_3F8 == 0)) { +void EnRailgibud_CheckIfTalkingToPlayer(EnRailgibud* this, GlobalContext* globalCtx) { + if ((this->textId == 0) && (this->type == EN_RAILGIBUD_TYPE_GIBDO)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->unk_3FA = 1; - func_801518B0(globalCtx, 0x13B2, &this->actor); + this->isInvincible = true; + Message_StartTextbox(globalCtx, 0x13B2, &this->actor); this->textId = 0x13B2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); this->actor.speedXZ = 0.0f; - } else if (((this->actor.flags & 9) == 9) && !(this->collider.base.acFlags & AC_HIT)) { + } else if (CHECK_FLAG_ALL(this->actor.flags, (ACTOR_FLAG_1 | ACTOR_FLAG_8)) && + !(this->collider.base.acFlags & AC_HIT)) { func_800B8614(&this->actor, globalCtx, 100.0f); } } else { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { - func_801518B0(globalCtx, 0x13B3, &this->actor); + if (Message_ShouldAdvance(globalCtx)) { + Message_StartTextbox(globalCtx, 0x13B3, &this->actor); this->textId = 0x13B3; } break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->textId = 0; - this->unk_3FA = 0; + this->isInvincible = false; this->actor.speedXZ = 0.6f; } break; @@ -874,14 +993,16 @@ void func_80BA7578(EnRailgibud* this, GlobalContext* globalCtx) { } } -void func_80BA76C4(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_UpdateCollision(EnRailgibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->actionFunc != func_80BA66C8) && ((this->actionFunc != func_80BA5E18) || (this->unk_3F0 == 2))) { + if ((this->actionFunc != EnRailgibud_Dead) && + ((this->actionFunc != EnRailgibud_Grab) || (this->grabState == EN_RAILGIBUD_GRAB_RELEASE))) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (((this->actionFunc != func_80BA64AC) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_405))) && - ((this->actionFunc != func_80BA6604) || (this->unk_3F2 == 0))) { + if (((this->actionFunc != EnRailgibud_Damage) || + ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_405))) && + ((this->actionFunc != EnRailgibud_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } @@ -890,35 +1011,38 @@ void func_80BA76C4(EnRailgibud* this, GlobalContext* globalCtx) { void EnRailgibud_Update(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; - func_80BA6B30(this); - func_80BA7434(this, globalCtx); - func_80BA6DF8(this, globalCtx); + EnRailgibud_UpdateWalkForwardState(this); + EnRailgibud_CheckForGibdoMask(this, globalCtx); + EnRailgibud_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); - if (this->actionFunc != func_80BA6604) { + if (this->actionFunc != EnRailgibud_Stunned) { SkelAnime_Update(&this->skelAnime); } - func_80BA71E4(this, globalCtx); - func_80BA76C4(this, globalCtx); - func_80BA7234(this, globalCtx); - func_80BA7388(this, globalCtx); + + EnRailgibud_MoveWithGravity(this, globalCtx); + EnRailgibud_UpdateCollision(this, globalCtx); + EnRailgibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); + EnRailgibud_UpdateEffect(this, globalCtx); + this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } -void func_80BA7878(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_MainGibdo_DeadUpdate(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; - func_80BA6B30(this); + EnRailgibud_UpdateWalkForwardState(this); } s32 EnRailgibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRailgibud* this = THIS; - if (limbIndex == 12) { - rot->y += this->unk_3E8; - } else if (limbIndex == 23) { - rot->y += this->unk_3E2; + if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { + rot->y += this->upperBodyRotation.y; + } else if (limbIndex == GIBDO_LIMB_HEAD_ROOT) { + rot->y += this->headRotation.y; } return false; @@ -928,12 +1052,16 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnRailgibud* this = THIS; - if ((this->unk_3F6 != 0) && - ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || - (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || - (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - Matrix_GetStateTranslation(&this->unk_1D8[this->unk_28C]); - this->unk_28C++; + if ((this->drawDmgEffTimer != 0) && + ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || + (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || + (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || + (limbIndex == GIBDO_LIMB_TORSO) || (limbIndex == GIBDO_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || + (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || + (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { + Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + this->limbIndex++; } } @@ -942,7 +1070,7 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_28C = 0; + this->limbIndex = 0; if (this->actor.shape.shadowAlpha == 255) { func_8012C28C(globalCtx->state.gfxCtx); @@ -963,133 +1091,135 @@ void EnRailgibud_Draw(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->unk_3F6 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_1D8, ARRAY_COUNT(this->unk_1D8), this->unk_2A4, 0.5f, - this->unk_2A0, this->unk_404); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); } -void func_80BA7B6C(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_InitCutsceneGibdo(EnRailgibud* this, GlobalContext* globalCtx) { s32 pad[2]; - func_80BA7C78(this); - this->unk_3FE = 99; - this->actor.flags |= 0x100000; - this->actor.flags |= 0x10; + EnRailgibud_InitActorActionCommand(this); + this->csAction = 99; + this->actor.flags |= ACTOR_FLAG_100000; + this->actor.flags |= ACTOR_FLAG_10; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (gSaveContext.save.entranceIndex != 0x2090) { // NOT Cutscene: Music Box House Opens Actor_MarkForDeath(&this->actor); } - func_80BA7CF0(this); - this->actor.update = func_80BA8050; + + EnRailgibud_SetupDoNothing(this); + this->actor.update = EnRailgibud_Cutscene_Update; } -void func_80BA7C78(EnRailgibud* this) { - switch (ENRAILGIBUD_GET_7F(&this->actor)) { +void EnRailgibud_InitActorActionCommand(EnRailgibud* this) { + switch (ENRAILGIBUD_GET_CUTSCENE_TYPE(&this->actor)) { case 1: - this->unk_3FC = 0x207; + this->actorActionCommand = 519; break; case 2: - this->unk_3FC = 0x208; + this->actorActionCommand = 520; break; case 3: - this->unk_3FC = 0x209; + this->actorActionCommand = 521; break; case 4: - this->unk_3FC = 0x20A; + this->actorActionCommand = 522; break; case 5: - this->unk_3FC = 0x20B; + this->actorActionCommand = 523; break; default: - this->unk_3FC = 0x207; + this->actorActionCommand = 519; break; } } -void func_80BA7CF0(EnRailgibud* this) { - this->actionFunc = func_80BA7D04; +void EnRailgibud_SetupDoNothing(EnRailgibud* this) { + this->actionFunc = EnRailgibud_DoNothing; } -void func_80BA7D04(EnRailgibud* this, GlobalContext* globalCtx) { +void EnRailgibud_DoNothing(EnRailgibud* this, GlobalContext* globalCtx) { } -void func_80BA7D14(EnRailgibud* this) { - this->unk_3F2 = 30; - this->actionFunc = func_80BA7D30; +void EnRailgibud_SetupSinkIntoGround(EnRailgibud* this) { + this->sinkTimer = 30; + this->actionFunc = EnRailgibud_SinkIntoGround; } -void func_80BA7D30(EnRailgibud* this, GlobalContext* globalCtx) { - if (this->unk_3F2 != 0) { - this->unk_3F2--; +void EnRailgibud_SinkIntoGround(EnRailgibud* this, GlobalContext* globalCtx) { + if (this->sinkTimer != 0) { + this->sinkTimer--; } else if (Math_SmoothStepToF(&this->actor.shape.yOffset, -9500.0f, 0.5f, 200.0f, 10.0f) < 10.0f) { Actor_MarkForDeath(&this->actor); } else { - func_80BA6800(this, globalCtx, 0); + EnRailgibud_SpawnEffectsForSinkingIntoTheGround(this, globalCtx, 0); } } -s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { - u32 sp2C; +s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, GlobalContext* globalCtx) { + s32 actionIndex; - if (func_800EE29C(globalCtx, this->unk_3FC)) { - sp2C = func_800EE200(globalCtx, this->unk_3FC); - if (this->unk_3FE != globalCtx->csCtx.npcActions[sp2C]->unk0) { - this->unk_3FE = globalCtx->csCtx.npcActions[sp2C]->unk0; - switch (globalCtx->csCtx.npcActions[sp2C]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCommand)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, this->actorActionCommand); + if (this->csAction != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->csAction = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: - this->unk_3F0 = 9; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_IDLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_IDLE); break; case 2: - this->unk_3F0 = 15; + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_SLUMP_START; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 15); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_SLUMP_START); break; case 3: - this->unk_3F0 = 17; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 17); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_CONVULSION; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_CONVULSION); break; case 4: - this->unk_3F0 = 18; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 18); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_ARMS_UP_START; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_ARMS_UP_START); break; case 5: - this->unk_3F0 = 10; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 10); + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_WALK; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_WALK); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (this->unk_3F0 == 15) { - this->unk_3F0 = 16; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 16); - } else if (this->unk_3F0 == 18) { - this->unk_3F0 = 19; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 19); - func_80BA7D14(this); + if (this->cutsceneAnimationIndex == EN_RAILGIBUD_ANIMATION_SLUMP_START) { + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_SLUMP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_SLUMP_LOOP); + } else if (this->cutsceneAnimationIndex == EN_RAILGIBUD_ANIMATION_ARMS_UP_START) { + this->cutsceneAnimationIndex = EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_ARMS_UP_LOOP); + EnRailgibud_SetupSinkIntoGround(this); } } - switch (this->unk_3FE) { + switch (this->csAction) { case 3: case 4: - if (this->actionFunc == func_80BA7D30) { + if (this->actionFunc == EnRailgibud_SinkIntoGround) { func_800B9010(&this->actor, NA_SE_EN_REDEAD_WEAKENED_L2 - SFX_FLAG); } else { func_800B9010(&this->actor, NA_SE_EN_REDEAD_WEAKENED_L1 - SFX_FLAG); @@ -1107,18 +1237,18 @@ s32 func_80BA7DC8(EnRailgibud* this, GlobalContext* globalCtx) { break; } - func_800EDF24(&this->actor, globalCtx, sp2C); + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); return true; } - this->unk_3FE = 99; + this->csAction = 99; return false; } -void func_80BA8050(Actor* thisx, GlobalContext* globalCtx) { +void EnRailgibud_Cutscene_Update(Actor* thisx, GlobalContext* globalCtx) { EnRailgibud* this = THIS; this->actionFunc(this, globalCtx); - func_80BA7DC8(this, globalCtx); + EnRailgibud_PerformCutsceneActions(this, globalCtx); SkelAnime_Update(&this->skelAnime); } 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 546a885b5..a51fd37d4 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -2,49 +2,57 @@ #define Z_EN_RAILGIBUD_H #include "global.h" +#include "objects/object_rd/object_rd.h" struct EnRailgibud; typedef void (*EnRailgibudActionFunc)(struct EnRailgibud*, GlobalContext*); -#define ENRAILGIBUD_GET_7F(thisx) ((thisx)->params & 0x7F) -#define ENRAILGIBUD_GET_80(thisx) ((thisx)->params & 0x80) -#define ENRAILGIBUD_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define ENRAILGIBUD_GET_CUTSCENE_TYPE(thisx) ((thisx)->params & 0x7F) +#define ENRAILGIBUD_IS_CUTSCENE_TYPE(thisx) ((thisx)->params & 0x80) +#define ENRAILGIBUD_GET_PATH(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct EnRailgibud { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnRailgibudActionFunc actionFunc; - /* 0x01D8 */ Vec3f unk_1D8[15]; - /* 0x028C */ s32 unk_28C; + /* 0x01D8 */ Vec3f limbPos[15]; + /* 0x028C */ s32 limbIndex; /* 0x0290 */ UNK_TYPE1 unk290[0x4]; - /* 0x0294 */ Vec3s* unk_294; - /* 0x0298 */ s32 unk_298; - /* 0x029C */ s32 unk_29C; - /* 0x02A0 */ f32 unk_2A0; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ Vec3s jointTable[26]; - /* 0x0344 */ Vec3s morphTable[26]; - /* 0x03E0 */ UNK_TYPE1 unk3E0[0x2]; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ UNK_TYPE1 unk3E4[0x4]; - /* 0x03E8 */ s16 unk_3E8; - /* 0x03EA */ UNK_TYPE1 unk3EA[0x2]; - /* 0x03EC */ s16 unk_3EC; - /* 0x03EE */ s16 unk_3EE; - /* 0x03F0 */ s16 unk_3F0; - /* 0x03F2 */ s16 unk_3F2; - /* 0x03F4 */ s16 unk_3F4; - /* 0x03F6 */ s16 unk_3F6; - /* 0x03F8 */ s16 unk_3F8; - /* 0x03FA */ s16 unk_3FA; - /* 0x03FC */ u16 unk_3FC; - /* 0x03FE */ u16 unk_3FE; + /* 0x0294 */ Vec3s* points; + /* 0x0298 */ s32 currentPoint; + /* 0x029C */ s32 pathCount; + /* 0x02A0 */ f32 drawDmgEffAlpha; + /* 0x02A4 */ f32 drawDmgEffScale; + /* 0x02A8 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x0344 */ Vec3s morphTable[GIBDO_LIMB_MAX]; + /* 0x03E0 */ Vec3s headRotation; + /* 0x03E6 */ Vec3s upperBodyRotation; + /* 0x03EC */ s16 shouldWalkForward; // Only used by the "main" Gibdo + /* 0x03EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo + /* 0x03F0 */ union { + s16 grabState; + s16 cutsceneAnimationIndex; + }; + /* 0x03F2 */ union { + s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero + s16 grabDamageTimer; + s16 headShakeTimer; + s16 stunTimer; + s16 deathTimer; + s16 sinkTimer; + }; + /* 0x03F4 */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x03F6 */ s16 drawDmgEffTimer; + /* 0x03F8 */ s16 type; + /* 0x03FA */ s16 isInvincible; + /* 0x03FC */ u16 actorActionCommand; + /* 0x03FE */ u16 csAction; /* 0x0400 */ u16 textId; - /* 0x0402 */ s16 unk_402; - /* 0x0404 */ u8 unk_404; - /* 0x0405 */ s8 unk_405; + /* 0x0402 */ s16 timeInitialized; // unused other than setting it + /* 0x0404 */ u8 drawDmgEffType; + /* 0x0405 */ s8 unk_405; // related to player->unk_ADD } EnRailgibud; // size = 0x408 extern const ActorInit En_Railgibud_InitVars; 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 5160203b2..583d3637c 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -6,7 +6,7 @@ #include "z_en_rat.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnRat*)thisx) 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 4b942f03f..0326c13b7 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -1,13 +1,31 @@ /* * File: z_en_rd.c * Overlay: ovl_En_Rd - * Description: Redead/Gibdo (able to dance) + * Description: Redead/Gibdo that cannot talk to the player. + * + * A variety of different Redeads/Gibdos are represented by this actor; + * one of the few things they all have in common is that none of them + * can talk with the player, which separates them from Talk_Gibud and + * Railgibud. Some of the different kinds of Redeads/Gibdos that this + * actor controls are: + * - Three different types of dancing Redeads. These are the only + * Redead/Gidbo variations that are actually used in the final game. + * - A Redead frozen in a block of ice. + * - An invisible Redead. + * - A crying Redead. + * - A Gidbo that rises out of a "coffin"; this is leftover from OoT. + * + * Another thing that separates this actor from Talk_Gibud and Railgibud + * is that most Redead variations will "mourn" other fallen Redeads in + * the same area by walking over to their corpse. Note that some Redeads, + * depending on their params, will refuse to mourn under certain + * circumstances, and all Gibdo variations will refuse to mourn as well. */ #include "z_en_rd.h" #include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnRd*)thisx) @@ -16,39 +34,67 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRd_Update(Actor* thisx, GlobalContext* globalCtx); void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx); -s32 func_808D41FC(GlobalContext* globalCtx); -void func_808D4308(EnRd* this); -void func_808D43AC(EnRd* this, GlobalContext* globalCtx); -void func_808D45D4(EnRd* this); -void func_808D4660(EnRd* this, GlobalContext* globalCtx); -void func_808D47DC(EnRd* this); -void func_808D4868(EnRd* this, GlobalContext* globalCtx); -void func_808D49E4(EnRd* this, GlobalContext* globalCtx); -void func_808D4A90(EnRd* this); -void func_808D4B20(EnRd* this, GlobalContext* globalCtx); -void func_808D4CA8(EnRd* this, GlobalContext* globalCtx); -void func_808D4DC4(EnRd* this); -void func_808D4E60(EnRd* this, GlobalContext* globalCtx); -void func_808D506C(EnRd* this, GlobalContext* globalCtx); -void func_808D53C0(EnRd* this, GlobalContext* globalCtx); -void func_808D5440(EnRd* this, GlobalContext* globalCtx); -void func_808D5660(EnRd* this); -void func_808D56E4(EnRd* this, GlobalContext* globalCtx); -void func_808D586C(EnRd* this); -void func_808D58CC(EnRd* this, GlobalContext* globalCtx); -void func_808D5C54(EnRd* this); -void func_808D5CCC(EnRd* this, GlobalContext* globalCtx); -void func_808D5D88(EnRd* this); -void func_808D5DF4(EnRd* this, GlobalContext* globalCtx); -void func_808D5E98(EnRd* this); -void func_808D5F18(EnRd* this, GlobalContext* globalCtx); -void func_808D6008(EnRd* this); -void func_808D6054(EnRd* this, GlobalContext* globalCtx); -void func_808D60B0(EnRd* this); -void func_808D6130(EnRd* this, GlobalContext* globalCtx); -void func_808D6200(EnRd* this, GlobalContext* globalCtx); -void func_808D6388(EnRd* this, GlobalContext* globalCtx); -void func_808D65BC(EnRd* this, GlobalContext* globalCtx); +s32 EnRd_ShouldNotDance(GlobalContext* globalCtx); +void EnRd_SetupIdle(EnRd* this); +void EnRd_Idle(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupSquattingDance(EnRd* this); +void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupClappingDance(EnRd* this); +void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx); +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupPirouette(EnRd* this); +void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx); +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupRiseFromCoffin(EnRd* this); +void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx); +void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupWalkToHome(EnRd* this, GlobalContext* globalCtx); +void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupWalkToParent(EnRd* this); +void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupGrab(EnRd* this); +void EnRd_Grab(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupAttemptPlayerFreeze(EnRd* this); +void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupGrabFail(EnRd* this); +void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupTurnAwayAndShakeHead(EnRd* this); +void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupStandUp(EnRd* this); +void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx); +void EnRd_SetupCrouch(EnRd* this); +void EnRd_Crouch(EnRd* this, GlobalContext* globalCtx); +void EnRd_Damage(EnRd* this, GlobalContext* globalCtx); +void EnRd_Dead(EnRd* this, GlobalContext* globalCtx); +void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ EN_RD_ACTION_IDLE, + /* 1 */ EN_RD_ACTION_STUNNED, + /* 2 */ EN_RD_ACTION_WALKING_TO_HOME, + /* 3 */ EN_RD_ACTION_WALKING_TO_PARENT, + /* 4 */ EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB, + /* 5 */ EN_RD_ACTION_STANDING_UP, + /* 6 */ EN_RD_ACTION_CROUCHING, + /* 7 */ EN_RD_ACTION_ATTEMPTING_PLAYER_STUN, + /* 8 */ EN_RD_ACTION_FAILING_GRAB, + /* 9 */ EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD, + /* 10 */ EN_RD_ACTION_GRABBING, + /* 11 */ EN_RD_ACTION_DAMAGE, + /* 12 */ EN_RD_ACTION_DEAD, + /* 13 */ EN_RD_ACTION_RISING_FROM_COFFIN, + /* 14 */ EN_RD_ACTION_SQUATTING_DANCE, + /* 15 */ EN_RD_ACTION_CLAPPING_DANCE, + /* 16 */ EN_RD_ACTION_PIROUETTE +} EnRdAction; + +typedef enum { + /* 0 */ EN_RD_GRAB_START, + /* 1 */ EN_RD_GRAB_INITIAL_DAMAGE, + /* 2 */ EN_RD_GRAB_ATTACK, + /* 3 */ EN_RD_GRAB_RELEASE, + /* 4 */ EN_RD_GRAB_END, +} EnRdGrabState; const ActorInit En_Rd_InitVars = { ACTOR_EN_RD, @@ -82,39 +128,52 @@ static ColliderCylinderInit sCylinderInit = { { 20, 70, 0, { 0, 0, 0 } }, }; +typedef enum { + /* 0x0 */ EN_RD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_RD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_RD_DMGEFF_FIRE_ARROW, // Damages and applies a fire effect + /* 0x4 */ EN_RD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect + /* 0x6 */ EN_RD_DMGEFF_UNUSED_6 = 0x6, // Referenced in EnRd_Update, but no attack uses this damage effect. + // Likely to have originally been used for Ice Arrows like OoT. + /* 0xC */ EN_RD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect + /* 0xD */ EN_RD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation + /* 0xE */ EN_RD_DMGEFF_LIGHT_RAY, // Instantly kills on contact + /* 0xF */ EN_RD_DMGEFF_DAMAGE, // Deals damage and plays the damage animation +} EnRdDamageEffect; + static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, 0x0), - /* Deku Stick */ DMG_ENTRY(2, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(0, 0xD), - /* Normal arrow */ DMG_ENTRY(0, 0xD), - /* UNK_DMG_0x06 */ DMG_ENTRY(2, 0xF), - /* Hookshot */ DMG_ENTRY(0, 0xD), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(1, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(0, 0xD), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(0, 0xD), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x0), - /* Zora barrier */ DMG_ENTRY(0, 0xC), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0xE), - /* Thrown object */ DMG_ENTRY(1, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* 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, 0xF), + /* Deku Nut */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* Horse trample */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Zora boomerang */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Normal arrow */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* UNK_DMG_0x06 */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* Hookshot */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Goron punch */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Sword */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Goron pound */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Fire arrow */ DMG_ENTRY(1, EN_RD_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Light arrow */ DMG_ENTRY(2, EN_RD_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Deku spin */ DMG_ENTRY(0, EN_RD_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(0, EN_RD_DMGEFF_RECOIL), + /* Deku launch */ DMG_ENTRY(2, EN_RD_DMGEFF_DAMAGE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(0, EN_RD_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_RD_DMGEFF_LIGHT_RAY), + /* Thrown object */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Zora punch */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Spin attack */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), + /* Sword beam */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_RD_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_RD_DMGEFF_DAMAGE), }; static InitChainEntry sInitChain[] = { @@ -131,86 +190,86 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.colChkInfo.damageTable = &sDamageTable; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - this->unk_3DA = this->unk_3D8 = 0; + this->upperBodyYRotation = this->headYRotation = 0; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.colChkInfo.health = 8; - this->unk_3DE = 255; + this->alpha = 255; this->unk_3F1 = -1; - this->unk_3DC = ENRD_GET_FF00(thisx); + this->flags = EN_RD_GET_FLAGS(thisx); - if (ENRD_GET_80(&this->actor)) { + if (EN_RD_GET_80(&this->actor)) { this->actor.params |= 0xFF00; } else { this->actor.params &= 0xFF; } - if (this->actor.params >= ENRD_GET_MINUS_1) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, &object_rd_Anim_00ABE0, - this->jointTable, this->morphTable, 26); + if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_GIBDO) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, REDEAD_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, - this->jointTable, this->morphTable, 26); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, REDEAD_LIMB_MAX); } Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (this->actor.params >= ENRD_GET_MINUS_2) { - switch (this->actor.params) { - case 5: - if (!func_808D41FC(globalCtx)) { - func_808D45D4(this); + if (EN_RD_GET_TYPE(&this->actor) >= EN_RD_TYPE_GIBDO) { + switch (EN_RD_GET_TYPE(&this->actor)) { + case EN_RD_TYPE_SQUATTING_DANCE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupSquattingDance(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D45D4; + this->setupDanceFunc = EnRd_SetupSquattingDance; break; - case 6: - if (!func_808D41FC(globalCtx)) { - func_808D47DC(this); + case EN_RD_TYPE_CLAPPING_DANCE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupClappingDance(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D47DC; + this->setupDanceFunc = EnRd_SetupClappingDance; break; - case 7: - if (!func_808D41FC(globalCtx)) { - func_808D4A90(this); + case EN_RD_TYPE_PIROUETTE: + if (!EnRd_ShouldNotDance(globalCtx)) { + EnRd_SetupPirouette(this); } else { this->actor.hintId = 0x2A; - func_808D4308(this); + EnRd_SetupIdle(this); } - this->unkFunc = func_808D4A90; + this->setupDanceFunc = EnRd_SetupPirouette; break; default: - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); - this->unkFunc = func_808D4308; + EnRd_SetupIdle(this); + this->setupDanceFunc = EnRd_SetupIdle; break; } } else { - func_808D4DC4(this); + EnRd_SetupRiseFromCoffin(this); } SkelAnime_Update(&this->skelAnime); - if (this->actor.params == ENRD_GET_3) { - this->actor.flags |= 0x80; + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_INVISIBLE) { + this->actor.flags |= ACTOR_FLAG_80; } - if (this->actor.params == ENRD_GET_4) { - s32 pad2; + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_FROZEN) { + s32 requiredScopeTemp; Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, @@ -227,96 +286,124 @@ void EnRd_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_808D4190(GlobalContext* globalCtx, EnRd* this, s32 arg2) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; +/** + * This function does two things depending on whether setParent is true or false. + * - If setParent is true, this function sets thisx to be the parent for all Redeads + * in the area that are capable of mourning. This is used right when thisx first + * dies to make the other Redeads mourn it. + * - If setParent is false, this function nulls out the parent for all Redeads in the + * are whose parents is thisx. This is used when thisx is fading away to make the + * other Redeads stop mourning over it. + */ +void EnRd_UpdateParentForOtherRedeads(GlobalContext* globalCtx, Actor* thisx, s32 setParent) { + Actor* enemyIterator = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; - while (actor != NULL) { - if ((actor->id != ACTOR_EN_RD) || (this == (EnRd*)actor) || (actor->params < ENRD_GET_0)) { - actor = actor->next; + while (enemyIterator != NULL) { + if ((enemyIterator->id != ACTOR_EN_RD) || (enemyIterator == thisx) || + (EN_RD_GET_TYPE(enemyIterator) < EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING)) { + enemyIterator = enemyIterator->next; continue; - } else if (arg2 != 0) { - actor->parent = &this->actor; - } else if (this == (EnRd*)actor->parent) { - actor->parent = NULL; } - actor = actor->next; + + if (setParent) { + enemyIterator->parent = thisx; + } else if (thisx == enemyIterator->parent) { + enemyIterator->parent = NULL; + } + + enemyIterator = enemyIterator->next; } } -s32 func_808D41FC(GlobalContext* globalCtx) { +/** + * Returns true if the various dancing Redead types *should not* be dancing + * and returns false if they *should* be dancing. The non-dancing Redeads + * do not call this function in the final game and thus don't care about + * what mask the player has equipped. + */ +s32 EnRd_ShouldNotDance(GlobalContext* globalCtx) { if ((Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) || (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) || (Player_GetMask(globalCtx) == PLAYER_MASK_GARO)) { return false; } + return true; } -void func_808D4260(EnRd* this, GlobalContext* globalCtx) { - if ((this->actor.params >= ENRD_GET_5) && (this->actionFunc != func_808D4660) && - (this->actionFunc != func_808D4868) && (this->actionFunc != func_808D4B20) && - (this->actionFunc != func_808D65BC) && (this->actionFunc != func_808D58CC) && - (this->actionFunc != func_808D6200) && (this->actionFunc != func_808D6388)) { - if (!func_808D41FC(globalCtx)) { - this->unkFunc(this); +/** + * If the Redead/Gibdo is a dancing Redead; if it isn't already dancing; if it isn't stunned, + * taking damage, dead, or currently grabbing the player; and if the player is wearing the + * appropriate mask, this function will make the Redead start dancing. + */ +void EnRd_SetupDanceIfConditionsMet(EnRd* this, GlobalContext* globalCtx) { + if ((EN_RD_GET_TYPE(&this->actor) >= EN_RD_TYPE_SQUATTING_DANCE) && (this->actionFunc != EnRd_SquattingDance) && + (this->actionFunc != EnRd_ClappingDance) && (this->actionFunc != EnRd_Pirouette) && + (this->actionFunc != EnRd_Stunned) && (this->actionFunc != EnRd_Grab) && (this->actionFunc != EnRd_Damage) && + (this->actionFunc != EnRd_Dead)) { + if (!EnRd_ShouldNotDance(globalCtx)) { + this->setupDanceFunc(this); } } } -void func_808D4308(EnRd* this) { - if (this->actor.params != ENRD_GET_2) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_00ABE0, -6.0f); +void EnRd_SetupIdle(EnRd* this) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadIdleAnim, -6.0f); } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_0081A8); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadSobbingAnim); } - this->unk_3EF = 0; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->action = EN_RD_ACTION_IDLE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D43AC; + this->actionFunc = EnRd_Idle; } -void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Idle(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if ((this->actor.params == ENRD_GET_2) && Animation_OnFrame(&this->skelAnime, 0.0f)) { + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if ((EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_CRYING) && Animation_OnFrame(&this->skelAnime, 0.0f)) { if (Rand_ZeroOne() >= 0.5f) { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_0081A8); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadSobbingAnim); } else { - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_007BBC); + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadWipingTearsAnim); } } else { - this->unk_3D6--; - if (this->unk_3D6 == 0) { - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 10.0f; + this->animationJudderTimer--; + if (this->animationJudderTimer == 0) { + // This resets the idle animation back to its first frame, making the + // Redead/Gibdo appear to "judder" in place. + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 10.0f; this->skelAnime.curFrame = 0.0f; } } if (this->actor.parent != NULL) { - if (this->unk_3EC == 0) { - if (this->actor.params != ENRD_GET_2) { - func_808D5660(this); + if (!this->isMourning) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupWalkToParent(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } else { - if (this->unk_3EC != 0) { - if (this->actor.params != ENRD_GET_2) { - func_808D5C54(this); + if (this->isMourning) { + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } - this->unk_3EC = 0; + this->isMourning = false; if ((this->actor.xzDistToPlayer <= 150.0f) && func_800B715C(globalCtx)) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } @@ -326,42 +413,43 @@ void func_808D43AC(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D45D4(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_01216C, -6.0f); - this->unk_3EF = 14; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 0; +void EnRd_SetupSquattingDance(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadSquattingDanceAnim, -6.0f); + 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.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4660; + this->actionFunc = EnRd_SquattingDance; } -void func_808D4660(EnRd* this, GlobalContext* globalCtx) { +void EnRd_SquattingDance(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - this->actionFunc = func_808D49E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -369,42 +457,43 @@ void func_808D4660(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D47DC(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_011DB8, -6.0f); - this->unk_3EF = 15; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 0; +void EnRd_SetupClappingDance(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadClappingDanceAnim, -6.0f); + 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.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4868; + this->actionFunc = EnRd_ClappingDance; } -void func_808D4868(EnRd* this, GlobalContext* globalCtx) { +void EnRd_ClappingDance(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - this->actionFunc = func_808D49E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + this->actionFunc = EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -412,58 +501,59 @@ void func_808D4868(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D49E4(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } - this->unk_3E4++; - if (this->unk_3E4 > 10) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + this->danceEndTimer++; + if (this->danceEndTimer > 10) { + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } - this->unk_3E4 = 0; + this->danceEndTimer = 0; } } -void func_808D4A90(EnRd* this) { - Animation_MorphToLoop(&this->skelAnime, &object_rd_Anim_0118D8, -6.0f); - this->unk_3EF = 16; - this->unk_3D6 = (Rand_ZeroOne() * 10.0f) + 5.0f; - this->unk_3E4 = 4370; +void EnRd_SetupPirouette(EnRd* this) { + Animation_MorphToLoop(&this->skelAnime, &gGibdoRedeadPirouetteAnim, -6.0f); + this->action = EN_RD_ACTION_PIROUETTE; + this->animationJudderTimer = (Rand_ZeroOne() * 10.0f) + 5.0f; + this->pirouetteRotationalVelocity = 0x1112; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actionFunc = func_808D4B20; + this->actionFunc = EnRd_Pirouette; } -void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Pirouette(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); - if (this->unk_3EC != 0) { - func_808D5C54(this); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); + + if (this->isMourning) { + EnRd_SetupAttemptPlayerFreeze(this); } - this->unk_3EC = 0; - if ((this->actor.xzDistToPlayer <= 150.0f) && func_808D41FC(globalCtx) && func_800B715C(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + this->isMourning = false; + if ((this->actor.xzDistToPlayer <= 150.0f) && EnRd_ShouldNotDance(globalCtx) && func_800B715C(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - this->actionFunc = func_808D4CA8; + this->actionFunc = EnRd_EndPirouetteWhenPlayerIsClose; } - if (func_808D41FC(globalCtx)) { - if (this->actor.params == ENRD_GET_MINUS_2) { + if (EnRd_ShouldNotDance(globalCtx)) { + if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { this->actor.hintId = 0x2D; } else { this->actor.hintId = 0x2A; } - func_808D4308(this); + EnRd_SetupIdle(this); } if ((globalCtx->gameplayFrames & 0x5F) == 0) { @@ -471,54 +561,54 @@ void func_808D4B20(EnRd* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_3E4 = 4370; + this->pirouetteRotationalVelocity = 0x1112; } else if (Animation_OnFrame(&this->skelAnime, 15.0f)) { - this->unk_3E4 = 6554; + this->pirouetteRotationalVelocity = 0x199A; } - this->actor.world.rot.y -= this->unk_3E4; + this->actor.world.rot.y -= this->pirouetteRotationalVelocity; this->actor.shape.rot.y = this->actor.world.rot.y; } -void func_808D4CA8(EnRd* this, GlobalContext* globalCtx) { +void EnRd_EndPirouetteWhenPlayerIsClose(EnRd* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); if ((globalCtx->gameplayFrames & 0x5F) == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } - this->actor.world.rot.y -= this->unk_3E4; + this->actor.world.rot.y -= this->pirouetteRotationalVelocity; this->actor.shape.rot.y = this->actor.world.rot.y; - this->unk_3E4 -= 100; - if ((this->unk_3E4 < 2100) && (this->unk_3E4 >= 2000)) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, 19.0f, 2, -10.0f); - } else if (this->unk_3E4 < 1000) { - if ((this->actor.params != ENRD_GET_2) && (this->unk_3EC == 0)) { - func_808D5C54(this); + this->pirouetteRotationalVelocity -= 0x64; + if ((this->pirouetteRotationalVelocity < 0x834) && (this->pirouetteRotationalVelocity >= 0x7D0)) { + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 19.0f, 2, -10.0f); + } else if (this->pirouetteRotationalVelocity < 0x3E8) { + if ((EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) && (!this->isMourning)) { + EnRd_SetupAttemptPlayerFreeze(this); } else { - func_808D6008(this); + EnRd_SetupStandUp(this); } } } -void func_808D4DC4(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00ABE0, 0.0f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_00ABE0), 0, -6.0f); - this->unk_3EF = 13; - this->unk_3D6 = 6; +void EnRd_SetupRiseFromCoffin(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadIdleAnim, 0.0f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadIdleAnim), + 0, -6.0f); + this->action = EN_RD_ACTION_RISING_FROM_COFFIN; + this->coffinRiseForwardAccelTimer = 6; this->actor.shape.rot.x = -0x4000; this->actor.gravity = 0.0f; this->actor.shape.yOffset = 0.0f; this->actor.speedXZ = 0.0f; - this->actionFunc = func_808D4E60; + this->actionFunc = EnRd_RiseFromCoffin; } -void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { +void EnRd_RiseFromCoffin(EnRd* this, GlobalContext* globalCtx) { if (this->actor.shape.rot.x != -0x4000) { Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); if (Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.home.pos.y, 0.3f, 2.0f, 0.3f) == 0.0f) { this->actor.gravity = -3.5f; - func_808D4308(this); + EnRd_SetupIdle(this); } } else { if (this->actor.world.pos.y == this->actor.home.pos.y) { @@ -526,8 +616,8 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } 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->unk_3D6 != 0) { - this->unk_3D6--; + 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_SmoothStepToS(&this->actor.shape.rot.x, 0, 1, 0x7D0, 0); @@ -536,71 +626,74 @@ void func_808D4E60(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D4FE0(EnRd* this, GlobalContext* globalCtx) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupWalkToPlayer(EnRd* this, GlobalContext* globalCtx) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 1.0f, 4.0f, frameCount, 1, -4.0f); + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 1.0f, 4.0f, frameCount, 1, -4.0f); this->actor.speedXZ = 0.4f; - this->unk_3EF = 4; - this->actionFunc = func_808D506C; + this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; + this->actionFunc = EnRd_WalkToPlayer; } -void func_808D506C(EnRd* this, GlobalContext* globalCtx) { +void EnRd_WalkToPlayer(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; - s16 sp36 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + s16 yaw = + ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; this->skelAnime.playSpeed = this->actor.speedXZ; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 250, 0); - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 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) { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } - if ((ABS_ALT(sp36) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { + if ((ABS_ALT(yaw) < 0x1554) && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 150.0f)) { if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & 0x4080)) { - if (this->unk_3ED == 0) { - if (!(this->unk_3DC & 0x80)) { + !(player->stateFlags2 & (0x4000 | 0x80))) { + if (this->playerStunWaitTimer == 0) { + if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 40; func_80123E90(globalCtx, &this->actor); GET_PLAYER(globalCtx)->unk_A78 = &this->actor; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); } - this->unk_3ED = 60; + this->playerStunWaitTimer = 60; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); } } else { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } } - if (this->unk_3EE != 0) { - this->unk_3EE--; + if (this->grabWaitTimer != 0) { + this->grabWaitTimer--; } - if (!this->unk_3EE && (Actor_DistanceBetweenActors(&this->actor, &player->actor) <= 45.0f) && + if (!this->grabWaitTimer && (Actor_DistanceBetweenActors(&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) { - func_808D5D88(this); + // 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); } else { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } } else if (globalCtx->grabPlayer(globalCtx, player)) { - this->actor.flags &= ~1; - func_808D586C(this); + this->actor.flags &= ~ACTOR_FLAG_1; + EnRd_SetupGrab(this); } - } else if (this->actor.params > ENRD_GET_0) { + } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - this->unk_3EC = 0; + this->isMourning = false; } } @@ -611,14 +704,14 @@ void func_808D506C(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D53C0(EnRd* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_0113EC), 1, -4.0f); - this->unk_3EF = 2; - this->actionFunc = func_808D5440; +void EnRd_SetupWalkToHome(EnRd* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, Animation_GetLastFrame(&gGibdoRedeadWalkAnim), + 1, -4.0f); + this->action = EN_RD_ACTION_WALKING_TO_HOME; + this->actionFunc = EnRd_WalkToHome; } -void func_808D5440(EnRd* this, GlobalContext* globalCtx) { +void EnRd_WalkToHome(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; s16 sp36 = Actor_YawToPoint(&this->actor, &this->actor.home.pos); @@ -628,30 +721,30 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } else { this->actor.speedXZ = 0.0f; if (!Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 450, 0)) { - if (this->actor.params != ENRD_GET_2) { - func_808D4308(this); + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupIdle(this); } else { - func_808D60B0(this); + EnRd_SetupCrouch(this); } } } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 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 (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & 0x4080) && (player->transformation != PLAYER_FORM_GORON) && + !(player->stateFlags2 & (0x4000 | 0x80)) && (player->transformation != PLAYER_FORM_GORON) && (player->transformation != PLAYER_FORM_DEKU) && (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { this->actor.targetMode = 0; - func_808D4FE0(this, globalCtx); - } else if (this->actor.params > ENRD_GET_0) { + EnRd_SetupWalkToPlayer(this, globalCtx); + } else if (EN_RD_GET_TYPE(&this->actor) > EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - this->unk_3EC = 0; + this->isMourning = false; } } @@ -662,39 +755,45 @@ void func_808D5440(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D5660(EnRd* this) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupWalkToParent(EnRd* this) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); - this->unk_3EF = 3; - this->unk_3EC = 1; - this->actionFunc = func_808D56E4; + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->action = EN_RD_ACTION_WALKING_TO_PARENT; + this->isMourning = true; + this->actionFunc = EnRd_WalkToParent; } -void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { +/** + * When a Redead or Gibdo dies, it sets itself to be the parent for all other + * Redeads in the area that are capable of mourning. This function will make + * these Redeads walk over to the corpse and stand near until it begins to + * fade away. + */ +void EnRd_WalkToParent(EnRd* this, GlobalContext* globalCtx) { s32 pad; s16 yaw; - Vec3f sp2C; + Vec3f parentPos; if (this->actor.parent != NULL) { - sp2C = this->actor.parent->world.pos; - yaw = Actor_YawToPoint(&this->actor, &sp2C); + parentPos = this->actor.parent->world.pos; + yaw = Actor_YawToPoint(&this->actor, &parentPos); Math_SmoothStepToS(&this->actor.shape.rot.y, yaw, 1, 250, 0); - if (Actor_DistanceToPoint(&this->actor, &sp2C) >= 45.0f) { + if (Actor_DistanceToPoint(&this->actor, &parentPos) >= 45.0f) { this->actor.speedXZ = 0.4f; } else { this->actor.speedXZ = 0.0f; - if (this->actor.params != ENRD_GET_2) { - func_808D4308(this); + if (EN_RD_GET_TYPE(&this->actor) != EN_RD_TYPE_CRYING) { + EnRd_SetupIdle(this); } else { - func_808D60B0(this); + EnRd_SetupCrouch(this); } } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 100, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 100, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 100, 0); } else { - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } this->actor.world.rot.y = this->actor.shape.rot.y; @@ -707,57 +806,57 @@ void func_808D56E4(EnRd* this, GlobalContext* globalCtx) { } } -void func_808D586C(EnRd* this) { - Animation_PlayOnce(&this->skelAnime, &object_rd_Anim_006EEC); - this->unk_3D6 = 0; - this->unk_3EB = 0; - this->unk_3EA = 200; - this->unk_3EF = 10; +void EnRd_SetupGrab(EnRd* this) { + Animation_PlayOnce(&this->skelAnime, &gGibdoRedeadGrabStartAnim); + this->animationJudderTimer = 0; + this->grabState = 0; + this->grabDamageTimer = 200; + this->action = EN_RD_ACTION_GRABBING; this->actor.speedXZ = 0.0f; - this->actionFunc = func_808D58CC; + this->actionFunc = EnRd_Grab; } -void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s32 pad; if (SkelAnime_Update(&this->skelAnime)) { - this->unk_3EB++; + this->grabState++; } - switch (this->unk_3EB) { - case 1: - Animation_PlayLoop(&this->skelAnime, &object_rd_Anim_006678); - this->unk_3EB++; + switch (this->grabState) { + case EN_RD_GRAB_INITIAL_DAMAGE: + Animation_PlayLoop(&this->skelAnime, &gGibdoRedeadGrabAttackAnim); + this->grabState++; globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 255, 1, 12); - this->unk_3EA = 20; + this->grabDamageTimer = 20; - case 0: - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 1500, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 1500, 0); + case EN_RD_GRAB_START: + Math_SmoothStepToS(&this->headYRotation, 0, 1, 1500, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 1500, 0); - case 2: + case EN_RD_GRAB_ATTACK: if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Animation_Change(&this->skelAnime, &object_rd_Anim_006B08, 0.5f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_006B08), 3, 0.0f); - this->unk_3EB++; - this->unk_3EF = 4; + Animation_Change(&this->skelAnime, &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, + Animation_GetLastFrame(&gGibdoRedeadGrabEndAnim), 3, 0.0f); + this->grabState++; + this->action = EN_RD_ACTION_WALKING_TO_PLAYER_OR_RELEASING_GRAB; break; } switch (player->transformation) { - case 0: - case 1: - case 2: - case 3: + case PLAYER_FORM_FIERCE_DEITY: + case PLAYER_FORM_GORON: + case PLAYER_FORM_ZORA: + case PLAYER_FORM_DEKU: break; - case 4: + case PLAYER_FORM_HUMAN: Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); break; } @@ -775,144 +874,145 @@ void func_808D58CC(EnRd* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - this->unk_3EA--; - if (this->unk_3EA == 0) { + this->grabDamageTimer--; + if (this->grabDamageTimer == 0) { globalCtx->damagePlayer(globalCtx, -8); func_8013ECE0(this->actor.xzDistToPlayer, 240, 1, 12); - this->unk_3EA = 20; - func_800B8E58(player, player->ageProperties->unk_92 + 0x6805); + this->grabDamageTimer = 20; + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); } break; - case 3: + case EN_RD_GRAB_RELEASE: if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } break; - case 4: + case EN_RD_GRAB_END: if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { Math_SmoothStepToF(&this->actor.shape.yOffset, 0.0f, 1.0f, 400.0f, 0.0f); } this->actor.targetMode = 0; - this->actor.flags |= 1; - this->unk_3ED = 10; - this->unk_3EE = 15; - func_808D4FE0(this, globalCtx); + this->actor.flags |= ACTOR_FLAG_1; + this->playerStunWaitTimer = 10; + this->grabWaitTimer = 15; + EnRd_SetupWalkToPlayer(this, globalCtx); break; } } -void func_808D5C54(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_0073A4, 0.0f, 0.0f, - Animation_GetLastFrame(&object_rd_Anim_0073A4), 2, 0.0f); - this->unk_3EF = 7; - this->actionFunc = func_808D5CCC; +void EnRd_SetupAttemptPlayerFreeze(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, + Animation_GetLastFrame(&gGibdoRedeadLookBackAnim), 2, 0.0f); + this->action = EN_RD_ACTION_ATTEMPTING_PLAYER_STUN; + this->actionFunc = EnRd_AttemptPlayerFreeze; } -void func_808D5CCC(EnRd* this, GlobalContext* globalCtx) { +void EnRd_AttemptPlayerFreeze(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - s16 temp_v0 = ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3D8) - this->unk_3DA; + s16 yaw = + ((this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->headYRotation) - this->upperBodyYRotation; - if (ABS_ALT(temp_v0) < 0x2008) { - if (!(this->unk_3DC & 0x80)) { + if (ABS_ALT(yaw) < 0x2008) { + if (!(this->flags & EN_RD_FLAG_CANNOT_FREEZE_PLAYER)) { player->actor.freezeTimer = 60; func_8013ECE0(this->actor.xzDistToPlayer, 255, 20, 150); func_80123E90(globalCtx, &this->actor); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } } -void func_808D5D88(EnRd* this) { - this->unk_3EF = 8; - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009900, -6.0f); +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->unk_3EF = 8; - this->actionFunc = func_808D5DF4; + this->action = EN_RD_ACTION_FAILING_GRAB; + this->actionFunc = EnRd_GrabFail; } -void func_808D5DF4(EnRd* this, GlobalContext* globalCtx) { +void EnRd_GrabFail(EnRd* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 300, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 300, 0); if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; - func_808D5E98(this); + EnRd_SetupTurnAwayAndShakeHead(this); } } -void func_808D5E98(EnRd* this) { - f32 frameCount = Animation_GetLastFrame(&object_rd_Anim_0113EC); +void EnRd_SetupTurnAwayAndShakeHead(EnRd* this) { + f32 frameCount = Animation_GetLastFrame(&gGibdoRedeadWalkAnim); - Animation_Change(&this->skelAnime, &object_rd_Anim_0113EC, 0.5f, 0.0f, frameCount, 1, -4.0f); - this->unk_3EF = 9; - this->unk_3D4 = 0; - this->actionFunc = func_808D5F18; + Animation_Change(&this->skelAnime, &gGibdoRedeadWalkAnim, 0.5f, 0.0f, frameCount, 1, -4.0f); + this->action = EN_RD_ACTION_TURNING_AWAY_AND_SHAKING_HEAD; + this->headShakeTimer = 0; + this->actionFunc = EnRd_TurnAwayAndShakeHead; } -void func_808D5F18(EnRd* this, GlobalContext* globalCtx) { +void EnRd_TurnAwayAndShakeHead(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, BINANG_ROT180(this->actor.yawTowardsPlayer), 5, 3500, 200); this->actor.shape.rot.y = this->actor.world.rot.y; - if (this->unk_3D4 > 60) { - func_808D53C0(this, globalCtx); - this->unk_3D4 = 0; + if (this->headShakeTimer > 60) { + EnRd_SetupWalkToHome(this, globalCtx); + this->headShakeTimer = 0; } else { - this->unk_3D8 = Math_SinS(this->unk_3D4 * 4000) * (9583.0f * ((60 - this->unk_3D4) / 60.0f)); + this->headYRotation = Math_SinS(this->headShakeTimer * 4000) * (0x256F * ((60 - this->headShakeTimer) / 60.0f)); SkelAnime_Update(&this->skelAnime); - this->unk_3D4++; + this->headShakeTimer++; } } -void func_808D6008(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_00A450, -4.0f); - this->unk_3EF = 5; - this->actionFunc = func_808D6054; +void EnRd_SetupStandUp(EnRd* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadStandUpAnim, -4.0f); + this->action = EN_RD_ACTION_STANDING_UP; + this->actionFunc = EnRd_StandUp; } -void func_808D6054(EnRd* this, GlobalContext* globalCtx) { +void EnRd_StandUp(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else { - func_808D5C54(this); + EnRd_SetupAttemptPlayerFreeze(this); } } } -void func_808D60B0(EnRd* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_00A450, -1.0f, Animation_GetLastFrame(&object_rd_Anim_00A450), - 0.0f, 2, -4.0f); - this->unk_3EF = 6; - this->actionFunc = func_808D6130; +void EnRd_SetupCrouch(EnRd* this) { + Animation_Change(&this->skelAnime, &gGibdoRedeadStandUpAnim, -1.0f, + Animation_GetLastFrame(&gGibdoRedeadStandUpAnim), 0.0f, 2, -4.0f); + this->action = EN_RD_ACTION_CROUCHING; + this->actionFunc = EnRd_Crouch; } -void func_808D6130(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Crouch(EnRd* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { - func_808D4308(this); + EnRd_SetupIdle(this); } } -void func_808D616C(EnRd* this) { +void EnRd_SetupDamage(EnRd* this) { this->actor.shape.yOffset = 0.0f; - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009900, -6.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDamageAnim, -6.0f); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -2.0f; } - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->unk_3EF = 11; - this->actionFunc = func_808D6200; + this->action = EN_RD_ACTION_DAMAGE; + this->actionFunc = EnRd_Damage; } -void func_808D6200(EnRd* this, GlobalContext* globalCtx) { +void EnRd_Damage(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->actor.speedXZ < 0.0f) { @@ -920,95 +1020,95 @@ void func_808D6200(EnRd* this, GlobalContext* globalCtx) { } this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 300, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 300, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 300, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 300, 0); if (SkelAnime_Update(&this->skelAnime)) { this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.parent != NULL) { - func_808D5660(this); + EnRd_SetupWalkToParent(this); } else if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) >= 150.0f) { - func_808D53C0(this, globalCtx); + EnRd_SetupWalkToHome(this, globalCtx); } else { - func_808D4FE0(this, globalCtx); + EnRd_SetupWalkToPlayer(this, globalCtx); } this->unk_3F1 = -1; } } -void func_808D6310(EnRd* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_rd_Anim_009298, -1.0f); - this->unk_3EF = 12; - this->unk_3D6 = 300; - this->actor.flags &= ~1; +void EnRd_SetupDead(EnRd* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f); + 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->actionFunc = func_808D6388; + this->actionFunc = EnRd_Dead; } -void func_808D6388(EnRd* this, GlobalContext* globalCtx) { - if (this->actor.category != 6) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); +void EnRd_Dead(EnRd* this, GlobalContext* globalCtx) { + if (this->actor.category != ACTORCAT_PROP) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_PROP); } - Math_SmoothStepToS(&this->unk_3D8, 0, 1, 2000, 0); - Math_SmoothStepToS(&this->unk_3DA, 0, 1, 2000, 0); + Math_SmoothStepToS(&this->headYRotation, 0, 1, 2000, 0); + Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 2000, 0); if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_3D6 == 0) { - if (!Flags_GetSwitch(globalCtx, this->unk_3DC & 0x7F)) { - Flags_SetSwitch(globalCtx, this->unk_3DC & 0x7F); + if (this->deathTimer == 0) { + if (!Flags_GetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this))) { + Flags_SetSwitch(globalCtx, EN_RD_GET_SWITCH_FLAG(this)); } - if (this->unk_3DE != 0) { - if (this->unk_3DE == 180) { - func_808D4190(globalCtx, this, 0); + if (this->alpha != 0) { + if (this->alpha == 180) { + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, false); } this->actor.scale.y -= (75.0f / 1000000.0f); - this->unk_3DE -= 5; + this->alpha -= 5; } else { Actor_MarkForDeath(&this->actor); } } else { - this->unk_3D6--; + 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); } } -void func_808D64D0(EnRd* this) { - this->unk_3EF = 1; - this->unk_3D6 = 0xA; +void EnRd_SetupStunned(EnRd* this) { + this->action = EN_RD_ACTION_STUNNED; + this->stunTimer = 10; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { - this->unk_3E9 = 1; - this->unk_3E0 = 600; + this->stunnedBySunsSong = true; + this->sunsSongStunTimer = 600; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIGHT_ARROW_HIT); Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); - } else if (this->unk_3F0 == 1) { + } else if (this->damageEffect == EN_RD_DMGEFF_STUN) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); - } else if (this->unk_3F0 == 12) { + } else if (this->damageEffect == EN_RD_DMGEFF_ZORA_MAGIC) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 40); } - this->actionFunc = func_808D65BC; + this->actionFunc = EnRd_Stunned; } -void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { - if (this->unk_3D6 > 0) { - this->unk_3D6--; +void EnRd_Stunned(EnRd* this, GlobalContext* globalCtx) { + if (this->stunTimer > 0) { + this->stunTimer--; } - if (this->unk_3E9 != 0) { - if (this->unk_3E0 != 0) { - this->unk_3E0--; - if (this->unk_3E0 >= 255) { + if (this->stunnedBySunsSong) { + if (this->sunsSongStunTimer != 0) { + this->sunsSongStunTimer--; + if (this->sunsSongStunTimer >= 255) { Actor_SetColorFilter(&this->actor, 0x8000, 0x80C8, 0, 255); } - if (this->unk_3E0 == 0) { - this->unk_3E9 = 0; + if (this->sunsSongStunTimer == 0) { + this->stunnedBySunsSong = false; gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } } @@ -1016,49 +1116,50 @@ void func_808D65BC(EnRd* this, GlobalContext* globalCtx) { if (this->actor.colorFilterTimer == 0) { if (this->actor.colChkInfo.health == 0) { - func_808D4190(globalCtx, this, 1); - func_808D6310(this); + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_SetupDead(this); Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); } else { - func_808D616C(this); + EnRd_SetupDamage(this); } } } -void func_808D66A0(EnRd* this, GlobalContext* globalCtx) { - s16 phi_v0 = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->unk_3DA; - s16 temp_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); +void EnRd_TurnTowardsPlayer(EnRd* this, GlobalContext* globalCtx) { + s16 headAngle = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - this->upperBodyYRotation; + s16 upperBodyAngle = CLAMP(headAngle, -500, 500); - phi_v0 -= this->unk_3D8; - phi_v0 = CLAMP(phi_v0, -0x1F4, 0x1F4); + headAngle -= this->headYRotation; + headAngle = CLAMP(headAngle, -500, 500); if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y) >= 0) { - this->unk_3DA += ABS_ALT(temp_v0); - this->unk_3D8 += ABS_ALT(phi_v0); + this->upperBodyYRotation += ABS_ALT(upperBodyAngle); + this->headYRotation += ABS_ALT(headAngle); } else { - this->unk_3DA -= ABS_ALT(temp_v0); - this->unk_3D8 -= ABS_ALT(phi_v0); + this->upperBodyYRotation -= ABS_ALT(upperBodyAngle); + this->headYRotation -= ABS_ALT(headAngle); } - this->unk_3DA = CLAMP(this->unk_3DA, -0x495F, 0x495F); - this->unk_3D8 = CLAMP(this->unk_3D8, -0x256F, 0x256F); + this->upperBodyYRotation = CLAMP(this->upperBodyYRotation, -0x495F, 0x495F); + this->headYRotation = CLAMP(this->headYRotation, -0x256F, 0x256F); } -void func_808D6814(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateDamage(EnRd* this, GlobalContext* globalCtx) { s32 pad; Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && (this->unk_3E9 == 0) && - (this->unk_3EF != 11) && (this->unk_3EF != 12) && (this->unk_3EF != 1)) { - func_808D64D0(this); + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->actor.shape.rot.x == 0) && + (!this->stunnedBySunsSong) && (this->action != EN_RD_ACTION_DAMAGE) && (this->action != EN_RD_ACTION_DEAD) && + (this->action != EN_RD_ACTION_STUNNED)) { + EnRd_SetupStunned(this); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - this->unk_3F0 = this->actor.colChkInfo.damageEffect; + this->damageEffect = this->actor.colChkInfo.damageEffect; - if (this->unk_3EF == 13) { + if (this->action == EN_RD_ACTION_RISING_FROM_COFFIN) { return; } @@ -1068,49 +1169,48 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { this->unk_3F1 = player->unk_ADD; } - switch (this->unk_3F0) { - case 12: - if ((this->actionFunc != func_808D58CC) && - ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { - this->unk_3E6 = 40; - this->unk_3E8 = 30; - this->unk_294 = 1.0f; - func_808D64D0(this); + switch (this->damageEffect) { + case EN_RD_DMGEFF_ZORA_MAGIC: + if ((this->actionFunc != EnRd_Grab) && ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffAlpha = 1.0f; + EnRd_SetupStunned(this); } return; - case 1: - func_808D64D0(this); + case EN_RD_DMGEFF_STUN: + EnRd_SetupStunned(this); return; - case 2: + case EN_RD_DMGEFF_FIRE_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->unk_3E6 = 180; - this->unk_3E8 = 0; - this->unk_3E9 = 0; - this->unk_3E0 = 0; - this->unk_294 = 1.0f; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; + this->drawDmgEffAlpha = 1.0f; break; - case 4: + case EN_RD_DMGEFF_LIGHT_ARROW: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); - this->unk_3E6 = 60; - this->unk_3E8 = 20; - this->unk_3E9 = 0; - this->unk_3E0 = 0; - this->unk_294 = 1.0f; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; + this->drawDmgEffAlpha = 1.0f; break; - case 15: + case EN_RD_DMGEFF_DAMAGE: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - this->unk_3E9 = 0; - this->unk_3E0 = 0; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; break; - case 14: + case EN_RD_DMGEFF_LIGHT_RAY: Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - this->unk_3E9 = 0; - this->unk_3E0 = 0; + this->stunnedBySunsSong = false; + this->sunsSongStunTimer = 0; this->actor.colChkInfo.health = 0; break; @@ -1120,84 +1220,87 @@ void func_808D6814(EnRd* this, GlobalContext* globalCtx) { Actor_ApplyDamage(&this->actor); if (this->actor.colChkInfo.health == 0) { - func_808D4190(globalCtx, this, 1); - func_808D6310(this); + EnRd_UpdateParentForOtherRedeads(globalCtx, &this->actor, true); + EnRd_SetupDead(this); Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0x90); } else { - func_808D616C(this); + EnRd_SetupDamage(this); } } } -void func_808D6A94(EnRd* this, GlobalContext* globalCtx) { +void EnRd_UpdateCollision(EnRd* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((this->actor.colChkInfo.health > 0) && (this->unk_3EF != 10)) { + if ((this->actor.colChkInfo.health > 0) && (this->action != EN_RD_ACTION_GRABBING)) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (((this->unk_3EF != 11) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F1))) && - ((this->actionFunc != func_808D65BC) || (this->unk_3D6 == 0))) { + if (((this->action != EN_RD_ACTION_DAMAGE) || ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F1))) && + ((this->actionFunc != EnRd_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } } -void func_808D6B64(EnRd* this, GlobalContext* globalCtx) { - if (this->unk_3E6 > 0) { - this->unk_3E6--; +void EnRd_UpdateEffect(EnRd* this, GlobalContext* globalCtx) { + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->unk_3E6 < 20) { - Math_SmoothStepToF(&this->unk_298, 0.0f, 0.5f, 0.03f, 0.0f); - this->unk_294 = this->unk_3E6 * 0.05f; + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_298, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } void EnRd_Update(Actor* thisx, GlobalContext* globalCtx) { EnRd* this = THIS; - func_808D6814(this, globalCtx); - if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (this->unk_3E9 == 0)) { + EnRd_UpdateDamage(this, globalCtx); + if ((gSaveContext.sunsSongState != SUNSSONG_INACTIVE) && (!this->stunnedBySunsSong)) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; } - if ((this->unk_3F0 != 6) && ((this->unk_3EF != 13) || (this->unk_3F0 != 2))) { - if (this->unk_3ED != 0) { - this->unk_3ED--; + if ((this->damageEffect != EN_RD_DMGEFF_UNUSED_6) && + ((this->action != EN_RD_ACTION_RISING_FROM_COFFIN) || (this->damageEffect != EN_RD_DMGEFF_FIRE_ARROW))) { + if (this->playerStunWaitTimer != 0) { + this->playerStunWaitTimer--; } this->actionFunc(this, globalCtx); - if ((this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + if ((this->action != EN_RD_ACTION_GRABBING) && (this->actor.speedXZ != 0.0f)) { Actor_MoveWithGravity(&this->actor); } - if ((this->actor.shape.rot.x == 0) && (this->unk_3EF != 10) && (this->actor.speedXZ != 0.0f)) { + if ((this->actor.shape.rot.x == 0) && (this->action != EN_RD_ACTION_GRABBING) && + (this->actor.speedXZ != 0.0f)) { Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 35.0f, 0x1D); } - if (this->unk_3EF == 7) { - func_808D66A0(this, globalCtx); + if (this->action == EN_RD_ACTION_ATTEMPTING_PLAYER_STUN) { + EnRd_TurnTowardsPlayer(this, globalCtx); } } this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; - func_808D6A94(this, globalCtx); - func_808D4260(this, globalCtx); - func_808D6B64(this, globalCtx); + + EnRd_UpdateCollision(this, globalCtx); + EnRd_SetupDanceIfConditionsMet(this, globalCtx); + EnRd_UpdateEffect(this, globalCtx); } s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if (limbIndex == 23) { - rot->y += this->unk_3D8; - } else if (limbIndex == 12) { - rot->y += this->unk_3DA; + if (limbIndex == REDEAD_LIMB_HEAD_ROOT) { + rot->y += this->headYRotation; + } else if (limbIndex == REDEAD_LIMB_UPPER_BODY_ROOT) { + rot->y += this->upperBodyYRotation; } return false; } @@ -1205,12 +1308,17 @@ s32 EnRd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnRd* this = THIS; - if ((this->unk_3E6 != 0) && - ((limbIndex == 3) || (limbIndex == 4) || (limbIndex == 6) || (limbIndex == 8) || (limbIndex == 9) || - (limbIndex == 11) || (limbIndex == 14) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18) || - (limbIndex == 20) || (limbIndex == 21) || (limbIndex == 22) || (limbIndex == 24) || (limbIndex == 25))) { - Matrix_GetStateTranslation(&this->unk_1DC[this->unk_290]); - this->unk_290++; + if ((this->drawDmgEffTimer != 0) && + ((limbIndex == REDEAD_LIMB_LEFT_THIGH) || (limbIndex == REDEAD_LIMB_LEFT_SHIN) || + (limbIndex == REDEAD_LIMB_LEFT_FOOT) || (limbIndex == REDEAD_LIMB_RIGHT_THIGH) || + (limbIndex == REDEAD_LIMB_RIGHT_SHIN) || (limbIndex == REDEAD_LIMB_RIGHT_FOOT) || + (limbIndex == REDEAD_LIMB_TORSO) || (limbIndex == REDEAD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == REDEAD_LIMB_LEFT_FOREARM) || (limbIndex == REDEAD_LIMB_LEFT_HAND) || + (limbIndex == REDEAD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == REDEAD_LIMB_RIGHT_FOREARM) || + (limbIndex == REDEAD_LIMB_RIGHT_HAND) || (limbIndex == REDEAD_LIMB_HEAD) || + (limbIndex == REDEAD_LIMB_PELVIS))) { + Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); + this->limbIndex++; } } @@ -1222,12 +1330,12 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); - this->unk_290 = 0; + this->limbIndex = 0; - if (this->unk_3DE == 255) { + if (this->alpha == 255) { func_8012C28C(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->unk_3DE); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, @@ -1238,19 +1346,19 @@ void EnRd_Draw(Actor* thisx, GlobalContext* globalCtx) { } else { func_8012C2DC(globalCtx->state.gfxCtx); - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_3DE); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnRd_OverrideLimbDraw, NULL, &this->actor, POLY_XLU_DISP); - func_800BC620(&sp54, &D_808D7138, this->unk_3DE, globalCtx); + func_800BC620(&sp54, &D_808D7138, this->alpha, globalCtx); } CLOSE_DISPS(globalCtx->state.gfxCtx); - if (this->unk_3E6 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_1DC, ARRAY_COUNT(this->unk_1DC), this->unk_298, 0.5f, - this->unk_294, this->unk_3E8); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Rd/z_en_rd.h b/src/overlays/actors/ovl_En_Rd/z_en_rd.h index 2c6637d76..7bf5a6ddc 100644 --- a/src/overlays/actors/ovl_En_Rd/z_en_rd.h +++ b/src/overlays/actors/ovl_En_Rd/z_en_rd.h @@ -2,58 +2,74 @@ #define Z_EN_RD_H #include "global.h" +#include "objects/object_rd/object_rd.h" struct EnRd; typedef void (*EnRdActionFunc)(struct EnRd*, GlobalContext*); -typedef void (*EnRdFunc)(struct EnRd*); +typedef void (*EnRdSetupDanceFunc)(struct EnRd*); -#define ENRD_GET_80(thisx) ((thisx)->params & 0x80) -#define ENRD_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_RD_GET_80(thisx) ((thisx)->params & 0x80) +#define EN_RD_GET_FLAGS(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_RD_GET_TYPE(thisx) ((thisx)->params) +#define EN_RD_GET_SWITCH_FLAG(this) ((this)->flags & 0x7F) -enum { - /* -2 */ ENRD_GET_MINUS_2 = -2, - /* -1 */ ENRD_GET_MINUS_1 = -1, - /* 0x00 */ ENRD_GET_0 = 0, - /* 0x01 */ ENRD_GET_1, - /* 0x02 */ ENRD_GET_2, - /* 0x03 */ ENRD_GET_3, - /* 0x04 */ ENRD_GET_4, - /* 0x05 */ ENRD_GET_5, -}; +#define EN_RD_FLAG_CANNOT_FREEZE_PLAYER (1 << 7) + +typedef enum { + /* -3 */ EN_RD_TYPE_GIBDO_RISING_OUT_OF_COFFIN = -3, // Unused OoT leftover + /* -2 */ EN_RD_TYPE_GIBDO = -2, // Unused OoT leftover + /* -1 */ EN_RD_TYPE_DOES_NOT_MOURN = -1, // Unused OoT leftover + /* 0 */ EN_RD_TYPE_DOES_NOT_MOURN_IF_WALKING = 0, // Unused OoT leftover. Still mourns, but it must come to a complete stop first + /* 1 */ EN_RD_TYPE_REGULAR, // Unused OoT leftover + /* 2 */ EN_RD_TYPE_CRYING, // Unused in the final game + /* 3 */ EN_RD_TYPE_INVISIBLE, // Unused OoT leftover + /* 4 */ EN_RD_TYPE_FROZEN, // Unused in the final game + /* 5 */ EN_RD_TYPE_SQUATTING_DANCE, + /* 6 */ EN_RD_TYPE_CLAPPING_DANCE, + /* 7 */ EN_RD_TYPE_PIROUETTE, +} EnRdType; typedef struct EnRd { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnRdActionFunc actionFunc; - /* 0x018C */ EnRdFunc unkFunc; + /* 0x018C */ EnRdSetupDanceFunc setupDanceFunc; /* 0x0190 */ ColliderCylinder collider; - /* 0x01DC */ Vec3f unk_1DC[15]; - /* 0x0290 */ s32 unk_290; - /* 0x0294 */ f32 unk_294; - /* 0x0298 */ f32 unk_298; - /* 0x029C */ Vec3s jointTable[26]; - /* 0x0338 */ Vec3s morphTable[26]; - /* 0x03D4 */ s16 unk_3D4; - /* 0x03D6 */ s16 unk_3D6; - /* 0x03D8 */ s16 unk_3D8; - /* 0x03DA */ s16 unk_3DA; - /* 0x03DC */ s16 unk_3DC; - /* 0x03DE */ s16 unk_3DE; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ u8 unk_3E8; - /* 0x03E9 */ u8 unk_3E9; - /* 0x03EA */ u8 unk_3EA; - /* 0x03EB */ u8 unk_3EB; - /* 0x03EC */ u8 unk_3EC; - /* 0x03ED */ u8 unk_3ED; - /* 0x03EE */ u8 unk_3EE; - /* 0x03EF */ u8 unk_3EF; - /* 0x03F0 */ u8 unk_3F0; - /* 0x03F1 */ s8 unk_3F1; + /* 0x01DC */ Vec3f limbPos[15]; + /* 0x0290 */ s32 limbIndex; + /* 0x0294 */ f32 drawDmgEffAlpha; + /* 0x0298 */ f32 drawDmgEffScale; + /* 0x029C */ Vec3s jointTable[REDEAD_LIMB_MAX]; + /* 0x0338 */ Vec3s morphTable[REDEAD_LIMB_MAX]; + /* 0x03D4 */ s16 headShakeTimer; + /* 0x03D6 */ union { + s16 animationJudderTimer; + s16 stunTimer; + s16 deathTimer; + s16 coffinRiseForwardAccelTimer; + }; + /* 0x03D8 */ s16 headYRotation; + /* 0x03DA */ s16 upperBodyYRotation; + /* 0x03DC */ s16 flags; + /* 0x03DE */ s16 alpha; + /* 0x03E0 */ s16 sunsSongStunTimer; + /* 0x03E2 */ UNK_TYPE1 unk3E2[0x2]; + /* 0x03E4 */ union { + s16 danceEndTimer; + s16 pirouetteRotationalVelocity; + }; + /* 0x03E6 */ s16 drawDmgEffTimer; + /* 0x03E8 */ u8 drawDmgEffType; + /* 0x03E9 */ u8 stunnedBySunsSong; + /* 0x03EA */ u8 grabDamageTimer; + /* 0x03EB */ u8 grabState; + /* 0x03EC */ u8 isMourning; + /* 0x03ED */ u8 playerStunWaitTimer; // Cannot stun the player if this is non-zero + /* 0x03EE */ u8 grabWaitTimer; // Cannot grab the player if this is non-zero + /* 0x03EF */ u8 action; + /* 0x03F0 */ u8 damageEffect; + /* 0x03F1 */ s8 unk_3F1; // related to player->unk_ADD } EnRd; // size = 0x3F4 extern const ActorInit En_Rd_InitVars; 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 7f8d65511..8c2f5b6c8 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -7,7 +7,7 @@ #include "z_en_recepgirl.h" #include "objects/object_bg/object_bg.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnRecepgirl*)thisx) @@ -144,7 +144,7 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { if (temp_v0_2 == 2) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + } else if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(globalCtx, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); 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 e5643efd3..13d4a93e9 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -118,9 +118,9 @@ s32 D_80BF57E4[][4] = { { 56, 34, 44, 41 }, { 60, 38, 50, 45 }, { 67, 42, 55, 49 }, { 74, 47, 61, 54 }, }; -ActorAnimationEntryS D_80BF5914[] = { - { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, 2, 0 }, - { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, 2, 0 }, +AnimationInfoS D_80BF5914[] = { + { &object_oF1d_map_Anim_012DE0, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_oF1d_map_Anim_012DE0, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; TexturePtr D_80BF5934[] = { @@ -303,7 +303,7 @@ s32 func_80BF409C(EnRg* this, s32 arg1) { if (arg1 != this->unk_334) { this->unk_334 = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80BF5914, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80BF5914, arg1); this->unk_314 = this->skelAnime.playSpeed; } return ret; @@ -383,8 +383,8 @@ s32 func_80BF43FC(EnRg* this) { s32 phi_s0 = D_80BF57E4[this->unk_344][temp_s7]; while (true) { - func_8013C8B8(this->path, phi_s0 - 1, &sp9C); - func_8013C8B8(this->path, phi_s0 + 1, &sp90); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 - 1, &sp9C); + SubS_CopyPointFromPathCheckBounds(this->path, phi_s0 + 1, &sp90); if (Math3D_PointDistToLine2D(this->actor.world.pos.x, this->actor.world.pos.z, sp9C.x, sp9C.z, sp90.x, sp90.z, &sp8C, &sp88, &sp84) && (!phi_s6 || ((phi_s4 + 1) == phi_s0) || (sp84 < phi_f20))) { @@ -477,11 +477,11 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { if ((this->unk_310 & 0x400) || (this->unk_310 & 0x1000)) { phi_f0 = 0.0f; - } else if (this->unk_348 >= 2) { + } else if (this->numCheckpointsAheadOfPlayer >= 2) { phi_f0 = phi_f2 * 0.5f; - } else if (this->unk_348 == 1) { + } else if (this->numCheckpointsAheadOfPlayer == 1) { phi_f0 = phi_f2 * 0.75f; - } else if (this->unk_348 == 0) { + } else if (this->numCheckpointsAheadOfPlayer == 0) { s16 temp_v0_3 = this->actor.yawTowardsPlayer - this->actor.world.rot.y; if ((ABS_ALT(temp_v0_3) > 0x4000) || (this->unk_326 > 0)) { @@ -489,7 +489,7 @@ s32 func_80BF47AC(EnRg* this, GlobalContext* globalCtx) { } else { phi_f0 = phi_f2 * 0.94f; } - } else if (this->unk_348 == -1) { + } else if (this->numCheckpointsAheadOfPlayer == -1) { phi_f0 = phi_f2 * 1.6f; } else { phi_f0 = 2.0f * phi_f2; @@ -521,7 +521,7 @@ void func_80BF4964(EnRg* this) { if (this->path != NULL) { sp3C = Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_33C)) { + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_33C)) { if ((this->path->count - 1) < (this->unk_33C + 1)) { this->unk_33C = this->path->count - 1; } else { @@ -677,13 +677,13 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->unk_318 = Rand_S16Offset(0, 20); } } - func_8013D9C8(globalCtx, this->unk_32E, this->unk_328, ARRAY_COUNT(this->unk_328)); + SubS_FillLimbRotTables(globalCtx, this->unk_32E, this->unk_328, ARRAY_COUNT(this->unk_328)); } void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { this->unk_344 = func_80BF4560(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { if (this->actor.bgCheckFlags & 2) { if (this->unk_310 & 0x400) { this->unk_310 &= ~0x400; @@ -749,7 +749,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { Effect_Add(globalCtx, &this->unk_340, EFFECT_TIRE_MARK, 0, 0, &D_80BF59F0); - this->path = func_8013BEDC(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); + this->path = SubS_GetDayDependentPath(globalCtx, ENRG_GET_7F80(&this->actor), 255, &this->unk_33C); if (this->path != NULL) { this->unk_33C = 1; } @@ -757,7 +757,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_310 = 8; this->actor.gravity = -1.0f; - func_8013AED4(&this->unk_310, 3, 7); + SubS_UpdateFlags(&this->unk_310, 3, 7); if (!(gSaveContext.save.weekEventReg[12] & 2)) { this->unk_318 = Rand_S16Offset(30, 30); @@ -802,7 +802,7 @@ void EnRg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF3ED4(this, globalCtx); - if (!func_801690CC(globalCtx)) { + if (!Play_InCsMode(globalCtx)) { func_80BF3C64(this); } } diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.h b/src/overlays/actors/ovl_En_Rg/z_en_rg.h index 87f712fe8..9f7e60ba4 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.h +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.h @@ -48,7 +48,7 @@ typedef struct EnRg { /* 0x033C */ s32 unk_33C; /* 0x0340 */ s32 unk_340; /* 0x0344 */ s32 unk_344; - /* 0x0348 */ s32 unk_348; + /* 0x0348 */ s32 numCheckpointsAheadOfPlayer; /* 0x034C */ EnRgStruct unk_34C[32]; } EnRg; // size = 0xACC 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 2dc6842c9..2084130ce 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 @@ -1,12 +1,12 @@ /* * File: z_en_river_sound.c * Overlay: ovl_En_River_Sound - * Description: Various environment Sfx (e.g., ocean waves, gulls, waterfall, lava, etc) + * Description: Various environment Sfx along a path (e.g., ocean waves, gulls, waterfall, lava, etc) */ #include "z_en_river_sound.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnRiverSound*)thisx) @@ -14,7 +14,6 @@ void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx); void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_River_Sound_InitVars = { ACTOR_EN_RIVER_SOUND, ACTORCAT_ITEMACTION, @@ -27,10 +26,68 @@ const ActorInit En_River_Sound_InitVars = { (ActorFunc)EnRiverSound_Draw, }; -#endif +void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRiverSound* this = THIS; + Path* path; + s32 pathIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Init.s") + this->playSound = false; + pathIndex = RS_GET_PATH_INDEX(&this->actor); + this->actor.params = RS_GET_TYPE(&this->actor); + if (pathIndex == 0xFF) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Update.s") + path = &globalCtx->setupPathList[pathIndex]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->numPoints = path->count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_River_Sound/EnRiverSound_Draw.s") +void EnRiverSound_Update(Actor* thisx, GlobalContext* globalCtx) { + EnRiverSound* this = THIS; + Vec3f* worldPos = &this->actor.world.pos; + Vec3f eye; + s32 bgId; + + Math_Vec3f_Copy(&eye, &globalCtx->view.eye); + + if (this->actor.params < RS_RIVER_DEFAULT_LOW_FREQ) { + // All sfx from river_sound that accesses gAudioEnvironmentalSfx is associated with a closed-loop + // path that is used to play a regional sfx + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, true); + } else { + Actor_GetClosestPosOnPath(this->pathPoints, this->numPoints, &eye, worldPos, false); + if (BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, &this->actor, worldPos) != + BGCHECK_Y_MIN) { + this->soundFreqIndex = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, this->actor.floorPoly, bgId); + } else { + this->soundFreqIndex = 0; + } + + if (this->soundFreqIndex == 0) { + this->soundFreqIndex = this->actor.params - RS_RIVER_DEFAULT_LOW_FREQ; + } else { + this->soundFreqIndex--; + } + + this->soundFreqIndex = CLAMP_MAX(this->soundFreqIndex, 2); + } +} + +void EnRiverSound_Draw(Actor* thisx, GlobalContext* globalCtx) { + static f32 freqScale[] = { + 0.7f, // 1 / sqrt(2) + 1.0f, // 1 + 1.4f, // sqrt(2) + }; + EnRiverSound* this = THIS; + s16 params = this->actor.params; + + if (params < RS_RIVER_DEFAULT_LOW_FREQ) { + Actor_PlaySfxAtPos(&this->actor, gAudioEnvironmentalSfx[params]); + } else { + Audio_PlaySfxForRiver(&this->actor.projectedPos, freqScale[this->soundFreqIndex]); + } +} diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h index dc02f58fa..b8dbcc513 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h @@ -5,9 +5,44 @@ struct EnRiverSound; +#define RS_GET_TYPE(thisx) ((thisx)->params & 0xFF); +#define RS_GET_PATH_INDEX(thisx) (((thisx)->params >> 8) & 0xFF); + +// Any param not as one of these values will result in UB +typedef enum { + /* 0x00 */ RS_RIVER_STREAM, + /* 0x01 */ RS_WAVE, + /* 0x02 */ RS_WATER_WALL_BIG, + /* 0x03 */ RS_WATER_WALL, + /* 0x04 */ RS_MAGMA_LEVEL, + /* 0x05 */ RS_MAGMA_LEVEL_M, + /* 0x06 */ RS_MAGMA_LEVEL_L, + /* 0x07 */ RS_TORCH, + /* 0x08 */ RS_FOUNTAIN, + /* 0x09 */ RS_DRAIN, + /* 0x0A */ RS_CROWD, + /* 0x0B */ RS_WATER_CONVECTION, + /* 0x0C */ RS_GORON_CHEER, + /* 0x0D */ RS_WATER_WALL_BIG_SILENT, + /* 0x0E */ RS_WATER_BUBBLE, + /* 0x0F */ RS_COW_CRY_LV, + /* 0x10 */ RS_MAKE_TURRET, + /* 0x11 */ RS_BOILED_WATER_S, + /* 0x12 */ RS_BOILED_WATER_L, + /* 0x13 */ RS_WAVE_0, + /* 0x14 */ RS_WAVE_1, + /* 0x15 */ RS_WAVE_2, + /* 0xFD */ RS_RIVER_DEFAULT_LOW_FREQ = 0xFD, + /* 0xFE */ RS_RIVER_DEFAULT_MEDIUM_FREQ, + /* 0xFF */ RS_RIVER_DEFAULT_HIGH_FREQ +} RiverSoundType; + typedef struct EnRiverSound { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ u8 playSound; // Unused remnant of OoT + /* 0x145 */ u8 soundFreqIndex; + /* 0x146 */ u8 numPoints; + /* 0x148 */ Vec3s* pathPoints; } EnRiverSound; // size = 0x14C extern const ActorInit En_River_Sound_InitVars; 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 d3f9951cc..4bd5bcf32 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -7,7 +7,7 @@ #include "z_en_rr.h" #include "objects/object_rr/object_rr.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnRr*)thisx) @@ -170,45 +170,45 @@ void EnRr_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_808FA01C(EnRr* this, GlobalContext* globalCtx, ColliderCylinder* collider) { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 0; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 20; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_220 = 0.85f; - this->unk_21C = 4.0f; - this->unk_1E0 = 30; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; } } void func_808FA11C(EnRr* this) { - this->unk_1E0 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider1.base.colType = COLTYPE_HIT3; this->collider1.info.elemType = ELEMTYPE_UNK0; this->unk_1EE = 80; - this->unk_220 = 0.85f; - this->unk_224 = 1.2750001f; - this->unk_21C = 1.0f; - this->actor.flags &= ~0x400; + this->drawDmgEffScale = 0.85f; + this->drawDmgEffFrozenSteamScale = 1.2750001f; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_808FA19C(EnRr* this, GlobalContext* globalCtx) { this->unk_1EE = 0; - if (this->unk_1E0 == 10) { - this->unk_1E0 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider1.base.colType = COLTYPE_HIT0; this->collider1.info.elemType = ELEMTYPE_UNK1; - this->unk_21C = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_234, 20, 2, this->actor.scale.y * 23.333334f, + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 20, 2, this->actor.scale.y * 23.333334f, this->actor.scale.y * 20.000002f); - this->actor.flags |= 0x400; + this->actor.flags |= ACTOR_FLAG_400; } } @@ -267,7 +267,7 @@ void func_808FA3F8(EnRr* this, Player* player) { this->unk_1EA = 100; this->unk_1FC = 20; this->collider1.base.ocFlags1 &= ~OC1_TYPE_PLAYER; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_1F0 = 8; this->unk_1E1 = 0; this->actor.speedXZ = 0.0f; @@ -298,14 +298,14 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { if (player->stateFlags2 & 0x80) { player->actor.parent = NULL; player->unk_AE8 = 100; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->unk_1F0 = 110; this->unk_1F6 = 2500; this->unk_210 = 0.0f; this->unk_20C = 0x800; if (((this->unk_1E2 == 0) && (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) && - (CUR_EQUIP_VALUE_VOID(EQUIP_SHIELD) == EQUIP_SHIELD)) { + (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1)) { sp34 = true; this->unk_1E2 = Inventory_DeleteEquipment(globalCtx, 1); } else { @@ -313,7 +313,7 @@ void func_808FA4F4(EnRr* this, GlobalContext* globalCtx) { } if (sp34 && (Message_GetState(&globalCtx->msgCtx) == 0)) { - func_801518B0(globalCtx, 0xF6, NULL); + Message_StartTextbox(globalCtx, 0xF6, NULL); } if (this->actor.params == ENRR_0) { @@ -415,7 +415,7 @@ void func_808FA910(EnRr* this) { this->actionFunc = func_808FB42C; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_LIKE_DEAD); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void func_808FA9CC(EnRr* this) { @@ -456,7 +456,8 @@ s32 func_808FAA94(EnRr* this, GlobalContext* globalCtx) { this->collider1.base.acFlags &= ~AC_HIT; this->collider2.base.acFlags &= ~AC_HIT; - if ((this->unk_1E0 == 10) && (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) && + (sp2C->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { return false; } @@ -672,7 +673,7 @@ void func_808FB398(EnRr* this, GlobalContext* globalCtx) { return; } - if (this->unk_1E0 == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_1EC & 2) { phi_v1 = 1000; } else { @@ -854,12 +855,12 @@ void EnRr_Update(Actor* thisx, GlobalContext* globalCtx) { Math_StepToF(&this->unk_210, 1.0f, 0.2f); } - if (this->unk_21C > 0.0f) { - if (this->unk_1E0 != 10) { - Math_StepToF(&this->unk_21C, 0.0f, 0.05f); - this->unk_220 = (this->unk_21C + 1.0f) * 0.425f; - this->unk_220 = CLAMP_MAX(this->unk_220, 0.85f); - } else if (!Math_StepToF(&this->unk_224, 0.85f, 0.02125f)) { + 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.425f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.85f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.85f, 0.02125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -875,7 +876,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Vec3f spA4; f32 temp_f20; - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, 256); + matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 4); OPEN_DISPS(globalCtx->state.gfxCtx); @@ -890,7 +891,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, (1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, MTXMODE_APPLY); - vecPtr = &this->unk_234[0]; + vecPtr = &this->limbPos[0]; gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -932,8 +933,9 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_OPA_DISP++, object_rr_DL_000470); - func_800BE680(globalCtx, &this->actor, this->unk_234, ARRAY_COUNT(this->unk_234), - this->actor.scale.y * 66.66667f * this->unk_220, this->unk_224, this->unk_21C, this->unk_1E0); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->actor.scale.y * 66.66667f * this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, + this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.h b/src/overlays/actors/ovl_En_Rr/z_en_rr.h index 036107477..e2c935b47 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.h +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.h @@ -31,7 +31,7 @@ typedef struct EnRr { /* 0x144 */ EnRrActionFunc actionFunc; /* 0x148 */ ColliderCylinder collider1; /* 0x194 */ ColliderCylinder collider2; - /* 0x1E0 */ u8 unk_1E0; + /* 0x1E0 */ u8 drawDmgEffType; /* 0x1E1 */ u8 unk_1E1; /* 0x1E2 */ u8 unk_1E2; /* 0x1E4 */ s16 unk_1E4; @@ -54,11 +54,11 @@ typedef struct EnRr { /* 0x210 */ f32 unk_210; /* 0x214 */ f32 unk_214; /* 0x218 */ f32 unk_218; - /* 0x21C */ f32 unk_21C; - /* 0x220 */ f32 unk_220; - /* 0x224 */ f32 unk_224; + /* 0x21C */ f32 drawDmgEffAlpha; + /* 0x220 */ f32 drawDmgEffScale; + /* 0x224 */ f32 drawDmgEffFrozenSteamScale; /* 0x228 */ Vec3f unk_228; - /* 0x234 */ Vec3f unk_234[20]; + /* 0x234 */ Vec3f limbPos[20]; /* 0x324 */ EnRrStruct unk_324[5]; } EnRr; // size = 0x3C4 diff --git a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c index cd7bcf6fa..cb110f780 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -7,7 +7,7 @@ #include "z_en_rsn.h" #include "objects/object_rs/object_rs.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnRsn*)thisx) @@ -30,10 +30,10 @@ const ActorInit En_Rsn_InitVars = { (ActorFunc)EnRsn_Draw, }; -static ActorAnimationEntry animations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, 0, 0.0f } }; +static AnimationInfo sAnimations[] = { { &object_rs_Anim_00788C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f } }; void func_80C25D40(EnRsn* this) { - Actor_ChangeAnimation(&this->skelAnime, animations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actionFunc = func_80C25D84; } @@ -45,7 +45,7 @@ void EnRsn_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, NULL, NULL, 0); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; func_80C25D40(this); } 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 f3edfa7c3..3e9538f61 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -6,7 +6,7 @@ #include "z_en_ru.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnRu*)thisx) 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 034004cc3..eab2461d2 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -7,7 +7,7 @@ #include "z_en_ruppecrow.h" #include "objects/object_crow/object_crow.h" -#define FLAGS 0x00004030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000) #define THIS ((EnRuppecrow*)thisx) @@ -225,7 +225,7 @@ void EnRuppecrow_ShatterIce(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->currentEffect == ENRUPPECROW_EFFECT_ICE) { this->currentEffect = ENRUPPECROW_EFFECT_NONE; this->unk_2C8 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ENRUPPECROW_LIMB_POS_COUNT, 0x2, 0.2f, 0.2f); + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0x2, 0.2f, 0.2f); } } @@ -285,7 +285,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } else { rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, this->actor.world.pos.y, @@ -296,7 +296,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } } else if (this->rupeeIndex == 19) { rupee = @@ -308,7 +308,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } else { rupee = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, this->actor.world.pos.x + xOffset, @@ -319,7 +319,7 @@ void EnRuppecrow_SpawnRupee(EnRuppecrow* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_RUPY_FALL); rupee = this->rupees[rupeeIndex]; rupee->unk152 = 60; - this->rupees[rupeeIndex]->actor.flags |= 0x10; + this->rupees[rupeeIndex]->actor.flags |= ACTOR_FLAG_10; } this->rupeeIndex++; @@ -440,7 +440,7 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); this->actor.velocity.y = 0.0f; - Animation_Change(&this->skelAnime, &object_crow_Anim_0000F0, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 0x1, -3.0f); this->actor.shape.yOffset = 0.0f; this->actor.targetArrowOffset = 0.0f; @@ -465,12 +465,12 @@ void EnRuppecrow_HandleDeath(EnRuppecrow* this) { } Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0x0, 0x28); - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { this->actor.speedXZ = 0.0f; } this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = EnRuppecrow_FallToDespawn; } @@ -481,7 +481,7 @@ void EnRuppecrow_UpdateDamage(EnRuppecrow* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect != 0x1) { this->actor.colChkInfo.health = 0; - this->actor.flags &= ~0x1; + this->actor.flags &= ~ACTOR_FLAG_1; Enemy_StartFinishingBlow(globalCtx, &this->actor); EnRuppecrow_HandleDeath(this); } @@ -602,7 +602,7 @@ void EnRuppecrow_FallToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { } this->actor.colorFilterTimer = 40; - if (!(this->actor.flags & 0x8000)) { + if (!(this->actor.flags & ACTOR_FLAG_8000)) { if (this->currentEffect != ENRUPPECROW_EFFECT_ICE) { Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); this->actor.shape.rot.z += 0x1780; @@ -627,8 +627,8 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { EnRuppecrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_crow_Skel_0010C0, &object_crow_Anim_0000F0, this->joinTable, - this->morphTable, ENRUPPECROW_LIMB_COUNT); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->joinTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); Collider_InitJntSph(globalCtx, &this->collider); @@ -637,9 +637,9 @@ void EnRuppecrow_Init(Actor* thisx, GlobalContext* globalCtx2) { CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; - this->path = func_8013D648(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENRUPPECROW_GET_PATH(&this->actor), 0x3F); if (this->path != NULL) { this->actionFunc = EnRuppecrow_HandleSong; } else { diff --git a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h index 4c9cafa67..de9fceac9 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.h @@ -2,11 +2,11 @@ #define Z_EN_RUPPECROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" #define ENRUPPECROW_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) #define ENRUPPECROW_RUPEE_COUNT 20 -#define ENRUPPECROW_LIMB_COUNT 9 #define ENRUPPECROW_LIMB_POS_COUNT 4 struct EnRuppecrow; @@ -19,8 +19,8 @@ typedef struct EnRuppecrow { /* 0x194 */ SkelAnime skelAnime; /* 0x1D8 */ EnRuppecrowActionFunc actionFunc; /* 0x1DC */ UNK_TYPE4 unk_1DC; // unused - /* 0x1E0 */ Vec3s joinTable[ENRUPPECROW_LIMB_COUNT]; - /* 0x216 */ Vec3s morphTable[ENRUPPECROW_LIMB_COUNT]; + /* 0x1E0 */ Vec3s joinTable[OBJECT_CROW_LIMB_MAX]; + /* 0x216 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; /* 0x24C */ Path* path; /* 0x250 */ s32 currentPoint; /* 0x254 */ ColliderJntSph collider; 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 26551895a..57f679803 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -6,7 +6,7 @@ #include "z_en_rz.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnRz*)thisx) 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 07d0dc3f9..99e92b017 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 @@ -1,12 +1,12 @@ /* * File: z_en_s_goro.c * Overlay: ovl_En_S_Goro - * Description: Goron Complaining About Crying / Bomb Shop Goron + * Description: Goron in Goron Shrine / Bomb Shop Goron */ #include "z_en_s_goro.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSGoro*)thisx) diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h index 489499b33..99c35127a 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.h @@ -3,6 +3,8 @@ #include "global.h" +#define EN_S_GORO_GET_PARAM_F(thisx) ((thisx)->params & 0xF) + struct EnSGoro; typedef void (*EnSGoroActionFunc)(struct EnSGoro*, GlobalContext*); 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 b264a068b..7ffeb543b 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -7,7 +7,7 @@ #include "z_en_sb.h" #include "objects/object_sb/object_sb.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSb*)thisx) @@ -109,14 +109,14 @@ void EnSb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; - this->actor.colChkInfo.mass = 0xA; + this->actor.colChkInfo.mass = 10; this->actor.colChkInfo.health = 2; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_sb_Skel_002BF0, &object_sb_Anim_000194, this->jointTable, this->morphTable, 9); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); this->isDead = false; - this->actor.colChkInfo.mass = 0x5A; + this->actor.colChkInfo.mass = 90; this->actor.shape.rot.y = 0; this->actor.speedXZ = 0.0f; this->actor.gravity = -0.35f; 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 c813759cb..357d41ba7 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 @@ -6,7 +6,7 @@ #include "z_en_sc_ruppe.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScRuppe*)thisx) diff --git a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c index 136586072..dd6453773 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -7,7 +7,7 @@ #include "z_en_scopecoin.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScopecoin*)thisx) 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 76665f67a..bf0b6a839 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.c @@ -6,7 +6,7 @@ #include "z_en_scopecrow.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnScopecrow*)thisx) 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 177dff76f..b266cc0b6 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -64,22 +64,33 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS sAnimations[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; -Gfx* D_80BCCCDC[] = { gameplay_keep_DL_0527F0, gameplay_keep_DL_0528B0 }; +Gfx* D_80BCCCDC[] = { gKakeraLeafMiddle, gKakeraLeafTip }; Vec3f D_80BCCCE4 = { 0.0f, -0.5f, 0.0f }; @@ -186,7 +197,7 @@ void func_80BCAFA8(EnScopenuts* this, GlobalContext* globalCtx) { if (sp1C.y < 150.0f) { this->actor.draw = EnScopenuts_Draw; this->unk_348 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); this->actionFunc = func_80BCB078; } } @@ -235,7 +246,7 @@ void func_80BCB1C8(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38); @@ -246,30 +257,30 @@ void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_348 = 3; this->collider.dim.height = 64; func_80BCAC40(this, globalCtx); - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); } else if (sp26 == sp24) { 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); - func_8013BC6C(&this->skelAnime, sAnimations, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 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); - func_8013BC6C(&this->skelAnime, sAnimations, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 16); } else if (this->unk_348 == 17) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_ZeroOne() * 10.0f; this->unk_348 = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 2); } } else if ((this->unk_348 == 16) && (DECR(this->unk_34E) == 0)) { this->unk_34E = Rand_S16Offset(40, 40); this->unk_348 = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, sAnimations, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 18); } } } @@ -277,7 +288,7 @@ void func_80BCB230(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCB4DC(EnScopenuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80BCB52C; - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); } } @@ -286,7 +297,7 @@ void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_33C = func_80BCAF0C(this); - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else if (((this->actor.xzDistToPlayer < 100.0f) && (((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false)) || @@ -295,7 +306,7 @@ void func_80BCB52C(EnScopenuts* this, GlobalContext* globalCtx) { } else if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_348 = 4; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BCB230; } } @@ -304,7 +315,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->unk_328 & 1) { this->unk_328 &= ~1; globalCtx->msgCtx.msgMode = 0x43; @@ -312,22 +323,22 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_328 &= ~4; this->unk_348 = 8; - func_8013BC6C(&this->skelAnime, sAnimations, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 8); this->actionFunc = func_80BCBA00; } else { this->unk_33C = func_80BCAF0C(this); - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } } } else if (temp_v0 == 4) { - if (func_80147624(globalCtx) != 0) { + if (Message_ShouldAdvance(globalCtx) != 0) { switch (globalCtx->msgCtx.choiceIndex) { case 0: if (gSaveContext.save.playerData.rupees < this->unk_358) { play_sound(NA_SE_SY_ERROR); this->unk_33C = 0x1636; this->unk_328 |= 1; - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); } else { func_8019F208(); globalCtx->msgCtx.msgMode = 0x43; @@ -344,7 +355,7 @@ void func_80BCB6D0(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_33C = 0x1635; this->unk_328 |= 1; } - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); break; } } @@ -368,7 +379,7 @@ void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_33C = 0x1637; this->unk_328 |= 1; - func_801518B0(globalCtx, this->unk_33C, &this->actor); + Message_StartTextbox(globalCtx, this->unk_33C, &this->actor); this->actionFunc = func_80BCB6D0; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); @@ -377,7 +388,7 @@ void func_80BCB980(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { s16 sp26 = this->skelAnime.curFrame; - s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp24 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); switch (sp26) { case 10: @@ -452,7 +463,7 @@ void func_80BCBA00(EnScopenuts* this, GlobalContext* globalCtx) { if (sp26 == sp24) { this->unk_35A = 3; this->unk_348 = 19; - func_8013BC6C(&this->skelAnime, sAnimations, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_328 &= ~2; this->unk_34E = 50; @@ -487,7 +498,7 @@ void func_80BCBC60(EnScopenuts* this, GlobalContext* globalCtx) { void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { Vec3f sp44; s16 sp42 = this->skelAnime.curFrame; - s16 sp40 = Animation_GetLastFrame(sAnimations[this->unk_348].animationSeg); + s16 sp40 = Animation_GetLastFrame(sAnimations[this->unk_348].animation); Vec3s sp38; func_80BCC448(this->path, this->unk_334, &this->actor.world.pos, &sp38); @@ -516,7 +527,7 @@ void func_80BCBD28(EnScopenuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_368 = 0.3f; this->unk_348 = 9; - func_8013BC6C(&this->skelAnime, sAnimations, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); func_80BCAC40(this, globalCtx); this->actionFunc = func_80BCBF0C; @@ -536,7 +547,7 @@ void func_80BCBF0C(EnScopenuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 50.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_348 = 10; - func_8013BC6C(&this->skelAnime, sAnimations, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 10); this->unk_328 |= 2; this->unk_36E = 0; this->actionFunc = func_80BCBFFC; @@ -673,7 +684,8 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnScopenuts* this = THIS; - if (!(gSaveContext.save.weekEventReg[74] & 0x40) && (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { + if (!(gSaveContext.save.weekEventReg[74] & 0x40) && + (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { Actor_MarkForDeath(&this->actor); return; } @@ -696,7 +708,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.weekEventReg[52] & 0x40) { Actor_MarkForDeath(&this->actor); } else if (globalCtx->actorCtx.unk5 & 2) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; this->actor.gravity = 0.0f; @@ -705,7 +717,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { } } else if (ENSCOPENUTS_GET_3E0(&this->actor) == ENSCOPENUTS_3E0_1) { if (gSaveContext.save.weekEventReg[52] & 0x40) { - this->path = func_8013D648(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { Actor_MarkForDeath(&this->actor); } else { @@ -716,7 +728,7 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_358 = 150; this->unk_348 = 4; this->unk_35A = 0; - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->actionFunc = func_80BCB230; } } else { diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index e423a2046..0103b1d62 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -6,7 +6,7 @@ #include "z_en_sda.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSda*)thisx) @@ -15,7 +15,11 @@ void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSda_Update(Actor* thisx, GlobalContext* globalCtx); void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx); +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx); + +Vec3f D_80947EA0[16]; + const ActorInit En_Sda_InitVars = { ACTOR_EN_SDA, ACTORCAT_BOSS, @@ -28,18 +32,327 @@ const ActorInit En_Sda_InitVars = { (ActorFunc)EnSda_Draw, }; -#endif +Vec3f D_80947A60 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Init.s") +s16 D_80947A6C[] = { 1, 2, 3, 3, 2, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Destroy.s") +s16 D_80947A78[] = { 2, 3, 4, 4, 4, 3, 2, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Update.s") +s16 D_80947A88[] = { 2, 3, 4, 4, 4, 4, 3, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/EnSda_Draw.s") +s16 D_80947A98[] = { 2, 4, 5, 5, 6, 6, 6, 6, 5, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_809469C0.s") +s16 D_80947AB0[] = { 2, 4, 5, 6, 7, 8, 8, 8, 8, 7, 6, 5, 4, 2 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_8094702C.s") +s16 D_80947ACC[] = { 1, -1, 1, 1, 3, 4, 1, 6, 7, 2, 9, 0xA, 2, 0xC, 0xD, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sda/func_80947668.s") +u8 D_80947AEC[] = { + 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 3, +}; + +s8 D_80947AFC[] = { + 2, 9, 10, 11, 12, 13, 14, 0, 15, -1, 3, 4, 5, 6, 7, 8, -1, 1, 0, 0, +}; + +Vec3f D_80947B10[] = { + { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, + { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, + { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, + { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, + { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, + { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, { -1.0f, 2.0f, -0.2f }, { 0.0f, 2.0f, -0.5f }, + { 1.0f, 2.0f, -0.2f }, { -2.0f, 1.0f, -0.5f }, { -1.0f, 1.0f, -0.2f }, { 0.0f, 1.0f, -0.2f }, + { 1.0f, 1.0f, -0.2f }, { 2.0f, 1.0f, -0.5f }, { -2.0f, 0.0f, -0.5f }, { -1.0f, 0.0f, -0.2f }, + { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, -0.2f }, { 2.0f, 0.0f, -0.5f }, { -2.0f, -1.0f, -0.5f }, + { -1.0f, -1.0f, -0.2f }, { 0.0f, -1.0f, -0.1f }, { 1.0f, -1.0f, -0.2f }, { 2.0f, -1.0f, -0.5f }, + { -1.0f, -2.0f, -0.2f }, { 0.0f, -2.0f, -0.2f }, { 1.0f, -2.0f, -0.2f }, { 0.0f, -3.0f, -0.5f }, +}; + +static s32 sPad[2] = { 0, 0 }; + +#include "overlays/ovl_En_Sda/ovl_En_Sda.c" + +void EnSda_Init(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnSda_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + this->actor.world.pos = player->actor.world.pos; +} + +void EnSda_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSda* this = THIS; + Player* player; + u8* shadowTexture = GRAPH_ALLOC(globalCtx->state.gfxCtx, 64 * 64); + + if (this->actor.params == ENSDA_1) { + player = (Player*)this->actor.parent; + } else { + player = GET_PLAYER(globalCtx); + } + + player->actor.shape.shadowAlpha = 0; + func_8094702C(this, shadowTexture, player, globalCtx); + + if (KREG(0) < 5) { + func_80947668(shadowTexture, player, globalCtx); + } +} + +void func_809469C0(Player* player, u8* shadowTexture, f32 arg2) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v1; + s16 temp_v0; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f lerp; + Vec3f sp88; + Vec3f sp7C; + + for (i = 0; i < 16; i++) { + if ((arg2 == 0.0f) || ((j = D_80947ACC[i]) >= 0)) { + if (arg2 > 0.0f) { + lerp.x = D_80947EA0[i].x + (D_80947EA0[j].x - D_80947EA0[i].x) * arg2; + lerp.y = D_80947EA0[i].y + (D_80947EA0[j].y - D_80947EA0[i].y) * arg2; + lerp.z = D_80947EA0[i].z + (D_80947EA0[j].z - D_80947EA0[i].z) * arg2; + + sp88.x = lerp.x - player->actor.world.pos.x; + sp88.y = lerp.y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = lerp.z - player->actor.world.pos.z; + } else { + sp88.x = D_80947EA0[i].x - player->actor.world.pos.x; + sp88.y = D_80947EA0[i].y - player->actor.world.pos.y + BREG(48) + 76.0f + 30.0f - 105.0f + 15.0f; + sp88.z = D_80947EA0[i].z - player->actor.world.pos.z; + } + + Matrix_MultiplyVector3fByState(&sp88, &sp7C); + sp7C.x *= (1.0f + (BREG(49) / 100.0f)); + sp7C.y *= (1.0f + (BREG(49) / 100.0f)); + temp_t0 = sp7C.x + 32.0f; + temp_t1 = sp7C.y * 64.0f; + + if (D_80947AEC[i] == 2) { + for (j = 0, phi_a3 = -0x180; j < 12; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A98[j]; phi_a0 < D_80947A98[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 1) { + for (j = 0, phi_a3 = -0x100; j < 8; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A88[j]; phi_a0 < D_80947A88[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 0) { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else if (D_80947AEC[i] == 4) { + for (j = 0, phi_a3 = -0x1C0; j < 14; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947AB0[j]; phi_a0 < D_80947AB0[j]; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } else { + for (j = 0, phi_a3 = -0x80; j < 6; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A6C[j]; phi_a0 < D_80947A6C[j] - 1; phi_a0++) { + temp_v1 = temp_t0 + phi_a0; + if ((temp_v1 >= 0) && (temp_v1 < 0x40)) { + temp_v0 = temp_t1 + phi_a3; + if ((temp_v0 >= 0) && (temp_v0 < 0x1000)) { + shadowTexture[temp_v1 + temp_v0] = 255; + } + } + } + } + } + } + } +} + +void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + s16 temp_t0; + s16 temp_t1; + s16 temp_v0; + s16 temp_v1; + s16 phi_a0; + s16 phi_a3; + s16 i; + s16 j; + Vec3f sp194; + Vec3f sp188; + s32* shadowTextureTemp32; + u8* shadowTextureTemp; + Vec3s sp178; + Vec3f sp16C; + Vec3f sp64[22]; + + if (BREG(57) != 0) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if ((i >= 0 && i < 0x40) || (i >= 0xFC0 && i < 0x1000) || ((i & 0x3F) == 0) || ((i & 0x3F) == 0x3F)) { + *shadowTextureTemp = 255; + } else { + *shadowTextureTemp = 0; + } + } + } else { + for (shadowTextureTemp32 = (s32*)shadowTexture, i = 0; i < 0x400; i++, shadowTextureTemp32++) { + *shadowTextureTemp32 = 0; + } + } + + Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 18; i++) { + if (D_80947AFC[i] >= 0) { + D_80947EA0[D_80947AFC[i]] = player->bodyPartsPos[i]; + } + } + + D_80947EA0[0].y += 3.0f; + D_80947EA0[15].x = D_80947EA0[0].x + ((D_80947EA0[15].x - D_80947EA0[0].x) * 1.2f); + D_80947EA0[15].y = D_80947EA0[0].y + ((D_80947EA0[15].y - D_80947EA0[0].y) * -1.2f); + D_80947EA0[15].z = D_80947EA0[0].z + ((D_80947EA0[15].z - D_80947EA0[0].z) * 1.2f); + + for (i = 0; i < 6; i++) { + func_809469C0(player, shadowTexture, i / 5.0f); + } + + if (this->actor.params != ENSDA_1) { + func_8018219C(&player->shieldMf, &sp178, false); + + sp178.y += (KREG(87) * 0x8000) + 0x8000; + sp178.x *= (KREG(88) - 1); + + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&D_80947A60, &sp16C); + Matrix_RotateY(sp178.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(sp178.x, MTXMODE_APPLY); + + for (i = 0; i < 22; i++) { + Matrix_MultiplyVector3fByState(&D_80947B10[i], &sp188); + sp64[i].x = (((KREG(82) / 100.0f) + 4.0f) * sp188.x) + sp16C.x; + sp64[i].y = (((KREG(82) / 100.0f) + 4.0f) * sp188.y) + sp16C.y; + sp64[i].z = (((KREG(82) / 100.0f) + 4.0f) * sp188.z) + sp16C.z; + } + + Matrix_SetStateXRotation((BREG(50) + 70) / 100.0f); + + for (i = 0; i < 22; i++) { + sp194.x = sp64[i].x - player->actor.world.pos.x; + sp194.y = sp64[i].y - player->actor.world.pos.y + KREG(80) + 16.0f; + sp194.z = sp64[i].z - player->actor.world.pos.z; + + Matrix_MultiplyVector3fByState(&sp194, &sp188); + + sp188.x *= (1.0f + (KREG(90) / 100.0f)); + sp188.y *= (1.0f + (KREG(90) / 100.0f)); + temp_t0 = sp188.x + 32.0f; + temp_t1 = sp188.y * 64.0f; + + do { + for (j = 0, phi_a3 = -0xC0; j < 7; j++, phi_a3 += 0x40) { + for (phi_a0 = -D_80947A78[j]; phi_a0 < D_80947A78[j] - 1; phi_a0++) { + temp_v0 = temp_t0 + phi_a0; + if ((temp_v0 >= 0) && (temp_v0 < 0x40)) { + temp_v1 = temp_t1 + phi_a3; + if ((temp_v1 >= 0) && (temp_v1 < 0x1000)) { + shadowTexture[temp_v0 + temp_v1] = 255; + } + } + } + } + j++; + } while (j < 6); + } + } + + if (BREG(61) == 1) { + for (shadowTextureTemp = shadowTexture, i = 0; i < 0x1000; i++, shadowTextureTemp++) { + if (*shadowTextureTemp != 0) { + *shadowTextureTemp = -((i >> 6) * (BREG(60) + 4)) + (255 - BREG(61)); + } + } + } +} + +void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 tempx; + f32 tempz; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x00, 0, 0, 0, (BREG(52) + 50)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); + + Matrix_InsertTranslation(player->actor.world.pos.x, player->actor.floorHeight, player->actor.world.pos.z, + MTXMODE_NEW); + Matrix_InsertYRotation_f(BREG(51) / 100.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, 1.0f, (BREG(63) / 10.0f) + 1.0f, MTXMODE_APPLY); + + tempx = (BREG(62) / 10.0f) + 2.0f; + tempz = ((player->actor.world.pos.y - player->actor.floorHeight + BREG(54)) * (BREG(55) - 5) / 10.0f) + BREG(58) - + 20.0f; + + Matrix_InsertTranslation(tempx, 0.0f, tempz, MTXMODE_APPLY); + Matrix_Scale(((BREG(56) - 250) / 1000.0f) + 0.6f, 1.0f, ((BREG(59) - 250) / 1000.0f) + 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_1498); + gDPLoadTextureBlock(POLY_XLU_DISP++, shadowTexture, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + + for (i = 0; i < KREG(78); i++) { + Matrix_Scale((KREG(79) / 100.0f) + 1.0f, 1.0f, (KREG(79) / 100.0f) + 1.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Sda_DL_14B8); + } + + CLOSE_DISPS(gfxCtx); + + if (1) {} +} diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.h b/src/overlays/actors/ovl_En_Sda/z_en_sda.h index fff04d601..ff17a2538 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.h +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.h @@ -5,6 +5,8 @@ struct EnSda; +#define ENSDA_1 1 + typedef struct EnSda { /* 0x000 */ Actor actor; } EnSda; // size = 0x144 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 29b673760..5ce4184a6 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -6,7 +6,7 @@ #include "z_en_sekihi.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSekihi*)thisx) 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 fa5739227..5735d1e28 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.c @@ -7,7 +7,7 @@ #include "z_en_sellnuts.h" #include "objects/object_dnt/object_dnt.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSellnuts*)thisx) @@ -35,11 +35,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx); s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2); f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3); -static u16 D_80ADD910[] = { - 0x0614, - 0x060E, - 0x0628, -}; +static u16 D_80ADD910[] = { 0x0614, 0x060E, 0x0628 }; static u16 D_80ADD918[] = { 0x0616, 0x0610, 0x0629 }; @@ -84,19 +80,30 @@ static ColliderCylinderInitType1 sCylinderInit = { { 27, 32, 0, { 0, 0, 0 } }, }; -static ActorAnimationEntryS D_80ADD990[] = { - { &object_dnt_Anim_005488, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_004AA0, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004E38, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_005CA8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_0038CC, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003CC0, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_0012F4, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_004700, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_003438, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001E2C, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_000994, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_002268, 1.0f, 0, -1, 2, 0 }, { &object_dnt_Anim_002F08, 1.0f, 0, -1, 0, 0 }, - { &object_dnt_Anim_00577C, 1.0f, 0, -1, 0, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 8, -1, 2, 0 }, - { &object_dnt_Anim_0029E8, 1.0f, 4, -1, 2, -4 }, { &object_dnt_Anim_0029E8, 1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_001BC8, 1.0f, 0, -1, 0, 0 }, { &object_dnt_Anim_0012F4, -1.0f, 0, -1, 2, 0 }, - { &object_dnt_Anim_002670, 1.0f, 0, -1, 2, 0 }, +static AnimationInfoS D_80ADD990[] = { + { &object_dnt_Anim_005488, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00B0B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_004AA0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004E38, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_005CA8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0038CC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003CC0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_004700, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_003438, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001E2C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_000994, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_002268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002F08, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_00577C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 8, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_0029E8, 1.0f, 4, -1, ANIMMODE_ONCE, -4 }, + { &object_dnt_Anim_0029E8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_001BC8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_dnt_Anim_0012F4, -1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_dnt_Anim_002670, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, }; static InitChainEntry sInitChain[] = { @@ -228,25 +235,25 @@ f32 func_80ADB08C(GlobalContext* globalCtx) { void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (currentFrame == frameCount) { switch (this->unk_340) { case 0x611: case 0x62A: this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADBFA0; break; case 0x618: if (this->unk_34C == 1) { this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADB544; } else { this->unk_34C = 1; - func_8013BC6C(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); this->actionFunc = func_80ADBFA0; } break; @@ -257,7 +264,7 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x614: case 0x628: this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); this->actionFunc = func_80ADB924; break; @@ -266,14 +273,14 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { case 0x616: case 0x629: this->unk_34C = 1; - func_8013BC6C(&this->skelAnime, D_80ADD990, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 1); this->actionFunc = func_80ADB924; break; case 0x613: case 0x619: this->unk_34C = 7; - func_8013BC6C(&this->skelAnime, D_80ADD990, 7); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 7); this->actionFunc = func_80ADBD64; break; } @@ -282,7 +289,7 @@ void func_80ADB0D8(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); 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) && @@ -291,31 +298,31 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADB4F4; this->unk_34C = 3; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, D_80ADD990, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 3); } else if (currentFrame == frameCount) { 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); - func_8013BC6C(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 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); - func_8013BC6C(&this->skelAnime, D_80ADD990, 16); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 16); } else if (this->unk_34C == 17) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_ZeroOne() * 10.0f; this->unk_34C = 2; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, D_80ADD990, 2); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 2); } } else if (this->unk_34C == 16) { if (DECR(this->unk_34E) == 0) { this->unk_34E = Rand_S16Offset(40, 40); this->unk_34C = 18; this->collider.dim.height = 32; - func_8013BC6C(&this->skelAnime, D_80ADD990, 18); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 18); } } } @@ -324,7 +331,7 @@ void func_80ADB254(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADB4F4(EnSellnuts* this, GlobalContext* globalCtx) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { this->actionFunc = func_80ADB544; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } } @@ -343,27 +350,27 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { case 0x60E: gSaveContext.save.weekEventReg[17] |= 0x20; gSaveContext.save.weekEventReg[86] |= 4; - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x628: gSaveContext.save.weekEventReg[77] |= 0x40; gSaveContext.save.weekEventReg[86] |= 4; - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x614: gSaveContext.save.weekEventReg[17] |= 0x40; - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; case 0x610: case 0x616: case 0x629: - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; break; @@ -402,7 +409,7 @@ void func_80ADB544(EnSellnuts* this, GlobalContext* globalCtx) { if (!(((this->actor.playerHeightRel < 50.0f) && (this->actor.playerHeightRel > -50.0f)) ? true : false) || !((this->actor.xzDistToPlayer < 200.0f) ? true : false)) { this->unk_34C = 4; - func_8013BC6C(&this->skelAnime, D_80ADD990, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 4); this->actionFunc = func_80ADB254; } } @@ -431,7 +438,7 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { func_80151938(globalCtx, this->unk_340); this->actionFunc = func_80ADB0D8; } - } else if ((msgState == 5) && func_80147624(globalCtx)) { + } else if ((msgState == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_340 == D_80ADD910[this->unk_33A]) { this->unk_340 = D_80ADD938[this->unk_33A]; func_80151938(globalCtx, this->unk_340); @@ -447,21 +454,21 @@ void func_80ADB924(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBAB8(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_368 == 0x28) { this->unk_34C = 5; - func_8013BC6C(&this->skelAnime, D_80ADD990, 5); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 5); } this->unk_368++; if ((currentFrame == frameCount) && (this->unk_34C == 5)) { this->unk_34C = 6; - func_8013BC6C(&this->skelAnime, D_80ADD990, 6); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 6); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->actionFunc = func_80ADBBEC; @@ -481,7 +488,7 @@ void func_80ADBBEC(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->unk_340, &this->actor); + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); this->actionFunc = func_80ADB0D8; } else { func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); @@ -490,7 +497,7 @@ void func_80ADBC60(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); this->unk_340 = D_80ADD930[this->unk_33A]; this->actionFunc = func_80ADBC60; @@ -500,27 +507,27 @@ void func_80ADBCE4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADBD64(EnSellnuts* this, GlobalContext* globalCtx) { u8 sp27 = Message_GetState(&globalCtx->msgCtx); s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if ((currentFrame == frameCount) && (this->unk_34C == 7)) { this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 0); } - if ((sp27 == 5) && func_80147624(globalCtx)) { + if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_338 &= ~2; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_34C = 8; - func_8013BC6C(&this->skelAnime, D_80ADD990, 8); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 8); this->actionFunc = func_80ADBE80; } } void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); func_80ADAE64(this); if (this->unk_366 == 0) { @@ -539,7 +546,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { if (currentFrame == frameCount) { this->unk_350 = 4; this->unk_34C = 19; - func_8013BC6C(&this->skelAnime, D_80ADD990, 19); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 19); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); this->unk_338 &= ~1; this->unk_338 |= 8; @@ -549,7 +556,7 @@ void func_80ADBE80(EnSellnuts* this, GlobalContext* globalCtx) { } void func_80ADBFA0(EnSellnuts* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->unk_34C == 0) { @@ -573,7 +580,7 @@ void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 200.0f) < this->actor.world.pos.y) { Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.2f, 1.0f); this->unk_34C = 10; - func_8013BC6C(&this->skelAnime, D_80ADD990, 10); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 10); this->unk_368 = 0; this->actionFunc = func_80ADC37C; } @@ -582,7 +589,7 @@ void func_80ADC034(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { Vec3f sp34; s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (currentFrame == frameCount) { Math_SmoothStepToS(&this->unk_364, 0x1C71, 3, 0x100, 0); @@ -608,7 +615,7 @@ void func_80ADC118(EnSellnuts* this, GlobalContext* globalCtx) { if ((this->actor.home.pos.y + 22.5f) < this->actor.world.pos.y) { this->unk_34C = 9; this->unk_360 = 0.3f; - func_8013BC6C(&this->skelAnime, D_80ADD990, 9); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 9); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->actionFunc = func_80ADC034; } @@ -691,8 +698,8 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { player->linearVelocity = 0.0f; - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, this->unk_340, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, this->unk_340, &this->actor); if (this->unk_340 == 0x625) { this->unk_338 |= 1; this->actor.draw = EnSellnuts_Draw; @@ -704,7 +711,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { this->actionFunc = func_80ADC6D0; } } else if (func_80ADB08C(globalCtx) < 80.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer); } } @@ -712,7 +719,7 @@ void func_80ADC5A4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADC6D0(EnSellnuts* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (player->transformation == PLAYER_FORM_DEKU) { @@ -742,7 +749,7 @@ void func_80ADC7B4(EnSellnuts* this, GlobalContext* globalCtx) { } ActorCutscene_SetIntentToPlay(this->cutscene); } - } else if ((this->unk_366 == 1) && (temp == 5) && func_80147624(globalCtx)) { + } else if ((this->unk_366 == 1) && (temp == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_366 = 0; @@ -786,7 +793,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->actor.velocity.y = -1.0f; this->actor.speedXZ = 0.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->unk_338 &= ~1; this->unk_338 &= ~2; this->actionFunc = func_80ADCA64; @@ -801,7 +808,7 @@ void func_80ADC8C4(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_34C == 22) { Math_SmoothStepToS(&this->unk_364, 0, 3, 0x100, 0); @@ -814,7 +821,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_350 = 4; this->unk_34C = 19; this->actor.velocity.y = 0.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DOWN); } return; @@ -825,7 +832,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { if (this->unk_34C == 19) { this->unk_34C = 17; this->collider.dim.height = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, 17); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, 17); } else if (this->unk_34C == 17) { ActorCutscene_Stop(this->cutscene); gSaveContext.save.weekEventReg[73] |= 4; @@ -836,7 +843,7 @@ void func_80ADCA64(EnSellnuts* this, GlobalContext* globalCtx) { void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { s16 currentFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animationSeg); + s16 frameCount = Animation_GetLastFrame(D_80ADD990[this->unk_34C].animation); if (this->unk_34C == 3) { if (currentFrame == frameCount) { @@ -845,18 +852,18 @@ void func_80ADCC04(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_354 = 1.0f; this->unk_358 = 1.0f; this->unk_35C = 1.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); } } else if (this->unk_34C == 21) { func_80ADAFC0(this); if (currentFrame == 0) { if (func_80ADB08C(globalCtx) < 9999.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 9999.0f); } this->unk_340 = 0x626; this->unk_34C = 0; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADC5A4; } } @@ -868,7 +875,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_338 |= 2; this->unk_338 |= 1; this->unk_340 = 0x626; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.gravity = -1.0f; this->actor.draw = EnSellnuts_Draw; this->unk_34A = 50; @@ -877,7 +884,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_34C = 3; this->unk_350 = 4; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCC04; } else if (D_80ADD940 != 0) { this->collider.dim.height = 64; @@ -885,7 +892,7 @@ void func_80ADCD3C(EnSellnuts* this, GlobalContext* globalCtx) { } s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + Vec3s* points = Lib_SegmentedToVirtual(path->points); s32 count = path->count; s32 var = arg2; s32 ret = false; @@ -908,7 +915,7 @@ s32 func_80ADCE4C(EnSellnuts* this, Path* path, s32 arg2) { pointY = points[var + 1].z - points[var - 1].z; } - func_8017B7F8(&sp30, func_80086B30(pointX, pointY) * 10430.378f, &sp44, &sp40, &sp3C); + func_8017B7F8(&sp30, RADF_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; } @@ -922,7 +929,7 @@ f32 func_80ADCFE8(Path* path, s32 arg1, Vec3f* pos, Vec3s* arg3) { Vec3s* points; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[arg1]; sp20.x = points->x; sp20.y = points->y; @@ -950,7 +957,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - this->path = func_8013D648(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENSELLNUTS_GET_FC00(&this->actor), 0x3F); this->cutscene = this->actor.cutscene; Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.cylRadius = 0; @@ -982,7 +989,7 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; this->unk_34A = 50; this->unk_34C = 4; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADB254; return; } @@ -995,23 +1002,23 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.draw = NULL; this->unk_34C = 20; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_35C = 1.0f; this->unk_358 = 1.0f; this->unk_354 = 1.0f; this->unk_360 = 1.0f; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADC5A4; } else { this->unk_338 |= 2; this->unk_338 &= ~1; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.gravity = 0.0f; this->actor.draw = NULL; this->unk_34C = 4; this->unk_34E = 20; this->collider.dim.height = 64; - func_8013BC6C(&this->skelAnime, D_80ADD990, this->unk_34C); + SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80ADD990, this->unk_34C); this->actionFunc = func_80ADCD3C; } } 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 c93402fbc..92d4c7514 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.c +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.c @@ -2,11 +2,12 @@ * File: z_en_shn.c * Overlay: ovl_En_Shn * Description: Swamp Tourist Center Guide + * Shashin(Shn) ~ Photo */ #include "z_en_shn.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnShn*)thisx) @@ -14,11 +15,42 @@ void EnShn_Init(Actor* thisx, GlobalContext* globalCtx); void EnShn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnShn_Update(Actor* thisx, GlobalContext* globalCtx); void EnShn_Draw(Actor* thisx, GlobalContext* globalCtx); - void func_80AE69E8(EnShn* this, GlobalContext* globalCtx); void func_80AE6A64(EnShn* this, GlobalContext* globalCtx); +s32 func_80AE6704(EnShn* this, GlobalContext* globalCtx); + +// Could be something related to text/dialogue? +static UNK_TYPE D_80AE6F00[] = { + 0x00170800, 0x0B0E09C4, 0x0C0F09C5, 0x0C111708, 0x03018C04, 0x018E1901, 0x860F00FF, 0x1E001300, 0x00011501, + 0x47280012, 0x28001928, 0x002D2800, 0x5D280093, 0x28003319, 0x00472C09, 0xE70C2F00, 0x000C1210, 0x2C09CB0C, + 0x2F00000C, 0x0F09CC0C, 0x0F09CD0C, 0x0500A500, 0xCB00CB2C, 0x09D10C2F, 0x00000C0F, 0x09D20C19, 0xFFE62C09, + 0xD30C2F00, 0x000C0F09, 0xD40C0F09, 0xD50C0500, 0x9200B200, 0xB22C09D9, 0x0C2F0000, 0x0C0F09DA, 0x0C102C09, + 0xE80C2F00, 0x000C0F09, 0xE90C0F09, 0xEA0C0057, 0x04001712, 0x06000C00, 0x0013000C, 0x0C115704, 0x0700000E, + 0x09EB0C12, 0x16101206, 0x00060000, 0x1300060C, 0x07FFEC2C, 0x09EC0C2F, 0x00000C0F, 0x09ED0C0F, 0x09EE0C00, + 0x57040017, 0x1206000C, 0x00001300, 0x0C0C1157, 0x04070000, 0x0E09EF0C, 0x12161012, 0x06000600, 0x00130006, + 0x0C07FFEC, 0x12060004, 0x00001300, 0x040C0700, 0x000E09CE, 0x0C161012, 0x06000200, 0x00130002, 0x0C070000, + 0x0E09D80C, 0x16100C0F, 0x09CF0C1C, 0x05011509, 0x0000100E, 0x09D60C19, 0xFFF10037, 0x40001C2C, 0x09DB0C2F, + 0x00000C0F, 0x09DC0C0F, 0x09DD0C0F, 0x09DE0C0F, 0x09DF0C11, 0x3740102C, 0x09E00C2F, 0x00000C0F, 0x09E10C0F, + 0x09E20C10, 0x00374000, 0x180E09DB, 0x0C0F09DC, 0x0C0F09DD, 0x0C0F09DE, 0x0C0F09DF, 0x0C113740, 0x100E09E0, + 0x0C0F09E1, 0x0C0F09E2, 0x0C100E09, 0xC90C0F09, 0xCA0C100E, 0x09C60C10, 0x001402FF, 0xED0E09C8, 0x0C19FE69 +}; + +static UNK_TYPE D_80AE70B0[] = { 0x0E09D00C, 0x16100000 }; + +static UNK_TYPE D_80AE70B8[] = { + 0x28001228, 0x00152800, 0x28280055, 0x28008A28, 0x002D1900, 0x402C09E7, 0x0C12102C, 0x09CB2F00, 0x000C0F09, + 0xCC0C0F09, 0xCD0C0500, 0xA000C600, 0xC62C09D1, 0x2F00000C, 0x0F09D20C, 0x19FFE72C, 0x09D32F00, 0x000C0F09, + 0xD40C0F09, 0xD50C0500, 0x8F00AF00, 0xAF2C09D9, 0x2F00000C, 0x0F09DA0C, 0x102C09E8, 0x2F00000C, 0x0F09E90C, + 0x0F09EA0C, 0x00570400, 0x17120600, 0x0C000013, 0x000C0C11, 0x57040700, 0x000E09EB, 0x0C121610, 0x12060006, + 0x00001300, 0x060C07FF, 0xEC2C09EC, 0x2F00000C, 0x0F09ED0C, 0x0F09EE0C, 0x00570800, 0x17120600, 0x0C000013, + 0x000C0C11, 0x57080700, 0x000E09EF, 0x0C121610, 0x12060006, 0x00001300, 0x060C07FF, 0xEC120600, 0x04000013, + 0x00040C07, 0x00000E09, 0xCE0C1610, 0x12060002, 0x00001300, 0x020C0700, 0x000E09D8, 0x0C16100C, 0x0F09CF0C, + 0x1C050115, 0x09000010, 0x0E09D60C, 0x19FFF100, +}; + +static UNK_TYPE D_80AE71C4[] = { 0x00374000, 0x1C2C09DB, 0x0C2F0000, 0x0C0F09DC, 0x0C0F09DD, 0x0C0F09DE, 0x0C0F09DF, + 0x0C113740, 0x102C09E0, 0x0C2F0000, 0x0C0F09E1, 0x0C0F09E2, 0x0C100000 }; -#if 0 const ActorInit En_Shn_InitVars = { ACTOR_EN_SHN, ACTORCAT_NPC, @@ -31,47 +63,379 @@ const ActorInit En_Shn_InitVars = { (ActorFunc)EnShn_Draw, }; -#endif +static AnimationInfoS sAnimations[] = { + { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, 0 }, + { &object_shn_Anim_00D9D0, 1.0f, 0, -1, 0, -4 }, + { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, 0 }, + { &object_shn_Anim_00E6C4, 1.0f, 0, -1, 0, -4 }, +}; -extern UNK_TYPE D_0600B738; -extern UNK_TYPE D_0600E7D0; +static s32 D_80AE7258[] = { 0, 2, 3, 8, 10, 1 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6130.s") +void func_80AE6130(EnShn* this) { + this->skelAnime.playSpeed = this->playSpeed; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE615C.s") +s32 func_80AE615C(EnShn* this, s32 arg1) { + s32 phi_v0 = 0; + s32 phi_v1 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE61C0.s") + if (arg1 != this->unk_2E8) { + phi_v0 = 1; + } + if (phi_v0 != 0) { + this->unk_2E8 = arg1; + phi_v1 = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + this->playSpeed = this->skelAnime.playSpeed; + } + return phi_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE625C.s") +s32 EnShn_IsFacingPlayer(EnShn* this) { + s16 phi_v1; + f32 range; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE626C.s") + if (this->unk_2C8 == 0) { + phi_v1 = 0; + } else { + this->unk_2C8--; + phi_v1 = this->unk_2C8; + } + if (phi_v1 == 0) { + this->unk_2EC ^= 1; + this->unk_2C8 = Rand_S16Offset(0x1E, 0x1E); + } + if (this->unk_2EC != 0) { + range = 120.0f; + } else { + range = 80.0f; + } + return Actor_IsFacingAndNearPlayer(&this->actor, range, 0x238C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE63A8.s") +Player* EnShn_GetPlayer(EnShn* this, GlobalContext* globalCtx) { + return GET_PLAYER(globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6488.s") +void func_80AE626C(EnShn* this) { + s32 topPad; + Vec3f playerPos; + Vec3f shnPos; + s32 bottomPad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE65F4.s") + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.world.pos); + Math_Vec3f_Copy(&shnPos, &this->actor.world.pos); + Math_ApproachS(&this->unk_2BC, (Math_Vec3f_Yaw(&shnPos, &playerPos) - this->actor.shape.rot.y), 4, 0x2AA8); + this->unk_2BC = CLAMP(this->unk_2BC, -0x1FFE, 0x1FFE); + Math_Vec3f_Copy(&shnPos, &this->actor.focus.pos); + if (this->shnPlayerRef->actor.id == ACTOR_PLAYER) { + playerPos.y = this->shnPlayerRef->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.focus.pos); + } + Math_ApproachS(&this->unk_2BA, Math_Vec3f_Pitch(&shnPos, &playerPos), 4, 0x2AA8); + this->unk_2BA = CLAMP(this->unk_2BA, -0x1554, 0x1554); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6704.s") +void func_80AE63A8(EnShn* this, GlobalContext* globalCtx) { + s16 phi_v1; + s16 phi_v1_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6880.s") + this->shnPlayerRef = EnShn_GetPlayer(this, globalCtx); + if ((this->unk_1D8 & 8) && (this->shnPlayerRef != NULL)) { + if (this->unk_2CA == 0) { + phi_v1 = 0; + } else { + this->unk_2CA--; + phi_v1 = this->unk_2CA; + } + if (phi_v1 == 0) { + func_80AE626C(this); + this->unk_1D8 &= ~0x20; + this->unk_1D8 |= 0x10; + return; + } + } + if (this->unk_1D8 & 0x10) { + this->unk_1D8 &= ~0x10; + this->unk_2BA = 0; + this->unk_2BC = 0; + this->unk_2CA = 20; + return; + } + if (this->unk_2CA == 0) { + phi_v1_2 = 0; + } else { + this->unk_2CA--; + phi_v1_2 = this->unk_2CA; + } + if (phi_v1_2 == 0) { + this->unk_1D8 |= 0x20; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE68F0.s") +void func_80AE6488(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 tempMsgState; + f32 phi_f0_2; + f32 phi_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE69E8.s") + tempMsgState = Message_GetState(&globalCtx->msgCtx); + this->unk_2D4 += (this->unk_2D0 != 0.0f) ? 40.0f : -40.0f; + this->unk_2D4 = CLAMP(this->unk_2D4, 0.0f, 80.0f); + Matrix_InsertTranslation(this->unk_2D4, 0.0f, 0.0f, 1); + if ((&this->actor == player->targetActor) && + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId >= 0x201)) && + (tempMsgState == 3) && (this->msgState == 3)) { + if (globalCtx->state.frames % 2 == 0) { + if (this->unk_2D0 != 0.0f) { + this->unk_2D0 = 0.0f; + } else { + this->unk_2D0 = 1.0f; + } + } + } else { + this->unk_2D0 = 0.0f; + } + this->msgState = tempMsgState; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6A64.s") +s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + u16 temp = globalCtx->msgCtx.currentTextId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Init.s") + if (player->stateFlags1 & 0x40) { + if (this->unk_1DA != temp) { + if ((this->unk_1D8 & 0x80) || (this->unk_1D8 & 0x100)) { + this->unk_1D8 |= 8; + func_80AE615C(this, 1); + } + if (temp == 0x9C5) { + if (1) {} + this->unk_1D8 |= 8; + func_80AE615C(this, 1); + } + } + this->unk_1DA = temp; + this->unk_1D8 |= 0x40; + } else if (this->unk_1D8 & 0x40) { + if (!(gSaveContext.save.weekEventReg[23] & 8)) { + func_80AE615C(this, 3); + } + this->unk_1DA = 0; + this->unk_1D8 &= ~0x40; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Destroy.s") +s32 func_80AE6704(EnShn* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Update.s") + switch (this->unk_2C6) { + case 0: + if (!CHECK_QUEST_ITEM(QUEST_UNK_19)) { + this->unk_2C6 = 6; + ret = 1; + } else { + this->unk_2C6++; + } + break; + case 1: + case 2: + case 3: + case 4: + case 5: + if (func_8013A4C4(D_80AE7258[this->unk_2C6])) { + this->unk_2C6 = 6; + ret = 1; + REMOVE_QUEST_ITEM(QUEST_UNK_19); + } else { + this->unk_2C6++; + } + break; + case 6: + gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_800B7298(globalCtx, &this->actor, 7); + globalCtx->nextEntranceIndex = 0x8460; + gSaveContext.nextCutsceneIndex = 0; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 7; + this->unk_2C6++; + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6CF0.s") +UNK_TYPE* func_80AE6880(EnShn* this, GlobalContext* globalCtx) { + if (this->unk_2BE != 0) { + return D_80AE70B0; + } + if (this->unk_1D8 & 0x80) { + this->unk_2D8 = func_80AE6704; + return D_80AE70B8; + } + if (this->unk_1D8 & 0x100) { + return D_80AE71C4; + } + this->unk_2D8 = func_80AE6704; + return D_80AE6F00; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6D40.s") +s32 func_80AE68F0(EnShn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/func_80AE6D90.s") + if (this->unk_1D8 & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->unk_1D8 &= ~0x180; + if (player->exchangeItemId == EXCH_ITEM_13) { + this->unk_1D8 |= 0x80; + this->unk_2E4 = player->exchangeItemId; + } else if (player->exchangeItemId != EXCH_ITEM_NONE) { + this->unk_1D8 |= 0x100; + this->unk_2E4 = player->exchangeItemId; + } + SubS_UpdateFlags(&this->unk_1D8, 0, 7); + this->unk_1DC = func_80AE6880(this, globalCtx); + this->unk_2C6 = 0; + if (gSaveContext.save.weekEventReg[23] & 8) { + this->unk_1D8 |= 8; + } + this->actionFunc = func_80AE6A64; + ret = 1; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Shn/EnShn_Draw.s") +void func_80AE69E8(EnShn* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); + if ((gSaveContext.save.weekEventReg[23] & 8) && EnShn_IsFacingPlayer(this)) { + this->unk_1D8 |= 8; + } else { + this->unk_1D8 &= ~0x8; + } +} + +void func_80AE6A64(EnShn* this, GlobalContext* globalCtx) { + s16 yawBetweenActors; + Vec3f playerPos; + Vec3f shnPos; + + if (func_8010BF58(&this->actor, globalCtx, this->unk_1DC, this->unk_2D8, &this->unk_1E0)) { + SubS_UpdateFlags(&this->unk_1D8, 3, 7); + this->unk_1D8 &= ~8; + this->unk_1D8 |= 0x20; + this->unk_2CA = 20; + this->unk_1E0 = 0; + this->unk_2BE = 0; + this->actionFunc = func_80AE69E8; + } else if (this->shnPlayerRef != 0) { + Math_Vec3f_Copy(&playerPos, &this->shnPlayerRef->actor.world.pos); + Math_Vec3f_Copy(&shnPos, &this->actor.world.pos); + yawBetweenActors = Math_Vec3f_Yaw(&shnPos, &playerPos); + Math_ApproachS(&this->actor.shape.rot.y, yawBetweenActors, 4, 0x2AA8); + } +} + +void EnShn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, NULL, this->jointTable, this->morphTable, + OBJECT_SHN_LIMB_MAX); + this->unk_2E8 = -1; + if (gSaveContext.save.weekEventReg[23] & 8) { + func_80AE615C(this, 0); + } else { + func_80AE615C(this, 2); + } + this->actor.targetMode = 6; + Actor_SetScale(&this->actor, 0.01f); + this->unk_2E0 = 0; + this->unk_2D8 = 0; + this->unk_1D8 = 0; + if (gSaveContext.save.entranceIndex != 0xA820) { + SubS_UpdateFlags(&this->unk_1D8, 3, 7); + this->unk_2BE = 0; + } else { + SubS_UpdateFlags(&this->unk_1D8, 4, 7); + this->unk_2BE = 1; + } + this->actionFunc = func_80AE69E8; +} + +void EnShn_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnShn_Update(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + func_80AE68F0(this, globalCtx); + this->actionFunc(this, globalCtx); + func_80AE65F4(this, globalCtx); + func_80AE6130(this); + func_80AE63A8(this, globalCtx); + this->unk_2E0 = 0; + func_8013C964(&this->actor, globalCtx, 120.0f, 40.0f, 0, this->unk_1D8 & 7); +} + +s32 EnShn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnShn* this = THIS; + + if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + func_80AE6488(this, globalCtx); + *dList = gObjectShnSwampGuideHead; + } + return false; +} + +Vec3f D_80AE7270 = { 1200.0f, 0.0f, 0.0f }; +void EnShn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_80AE7270, &thisx->focus.pos); + Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); + } +} + +void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnShn* this = THIS; + s32 phi_v0; + s32 phi_v1; + + if (!(this->unk_1D8 & 0x20)) { + if (this->unk_1D8 & 0x10) { + phi_v1 = 1; + } else { + phi_v1 = 0; + } + phi_v0 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == OBJECT_SHN_LIMB_HEAD) { + func_8013AD9C((this->unk_2BA + 0x4000), (this->unk_2BC + this->actor.shape.rot.y + 0x4000), &this->unk_1E8, + &this->unk_1F4, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8.x, this->unk_1E8.y, this->unk_1E8.z, 0); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); + Matrix_RotateY(this->unk_1F4.y, 1); + Matrix_InsertXRotation_s(this->unk_1F4.x, 1); + Matrix_InsertZRotation_s(this->unk_1F4.z, 1); + Matrix_StatePush(); + } +} + +void EnShn_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnShn* this = THIS; + + func_8012C5B0(globalCtx->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnShn_OverrideLimbDraw, EnShn_PostLimbDraw, + EnShn_TransformLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Shn/z_en_shn.h b/src/overlays/actors/ovl_En_Shn/z_en_shn.h index b5d98919d..bb54a8815 100644 --- a/src/overlays/actors/ovl_En_Shn/z_en_shn.h +++ b/src/overlays/actors/ovl_En_Shn/z_en_shn.h @@ -2,15 +2,44 @@ #define Z_EN_SHN_H #include "global.h" +#include "objects/object_shn/object_shn.h" struct EnShn; typedef void (*EnShnActionFunc)(struct EnShn*, GlobalContext*); typedef struct EnShn { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnShnActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x1A8]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnShnActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ UNK_TYPE1 pad_18C[0x4C]; + /* 0x1D8 */ u16 unk_1D8; + /* 0x1DA */ u16 unk_1DA; + /* 0x1DC */ UNK_TYPE* unk_1DC; + /* 0x1E0 */ s32 unk_1E0; + /* 0x1E4 */ Player* shnPlayerRef; + /* 0x1E8 */ Vec3f unk_1E8; + /* 0x1F4 */ Vec3s unk_1F4; + /* 0x1FA */ Vec3s jointTable[OBJECT_SHN_LIMB_MAX]; + /* 0x25A */ Vec3s morphTable[OBJECT_SHN_LIMB_MAX]; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ s16 unk_2C0; + /* 0x2C2 */ s16 unk_2C2; + /* 0x2C4 */ s16 unk_2C4; + /* 0x2C6 */ s16 unk_2C6; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ s16 unk_2CA; + /* 0x2CC */ f32 playSpeed; + /* 0x2D0 */ f32 unk_2D0; + /* 0x2D4 */ f32 unk_2D4; + /* 0x2D8 */ s32 unk_2D8; + /* 0x2DC */ s32 msgState; + /* 0x2E0 */ s32 unk_2E0; + /* 0x2E4 */ s32 unk_2E4; + /* 0x2E8 */ s32 unk_2E8; + /* 0x2EC */ s32 unk_2EC; } EnShn; // size = 0x2F0 extern const ActorInit En_Shn_InitVars; 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 35eddf10b..8933d5305 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -6,7 +6,7 @@ #include "z_en_si.h" -#define FLAGS 0x00000201 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_200) #define THIS ((EnSi*)thisx) 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 05929a181..f7fca7448 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.c +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Encount4/z_en_encount4.h" #include "objects/object_skb/object_skb.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSkb*)thisx) @@ -49,14 +49,20 @@ void func_809964A0(EnSkb* this, GlobalContext* globalCtx); s32 func_80996594(EnSkb* this, GlobalContext* globalCtx); void func_80996BEC(EnSkb* this, GlobalContext* globalCtx); -static ActorAnimationEntry sAnimations[] = { - { &object_skb_Anim_0064E0, 1.0f, 0.0f, 0.0f, 0, -4.0 }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, 3, 4.0f }, { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -4.0 }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, 2, -4.0 }, { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, 0, -4.0 }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, 0, -4.0 }, { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, 0, -4.0 }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, 2, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, 2, -4.0 }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, 0, -4.0 }, +static AnimationInfo sAnimations[] = { + { &object_skb_Anim_0064E0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0 }, + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0 }, + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0 }, + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0 }, }; static Vec3f D_80997468[] = { @@ -224,8 +230,9 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_3D6 = ENSKB_GET_F0(&this->actor); this->actor.floorHeight = this->actor.world.pos.y; - if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && (globalCtx->csCtx.unk_12 == 0)) { - this->actor.flags |= 0x100000; + if ((globalCtx->sceneNum == SCENE_BOTI) && (gSaveContext.sceneSetupIndex == 1) && + (globalCtx->csCtx.currentCsIndex == 0)) { + this->actor.flags |= ACTOR_FLAG_100000; } switch (this->unk_3D6) { @@ -242,7 +249,7 @@ void EnSkb_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - this->actor.flags &= ~0x100000; + this->actor.flags &= ~ACTOR_FLAG_100000; this->actor.hintId = 0x55; func_8099495C(this, globalCtx); break; @@ -281,8 +288,8 @@ void func_80994DA8(EnSkb* this, GlobalContext* globalCtx) { } void func_80994E2C(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 1); - this->actor.flags &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_APPEAR); this->unk_3D0 = 0; this->unk_3DE = 0; @@ -294,7 +301,7 @@ void func_80994E94(EnSkb* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } Math_ApproachZeroF(&this->actor.shape.yOffset, 1.0f, 800.0f); @@ -313,9 +320,9 @@ void func_80994F7C(EnSkb* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - func_801518B0(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(globalCtx, 0x13F8, &this->actor); } else { - func_801518B0(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(globalCtx, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; @@ -334,19 +341,19 @@ void func_80995068(EnSkb* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_3E2 = 1; if (this->unk_3E0 == 1) { - func_801518B0(globalCtx, 0x13F8, &this->actor); + Message_StartTextbox(globalCtx, 0x13F8, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } } else { - func_801518B0(globalCtx, 0x13F6, &this->actor); + Message_StartTextbox(globalCtx, 0x13F6, &this->actor); this->unk_3E0 = 1; } this->actionFunc = func_80995190; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_CAPTAIN) { - this->actor.flags |= (0x4 | 0x1); - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0x55; this->actor.colChkInfo.mass = MASS_HEAVY; func_80995A30(this); @@ -365,16 +372,16 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - func_801518B0(globalCtx, 0x13F7, &this->actor); + if (Message_ShouldAdvance(globalCtx)) { + Message_StartTextbox(globalCtx, 0x13F7, &this->actor); if (this->unk_3DE == 2) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); } } break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = func_80995244; } break; @@ -382,8 +389,8 @@ void func_80995190(EnSkb* this, GlobalContext* globalCtx) { } void func_80995244(EnSkb* this, GlobalContext* globalCtx) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); this->unk_3E2 = 0; switch (this->unk_3DE) { @@ -406,7 +413,7 @@ void func_80995244(EnSkb* this, GlobalContext* globalCtx) { } void func_809952D8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 9; this->actionFunc = func_8099533C; @@ -417,8 +424,8 @@ void func_809952D8(EnSkb* this) { void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; @@ -428,7 +435,7 @@ void func_8099533C(EnSkb* this, GlobalContext* globalCtx) { } void func_809953E8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 10; this->actionFunc = func_8099544C; @@ -439,8 +446,8 @@ void func_809953E8(EnSkb* this) { void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f)) { this->actor.hintId = 0x55; @@ -450,7 +457,7 @@ void func_8099544C(EnSkb* this, GlobalContext* globalCtx) { } void func_809954F8(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->unk_3DE = 11; this->actionFunc = func_8099556C; @@ -476,8 +483,8 @@ void func_8099556C(EnSkb* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = Math_SinS(this->unk_3D4 * sp26) * 20000.0f; if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80994F7C(this, globalCtx); } else if (Actor_IsFacingPlayer(&this->actor, 0x2AAA) && (this->actor.xzDistToPlayer < 200.0f) && (this->skelAnime.curFrame > 24.0f) && (this->skelAnime.curFrame < 28.0f)) { @@ -493,14 +500,14 @@ void func_8099571C(EnSkb* this) { this->unk_3DC = 0; this->actor.shape.shadowScale = 0.0f; if (this->unk_3DE == 9) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.speedXZ = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; } else if (this->unk_3DE == 0xA) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.gravity = -1.0f; this->actor.velocity.y = 2.0f; @@ -532,7 +539,7 @@ void func_809958F4(EnSkb* this) { Animation_Change(&this->skelAnime, &object_skb_Anim_003584, -1.0f, Animation_GetLastFrame(&object_skb_Anim_003584), 0.0f, 2, -4.0f); this->unk_3E4 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); this->unk_3DE = 1; @@ -554,7 +561,7 @@ void func_8099599C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995A30(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); this->actor.speedXZ = 1.6f; this->unk_3DA = 0; this->unk_3DE = 2; @@ -563,11 +570,11 @@ void func_80995A30(EnSkb* this) { void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.hintId = 0xFF; this->actor.colChkInfo.mass = MASS_HEAVY; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); func_8099504C(this); return; } @@ -579,7 +586,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + this->unk_3DA, 1, 0x2EE, 0); this->actor.world.rot.y = this->actor.shape.rot.y; if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { - Actor_PlaySfxAtPos(&this->actor, 0x3830); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_WALK); } if ((this->actor.xzDistToPlayer > 800.0f) || func_80996594(this, globalCtx)) { @@ -590,7 +597,7 @@ void func_80995A8C(EnSkb* this, GlobalContext* globalCtx) { } void func_80995C24(EnSkb* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speedXZ = 0.0f; this->unk_3DE = 3; @@ -675,17 +682,17 @@ void func_80995E64(EnSkb* this, GlobalContext* globalCtx) { void func_80995F98(EnSkb* this) { if ((this->unk_3DE == 9) || (this->unk_3DE == 0xA)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 8); this->actor.gravity = -1.0f; this->actor.speedXZ = 1.0f; } else if (this->unk_3DE == 0xB) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 9); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 9); this->actor.speedXZ = 3.2f; this->actor.velocity.y = 2.0f; this->actor.gravity = -1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -4.0f; } @@ -721,13 +728,13 @@ void func_809960AC(EnSkb* this, GlobalContext* globalCtx) { } void func_809961E4(EnSkb* this, GlobalContext* globalCtx) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); this->unk_3D8 |= 0x40; if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; } this->unk_3E4 = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALKID_DEAD); this->unk_3DE = 7; this->actionFunc = func_80996284; @@ -747,19 +754,19 @@ void func_809962D4(EnSkb* this) { } void func_8099630C(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { func_809961E4(this, globalCtx); } - } else if (this->unk_3D2 == 1) { + } else if (this->drawDmgEffTimer == 1) { func_80996BEC(this, globalCtx); } } @@ -769,13 +776,13 @@ void func_809963C4(EnSkb* this) { } void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 == 0) { - this->unk_3D2 = 0; - this->unk_230 = 0.0f; - this->unk_22C = 0.0f; + if (this->drawDmgEffTimer == 0) { + this->drawDmgEffTimer = 0; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); this->unk_3D8 |= 1; func_80995F98(this); } else { @@ -787,7 +794,7 @@ void func_809963D8(EnSkb* this, GlobalContext* globalCtx) { void func_80996474(EnSkb* this) { this->unk_3D0 = 0; this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_809964A0; } @@ -807,7 +814,7 @@ void func_809964DC(EnSkb* this, GlobalContext* globalCtx) { } } -s32 func_80996544(EnSkbVec2f arg0, EnSkbVec2f arg1) { +s32 func_80996544(Vec2f arg0, Vec2f arg1) { s32 ret; if ((arg1.x * arg0.z) < (arg0.x * arg1.z)) { @@ -822,8 +829,8 @@ s32 func_80996544(EnSkbVec2f arg0, EnSkbVec2f arg1) { s32 func_80996594(EnSkb* this, GlobalContext* globalCtx) { s32 temp_s2; s32 j; - EnSkbVec2f sp60; - EnSkbVec2f sp58; + Vec2f sp60; + Vec2f sp58; s32 sp54 = true; f32 worldZ; s32 i = 0; @@ -878,10 +885,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { if (this->actionFunc == func_8099630C) { switch (this->actor.colChkInfo.damageEffect) { default: - if (this->unk_3D2 >= 2) { + if (this->drawDmgEffTimer > 1) { func_80996BEC(this, globalCtx); } - this->unk_3D2 = 0; + this->drawDmgEffTimer = 0; break; case 1: @@ -902,10 +909,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { switch (this->actor.colChkInfo.damageEffect) { case 11: - this->unk_3E6 = 30; - this->unk_3D2 = 40; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffTimer = 40; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 40); func_80995E08(this); break; @@ -916,10 +923,10 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { break; case 2: - this->unk_3D2 = 0x50; - this->unk_3E6 = 0; - this->unk_22C = 1.0f; - this->unk_230 = 0.0f; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.0f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); this->unk_3D8 |= 1; func_80995F98(this); @@ -928,25 +935,25 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALKID_DAMAGE); - this->unk_3D2 = 0x50; + this->drawDmgEffTimer = 80; } else { - this->unk_3D2 = 3; + this->drawDmgEffTimer = 3; } - this->unk_3E6 = 0xB; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); func_809962D4(this); break; case 4: - this->unk_3D2 = 0x28; - this->unk_3E6 = 0x14; - this->unk_22C = 1.0f; - this->unk_230 = 0.5f; + this->drawDmgEffTimer = 40; + 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_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_809963C4(this); break; @@ -962,7 +969,7 @@ void func_8099672C(EnSkb* this, GlobalContext* globalCtx) { case 13: Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 8); - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); func_80995F98(this); break; } @@ -1008,29 +1015,29 @@ void func_80996BEC(EnSkb* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EV_ICE_BROKEN); for (i = 0; i < end; i++) { - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_234[i]); + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->limbPos[i]); sp84.x = Math_SinS(yaw) * 3.0f; sp84.z = Math_CosS(yaw) * 3.0f; sp84.y = (Rand_ZeroOne() * 4.0f) + 4.0f; - EffectSsEnIce_Spawn(globalCtx, &this->unk_234[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); + EffectSsEnIce_Spawn(globalCtx, &this->limbPos[i], 0.6f, &sp84, &D_80997558, &D_80997550, &D_80997554, 30); } } void func_80996D68(EnSkb* this, GlobalContext* globalCtx) { - if (this->unk_3D2 > 0) { - this->unk_3D2--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } if (this->actionFunc != func_8099630C) { - if (this->unk_3D2 < 20) { + if (this->drawDmgEffTimer < 20) { if (this->actionFunc == func_809963D8) { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.03f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); } else { - Math_SmoothStepToF(&this->unk_230, 0.0f, 0.5f, 0.01f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.01f, 0.0f); } - this->unk_22C = this->unk_3D2 * 0.05f; + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->unk_230, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } } @@ -1101,15 +1108,15 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve Actor_SpawnBodyParts(&this->actor, globalCtx, 1, dList); } - if (this->unk_3D2 != 0) { + if (this->drawDmgEffTimer != 0) { if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { - Matrix_GetStateTranslation(&this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_GetStateTranslation(&this->limbPos[this->limbCount]); + this->limbCount++; } else if ((limbIndex == 11) && !(this->unk_3D8 & 2)) { - Matrix_MultiplyVector3fByState(&D_80997564, &this->unk_234[this->unk_2DC]); - this->unk_2DC++; + Matrix_MultiplyVector3fByState(&D_80997564, &this->limbPos[this->limbCount]); + this->limbCount++; } } } @@ -1117,13 +1124,13 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve void EnSkb_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSkb* this = THIS; - this->unk_2DC = 0; + this->limbCount = 0; func_8012C28C(globalCtx->state.gfxCtx); SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSkb_OverrideLimbDraw, EnSkb_PostLimbDraw, &this->actor); - if (this->unk_3D2 > 0) { - func_800BE680(globalCtx, &this->actor, this->unk_234, this->unk_2DC, this->unk_230, 0.5f, this->unk_22C, - this->unk_3E6); + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, this->limbCount, this->drawDmgEffScale, 0.5f, + this->drawDmgEffAlpha, this->drawDmgEffType); } if (this->unk_3D8 & 0x40) { diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index 59186808d..fe5722e53 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -9,25 +9,20 @@ typedef void (*EnSkbActionFunc)(struct EnSkb*, GlobalContext*); #define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) -typedef struct { - f32 x; - f32 z; -} EnSkbVec2f; - typedef struct EnSkb { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ ColliderJntSph collider; /* 0x01A8 */ ColliderJntSphElement colliderElements[2]; /* 0x0228 */ EnSkbActionFunc actionFunc; - /* 0x022C */ f32 unk_22C; - /* 0x0230 */ f32 unk_230; - /* 0x0234 */ Vec3f unk_234[14]; - /* 0x02DC */ s32 unk_2DC; + /* 0x022C */ f32 drawDmgEffAlpha; + /* 0x0230 */ f32 drawDmgEffScale; + /* 0x0234 */ Vec3f limbPos[14]; + /* 0x02DC */ s32 limbCount; /* 0x02E0 */ Vec3s jointTable[20]; /* 0x0358 */ Vec3s morphTable[20]; /* 0x03D0 */ s16 unk_3D0; - /* 0x03D2 */ s16 unk_3D2; + /* 0x03D2 */ s16 drawDmgEffTimer; /* 0x03D4 */ s16 unk_3D4; /* 0x03D6 */ s16 unk_3D6; /* 0x03D8 */ s16 unk_3D8; @@ -38,7 +33,7 @@ typedef struct EnSkb { /* 0x03E2 */ s16 unk_3E2; /* 0x03E4 */ u8 unk_3E4; /* 0x03E5 */ u8 unk_3E5; - /* 0x03E6 */ u8 unk_3E6; + /* 0x03E6 */ u8 drawDmgEffType; } EnSkb; // size = 0x3E8 extern const ActorInit En_Skb_InitVars; 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 d313450f5..539d458ad 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -6,7 +6,7 @@ #include "z_en_slime.h" -#define FLAGS 0x00000215 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_200) #define THIS ((EnSlime*)thisx) 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 8f28748b7..32d38ecb9 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -6,7 +6,7 @@ #include "z_en_snowman.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSnowman*)thisx) 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 bad4bffe2..c91a50d80 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -12,7 +12,7 @@ #include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSob1*)thisx) @@ -20,13 +20,14 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx); -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx); + +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx); -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx); void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx); void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx); @@ -52,12 +53,12 @@ void EnSob1_Blink(EnSob1* this); s32 EnSob1_TakeItemOffShelf(EnSob1* this); s32 EnSob1_ReturnItemToShelf(EnSob1* this); -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -static ActorAnimationEntryS sAnimationsBombShopkeeper[] = { - { &object_rs_Anim_009120, 2.0f, 0, -1, 0, 20 }, - { &object_rs_Anim_008268, 1.0f, 0, -1, 2, 0 }, - { &object_rs_Anim_0087BC, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimationsBombShopkeeper[] = { + { &object_rs_Anim_009120, 2.0f, 0, -1, ANIMMODE_LOOP, 20 }, + { &object_rs_Anim_008268, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_rs_Anim_0087BC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Sob1_InitVars = { @@ -139,10 +140,10 @@ static InitChainEntry sInitChain[] = { }; static EnSob1ActionFunc sInitFuncs[] = { - EnSob1_InitZoraShopkeeper, - EnSob1_InitGoronShopkeeper, - EnSob1_InitBombShopkeeper, - EnSob1_InitGoronShopkeeper, + EnSob1_ZoraShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, + EnSob1_BombShopkeeper_Init, + EnSob1_GoronShopkeeper_Init, }; static Vec3f sPosOffset[] = { @@ -152,17 +153,17 @@ static Vec3f sPosOffset[] = { { 0.0f, -4.0f, 0.0f }, }; -void EnSob1_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s32 idx) { +void EnSob1_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { f32 frameCount; animations += idx; if (animations->frameCount < 0) { - frameCount = Animation_GetLastFrame(animations->animationSeg); + frameCount = Animation_GetLastFrame(animations->animation); } else { frameCount = animations->frameCount; } - Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animation, animations->playSpeed, animations->startFrame, frameCount, + animations->mode, animations->morphFrames); } void EnSob1_SetupAction(EnSob1* this, EnSob1ActionFunc action) { @@ -186,7 +187,7 @@ u16 EnSob1_GetTalkOption(EnSob1* this, GlobalContext* globalCtx) { if (this->shopType == BOMB_SHOP) { if (gSaveContext.save.day == 1 && gSaveContext.save.time >= CLOCK_TIME(6, 00)) { return 0x648; - } else if (gSaveContext.save.weekEventReg[0x21] & 8) { + } else if (gSaveContext.save.weekEventReg[33] & 8) { return 0x649; } else { return 0x64A; @@ -256,58 +257,58 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { } else if (this->shopType == ZORA_SHOP) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (gSaveContext.save.weekEventReg[0x39] & 0x10) { + if (gSaveContext.save.weekEventReg[57] & 0x10) { return 0x12CF; } - gSaveContext.save.weekEventReg[0x39] |= 0x10; + gSaveContext.save.weekEventReg[57] |= 0x10; return 0x12CE; case PLAYER_FORM_DEKU: - if (gSaveContext.save.weekEventReg[0x39] & 0x20) { + if (gSaveContext.save.weekEventReg[57] & 0x20) { return 0x12D1; } - gSaveContext.save.weekEventReg[0x39] |= 0x20; + gSaveContext.save.weekEventReg[57] |= 0x20; return 0x12D0; case PLAYER_FORM_GORON: - if (gSaveContext.save.weekEventReg[0x39] & 0x40) { + if (gSaveContext.save.weekEventReg[57] & 0x40) { return 0x12D3; } - gSaveContext.save.weekEventReg[0x39] |= 0x40; + gSaveContext.save.weekEventReg[57] |= 0x40; return 0x12D2; case PLAYER_FORM_ZORA: - if (gSaveContext.save.weekEventReg[0x39] & 0x80) { + if (gSaveContext.save.weekEventReg[57] & 0x80) { return 0x12D5; } - gSaveContext.save.weekEventReg[0x39] |= 0x80; + gSaveContext.save.weekEventReg[57] |= 0x80; return 0x12D4; default: return 0x12CE; } } else if (this->shopType == GORON_SHOP) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.save.weekEventReg[0x3A] & 4) { + if (gSaveContext.save.weekEventReg[58] & 4) { return 0xBB9; } - gSaveContext.save.weekEventReg[0x3A] |= 4; + gSaveContext.save.weekEventReg[58] |= 4; return 0xBB8; } else { - if (gSaveContext.save.weekEventReg[0x3A] & 8) { + if (gSaveContext.save.weekEventReg[58] & 8) { return 0xBBB; } - gSaveContext.save.weekEventReg[0x3A] |= 8; + gSaveContext.save.weekEventReg[58] |= 8; return 0xBBA; } } else if (this->shopType == GORON_SHOP_SPRING) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.save.weekEventReg[0x3A] & 0x10) { + if (gSaveContext.save.weekEventReg[58] & 0x10) { return 0xBBD; } - gSaveContext.save.weekEventReg[0x3A] |= 0x10; + gSaveContext.save.weekEventReg[58] |= 0x10; return 0xBBC; } else { - if (gSaveContext.save.weekEventReg[0x3A] & 0x20) { + if (gSaveContext.save.weekEventReg[58] & 0x20) { return 0xBBF; } - gSaveContext.save.weekEventReg[0x3A] |= 0x20; + gSaveContext.save.weekEventReg[58] |= 0x20; return 0xBBE; } } @@ -329,12 +330,12 @@ u16 EnSob1_GetGoodbye(EnSob1* this) { return 0x64C; } -void EnSob1_EndInteractionBombShop(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_EndInteraction(EnSob1* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; this->goodbyeTextId = EnSob1_GetGoodbye(this); - func_801518B0(globalCtx, this->goodbyeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->goodbyeTextId, &this->actor); EnSob1_SetupAction(this, EnSob1_EndingInteraction); } @@ -382,7 +383,7 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { this->shopType = ZORA_SHOP; break; case GORON_SHOP: - if (gSaveContext.save.weekEventReg[0x21] & 0x80) { + if (gSaveContext.save.weekEventReg[33] & 0x80) { this->shopType = GORON_SHOP_SPRING; } else { this->shopType = GORON_SHOP; @@ -451,7 +452,7 @@ void EnSob1_EndInteraction(GlobalContext* globalCtx, EnSob1* this) { s32 EnSob1_TestEndInteraction(EnSob1* this, GlobalContext* globalCtx, Input* input) { if (CHECK_BTN_ALL(input->press.button, BTN_B)) { if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -502,7 +503,7 @@ void EnSob1_SetupLookToShopkeeperFromShelf(GlobalContext* globalCtx, EnSob1* thi } void EnSob1_EndingInteraction(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { EnSob1_EndInteraction(globalCtx, this); } } @@ -531,7 +532,7 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { } player->stateFlags2 |= 0x20000000; this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); if (ENSOB1_GET_SHOPTYPE(&this->actor) == BOMB_SHOP) { this->headRotTarget = -0x2000; } @@ -606,7 +607,7 @@ void EnSob1_Hello(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if ((talkState == 5) && (func_80147624(globalCtx)) && + if ((talkState == 5) && (Message_ShouldAdvance(globalCtx)) && (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx)))) { if (this->welcomeTextId == 0x68A) { // Welcome text when wearing Kafei's mask EnSob1_EndInteraction(globalCtx, this); @@ -625,7 +626,7 @@ s32 EnSob1_FacingShopkeeperDialogResult(EnSob1* this, GlobalContext* globalCtx) case 1: func_8019F230(); if (this->shopType == BOMB_SHOP) { - EnSob1_EndInteractionBombShop(this, globalCtx); + EnSob1_BombShopkeeper_EndInteraction(this, globalCtx); } else { EnSob1_EndInteraction(globalCtx, this); } @@ -658,7 +659,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); if (!EnSob1_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if (!func_80147624(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { + if (!Message_ShouldAdvance(globalCtx) || !EnSob1_FacingShopkeeperDialogResult(this, globalCtx)) { if (this->stickAccumX > 0) { cursorIdx = EnSob1_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { @@ -676,7 +677,7 @@ void EnSob1_FaceShopkeeper(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_TalkingToShopkeeper(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnSob1_StartShopping(globalCtx, this); } } @@ -710,10 +711,9 @@ void EnSob1_EndWalk(EnSob1* this, GlobalContext* globalCtx) { s16 curFrame = this->skelAnime.curFrame / this->skelAnime.playSpeed; s16 animLastFrame = Animation_GetLastFrame(&object_rs_Anim_009120) / (s16)this->skelAnime.playSpeed; - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx - 1, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx - 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); if (distSq < 12.0f) { @@ -749,10 +749,9 @@ void EnSob1_Walk(EnSob1* this, GlobalContext* globalCtx) { } } if (this->path != NULL) { - Math_SmoothStepToS( - &this->actor.world.rot.y, - EnSob1_GetXZAngleAndDistanceSqToPoint(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), 4, - 1000, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, + EnSob1_GetDistSqAndOrient(this->path, this->pathPointsIdx, &this->actor.world.pos, &distSq), + 4, 1000, 1); this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.speedXZ = 2.0f; if (distSq < SQ(5.0f)) { @@ -789,7 +788,7 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { } player->stateFlags2 |= 0x20000000; this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); this->wasTalkedToWhileWalking = true; } else { if ((player->actor.world.pos.x >= this->posXZRange.xMin && @@ -1019,7 +1018,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { if (EnSob1_TakeItemOffShelf(this) && talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnSob1_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnSob1_HandleCanBuyItem(globalCtx, this); @@ -1036,7 +1035,7 @@ void EnSob1_SelectItem(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); } @@ -1046,7 +1045,7 @@ void EnSob1_CannotBuy(EnSob1* this, GlobalContext* globalCtx) { void EnSob1_CanBuy(EnSob1* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1066,7 +1065,7 @@ void EnSob1_BuyItemWithFanfare(EnSob1* this, GlobalContext* globalCtx) { } void EnSob1_SetupItemPurchased(EnSob1* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; EnSob1_SetupAction(this, EnSob1_ItemPurchased); @@ -1085,13 +1084,13 @@ void EnSob1_ContinueShopping(EnSob1* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnGirlA* item; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && (func_80147624(globalCtx))) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && (Message_ShouldAdvance(globalCtx))) { EnSob1_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->welcomeTextId, &this->actor); + Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); EnSob1_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 200.0f, EXCH_ITEM_MINUS1); } @@ -1192,10 +1191,7 @@ void EnSob1_UpdateCursorAnim(EnSob1* this) { void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1222,40 +1218,42 @@ void EnSob1_UpdateStickDirectionPromptAnim(EnSob1* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } -s16 EnSob1_GetXZAngleAndDistanceSqToPoint(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { +s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + points = Lib_SegmentedToVirtual(path->points); points = &points[pointIdx]; diffX = points->x - pos->x; diffZ = points->z - pos->z; @@ -1319,44 +1317,40 @@ s32 EnSob1_AreObjectsLoaded(EnSob1* this, GlobalContext* globalCtx) { return false; } -void EnSob1_InitZoraShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, NULL, this->jointTable, this->morphTable, 20); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &object_masterzoora_Anim_00078C, 1.0f, 0.0f, Animation_GetLastFrame(&object_masterzoora_Anim_00078C), 0, 0.0f); - this->actor.draw = EnSob1_DrawZoraShopkeeper; + this->actor.draw = EnSob1_ZoraShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitGoronShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_GoronShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, NULL, this->jointTable, this->morphTable, 18); gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->objIndices[2]].segment); Animation_Change(&this->skelAnime, &object_mastergolon_Anim_0000FC, 1.0f, 0.0f, Animation_GetLastFrame(&object_mastergolon_Anim_0000FC), 0, 0.0f); - this->actor.draw = EnSob1_DrawGoronShopkeeper; + this->actor.draw = EnSob1_GoronShopkeeper_Draw; this->changeObjectFunc = EnSob1_ChangeObject; } -void EnSob1_InitBombShopkeeper(EnSob1* this, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Init(EnSob1* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rs_Skel_009220, &object_rs_Anim_009120, this->jointTable, this->morphTable, 16); - this->actor.draw = EnSob1_DrawBombShopkeeper; + this->actor.draw = EnSob1_BombShopkeeper_Draw; this->changeObjectFunc = NULL; this->skelAnime.playSpeed = 2.0f; } void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { ShopItem* shopItems; - EnSob1XZRange* unkStruct; + EnSob1XZRange* xzRange; Vec3f* posOffset; - // Possibly fake temps - EnSob1* this2; - u32 maxColor = 255; - if (EnSob1_AreObjectsLoaded(this, globalCtx)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->actor.objBankIndex = this->objIndices[0]; Actor_SetObjectDependency(globalCtx, &this->actor); posOffset = &sPosOffset[this->shopType]; @@ -1364,7 +1358,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->actor.world.pos.y += posOffset->y; this->actor.world.pos.z += posOffset->z; shopItems = sShops[this->shopType]; - if ((this->shopType == BOMB_SHOP) && (gSaveContext.save.weekEventReg[0x21] & 8)) { + if ((this->shopType == BOMB_SHOP) && (gSaveContext.save.weekEventReg[33] & 8)) { sShops[this->shopType][0].shopItemId = SI_BOMB_BAG_30_2; } @@ -1379,7 +1373,7 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { this->pathPointsIdx = 0; if (this->shopType == BOMB_SHOP) { - this->path = func_8013D648(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); + this->path = SubS_GetPathByIndex(globalCtx, ENSOB1_GET_PATH(&this->actor), 0x1F); } if (this->shopType == BOMB_SHOP) { EnSob1_SetupAction(this, EnSob1_SetupWalk); @@ -1387,67 +1381,65 @@ void EnSob1_InitShop(EnSob1* this, GlobalContext* globalCtx) { EnSob1_SetupAction(this, EnSob1_Idle); } - this->cursorPos.y = (this->cursorPos.x = 100.0f); - this->stickAccumX = (this->stickAccumY = 0); + this->cursorPos.y = this->cursorPos.x = 100.0f; + this->stickAccumY = 0; + this->stickAccumX = 0; + this->cursorIdx = 0; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxColor; - this->cursorColor.a = maxColor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; + this->stickLeftPrompt.stickColor.r = 200; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - this2->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxColor; - this2->stickLeftPrompt.arrowColor.g = maxColor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = 0; + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - if (1) {} + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->shopItemSelectedTween = 0.0f; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxColor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = 0; - - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->shopItemSelectedTween = 0.0f; - - this2->actor.gravity = 0.0f; - this2->posXZRange = sPosXZRanges[this2->shopType]; - Actor_SetScale(&this2->actor, sActorScales[this2->shopType]); - EnSob1_SpawnShopItems(this2, globalCtx, shopItems); + this->actor.gravity = 0.0f; + this->posXZRange = sPosXZRanges[this->shopType]; + Actor_SetScale(&this->actor, sActorScales[this->shopType]); + EnSob1_SpawnShopItems(this, globalCtx, shopItems); this->headRot = this->headRotTarget = 0; - this2->blinkTimer = 20; - this2->eyeTexIndex = 0; + this->blinkTimer = 20; + this->eyeTexIndex = 0; this->blinkFunc = EnSob1_WaitForBlink; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } } @@ -1475,7 +1467,10 @@ void EnSob1_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1485,8 +1480,8 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1501,11 +1496,16 @@ void EnSob1_DrawCursor(GlobalContext* globalCtx, EnSob1* this, f32 x, f32 y, f32 void EnSob1_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1531,21 +1531,15 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_soB1.c"); // Unreferenced + (void)"../z_en_soB1.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1558,15 +1552,9 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnSob1_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, @@ -1583,8 +1571,8 @@ void EnSob1_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnSob1* this) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -s32 EnSob1_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_ZoraShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; if (limbIndex == 15) { @@ -1593,8 +1581,8 @@ s32 EnSob1_OverrideLimbDrawZoraShopkeeper(GlobalContext* globalCtx, s32 limbInde return false; } -s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnSob1_BombShopkeeper_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { EnSob1* this = THIS; if (limbIndex == 15) { @@ -1603,7 +1591,8 @@ s32 EnSob1_OverrideLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbInde return false; } -void EnSob1_PostLimbDrawBombShopkeeper(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSob1_BombShopkeeper_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, + Actor* thisx) { OPEN_DISPS(globalCtx->state.gfxCtx); if (limbIndex == 11) { gSPDisplayList(POLY_OPA_DISP++, object_rs_DL_000970); @@ -1621,7 +1610,7 @@ Gfx* EnSob1_EndDList(GraphicsContext* gfxCtx) { return dList; } -void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sZoraShopkeeperEyeTextures[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, gZoraEyeClosedTex }; EnSob1* this = THIS; s32 pad; @@ -1633,7 +1622,7 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0C, EnSob1_EndDList(globalCtx->state.gfxCtx)); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sZoraShopkeeperEyeTextures[this->eyeTexIndex])); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawZoraShopkeeper, NULL, &this->actor); + EnSob1_ZoraShopkeeper_OverrideLimbDraw, NULL, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; @@ -1644,7 +1633,7 @@ void EnSob1_DrawZoraShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_GoronShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { static TexturePtr sGoronShopkeeperEyeTextures[] = { object_oF1d_map_Tex_010438, object_oF1d_map_Tex_010C38, object_oF1d_map_Tex_011038 }; EnSob1* this = THIS; @@ -1666,7 +1655,7 @@ void EnSob1_DrawGoronShopkeeper(Actor* thisx, GlobalContext* globalCtx) { CLOSE_DISPS(globalCtx->state.gfxCtx); } -void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { +void EnSob1_BombShopkeeper_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSob1* this = THIS; s32 pad; u32 frames; @@ -1676,7 +1665,7 @@ void EnSob1_DrawBombShopkeeper(Actor* thisx, GlobalContext* globalCtx) { func_8012C28C(globalCtx->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(object_rs_Tex_005458)); SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - EnSob1_OverrideLimbDrawBombShopkeeper, EnSob1_PostLimbDrawBombShopkeeper, &this->actor); + EnSob1_BombShopkeeper_OverrideLimbDraw, EnSob1_BombShopkeeper_PostLimbDraw, &this->actor); for (i = 0; i < ARRAY_COUNT(this->items); i++) { this->items[i]->actor.scale.x = 0.2f; this->items[i]->actor.scale.y = 0.2f; 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 489e8f5c0..d880c4873 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -7,7 +7,7 @@ #include "z_en_ssh.h" #include "objects/object_ssh/object_ssh.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnSsh*)thisx) @@ -151,8 +151,8 @@ s32 EnSsh_CheckCeilingPos(EnSsh* this, GlobalContext* globalCtx) { posB.x = this->actor.world.pos.x; posB.y = this->actor.world.pos.y + 1000.0f; posB.z = this->actor.world.pos.z; - if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, 0, 0, 1, - 1, &bgId)) { + if (!BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &posB, &this->ceilingPos, &poly, false, + false, true, true, &bgId)) { return false; } return true; @@ -683,8 +683,8 @@ void EnSsh_Wait(EnSsh* this, GlobalContext* globalCtx) { void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { EnSsh_Bob(this, globalCtx); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x904: case 0x905: case 0x906: @@ -693,7 +693,7 @@ void EnSsh_Talk(EnSsh* this, GlobalContext* globalCtx) { case 0x911: case 0x912: case 0x914: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; default: @@ -713,7 +713,7 @@ void func_809756D0(EnSsh* this, GlobalContext* globalCtx) { phi_a1 = 0x910; gSaveContext.save.weekEventReg[34] |= 8; } - func_801518B0(globalCtx, phi_a1, &this->actor); + Message_StartTextbox(globalCtx, phi_a1, &this->actor); } void EnSsh_Idle(EnSsh* this, GlobalContext* globalCtx) { 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 e3116fb3c..a50bf92b4 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -8,7 +8,7 @@ #include "objects/object_st/object_st.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x01004035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000 | ACTOR_FLAG_1000000) #define THIS ((EnSt*)thisx) @@ -152,11 +152,15 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_st_Anim_000304, 1.0f, 0, -1, 0, 0 }, { &object_st_Anim_005B98, 1.0f, 0, -1, 2, -4 }, - { &object_st_Anim_000304, 4.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 1.0f, 0, -1, 0, -4 }, - { &object_st_Anim_0055A8, 1.0f, 0, -1, 2, -4 }, { &object_st_Anim_000304, 8.0f, 0, -1, 0, -4 }, - { &object_st_Anim_000304, 6.0f, 0, -1, 2, -4 }, { &object_st_Anim_005B98, 2.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_st_Anim_005B98, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 4.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_000304, 8.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_st_Anim_000304, 6.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_st_Anim_005B98, 2.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; void func_808A5050(EnSt* this, GlobalContext* globalCtx) { @@ -270,15 +274,15 @@ s32 func_808A576C(EnSt* this) { s16 phi_s2 = (s16)((s16)(Rand_ZeroOne() * 1000.0f) % 12) * 0x1555; for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++, phi_s2 += 0x1555) { - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_31C[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_31C[i] = 80; } this->unk_334[i] = this->unk_31C[i]; - this->unk_2DC[i] = 0.90000004f; + this->drawDmgEffFrozenSteamScales[i] = 0.90000004f; - if ((this->unk_18E == 0) || (this->unk_18E == 1)) { + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 40.0f) - 10.0f; } else { this->unk_358[i].y = ((Rand_ZeroOne() - 0.5f) * 30.0f) + 10.0f; @@ -294,29 +298,30 @@ s32 func_808A576C(EnSt* this) { s32 func_808A5988(EnSt* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_31A) { if (this->unk_31C[arg2] != 0) { - sp40 = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; - sp53 = this->unk_18E; + drawDmgEffAlpha = (f32)this->unk_31C[arg2] / this->unk_334[arg2]; + drawDmgEffType = this->drawDmgEffType; - Math_ApproachF(&this->unk_2DC[arg2], 0.6f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.6f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); - sp44.x += this->unk_358[arg2].x; - sp44.y += this->unk_358[arg2].y; - sp44.z += this->unk_358[arg2].z; + limbPos[0].x += this->unk_358[arg2].x; + limbPos[0].y += this->unk_358[arg2].y; + limbPos[0].z += this->unk_358[arg2].z; - if (sp53 == 10) { + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_334[arg2] - this->unk_31C[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.6f, this->unk_2DC[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.6f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -452,7 +457,7 @@ void func_808A60E0(EnSt* this) { sp1C = this->skelAnime.curFrame / (this->skelAnime.animLength - 1.0f); if (sp1C == 1.0f) { - func_8013BC6C(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -504,7 +509,7 @@ void func_808A6220(EnSt* this, GlobalContext* globalCtx) { } void func_808A63E8(EnSt* this) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); this->unk_2C8 = 1.0f; func_808A5D7C(this); this->unk_30C = 0; @@ -517,7 +522,7 @@ void func_808A63E8(EnSt* this) { void func_808A6468(EnSt* this, GlobalContext* globalCtx) { func_808A5050(this, globalCtx); - func_8013BC6C(&this->skelAnime, sAnimations, 4); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 4); this->unk_18C |= (0x8 | 0x4); this->unk_18C &= ~(0x10 | 0x2); this->unk_2C8 = -1.0f; @@ -534,7 +539,7 @@ void func_808A6468(EnSt* this, GlobalContext* globalCtx) { void func_808A650C(EnSt* this) { s32 idx = (this->unk_2C8 > 0.0f) ? 2 : 6; - func_8013BC6C(&this->skelAnime, sAnimations, idx); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, idx); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->unk_2D8 = 0.0f; @@ -552,7 +557,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { } if (this->collider3.base.acFlags & AC_HIT) { - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -575,7 +580,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { this->unk_31C[i] = 0; } // clang-format on @@ -590,7 +595,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { break; case 5: - this->unk_18E = 30; + 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); @@ -601,7 +606,7 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { this->unk_314 = 20; this->unk_312 = 0; Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->unk_314); - func_8013BC6C(&this->skelAnime, sAnimations, 1); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 1); this->unk_18C |= 8; this->actionFunc = func_808A6D84; this->unk_2C8 = -1.0f; @@ -614,35 +619,35 @@ s32 func_808A6580(EnSt* this, GlobalContext* globalCtx) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_18E = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_318 = 20; func_808A576C(this); break; case 3: - this->unk_18E = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_318 = 0; func_808A576C(this); break; case 2: - this->unk_18E = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_318 = 20; func_808A576C(this); break; default: - this->unk_18E = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_318 = 0; break; } - if (this->unk_18E != 10) { - func_8013BC6C(&this->skelAnime, sAnimations, 7); + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -688,7 +693,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 8.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); @@ -697,7 +702,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); if (ENST_GET_1C0(&this->actor) == ENST_1C0_1) { - this->actor.flags |= 0x80; + this->actor.flags |= ACTOR_FLAG_80; } Actor_SetScale(&this->actor, 0.04f); @@ -719,7 +724,7 @@ void func_808A6C04(EnSt* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); if ((this->unk_18C & 8) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); this->unk_18C &= ~8; } else if ((this->unk_310 == 0) && func_808A5F28(this, globalCtx) && !func_808A6064(this)) { func_808A650C(this); @@ -753,7 +758,7 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { s32 i; s32 count = 0; - if (this->unk_18E == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { for (i = 0; i < ARRAY_COUNT(this->unk_31C); i++) { if (DECR(this->unk_31C[i]) == 0) { count++; @@ -761,8 +766,8 @@ void func_808A6E24(EnSt* this, GlobalContext* globalCtx) { } if (count == ARRAY_COUNT(this->unk_31C)) { - func_8013BC6C(&this->skelAnime, sAnimations, 7); - this->unk_18E = 1; + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 7); + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_2CC = 0.0f; this->unk_2D4 = 0.0f; this->actor.gravity = -1.0f; @@ -824,7 +829,7 @@ void func_808A701C(EnSt* this, GlobalContext* globalCtx) { } } else if (DECR(this->unk_318) == 0) { this->unk_18C |= 0x40; - if (this->unk_18E == 1) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) { func_808A576C(this); this->unk_318 = 10; } @@ -855,21 +860,21 @@ void EnSt_Destroy(Actor* thisx, GlobalContext* globalCtx) { void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { EnSt* this = THIS; - if (this->actor.flags & 0x8000) { + if (this->actor.flags & ACTOR_FLAG_8000) { SkelAnime_Update(&this->skelAnime); this->unk_18C |= 0x80; return; } - if (!(this->actor.flags & 0x80) && func_808A6A3C(this)) { - this->actor.flags |= 0x80; + if (!(this->actor.flags & ACTOR_FLAG_80) && func_808A6A3C(this)) { + this->actor.flags |= ACTOR_FLAG_80; } if (func_808A6580(this, globalCtx)) { this->actionFunc = func_808A6E24; } else if (DECR(this->unk_312) == 0) { this->actionFunc(this, globalCtx); - if (this->unk_18E != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { SkelAnime_Update(&this->skelAnime); } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 5); @@ -880,7 +885,7 @@ void EnSt_Update(Actor* thisx, GlobalContext* globalCtx) { idx += this->actor.world.rot.y; this->actor.shape.rot.y = idx; - if (this->unk_18E == 30) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL) { if (this->unk_312 == 1) { s32 i; diff --git a/src/overlays/actors/ovl_En_St/z_en_st.h b/src/overlays/actors/ovl_En_St/z_en_st.h index a82ff397b..f3a827515 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.h +++ b/src/overlays/actors/ovl_En_St/z_en_st.h @@ -18,7 +18,7 @@ typedef struct EnSt { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnStActionFunc actionFunc; /* 0x18C */ u16 unk_18C; - /* 0x18E */ u8 unk_18E; + /* 0x18E */ u8 drawDmgEffType; /* 0x190 */ ColliderCylinder collider1; /* 0x1DC */ ColliderCylinder collider2; /* 0x228 */ ColliderCylinder collider3; @@ -30,7 +30,7 @@ typedef struct EnSt { /* 0x2D0 */ f32 unk_2D0; /* 0x2D4 */ f32 unk_2D4; /* 0x2D8 */ f32 unk_2D8; - /* 0x2DC */ f32 unk_2DC[12]; + /* 0x2DC */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x30C */ s16 unk_30C; /* 0x30E */ s16 unk_30E; /* 0x310 */ s16 unk_310; 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 9b6d621a0..82e314d60 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -5,8 +5,11 @@ */ #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 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnSth*)thisx) @@ -14,7 +17,16 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx); void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSth_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B67208(EnSth* this, GlobalContext* globalCtx); +void func_80B67540(EnSth* this, GlobalContext* globalCtx); +void func_80B677BC(EnSth* this, GlobalContext* globalCtx); +void func_80B678A8(EnSth* this, GlobalContext* globalCtx); +void func_80B67958(EnSth* this, GlobalContext* globalCtx); +void func_80B67C1C(EnSth* this, GlobalContext* globalCtx); +void func_80B67DA0(EnSth* this, GlobalContext* globalCtx); +void func_80B680A8(Actor* thisx, GlobalContext* globalCtx); +void func_80B6849C(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Sth_InitVars = { ACTOR_EN_STH, ACTORCAT_NPC, @@ -27,68 +39,677 @@ const ActorInit En_Sth_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B6D19C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +#include "overlays/ovl_En_Sth/ovl_En_Sth.c" + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +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, +}; -extern ColliderCylinderInit D_80B6D19C; +u16 D_80B6D1E8[] = { 0x1144, 0x1145, 0x1146 }; -extern UNK_TYPE D_06005998; -extern UNK_TYPE D_0A0001A0; +u16 D_80B6D1F0[] = { 0x1139, 0x113E, 0x1143 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Init.s") +u16 D_80B6D1F8[] = { 0x1132, 0x113A, 0x113F }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Destroy.s") +Vec3f D_80B6D200 = { 700.0f, 400.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B6703C.s") +Color_RGB8 D_80B6D20C[] = { + { 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 0x50 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B670A4.s") +void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + s32 objectId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67148.s") + if (ENSTH_GET_100(&this->actor)) { + objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_AHG); + } else { + objectId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_STH); + } + this->unk_29E = objectId; + this->unk_29F = Object_GetIndex(&globalCtx->objectCtx, OBJECT_MASK_TRUTH); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B671A0.s") + Actor_SetScale(&this->actor, 0.01f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67208.s") + this->unk_29C = 0; + this->unk_29A = 8; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B672A4.s") + switch (ENSTH_GET_F(&this->actor)) { + case ENSTH_F_1: + if (globalCtx->actorCtx.unk5 & 2) { + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + this->actionFunc = func_80B67958; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67348.s") + case ENSTH_F_2: + if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + this->actionFunc = func_80B67DA0; + } else { + Actor_MarkForDeath(&this->actor); + } + this->actor.textId = 0; + if (!(gSaveContext.save.weekEventReg[34] & 0x40) || !(gSaveContext.save.weekEventReg[34] & 8)) { + this->unk_29C |= 1; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67458.s") + case ENSTH_F_3: + if ((gSaveContext.save.skullTokenCount & 0xFFFF) >= 30) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80B678A8; + this->unk_29C |= 8; + this->actor.targetMode = 3; + this->actor.uncullZoneForward = 800.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67540.s") + case ENSTH_F_4: + if (gSaveContext.save.weekEventReg[13] & 0x20) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0; + this->actionFunc = func_80B677BC; + if (gSaveContext.save.weekEventReg[13] & 0x80) { + this->unk_29C |= 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B677BC.s") + case ENSTH_F_5: + if (!(gSaveContext.save.weekEventReg[13] & 0x20) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actionFunc = func_80B67208; + this->actor.textId = 0; + this->unk_29C |= 8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67838.s") + default: + this->actionFunc = func_80B67958; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B678A8.s") +void EnSth_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSth* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67958.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67984.s") +s32 func_80B6703C(EnSth* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x2000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67AB4.s") +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]), 0, + -5.0f); + this->unk_29A = arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67B50.s") +void func_80B67148(EnSth* this, GlobalContext* globalCtx) { + s32 day = CURRENT_DAY - 1; + u16 val; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67C1C.s") + if (day < 0) { + day = 0; + } + val = D_80B6D1E8[day]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67DA0.s") + Message_StartTextbox(globalCtx, val, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B67E20.s") +void func_80B671A0(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/EnSth_Update.s") + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actionFunc = func_80B67208; + func_801477B4(globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B680A8.s") +void func_80B67208(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B681E8.s") + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B67148(this, globalCtx); + this->actionFunc = func_80B671A0; + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B68310.s") +void func_80B672A4(EnSth* this, GlobalContext* globalCtx) { + u16 sp1E; + s32 day = CURRENT_DAY - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth/func_80B6849C.s") + if (day < 0) { + day = 0; + } + + if (this->unk_29C & 2) { + s32 pad; + + sp1E = D_80B6D1F0[day]; + if (day == 2) { + func_80B670A4(this, 5); + } + } else { + sp1E = D_80B6D1F8[day]; + } + Message_StartTextbox(globalCtx, sp1E, &this->actor); +} + +void func_80B67348(EnSth* this, GlobalContext* globalCtx) { + u16 phi_a1; + + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = func_80B67540; + + switch (this->actor.home.rot.z) { + case 8: + case 9: + phi_a1 = 0x1137; + break; + + case 6: + phi_a1 = 0x1138; + break; + + case 5: + if (gSaveContext.save.weekEventReg[13] & 0x40) { + phi_a1 = 0x113D; + } else { + phi_a1 = 0x113C; + } + break; + + default: + if (gSaveContext.save.weekEventReg[13] & 0x40) { + phi_a1 = 0x1142; + } else { + phi_a1 = 0x1141; + } + break; + } + Message_StartTextbox(globalCtx, phi_a1, &this->actor); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B67458(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B67348; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + if (CURRENT_DAY == 3) { + func_80B670A4(this, 6); + } else { + func_80B670A4(this, 3); + } + } else { + Actor_PickUp(&this->actor, globalCtx, this->actor.home.rot.z, 10000.0f, 500.0f); + } +} + +void func_80B67540(EnSth* this, GlobalContext* globalCtx) { + s32 sp2C = CURRENT_DAY - 1; + + if (sp2C < 0) { + sp2C = 0; + } + + if (this->unk_29A == 6) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + SkelAnime_Update(&this->skelAnime); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1134: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1132: + case 0x113A: + case 0x113F: + func_80151938(globalCtx, 0x1133); + break; + + case 0x1133: + func_80151938(globalCtx, 0x1136); + func_80B670A4(this, 6); + break; + + case 0x1136: + gSaveContext.save.weekEventReg[13] |= 0x80; + + switch (sp2C) { + case 0: + if (gSaveContext.save.weekEventReg[13] & 0x40) { + this->actor.home.rot.z = 6; + } else { + gSaveContext.save.weekEventReg[13] |= 0x40; + switch (CUR_UPG_VALUE(UPG_WALLET)) { + case 0: + this->actor.home.rot.z = 8; + break; + + case 1: + this->actor.home.rot.z = 9; + break; + } + } + break; + + case 1: + this->actor.home.rot.z = 5; + break; + + default: + this->actor.home.rot.z = 4; + break; + } + func_801477B4(globalCtx); + this->actionFunc = func_80B67458; + func_80B67458(this, globalCtx); + break; + + case 0x113C: + func_80151938(globalCtx, 0x113B); + break; + + case 0x1141: + func_80151938(globalCtx, 0x1140); + func_80B670A4(this, 3); + break; + + default: + this->actionFunc = func_80B677BC; + func_801477B4(globalCtx); + this->unk_29C |= 2; + break; + } + } + break; + + case 2: + this->actionFunc = func_80B677BC; + this->unk_29C |= 2; + break; + } +} + +void func_80B677BC(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B672A4(this, globalCtx); + this->actionFunc = func_80B67540; + } else if (func_80B6703C(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80B67838(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + this->actionFunc = func_80B678A8; + func_801477B4(globalCtx); + } + this->unk_294.x = -0x1388; +} + +void func_80B678A8(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B67838; + } else if (func_80B6703C(this, globalCtx) || this->actor.isTargeted) { + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + this->actor.textId = 0x1130; + } else { + this->actor.textId = 0x1131; + } + func_800B8614(&this->actor, globalCtx, 110.0f); + } + this->unk_294.x = -0x1388; +} + +void func_80B67958(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); +} + +void func_80B67984(EnSth* this, GlobalContext* globalCtx) { + u16 sp1E; + + if (gSaveContext.save.weekEventReg[34] & 0x10) { + sp1E = 0x903; + func_80B670A4(this, 2); + } else if (gSaveContext.save.weekEventReg[34] & 0x20) { + sp1E = 0x90F; + func_80B670A4(this, 2); + } else if (gSaveContext.save.weekEventReg[34] & 0x40) { + if (!(gSaveContext.save.weekEventReg[34] & 8)) { + sp1E = 0x91B; + } else { + sp1E = 0x918; + } + func_80B670A4(this, 2); + } else if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { + this->unk_29C |= 4; + sp1E = 0x919; + } else { + sp1E = 0x916; + } + } else if (gSaveContext.save.weekEventReg[34] & 2) { + sp1E = 0x8FF; + } else { + sp1E = 0x8FC; + gSaveContext.save.weekEventReg[34] |= 2; + } + Message_StartTextbox(globalCtx, sp1E, &this->actor); +} + +void func_80B67AB4(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B67C1C; + gSaveContext.save.weekEventReg[34] |= 0x40; + Message_StartTextbox(globalCtx, 0x918, &this->actor); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } +} + +void func_80B67B50(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = func_80B67AB4; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + this->unk_29C &= ~1; + gSaveContext.save.weekEventReg[34] |= 8; + Actor_PickUp(&this->actor, globalCtx, GI_MASK_CAPTAIN, 10000.0f, 50.0f); + } +} + +void func_80B67C1C(EnSth* this, GlobalContext* globalCtx) { + s32 pad; + + SkelAnime_Update(&this->skelAnime); + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x90C: + func_80B670A4(this, 2); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x916: + case 0x919: + func_80B670A4(this, 3); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x8FC: + case 0x8FD: + case 0x900: + case 0x90A: + case 0x90D: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x901: + case 0x90B: + case 0x917: + func_801477B4(globalCtx); + this->actionFunc = func_80B67B50; + func_80B67B50(this, globalCtx); + break; + + case 0x91A: + gSaveContext.save.weekEventReg[34] |= 0x40; + gSaveContext.save.weekEventReg[34] &= (u8)~8; + + case 0x902: + case 0x903: + case 0x90E: + case 0x90F: + case 0x918: + case 0x91B: + func_80B670A4(this, 3); + + default: + this->actor.flags &= ~ACTOR_FLAG_10000; + func_801477B4(globalCtx); + this->actionFunc = func_80B67DA0; + break; + } + } +} + +void func_80B67DA0(EnSth* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80B67984(this, globalCtx); + this->actionFunc = func_80B67C1C; + } else if (func_80B6703C(this, globalCtx)) { + this->actor.textId = 0; + func_800B8614(&this->actor, globalCtx, 110.0f); + } +} + +void func_80B67E20(Actor* thisx, GlobalContext* globalCtx) { + EnSth* this = THIS; + + if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + this->actor.update = func_80B680A8; + this->actor.draw = func_80B6849C; + this->actor.flags |= ACTOR_FLAG_1; + } +} + +void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29E)) { + this->actor.objBankIndex = this->unk_29E; + Actor_SetObjectDependency(globalCtx, &this->actor); + + if (ENSTH_GET_100(&this->actor)) { + SkelAnime_InitFlex(globalCtx, &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 ((gSaveContext.save.weekEventReg[34] & 0x10) || (gSaveContext.save.weekEventReg[34] & 0x20) || + (gSaveContext.save.weekEventReg[34] & 0x40) || + (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30)) { + func_80B670A4(this, 3); + } + } else { + SkelAnime_InitFlex(globalCtx, &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 (gSaveContext.save.weekEventReg[13] & 0x80) { + 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(globalCtx->sceneNum) < 30)) { + this->actor.update = func_80B67E20; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + } + } +} + +void func_80B680A8(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + Vec3s sp38; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->actionFunc(this, globalCtx); + + if (func_80B6703C(this, globalCtx) && !(this->unk_29C & 8) && (this->unk_29A != 5)) { + sp38.x = sp38.y = sp38.z = 0; + + func_800E9250(globalCtx, &this->actor, &this->unk_294, &sp38, 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); + } +} + +s32 func_80B681E8(GlobalContext* globalCtx, 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 == 8) || (limbIndex == 10) || (limbIndex == 13)) { + rot->y += (s16)(Math_SinS(globalCtx->state.frames * ((limbIndex * 50) + 0x814)) * 200.0f); + rot->z += (s16)(Math_CosS(globalCtx->state.frames * ((limbIndex * 50) + 0x940)) * 200.0f); + } + return false; +} + +void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSth* this = THIS; + + if (limbIndex == 15) { + s32 pad; + + Matrix_MultiplyVector3fByState(&D_80B6D200, &this->actor.focus.pos); + + if (!ENSTH_GET_100(&this->actor)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Sth_DL_0037C0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_29C & 1) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_29F)) { + Matrix_StatePush(); + Matrix_InsertZRotation_s(0x3A98, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 190.0f, 0.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x0A, globalCtx->objectCtx.status[this->unk_29F].segment); + gSPDisplayList(POLY_OPA_DISP++, object_mask_truth_DL_0001A0); + + Matrix_StatePop(); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} + +void func_80B6849C(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSth* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(globalCtx->state.gfxCtx, D_80B6D20C[1].r, D_80B6D20C[1].g, D_80B6D20C[1].b, 255)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(globalCtx->state.gfxCtx, 90, 110, 130, 255)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80B681E8, func_80B68310, &this->actor); + + CLOSE_DISPS(globalCtx->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 fcd6042aa..422a92c34 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.h +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.h @@ -5,9 +5,31 @@ struct EnSth; +typedef void (*EnSthActionFunc)(struct EnSth*, GlobalContext*); + +#define ENSTH_GET_F(thisx) ((thisx)->params & 0xF) +#define ENSTH_GET_100(thisx) ((thisx)->params & 0x100) + +enum { + /* 1 */ ENSTH_F_1 = 1, + /* 2 */ ENSTH_F_2, + /* 3 */ ENSTH_F_3, + /* 4 */ ENSTH_F_4, + /* 5 */ ENSTH_F_5, +}; + typedef struct EnSth { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x160]; + /* 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; + /* 0x2A0 */ EnSthActionFunc actionFunc; } EnSth; // size = 0x2A4 extern const ActorInit En_Sth_InitVars; 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 97b463567..0bf0ae73c 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -6,7 +6,7 @@ #include "z_en_sth2.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnSth2*)thisx) 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 387afd7e9..54a1f84a8 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 0x00000089 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_80) #define THIS ((EnStoneheishi*)thisx) 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 c5746771c..3ca829630 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 @@ -6,7 +6,7 @@ #include "z_en_stop_heishi.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnStopheishi*)thisx) diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 9ce7ac906..abf58da86 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -7,7 +7,7 @@ #include "z_en_stream.h" #include "objects/object_stream/object_stream.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnStream*)thisx) diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index d7b929dc5..dafed18c5 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_boj/object_boj.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnSuttari*)thisx) @@ -49,12 +49,16 @@ const ActorInit En_Suttari_InitVars = { (ActorFunc)EnSuttari_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_boj_Anim_00071C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_0128F4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_boj_Anim_011F84, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_012E84, 1.0f, 0.0f, 0.0f, 0, -6.0f }, - { &object_boj_Anim_01139C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_00071C, 2.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_boj_Anim_011F84, 2.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_boj_Anim_011C38, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_boj_Anim_010BDC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +static AnimationInfo sAnimations[] = { + { &object_boj_Anim_00071C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_0128F4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011F84, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_012E84, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, + { &object_boj_Anim_01139C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_00071C, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011F84, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &object_boj_Anim_011C38, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &object_boj_Anim_010BDC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -206,7 +210,7 @@ s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAA9B4(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->textId) { case 0x1454: @@ -217,15 +221,15 @@ void func_80BAA9B4(EnSuttari* this) { case 0x1459: case 0x145A: case 0x145B: - if ((this->animationIdx != 8) && (curFrame == frameCount)) { - this->animationIdx = 8; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 8) && (curFrame == frameCount)) { + this->animationIndex = 8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } break; default: - if ((this->animationIdx != 1) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex != 1) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } } } @@ -233,8 +237,8 @@ void func_80BAA9B4(EnSuttari* this) { void func_80BAAA94(EnSuttari* this) { switch (this->textId) { case 0x29E5: - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29E9: this->enFsn->flags |= ENFSN_ANGRY; @@ -246,12 +250,12 @@ void func_80BAAA94(EnSuttari* this) { this->enFsn->flags |= ENFSN_OFFER_FINAL_PRICE; break; case 0x29EC: - this->animationIdx = 7; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 7; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; case 0x29ED: - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); break; } } @@ -319,7 +323,7 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else if (this->flags1 & 1) { switch (this->textId) { case 0: - if (gSaveContext.save.weekEventReg[0x51] & 1) { + if (gSaveContext.save.weekEventReg[81] & 1) { this->textId = 0x1455; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; @@ -337,12 +341,12 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else { this->flags1 |= 0x400; this->textId = 0x1452; - gSaveContext.save.weekEventReg[0x51] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; } break; case 0x1453: this->flags1 |= 0x400; - gSaveContext.save.weekEventReg[0x51] |= 1; + gSaveContext.save.weekEventReg[81] |= 1; ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; @@ -368,19 +372,19 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { break; } } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } void func_80BAAF1C(EnSuttari* this) { s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if (this->animationIdx == 5) { - this->animationIdx = 3; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); - } else if ((this->animationIdx == 3) && (curFrame == frameCount)) { - this->animationIdx = 6; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 5) { + this->animationIndex = 3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); + } else if ((this->animationIndex == 3) && (curFrame == frameCount)) { + this->animationIndex = 6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 &= ~0x100; } } @@ -410,7 +414,7 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.save.weekEventReg[0x3D] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } @@ -442,7 +446,7 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.save.weekEventReg[0x3D] |= 8; + gSaveContext.save.weekEventReg[61] |= 8; this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } else { @@ -469,8 +473,8 @@ void func_80BAB434(EnSuttari* this) { } void EnSuttari_GetPaths(EnSuttari* this, GlobalContext* globalCtx) { - this->paths[0] = func_8013D648(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); - this->paths[1] = func_8013D648(globalCtx, this->paths[0]->unk1, 0x3F); + this->paths[0] = SubS_GetPathByIndex(globalCtx, ENSUTTARI_GET_PATH(&this->actor), 0x3F); + this->paths[1] = SubS_GetPathByIndex(globalCtx, this->paths[0]->unk1, 0x3F); } void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { @@ -482,7 +486,7 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { } SkelAnime_Update(&this->skelAnime); if (!(this->flags1 & 4) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { - if (func_8013D5E8(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) != 0) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; @@ -497,31 +501,32 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk2E2.y, 0, 4, 0x3E8, 1); } } - func_8013D9C8(globalCtx, this->unk2FA, this->unk31A, 16); + SubS_FillLimbRotTables(globalCtx, this->unk2FA, this->unk31A, ARRAY_COUNT(this->unk2FA)); } -s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { - points = (Vec3s*)Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = Lib_SegmentedToVirtual(path->points); + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { diffX = 0.0f; diffZ = 0.0f; } - *distSQ = SQ(diffX) + SQ(diffZ); - return Math_Acot2F(diffZ, diffX) * (0x8000 / M_PI); + + *distSq = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); } s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); s32 sp58 = path->count; - s32 idx = arg2; + s32 index = arg2; s32 ret = false; f32 sp54; f32 sp48; @@ -530,16 +535,16 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { f32 sp3C; Vec3f sp30; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[1].x - sp5C[0].x; sp48 = sp5C[1].z - sp5C[0].z; - } else if (idx == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; sp48 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; } else { - sp54 = sp5C[idx + 1].x - sp5C[idx - 1].x; - sp48 = sp5C[idx + 1].z - sp5C[idx - 1].z; + 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); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -550,29 +555,26 @@ s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { s32 func_80BAB8F4(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); - s32 sp58; + s32 sp58 = path->count; + s32 index = arg2; + s32 ret = false; f32 sp54; - s32 ret; - s32 pad4C; f32 sp48; f32 sp44; f32 sp40; f32 sp3C; Vec3f sp30; - if (sp5C[arg2 - 1].x) {} - sp58 = path->count; - ret = false; - Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); - if (arg2 == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[index]); + if (index == 0) { sp54 = sp5C[0].x - sp5C[1].x; sp48 = sp5C[0].z - sp5C[1].z; - } else if (arg2 == sp58 - 1) { + } else if (index == sp58 - 1) { sp54 = sp5C[sp58 - 2].x - sp5C[sp58 - 1].x; sp48 = sp5C[sp58 - 2].z - sp5C[sp58 - 1].z; } else { - sp54 = sp5C[arg2 - 1].x - sp5C[arg2 + 1].x; - sp48 = sp5C[arg2 - 1].z - sp5C[arg2 + 1].z; + 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); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -586,7 +588,7 @@ void func_80BABA90(EnSuttari* this, s32 arg1, u8 arg2) { f32 dist; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &dist); if (this->actor.bgCheckFlags & 8) { if (arg2 == 2) { this->unk1F4[arg1] = -0x63; @@ -615,7 +617,7 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { f32 sp30; if (this->paths[arg1] != NULL) { - target = func_80BAB698(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); + target = EnSuttari_GetDistSqAndOrient(this->paths[arg1], this->unk1F4[arg1], &this->actor.world.pos, &sp30); if (this->actor.bgCheckFlags & 8) { target = this->actor.wallYaw; } @@ -640,7 +642,7 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg u16 phi_a0; if (sp1C >= 0) { - this->unk404 = func_8013BB34(globalCtx, sp23, sp1C); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } if (this->unk404 == NULL) { return 0; @@ -682,12 +684,12 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); sp24 = D_80BAE8F8[unkStruct->unk0]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = func_8013BB34(globalCtx, sp47, sp24); + this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } if ((sp48 == NULL) || (this->unk404 == NULL)) { return 0; } - sp28 = (Vec3s*)Lib_SegmentedToVirtual(this->unk404->points); + sp28 = Lib_SegmentedToVirtual(this->unk404->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); this->unk434 = sp44 - unkStruct->unk4; @@ -802,7 +804,7 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); switch (this->unk428) { case 12: @@ -811,11 +813,11 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { func_80BABFD4(this, globalCtx); break; case 15: - if ((this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - if (!(gSaveContext.save.weekEventReg[0x53] & 4) && !(this->flags1 & 0x1000)) { + if (!(gSaveContext.save.weekEventReg[83] & 4) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { ActorCutscene_Start(this->cutscenes[0], &this->actor); if (!(player->stateFlags1 & 0x10000000)) { @@ -844,9 +846,9 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { this->flags1 |= 0x80; this->flags1 |= 0x20; this->enFsn->flags &= ~ENFSN_HAGGLE; - if (this->animationIdx != 2) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex != 2) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BAC220(this, globalCtx); break; @@ -864,7 +866,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); break; case 2: - if (!(gSaveContext.save.weekEventReg[0x51] & 4)) { + if (!(gSaveContext.save.weekEventReg[81] & 4)) { this->flags1 |= 0x80; this->actor.world.pos.x = -16.0f; this->actor.world.pos.z = -16.0f; @@ -874,10 +876,10 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { } break; case 4: - if (!(gSaveContext.save.weekEventReg[0x21] & 8)) { - if (this->animationIdx == 2 || this->animationIdx == 1) { - this->animationIdx = 5; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (!(gSaveContext.save.weekEventReg[33] & 8)) { + if (this->animationIndex == 2 || this->animationIndex == 1) { + this->animationIndex = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->flags1 |= 0x10; if (this->flags2 & 2) { @@ -888,7 +890,7 @@ void func_80BAC2FC(EnSuttari* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x10000000; } this->textId = 0x2A30; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = func_80BAD2B4; } break; @@ -901,20 +903,20 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_00071C, this->jointTable, this->morphTable, 16); this->actor.draw = EnSuttari_Draw; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (globalCtx->sceneNum == SCENE_IKANA) { this->flags1 |= 1; if (gSaveContext.save.day == 1 || gSaveContext.save.day == 2) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 0x80; this->actionFunc = func_80BACA14; return; - } else if ((gSaveContext.save.day == 3) && (gSaveContext.save.time <= CLOCK_TIME(19, 00)) && - !(gSaveContext.save.weekEventReg[0x3D] & 8) && !(gSaveContext.save.weekEventReg[0x21] & 8) && - (gSaveContext.save.weekEventReg[0x33] & 8)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + } else if ((gSaveContext.save.day == 3) && (gSaveContext.save.time <= CLOCK_TIME(19, 0)) && + !(gSaveContext.save.weekEventReg[61] & 8) && !(gSaveContext.save.weekEventReg[33] & 8) && + (gSaveContext.save.weekEventReg[51] & 8)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BACEE0; return; } @@ -922,34 +924,34 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { if (gSaveContext.save.time >= CLOCK_TIME(0, 20) && gSaveContext.save.time < CLOCK_TIME(6, 00)) { Actor_MarkForDeath(&this->actor); } - if ((gSaveContext.save.entranceIndex == 0xD670) || (gSaveContext.save.weekEventReg[0x3A] & 0x40)) { + if ((gSaveContext.save.entranceIndex == 0xD670) || (gSaveContext.save.weekEventReg[58] & 0x40)) { Actor_MarkForDeath(&this->actor); } this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 0x80; this->flags1 |= 8; - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->actionFunc = func_80BAD004; return; } else if (globalCtx->sceneNum == SCENE_ICHIBA) { - if (gSaveContext.save.weekEventReg[0x21] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->flags1 |= 2; this->actionFunc = func_80BAD5F8; return; } else if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { - if (gSaveContext.save.weekEventReg[0x21] & 8) { + if (gSaveContext.save.weekEventReg[33] & 8) { Actor_MarkForDeath(&this->actor); return; } - this->animationIdx = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + this->animationIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); this->cutscenes[0] = this->actor.cutscene; this->cutscenes[1] = ActorCutscene_GetAdditionalCutscene(this->cutscenes[0]); this->flags1 |= 4; @@ -967,9 +969,9 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->animationIdx == 1 || this->animationIdx == 8) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if (this->animationIndex == 1 || this->animationIndex == 8) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } func_80BABA90(this, 0, 0); func_80BAB434(this); @@ -978,7 +980,7 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; this->actionFunc = func_80BACBB0; } - } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { + } else if ((player->transformation == PLAYER_FORM_HUMAN) && GET_CUR_EQUIP_VALUE(EQUIP_SWORD) != 0) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk3F2 = this->unk2DC.y; func_80BAAB78(this, globalCtx); @@ -1063,16 +1065,16 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { - gSaveContext.save.weekEventReg[0x3A] |= 0x80; + gSaveContext.save.weekEventReg[58] |= 0x80; this->actionFunc = func_80BADDB4; this->actor.speedXZ = 0.0f; } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) { @@ -1088,15 +1090,15 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A3A, &this->actor); + Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 200.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1107,7 +1109,7 @@ void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { void func_80BAD130(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); - if ((talkState == 5 || talkState == 6) && func_80147624(globalCtx)) { + if ((talkState == 5 || talkState == 6) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; if (this->flags1 & 8) { @@ -1128,7 +1130,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { ActorCutscene_Start(this->cutscenes[1], &this->actor); this->textId = 0x2A31; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; @@ -1138,7 +1140,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD2B4(EnSuttari* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x2A30) { ActorCutscene_Stop(this->cutscenes[0]); ActorCutscene_SetIntentToPlay(this->cutscenes[1]); @@ -1158,13 +1160,13 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.unk11F04 != 0x2A31)) { + if ((player->stateFlags1 & 0x40) && (globalCtx->msgCtx.currentTextId != 0x2A31)) { this->flags1 |= 0x8000; this->actor.speedXZ = 0.0f; } else { this->flags1 &= ~0x8000; func_80BABA90(this, 1, 1); - if ((this->flags1 & 0x4000) && (talkState == 5) && func_80147624(globalCtx)) { + if ((this->flags1 & 0x4000) && (talkState == 5) && Message_ShouldAdvance(globalCtx)) { this->flags2 &= ~0x10; player->stateFlags1 &= ~0x10000000; this->flags1 &= ~0x4000; @@ -1177,7 +1179,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 8; func_80BAAF1C(this); } else if (this->flags1 & 0x200) { - gSaveContext.save.weekEventReg[0x4F] |= 0x40; + gSaveContext.save.weekEventReg[79] |= 0x40; this->flags2 |= 4; this->actor.speedXZ = 0.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->actor.world.pos.x, @@ -1188,7 +1190,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } if (this->unk1F4[1] == -0x63) { if (this->flags2 & 8) { - gSaveContext.save.weekEventReg[0x21] |= 8; + gSaveContext.save.weekEventReg[33] |= 8; } this->actor.speedXZ = 0.0f; Audio_QueueSeqCmd(0x101400FF); @@ -1207,19 +1209,19 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 unkStruct; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); - if ((curFrame == frameCount) && (this->animationIdx == 0) && (this->flags1 & 0x20)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((curFrame == frameCount) && (this->animationIndex == 0) && (this->flags1 & 0x20)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); @@ -1230,7 +1232,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { func_80BAB434(this); if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A02, &this->actor); + Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1243,22 +1245,22 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { u32* unk_14 = &gSaveContext.save.daySpeed; struct_80133038_arg2 unkStruct; s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->enFsn == NULL) { this->enFsn = (EnFsn*)EnSuttari_GetActorById(globalCtx, ACTOR_EN_FSN); } else { - if ((this->flags1 & 0x2000) && (this->animationIdx == 1) && (curFrame == frameCount)) { - this->animationIdx = 2; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + if ((this->flags1 & 0x2000) && (this->animationIndex == 1) && (curFrame == frameCount)) { + this->animationIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } this->unk42A = REG(15) + *unk_14; if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; unkStruct.unk0 = 0; } else { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; } this->unk428 = unkStruct.unk0; func_80BAC2FC(this, globalCtx); @@ -1268,7 +1270,7 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { } if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x2A02, &this->actor); + Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; } else if ((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) { func_800B863C(&this->actor, globalCtx); @@ -1280,11 +1282,11 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_80BAAB78(this, globalCtx); - gSaveContext.save.weekEventReg[0x51] |= 4; + gSaveContext.save.weekEventReg[81] |= 4; } else if (this->actor.xzDistToPlayer < 500.0f) { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); } } @@ -1292,17 +1294,17 @@ void func_80BADA08(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { u8 talkstate = Message_GetState(&globalCtx->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); + s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); if (this->flags1 & 1) { this->unk3F2 = this->unk2DC.y; func_80BAA9B4(this); - } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { - this->animationIdx = 1; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, this->animationIdx); + } else if ((this->animationIndex == 7) && (curFrame == frameCount)) { + this->animationIndex = 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } if (talkstate == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->flags1 & 0x400) { if (this->textId == 0x29EE) { ActorCutscene_Stop(this->cutscenes[this->cutsceneIdx]); @@ -1324,7 +1326,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { } func_80BAAB78(this, globalCtx); } - } else if ((talkstate == 4) && func_80147624(globalCtx)) { + } else if ((talkstate == 4) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -1360,7 +1362,7 @@ void func_80BADD0C(EnSuttari* this, GlobalContext* globalCtx) { void func_80BADDB4(EnSuttari* this, GlobalContext* globalCtx) { func_80BABA90(this, 1, 1); func_80BAB434(this); - if (gSaveContext.save.weekEventReg[0x33] & 0x10) { + if (gSaveContext.save.weekEventReg[51] & 0x10) { this->actionFunc = func_80BADE14; } Actor_MoveWithGravity(&this->actor); @@ -1381,11 +1383,11 @@ void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { this->unk3F2 = this->unk2DC.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; - func_801518B0(globalCtx, 0x2A3A, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); this->actionFunc = func_80BAD130; } else { - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 500.0f); } } @@ -1406,14 +1408,14 @@ void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { EnSuttari* this = THIS; s32 pad; - if (gSaveContext.save.weekEventReg[0x4F] & 0x40) { + if (gSaveContext.save.weekEventReg[79] & 0x40) { Actor_MarkForDeath(&this->actor); return; } Collider_InitCylinder(globalCtx, &this->collider); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; EnSuttari_GetPaths(this, globalCtx); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = func_80BAC6E8; @@ -1445,11 +1447,11 @@ void EnSuttari_Update(Actor* thisx, GlobalContext* globalCtx) { EnSuttari_UpdateTime(); } if (this->unk428 != 0) { - if (this->animationIdx == 2 || this->animationIdx == 6) { + if (this->animationIndex == 2 || this->animationIndex == 6) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 16.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } - } else if (this->animationIdx == 0 || this->animationIdx == 5) { + } else if (this->animationIndex == 0 || this->animationIndex == 5) { if (Animation_OnFrame(&this->skelAnime, 8.0f) || Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PAMERA_WALK); } 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 9c62be60f..c6f8cc153 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -55,7 +55,7 @@ typedef struct EnSuttari { /* 0x436 */ s16 unk436; /* 0x438 */ Vec3f unk438; /* 0x444 */ Vec3f unk444; - /* 0x450 */ s32 animationIdx; + /* 0x450 */ s32 animationIndex; /* 0x454 */ UNK_TYPE1 unk_454[0x2]; /* 0x456 */ s16 cutscenes[2]; /* 0x45A */ s16 cutsceneIdx; 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 392fe62bc..f0d1a3aa7 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -7,7 +7,7 @@ #include "z_en_sw.h" #include "objects/object_st/object_st.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnSw*)thisx) @@ -134,11 +134,11 @@ static DamageTable sDamageTable2 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static ActorAnimationEntryS sAnimations[] = { - { &object_st_Anim_000304, 1.0f, 0, -1, 3, 0 }, - { &object_st_Anim_000304, 1.0f, 0, -1, 3, -4 }, - { &object_st_Anim_0055A8, 1.0f, 0, -1, 1, -4 }, - { &object_st_Anim_005B98, 1.0f, 0, -1, 1, -4 }, +static AnimationInfoS sAnimations[] = { + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_ONCE_INTERP, 0 }, + { &object_st_Anim_000304, 1.0f, 0, -1, ANIMMODE_ONCE_INTERP, -4 }, + { &object_st_Anim_0055A8, 1.0f, 0, -1, ANIMMODE_LOOP_INTERP, -4 }, + { &object_st_Anim_005B98, 1.0f, 0, -1, ANIMMODE_LOOP_INTERP, -4 }, }; void func_808D8940(EnSw* this, GlobalContext* globalCtx) { @@ -176,14 +176,15 @@ s32 func_808D8B58(EnSw* this) { s32 i; for (i = 0; i < ARRAY_COUNT(this->unk_464); i++, phi_s2 += 0x1555) { - if (this->unk_412 != 10) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { this->unk_464[i] = (Rand_ZeroOne() * 16.0f) + 8.0f; } else { this->unk_464[i] = 80; } this->unk_47C[i] = this->unk_464[i]; - this->unk_418[i] = 0.45000002f; - if ((this->unk_412 == 0) || (this->unk_412 == 1) || (this->unk_412 == 10)) { + this->drawDmgEffFrozenSteamScales[i] = 0.45000002f; + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { this->unk_380[i].y = (Rand_ZeroOne() - 0.5f) * 20.0f; } else { this->unk_380[i].y = ((Rand_ZeroOne() - 0.5f) * 20.0f) + 10.0f; @@ -197,26 +198,27 @@ s32 func_808D8B58(EnSw* this) { s32 func_808D8D60(EnSw* this, GlobalContext* globalCtx, s32 arg2) { s32 ret = false; - u8 sp53; - Vec3f sp44; - f32 sp40; + u8 drawDmgEffType; + Vec3f limbPos[1]; + f32 drawDmgEffAlpha; if (arg2 < this->unk_462) { if (this->unk_464[arg2] != 0) { - sp40 = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; - sp53 = this->unk_412; - Math_ApproachF(&this->unk_418[arg2], 0.3f, 0.3f, 0.5f); - Math_Vec3f_Copy(&sp44, &this->actor.world.pos); - sp44.x += this->unk_380[arg2].x; - sp44.y += this->unk_380[arg2].y; - sp44.z += this->unk_380[arg2].z; - if (sp53 == 10) { + drawDmgEffAlpha = (f32)this->unk_464[arg2] / this->unk_47C[arg2]; + drawDmgEffType = this->drawDmgEffType; + Math_ApproachF(&this->drawDmgEffFrozenSteamScales[arg2], 0.3f, 0.3f, 0.5f); + Math_Vec3f_Copy(&limbPos[0], &this->actor.world.pos); + limbPos[0].x += this->unk_380[arg2].x; + limbPos[0].y += this->unk_380[arg2].y; + limbPos[0].z += this->unk_380[arg2].z; + if (drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if ((this->unk_47C[arg2] - this->unk_464[arg2]) < 20) { - sp53 = 11; + drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; } - sp40 = 1.0f; + drawDmgEffAlpha = 1.0f; } - func_800BE680(globalCtx, &this->actor, &sp44, 1, 0.3f, this->unk_418[arg2], sp40, sp53); + Actor_DrawDamageEffects(globalCtx, &this->actor, limbPos, ARRAY_COUNT(limbPos), 0.3f, + this->drawDmgEffFrozenSteamScales[arg2], drawDmgEffAlpha, drawDmgEffType); ret = true; } } @@ -275,7 +277,7 @@ void func_808D90F0(EnSw* this, s32 arg1, s16 arg2) { temp = arg2; } - Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, 0); + Matrix_InsertRotationAroundUnitVector_f(BINANG_TO_RAD(temp), &this->unk_368, MTXMODE_NEW); Matrix_MultiplyVector3fByState(&this->unk_350, &sp2C); Math_Vec3f_Copy(&this->unk_350, &sp2C); Math3D_CrossProduct(&this->unk_368, &this->unk_350, &this->unk_35C); @@ -665,7 +667,7 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { // clang-format off for (i = 0; i < ARRAY_COUNT(this->unk_464); i++) { this->unk_464[i] = 0; } // clang-format on @@ -674,43 +676,43 @@ s32 func_808DA08C(EnSw* this, GlobalContext* globalCtx) { } else if (!func_808D90C4(this)) { SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_STALTU_DEAD); Enemy_StartFinishingBlow(globalCtx, &this->actor); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (!ENSW_GET_3(&this->actor)) { - func_8013BC6C(&this->skelAnime, sAnimations, 3); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 3); } switch (this->actor.colChkInfo.damageEffect) { case 4: - this->unk_412 = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; this->unk_45C = 20; func_808D8B58(this); break; case 3: - this->unk_412 = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->unk_45C = 0; func_808D8B58(this); break; case 2: - this->unk_412 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->unk_45C = 20; func_808D8B58(this); break; case 5: - this->unk_412 = 30; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; this->unk_45C = 20; func_808D8B58(this); break; default: - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; this->unk_45C = 0; break; } - if (!ENSW_GET_3(&this->actor) && (this->unk_412 != 10)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { func_808D9E44(this); } this->unk_458 = 20; @@ -856,7 +858,7 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { #endif void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { - if (this->unk_412 == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { s32 i; s32 count; s16 phi_a0; @@ -877,7 +879,7 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { if (!ENSW_GET_3(&this->actor)) { func_808D9E44(this); } - this->unk_412 = 1; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_BLUE_FIRE; func_808D8ED0(this, globalCtx); } return; @@ -921,7 +923,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { Vec3f sp34; f32 temp_f16; - sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->points); + sp44 = Lib_SegmentedToVirtual(this->unk_1E4->points); sp40 = 0; if (DECR(this->unk_454) == 0) { @@ -1065,7 +1067,7 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { phi_a0 = DECR(this->unk_45C); if (phi_a0 == 0) { this->unk_410 |= 2; - if (!ENSW_GET_3(&this->actor) && (this->unk_412 == 1)) { + if (!ENSW_GET_3(&this->actor) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_BLUE_FIRE)) { func_808D8B58(this); this->unk_45C = 10; } else { @@ -1159,7 +1161,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &object_st_Skel_005298, NULL, this->jointTable, this->morphTable, 30); - func_8013BC6C(&this->skelAnime, sAnimations, 0); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, 0); this->skelAnime.playSpeed = 4.0f; Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); @@ -1173,7 +1175,7 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.info.toucher.damage = 16; } - this->unk_1E4 = func_8013BEDC(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); + this->unk_1E4 = SubS_GetDayDependentPath(globalCtx, ENSW_GET_FF00(&this->actor), 255, &this->unk_4A0); if (this->unk_1E4 != NULL) { this->unk_4A0 = 1; } @@ -1185,8 +1187,8 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { break; case 1: - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.world.rot.z < 0) { this->unk_460 = -thisx->world.rot.z; @@ -1206,8 +1208,8 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { case 2: case 3: - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.world.rot.z < 0) { this->unk_460 = -thisx->world.rot.z; @@ -1249,7 +1251,7 @@ void EnSw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc(this, globalCtx); } - if ((this->unk_412 != 10) || (this->unk_45A != 0)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || (this->unk_45A != 0)) { SkelAnime_Update(&this->skelAnime); } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 4c30b4965..b74062705 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -25,9 +25,9 @@ typedef struct EnSw { /* 0x0374 */ Vec3f unk_374; /* 0x0380 */ Vec3f unk_380[12]; /* 0x0410 */ u16 unk_410; - /* 0x0412 */ u8 unk_412; + /* 0x0412 */ u8 drawDmgEffType; /* 0x0414 */ f32 unk_414; - /* 0x0418 */ f32 unk_418[12]; + /* 0x0418 */ f32 drawDmgEffFrozenSteamScales[12]; /* 0x0448 */ f32 unk_448; /* 0x044C */ f32 unk_44C; /* 0x0450 */ f32 unk_450; 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 4b6d4a5d6..23a16debc 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 @@ -5,8 +5,10 @@ */ #include "z_en_syateki_crow.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "objects/object_crow/object_crow.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiCrow*)thisx) @@ -15,7 +17,15 @@ void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809CA5D4(EnSyatekiCrow* this); +void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CA71C(EnSyatekiCrow* this); +void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx); +void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx); + +static Vec3f D_809CB050 = { 0.0f, 0.0f, 0.0f }; + const ActorInit En_Syateki_Crow_InitVars = { ACTOR_EN_SYATEKI_CROW, ACTORCAT_ENEMY, @@ -28,60 +38,286 @@ const ActorInit En_Syateki_Crow_InitVars = { (ActorFunc)EnSyatekiCrow_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_809CB07C[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 1, { { 0, 60, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_809CB0A0 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_809CB07C, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809CB0B0[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -#endif +static Vec3f D_809CB0C0 = { 0.0f, 20.0f, 0.0f }; -extern ColliderJntSphElementInit D_809CB07C[1]; -extern ColliderJntSphInit D_809CB0A0; -extern InitChainEntry D_809CB0B0[]; +static Vec3f D_809CB0CC = { 0.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_060000F0; +static Vec3f D_809CB0D8 = { 2500.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Init.s") +void EnSyatekiCrow_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnSyatekiCrow* this = THIS; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Destroy.s") + path = syatekiMan->path; + while (path->unk2 != 0) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA5D4.s") + for (i = 0; i < EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA67C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + OBJECT_CROW_LIMB_MAX); + Collider_InitJntSph(globalCtx, &this->unk_23C); + Collider_SetJntSph(globalCtx, &this->unk_23C, &this->actor, &sJntSphInit, &this->unk_25C); + this->unk_23C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + ActorShape_Init(&this->actor.shape, 2000.0f, ActorShadow_DrawCircle, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA71C.s") + if ((path == NULL) || (EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor) >= 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA840.s") + this->unk_1C8 = Lib_SegmentedToVirtual(path->points); + this->unk_1CC = 1; + this->unk_1CE = path->count; + this->unk_1C4 = 0x14; + this->unk_1BC = 0; + func_809CA5D4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CA8E4.s") +void EnSyatekiCrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAAF8.s") + Collider_DestroyJntSph(globalCtx, &this->unk_23C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CABC0.s") +void func_809CA5D4(EnSyatekiCrow* this) { + Actor_SetScale(&this->actor, 0.03f); + this->actor.speedXZ = 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->unk_1CC = 1; + this->actor.draw = NULL; + this->actionFunc = func_809CA67C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CACD0.s") +void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Update.s") + if ((syatekiMan->unk_26A == 1) && (this->unk_1C2 == 1) && + (syatekiMan->unk_274 & (1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)))) { + func_809CA71C(this); + } else if (syatekiMan->unk_26A != 1) { + this->unk_1C2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAE5C.s") + if ((syatekiMan->unk_274 == 0) && (syatekiMan->unk_274 == 0)) { + this->unk_1C2 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/func_809CAF2C.s") +void func_809CA71C(EnSyatekiCrow* this) { + Vec3f sp24; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Crow/EnSyatekiCrow_Draw.s") + this->actor.world.pos.x = this->unk_1C8[0].x; + this->actor.world.pos.y = this->unk_1C8[0].y; + this->actor.world.pos.z = this->unk_1C8[0].z; + sp24.x = this->unk_1C8[this->unk_1CC].x; + sp24.y = this->unk_1C8[this->unk_1CC].y; + sp24.z = this->unk_1C8[this->unk_1CC].z; + temp = Math_Vec3f_Yaw(&this->actor.world.pos, &sp24); + this->actor.world.rot.y = temp; + this->actor.shape.rot.y = temp; + temp = Math_Vec3f_Pitch(&this->actor.world.pos, &sp24); + this->actor.shape.rot.x = temp; + this->actor.world.rot.x = temp; + this->actor.draw = EnSyatekiCrow_Draw; + this->actionFunc = func_809CA840; +} + +void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx) { + if (((EN_SYATEKI_CROW_GET_PARAM_F(&this->actor) * 20) + 20) < this->unk_1BC) { + Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_KAICHO_CRY); + this->unk_1BC = 0; + this->actor.speedXZ = EN_SYATEKI_CROW_GET_PARAM_F0(&this->actor) + 6.0f; + this->actor.gravity = -0.5f; + this->actionFunc = func_809CA8E4; + } else { + this->unk_1BC++; + } +} + +void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx) { + Vec3f sp34; + f32 sp30; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A != 1) { + func_809CA5D4(this); + return; + } + + sp34.x = this->unk_1C8[this->unk_1CC].x; + sp34.y = this->unk_1C8[this->unk_1CC].y; + sp34.z = this->unk_1C8[this->unk_1CC].z; + + sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp34); + this->unk_1C0 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); + this->unk_1BE = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34); + + if (sp30 > 100.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_1C0, 5, 0x3000, 0x100); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_1BE, 5, 0x3000, 0x100); + this->actor.world.rot.x = -this->actor.shape.rot.x; + } else if (this->unk_1CC < (this->unk_1CE - 1)) { + this->unk_1CC++; + } else { + this->unk_1C2 = 0; + syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); + func_809CA5D4(this); + } + + SkelAnime_Update(&this->skelAnime); + this->actor.shape.yOffset = (fabsf(this->skelAnime.curFrame - 3.0f) * 150.0f) + 1700.0f; + if ((syatekiMan->unk_26C % 90) == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_CRY); + } +} + +void func_809CAAF8(EnSyatekiCrow* this) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + syatekiMan->unk_280 += 60; + this->unk_1C2 = 0; + this->actor.speedXZ *= Math_CosS(this->actor.world.rot.x); + this->actor.velocity.y = 0.0f; + Animation_Change(&this->skelAnime, &gGuayFlyAnim, 0.4f, 0.0f, 0.0f, 1, -3.0f); + this->actor.bgCheckFlags &= ~1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KAICHO_DEAD); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); + this->actionFunc = func_809CABC0; +} + +void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + this->actor.colorFilterTimer = 40; + + if (this->actor.colorFilterParams & 0x4000) { + Math_ScaledStepToS(&this->actor.shape.rot.x, 0x4000, 0x200); + this->actor.shape.rot.z += 0x1780; + } + + if (this->unk_1C4 > 20) { + func_800B3030(globalCtx, &this->actor.world.pos, &D_809CB050, &D_809CB050, this->actor.scale.x * 10000.0f, 0, + 0); + syatekiMan->unk_27A++; + syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); + func_809CA5D4(this); + } + + this->unk_1C4++; +} + +void func_809CACD0(EnSyatekiCrow* this, GlobalContext* globalCtx) { + if (this->actionFunc == func_809CA8E4) { + if (this->unk_23C.base.acFlags & AC_HIT) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + this->unk_1C4 = 0; + this->unk_23C.base.acFlags &= ~AC_HIT; + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_809CB0C0, &D_809CB0CC, 5, 1); + func_809CAAF8(this); + } else { + this->unk_23C.elements->dim.worldSphere.center.x = this->actor.world.pos.x; + this->unk_23C.elements->dim.worldSphere.center.y = + sJntSphInit.elements[0].dim.modelSphere.center.y + this->actor.world.pos.y; + this->unk_23C.elements->dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_23C.base); + } + } +} + +void EnSyatekiCrow_Update(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_809CABC0) { + Actor_MoveWithoutGravity(&this->actor); + } else { + Actor_MoveWithGravity(&this->actor); + } + + func_809CACD0(this, globalCtx); +} + +s32 EnSyatekiCrow_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiCrow* this = THIS; + + if (limbIndex == OBJECT_CROW_LIMB_UPPER_TAIL) { + rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { + rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + } + + return false; +} + +void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSyatekiCrow* this = THIS; + Vec3f* sp1C; + + if (limbIndex == OBJECT_CROW_LIMB_BODY) { + Matrix_MultiplyVector3fByState(&D_809CB0D8, &this->unk_144[0]); + this->unk_144[0].y -= 20.0f; + } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + sp1C = &this->unk_144[(limbIndex >> 1) - 1]; + Matrix_MultiplyVector3fByState(&D_809CB050, sp1C); + sp1C->y -= 20.0f; + } +} + +void EnSyatekiCrow_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiCrow* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSyatekiCrow_OverrideLimbDraw, EnSyatekiCrow_PostLimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h index 48c9305dd..8946e213f 100644 --- a/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h +++ b/src/overlays/actors/ovl_En_Syateki_Crow/z_en_syateki_crow.h @@ -3,15 +3,31 @@ #include "global.h" +#define EN_SYATEKI_CROW_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_CROW_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_CROW_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + struct EnSyatekiCrow; typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, GlobalContext*); typedef struct EnSyatekiCrow { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x74]; - /* 0x01B8 */ EnSyatekiCrowActionFunc actionFunc; - /* 0x01BC */ char unk_1BC[0xE0]; + /* 0x000 */ Actor actor; + /* 0x144 */ Vec3f unk_144[4]; + /* 0x174 */ SkelAnime skelAnime; + /* 0x1B8 */ EnSyatekiCrowActionFunc actionFunc; + /* 0x1BC */ s16 unk_1BC; + /* 0x1BE */ s16 unk_1BE; + /* 0x1C0 */ s16 unk_1C0; + /* 0x1C2 */ s16 unk_1C2; + /* 0x1C4 */ s16 unk_1C4; + /* 0x1C8 */ Vec3s* unk_1C8; + /* 0x1CC */ s16 unk_1CC; + /* 0x1CE */ s16 unk_1CE; + /* 0x1D0 */ Vec3s jointTable[9]; + /* 0x206 */ Vec3s morphTable[9]; + /* 0x23C */ ColliderJntSph unk_23C; + /* 0x25C */ ColliderJntSphElement unk_25C; } EnSyatekiCrow; // size = 0x29C extern const ActorInit En_Syateki_Crow_InitVars; 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 6d606f8b7..944838b3c 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 @@ -5,8 +5,11 @@ */ #include "z_en_syateki_dekunuts.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" +#include "objects/object_dekunuts/object_dekunuts.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiDekunuts*)thisx) @@ -15,16 +18,23 @@ void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A2BE54(EnSyatekiDekunuts* this); void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2BFC4(EnSyatekiDekunuts* this); void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C150(EnSyatekiDekunuts* this); void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C1AC(EnSyatekiDekunuts* this); void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C27C(EnSyatekiDekunuts* this); void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C3AC(EnSyatekiDekunuts* this); void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void func_80A2C478(EnSyatekiDekunuts* this); void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, ACTORCAT_ENEMY, @@ -37,69 +47,390 @@ const ActorInit En_Syateki_Dekunuts_InitVars = { (ActorFunc)EnSyatekiDekunuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A2CAB0 = { - { COLTYPE_HIT6, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT6, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A2CB90[] = { +static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; + +static AnimationInfo sAnimations[] = { + { &object_dekunuts_Anim_003180, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_002A5C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_00326C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_dekunuts_Anim_002FA4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_dekunuts_Anim_00259C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_002BD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dekunuts_Anim_002DD4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), ICHAIN_F32(gravity, 0, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -#endif +void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { + static s32 D_80A2CB9C = 1; + EnSyatekiDekunuts* this = THIS; + GlobalContext* globalCtx = globalCtx2; + s32 phi_v0; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -extern ColliderCylinderInit D_80A2CAB0; -extern InitChainEntry D_80A2CB90[]; + path = syatekiMan->path; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -extern UNK_TYPE D_06001E50; -extern UNK_TYPE D_06002A5C; -extern UNK_TYPE D_06003180; + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + Actor_SetScale(&this->actor, 0.01f); + this->collider.dim = D_80A2CADC[0]; + phi_v0 = 3; + } else { + Actor_SetScale(&this->actor, 0.02f); + phi_v0 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Init.s") + while (path->unk2 != phi_v0) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Destroy.s") + for (i = 0; i < EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BE54.s") + if (D_80A2CB9C == 1) { + this->unk_1EC = 1; + D_80A2CB9C = 0; + } else { + this->unk_1EC = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BF18.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_dekunuts_Skel_002468, &object_dekunuts_Anim_002A5C, + this->jointTable, this->morphTable, 10); + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2BFC4.s") + this->unk_1E4 = Lib_SegmentedToVirtual(path->points); + this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(&this->actor); + this->unk_1EA = path->count; + this->unk_1D8 = 0; + this->unk_1DC = 0; + this->unk_1DA = 0; + func_80A2BE54(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C0F8.s") +void EnSyatekiDekunuts_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C150.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C168.s") +void func_80A2BE54(EnSyatekiDekunuts* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &object_dekunuts_Anim_003180, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C1AC.s") + this->actor.speedXZ = 0.0f; + this->actor.world = this->actor.home; + this->actor.prevPos = this->actor.home.pos; + this->actor.shape.rot = this->actor.world.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C208.s") + this->unk_1D8 = 0; + this->unk_1DC = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C27C.s") + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C2E0.s") + this->actionFunc = func_80A2BF18; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C33C.s") +void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3AC.s") + if ((syatekiMan->unk_26A == 1) && (this->unk_1E2 == 1) && ((syatekiMan->unk_272 & (1 << this->unk_1E8)) != 0)) { + func_80A2BFC4(this); + } else if (syatekiMan->unk_26A != 1) { + this->unk_1E2 = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C3F0.s") + if ((syatekiMan->unk_272 == 0) && (syatekiMan->unk_274 == 0) && + (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { + this->unk_1E2 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C478.s") +void func_80A2BFC4(EnSyatekiDekunuts* this) { + Vec3f sp14; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C48C.s") + this->unk_1D8 = 0; + sp14.x = this->unk_1E4[this->unk_1E8].x; + sp14.y = this->unk_1E4[this->unk_1E8].y; + sp14.z = this->unk_1E4[this->unk_1E8].z; + this->actor.world.pos = this->actor.prevPos = sp14; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->unk_1EE = 140 - (syatekiMan->unk_27C * 20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C4D0.s") + if ((syatekiMan->unk_27C & 1) != 0) { + this->unk_1F0 = 1; + this->unk_1F2 = 0; + } else { + this->unk_1F0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C5DC.s") + this->actionFunc = func_80A2C0F8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Update.s") +void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/func_80A2C8A0.s") + if (this->unk_1DA > 20) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1DA = 0; + func_80A2C150(this); + } else { + this->unk_1DA++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Dekunuts/EnSyatekiDekunuts_Draw.s") +void func_80A2C150(EnSyatekiDekunuts* this) { + this->unk_1D8 = 0; + this->actionFunc = func_80A2C168; +} + +void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2C1AC(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C1AC(EnSyatekiDekunuts* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actionFunc = func_80A2C208; +} + +void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A2C27C(this); + } + + if (this->unk_1F0 == 1) { + Math_SmoothStepToS(&this->unk_1F2, -0x8000, 5, 0x1000, 0x100); + } + + this->unk_1D8++; +} + +void func_80A2C27C(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + this->actionFunc = func_80A2C2E0; + } else { + this->actionFunc = func_80A2C33C; + } +} + +void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + this->unk_1D8++; +} + +void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->unk_26A != 1)) { + func_80A2C3AC(this); + } + + if (this->unk_1D8 < 11) { + this->unk_1D8++; + } +} + +void func_80A2C3AC(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A2C3F0; +} + +void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A == 1) { + if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_1D8 = 0; + func_80A2C150(this); + } else { + this->unk_1D8++; + } + } else { + func_80A2C478(this); + } +} + +void func_80A2C478(EnSyatekiDekunuts* this) { + this->actionFunc = func_80A2C48C; +} + +void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + if (this->unk_1DA > 20) { + func_80A2BE54(this); + this->unk_1DA = 0; + } else { + this->unk_1DA++; + } +} + +void func_80A2C4D0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Vec3f D_80A2CBA0 = { 0.0f, 20.0f, 0.0f }; + static Vec3f D_80A2CBAC = { 0.0f, 0.0f, 0.0f }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 2); + syatekiMan->unk_280 += 100; + syatekiMan->unk_26E++; + } else { + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A2CBA0, &D_80A2CBAC, 5, 0); + syatekiMan->unk_280 += 30; + syatekiMan->unk_278++; + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DAMAGE); + this->unk_1E2 = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->unk_1D8 = 160; + this->actionFunc = func_80A2C5DC; +} + +void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { + static Color_RGBA8 D_80A2CBB8 = { 255, 255, 255, 255 }; + static Color_RGBA8 D_80A2CBBC = { 150, 150, 150, 0 }; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_1D8 == 160) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); + this->unk_1D8--; + } else if (this->unk_1D8 < 160) { + Vec3f sp40; + + sp40.x = this->actor.world.pos.x; + sp40.y = this->actor.world.pos.y + 18.0f; + sp40.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + sp40.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(globalCtx, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { + syatekiMan->unk_272 &= ~(1 << this->unk_1E8); + } + + func_80A2BE54(this); + } + } else if (this->unk_1D8 < 160) { + this->unk_1D8--; + } +} + +void EnSyatekiDekunuts_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiDekunuts* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != func_80A2BF18) && (this->unk_1D8 < this->unk_1EE) && (this->unk_1D8 > 10)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->unk_1E2 == 1)) { + if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { + func_801A3098(NA_BGM_GET_ITEM | 0x900); + } else { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + + this->collider.base.acFlags &= ~AC_HIT; + func_80A2C4D0(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + SkelAnime_Update(&this->skelAnime); +} + +s32 EnSyatekiDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnSyatekiDekunuts* this = THIS; + + if ((limbIndex == OBJECT_DEKUNUTS_LIMB_03) && (this->unk_1F0 == 1)) { + rot->z += this->unk_1F2; + } + + return false; +} + +void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiDekunuts* this = THIS; + Vec3f temp_f20; + s32 i; + + if (this->actionFunc != func_80A2BF18) { + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); + } + + if (this->unk_1EC == 1) { + for (i = 0; i < this->unk_1EA; i++) { + temp_f20.x = this->unk_1E4[i].x; + temp_f20.y = this->unk_1E4[i].y; + temp_f20.z = this->unk_1E4[i].z; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &object_dekunuts_DL_001E50); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } + } +} diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h index 30712d917..4055dd6b8 100644 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h +++ b/src/overlays/actors/ovl_En_Syateki_Dekunuts/z_en_syateki_dekunuts.h @@ -3,15 +3,34 @@ #include "global.h" +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + struct EnSyatekiDekunuts; typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, GlobalContext*); typedef struct EnSyatekiDekunuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiDekunutsActionFunc actionFunc; - /* 0x018C */ char unk_18C[0xE4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiDekunutsActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ s16 unk_1D8; + /* 0x1DA */ s16 unk_1DA; + /* 0x1CD */ s16 unk_1DC; + /* 0x1DE */ UNK_TYPE1 unk_1DE[0x4]; + /* 0x1E2 */ s16 unk_1E2; + /* 0x1E4 */ Vec3s* unk_1E4; + /* 0x1E8 */ s16 unk_1E8; + /* 0x1EA */ s16 unk_1EA; + /* 0x1EC */ s16 unk_1EC; + /* 0x1EE */ s16 unk_1EE; + /* 0x1F0 */ s16 unk_1F0; + /* 0x1F2 */ s16 unk_1F2; + /* 0x1F4 */ Vec3s jointTable[10]; + /* 0x230 */ Vec3s morphTable[10]; + /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 extern const ActorInit En_Syateki_Dekunuts_InitVars; 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 5f57ec177..dcb1ec98d 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 @@ -7,7 +7,7 @@ #include "z_en_syateki_man.h" #include "objects/object_shn/object_shn.h" -#define FLAGS 0x08000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiMan*)thisx) @@ -47,10 +47,10 @@ const ActorInit En_Syateki_Man_InitVars = { (ActorFunc)EnSyatekiMan_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, 2, -8.0f }, +static AnimationInfo sAnimations[] = { + { &object_shn_Anim_00D9D0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_shn_Anim_00DFEC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_shn_Anim_00D2F8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, }; static s16 D_809C91C8[] = { @@ -132,11 +132,11 @@ void EnSyatekiMan_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 1; Actor_SetScale(&this->actor, 0.01f); if (globalCtx->sceneNum == SCENE_SYATEKI_MORI) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_shn_Skel_00E7D0, &object_shn_Anim_00DFEC, - this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00DFEC, this->jointTable, + this->morphTable, OBJECT_SHN_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_shn_Skel_00E7D0, &object_shn_Anim_00D9D0, - this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gObjectShnSkel, &object_shn_Anim_00D9D0, this->jointTable, + this->morphTable, OBJECT_SHN_LIMB_MAX); } this->actor.colChkInfo.cylRadius = 100; @@ -207,34 +207,34 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { u16 sp22; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); sp22 = Text_GetFaceReaction(globalCtx, 0x31); if (sp22 != 0) { - func_801518B0(globalCtx, sp22, &this->actor); + Message_StartTextbox(globalCtx, sp22, &this->actor); this->unk_284 = sp22; } else if (player->transformation == PLAYER_FORM_HUMAN) { if (this->unk_282 == 0) { this->unk_282 = 1; - func_801518B0(globalCtx, 0xA28, &this->actor); + Message_StartTextbox(globalCtx, 0xA28, &this->actor); this->unk_284 = 0xA28; } else { - func_801518B0(globalCtx, 0xA29, &this->actor); + Message_StartTextbox(globalCtx, 0xA29, &this->actor); this->unk_284 = 0xA29; } } else { switch (CURRENT_DAY) { case 1: - func_801518B0(globalCtx, 0xA38, &this->actor); + Message_StartTextbox(globalCtx, 0xA38, &this->actor); this->unk_284 = 0xA38; break; case 2: - func_801518B0(globalCtx, 0xA39, &this->actor); + Message_StartTextbox(globalCtx, 0xA39, &this->actor); this->unk_284 = 0xA39; break; case 3: - func_801518B0(globalCtx, 0xA3A, &this->actor); + Message_StartTextbox(globalCtx, 0xA3A, &this->actor); this->unk_284 = 0xA3A; break; } @@ -252,15 +252,15 @@ void func_809C6848(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0xA30, &this->actor); + Message_StartTextbox(globalCtx, 0xA30, &this->actor); this->unk_284 = 0xA30; } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); - func_801518B0(globalCtx, 0xA31, &this->actor); + Message_StartTextbox(globalCtx, 0xA31, &this->actor); this->unk_284 = 0xA31; if (this->unk_26A == 4) { gSaveContext.minigameState = 3; @@ -282,17 +282,17 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { switch (CURRENT_DAY) { case 1: - func_801518B0(globalCtx, 0xA2D, &this->actor); + Message_StartTextbox(globalCtx, 0xA2D, &this->actor); this->unk_284 = 0xA2D; break; case 2: - func_801518B0(globalCtx, 0xA2E, &this->actor); + Message_StartTextbox(globalCtx, 0xA2E, &this->actor); this->unk_284 = 0xA2E; break; case 3: - func_801518B0(globalCtx, 0xA2F, &this->actor); + Message_StartTextbox(globalCtx, 0xA2F, &this->actor); this->unk_284 = 0xA2F; break; } @@ -309,11 +309,11 @@ void func_809C6A04(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0xA28: case 0xA29: - func_801518B0(globalCtx, 0xA2A, &this->actor); + Message_StartTextbox(globalCtx, 0xA2A, &this->actor); this->unk_284 = 0xA2A; break; @@ -341,13 +341,13 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { gSaveContext.minigameState = 3; this->unk_26A = 0; } else { - func_801518B0(globalCtx, 0xA33, &this->actor); + Message_StartTextbox(globalCtx, 0xA33, &this->actor); this->unk_284 = 0xA33; } break; case 0xA33: - func_801518B0(globalCtx, 0xA2A, &this->actor); + Message_StartTextbox(globalCtx, 0xA2A, &this->actor); this->unk_284 = 0xA2A; this->unk_26A = 4; break; @@ -387,7 +387,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; player->stateFlags1 &= ~0x20; @@ -410,7 +410,7 @@ void func_809C6E30(EnSyatekiMan* this, GlobalContext* globalCtx) { if (this->skelAnime.animation == &object_shn_Anim_00D2F8) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); } } } @@ -422,18 +422,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 1)) { this->unk_282 |= 1; - func_801518B0(globalCtx, 0x3E8, &this->actor); + Message_StartTextbox(globalCtx, 0x3E8, &this->actor); this->unk_284 = 0x3E8; } else { - func_801518B0(globalCtx, 0x3E9, &this->actor); + Message_StartTextbox(globalCtx, 0x3E9, &this->actor); this->unk_284 = 0x3E9; } } else if (!(this->unk_282 & 1)) { this->unk_282 |= 1; - func_801518B0(globalCtx, 0x3EA, &this->actor); + Message_StartTextbox(globalCtx, 0x3EA, &this->actor); this->unk_284 = 0x3EA; } else { - func_801518B0(globalCtx, 0x3EB, &this->actor); + Message_StartTextbox(globalCtx, 0x3EB, &this->actor); this->unk_284 = 0x3EB; } break; @@ -442,18 +442,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 2)) { this->unk_282 |= 2; - func_801518B0(globalCtx, 0x3EC, &this->actor); + Message_StartTextbox(globalCtx, 0x3EC, &this->actor); this->unk_284 = 0x3EC; } else { - func_801518B0(globalCtx, 0x3ED, &this->actor); + Message_StartTextbox(globalCtx, 0x3ED, &this->actor); this->unk_284 = 0x3ED; } } else if (!(this->unk_282 & 2)) { this->unk_282 |= 2; - func_801518B0(globalCtx, 0x3EE, &this->actor); + Message_StartTextbox(globalCtx, 0x3EE, &this->actor); this->unk_284 = 0x3EE; } else { - func_801518B0(globalCtx, 0x3EF, &this->actor); + Message_StartTextbox(globalCtx, 0x3EF, &this->actor); this->unk_284 = 0x3EF; } break; @@ -462,18 +462,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 8)) { this->unk_282 |= 8; - func_801518B0(globalCtx, 0x3F0, &this->actor); + Message_StartTextbox(globalCtx, 0x3F0, &this->actor); this->unk_284 = 0x3F0; } else { - func_801518B0(globalCtx, 0x3F1, &this->actor); + Message_StartTextbox(globalCtx, 0x3F1, &this->actor); this->unk_284 = 0x3F1; } } else if (!(this->unk_282 & 8)) { this->unk_282 |= 8; - func_801518B0(globalCtx, 0x3F4, &this->actor); + Message_StartTextbox(globalCtx, 0x3F4, &this->actor); this->unk_284 = 0x3F4; } else { - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; } break; @@ -482,18 +482,18 @@ void func_809C6F98(EnSyatekiMan* this, GlobalContext* globalCtx) { if (CURRENT_DAY != 3) { if (!(this->unk_282 & 4)) { this->unk_282 |= 4; - func_801518B0(globalCtx, 0x3F2, &this->actor); + Message_StartTextbox(globalCtx, 0x3F2, &this->actor); this->unk_284 = 0x3F2; } else { - func_801518B0(globalCtx, 0x3F3, &this->actor); + Message_StartTextbox(globalCtx, 0x3F3, &this->actor); this->unk_284 = 0x3F3; } } else if (!(this->unk_282 & 4)) { this->unk_282 |= 4; - func_801518B0(globalCtx, 0x3F4, &this->actor); + Message_StartTextbox(globalCtx, 0x3F4, &this->actor); this->unk_284 = 0x3F4; } else { - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; } break; @@ -505,7 +505,7 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { u16 sp26 = Text_GetFaceReaction(globalCtx, 0x30); if (sp26 != 0) { - func_801518B0(globalCtx, sp26, &this->actor); + Message_StartTextbox(globalCtx, sp26, &this->actor); this->unk_284 = sp26; } else { func_809C6F98(this, globalCtx); @@ -519,24 +519,24 @@ void func_809C72D8(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex == 0) { if (!CUR_UPG_VALUE(UPG_QUIVER)) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3F9, &this->actor); + Message_StartTextbox(globalCtx, 0x3F9, &this->actor); this->unk_284 = 0x3F9; } else { - func_801518B0(globalCtx, 0x3FA, &this->actor); + Message_StartTextbox(globalCtx, 0x3FA, &this->actor); this->unk_284 = 0x3FA; } } else if (gSaveContext.save.playerData.rupees < 20) { play_sound(NA_SE_SY_ERROR); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3FB, &this->actor); + Message_StartTextbox(globalCtx, 0x3FB, &this->actor); this->unk_284 = 0x3FB; } else { - func_801518B0(globalCtx, 0x3FC, &this->actor); + Message_StartTextbox(globalCtx, 0x3FC, &this->actor); this->unk_284 = 0x3FC; } @@ -551,10 +551,10 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 2; if (!(this->unk_282 & 0x10)) { this->unk_282 |= 0x10; - func_801518B0(globalCtx, 0x3FD, &this->actor); + Message_StartTextbox(globalCtx, 0x3FD, &this->actor); this->unk_284 = 0x3FD; } else { - func_801518B0(globalCtx, 0x3FF, &this->actor); + Message_StartTextbox(globalCtx, 0x3FF, &this->actor); this->unk_284 = 0x3FF; } gSaveContext.save.weekEventReg[63] |= 1; @@ -563,10 +563,10 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { } else { func_8019F230(); if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x3F7, &this->actor); + Message_StartTextbox(globalCtx, 0x3F7, &this->actor); this->unk_284 = 0x3F7; } else { - func_801518B0(globalCtx, 0x3F8, &this->actor); + Message_StartTextbox(globalCtx, 0x3F8, &this->actor); this->unk_284 = 0x3F8; } @@ -582,38 +582,38 @@ void func_809C7380(EnSyatekiMan* this, GlobalContext* globalCtx) { void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->unk_284) { case 0x3E8: case 0x3E9: case 0x3EA: case 0x3EB: - func_801518B0(globalCtx, 0x3F6, &this->actor); + Message_StartTextbox(globalCtx, 0x3F6, &this->actor); this->unk_284 = 0x3F6; break; case 0x3EC: - func_801518B0(globalCtx, 0x3ED, &this->actor); + Message_StartTextbox(globalCtx, 0x3ED, &this->actor); this->unk_284 = 0x3ED; break; case 0x3EE: - func_801518B0(globalCtx, 0x3EF, &this->actor); + Message_StartTextbox(globalCtx, 0x3EF, &this->actor); this->unk_284 = 0x3EF; break; case 0x3F0: - func_801518B0(globalCtx, 0x3F1, &this->actor); + Message_StartTextbox(globalCtx, 0x3F1, &this->actor); this->unk_284 = 0x3F1; break; case 0x3F2: - func_801518B0(globalCtx, 0x3F3, &this->actor); + Message_StartTextbox(globalCtx, 0x3F3, &this->actor); this->unk_284 = 0x3F3; break; case 0x3F4: - func_801518B0(globalCtx, 0x3F5, &this->actor); + Message_StartTextbox(globalCtx, 0x3F5, &this->actor); this->unk_284 = 0x3F5; break; @@ -621,10 +621,10 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { case 0x3FF: if (this->unk_26A == 4) { if (this->unk_284 == 0x3FD) { - func_801518B0(globalCtx, 0x3FE, &this->actor); + Message_StartTextbox(globalCtx, 0x3FE, &this->actor); this->unk_284 = 0x3FE; } else { - func_801518B0(globalCtx, 0x400, &this->actor); + Message_StartTextbox(globalCtx, 0x400, &this->actor); this->unk_284 = 0x400; } } else { @@ -660,7 +660,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { - func_801518B0(globalCtx, 0x402, &this->actor); + Message_StartTextbox(globalCtx, 0x402, &this->actor); this->unk_284 = 0x402; } break; @@ -673,14 +673,14 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 0; this->actionFunc = func_809C72D8; } else { - func_801518B0(globalCtx, 0x404, &this->actor); + Message_StartTextbox(globalCtx, 0x404, &this->actor); this->unk_284 = 0x404; } break; case 0x402: case 0x404: - func_801518B0(globalCtx, 0x3F6, &this->actor); + Message_StartTextbox(globalCtx, 0x3F6, &this->actor); this->unk_284 = 0x3F6; this->unk_26A = 4; break; @@ -721,7 +721,7 @@ void func_809C7990(EnSyatekiMan* this, GlobalContext* globalCtx) { break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { gSaveContext.save.weekEventReg[63] &= (u8)~1; gSaveContext.save.weekEventReg[63] &= (u8)~2; player->stateFlags1 &= ~0x20; @@ -774,15 +774,15 @@ void func_809C7C14(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if ((CURRENT_DAY == 3) && (gSaveContext.save.time > CLOCK_TIME(12, 00))) { - func_801518B0(globalCtx, 0xA36, &this->actor); + if ((CURRENT_DAY == 3) && (gSaveContext.save.time > CLOCK_TIME(12, 0))) { + Message_StartTextbox(globalCtx, 0xA36, &this->actor); this->unk_284 = 0xA36; } else { - func_801518B0(globalCtx, 0xA37, &this->actor); + Message_StartTextbox(globalCtx, 0xA37, &this->actor); this->unk_284 = 0xA37; } player->stateFlags1 &= ~0x20; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_280 = 0; this->unk_26A = 0; this->actionFunc = func_809C6E30; @@ -832,7 +832,7 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (CURRENT_DAY != 3) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { player->stateFlags1 &= ~0x20; this->unk_280 = 0; this->unk_26A = 0; @@ -841,10 +841,10 @@ void func_809C7EB4(EnSyatekiMan* this, GlobalContext* globalCtx) { this->actionFunc = func_809C6810; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x408, &this->actor); + Message_StartTextbox(globalCtx, 0x408, &this->actor); this->unk_284 = 0x408; player->stateFlags1 &= ~0x20; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_280 = 0; this->unk_26A = 0; this->actionFunc = func_809C7990; @@ -861,10 +861,10 @@ void func_809C7FFC(EnSyatekiMan* this, GlobalContext* globalCtx) { this->unk_26A = 2; if (this->unk_282 != 2) { this->unk_282 = 2; - func_801518B0(globalCtx, 0xA2B, &this->actor); + Message_StartTextbox(globalCtx, 0xA2B, &this->actor); this->unk_284 = 0xA2B; } else { - func_801518B0(globalCtx, 0xA2C, &this->actor); + Message_StartTextbox(globalCtx, 0xA2C, &this->actor); this->unk_284 = 0xA2C; } this->actionFunc = func_809C6E30; @@ -979,7 +979,7 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { } this->unk_270 = 15; if (this->unk_280 >= 0x848) { - func_801518B0(globalCtx, 0xA34, &this->actor); + Message_StartTextbox(globalCtx, 0xA34, &this->actor); this->unk_284 = 0xA34; this->unk_26A = 6; } else if (this->unk_280 >= 0x7D0) { @@ -991,12 +991,12 @@ void func_809C8488(EnSyatekiMan* this, GlobalContext* globalCtx) { this->actionFunc = func_809C6848; return; } - func_801518B0(globalCtx, 0xA35, &this->actor); + Message_StartTextbox(globalCtx, 0xA35, &this->actor); this->unk_284 = 0xA35; this->unk_26A = 4; this->unk_280 = 0; } else { - func_801518B0(globalCtx, 0xA32, &this->actor); + Message_StartTextbox(globalCtx, 0xA32, &this->actor); this->unk_284 = 0xA32; this->unk_26A = 6; } @@ -1047,10 +1047,10 @@ void func_809C8710(EnSyatekiMan* this, GlobalContext* globalCtx) { if (func_809C6720(globalCtx, sp24)) { if (this->unk_284 == 0x3FD) { - func_801518B0(globalCtx, 0x3FE, &this->actor); + Message_StartTextbox(globalCtx, 0x3FE, &this->actor); this->unk_284 = 0x3FE; } else { - func_801518B0(globalCtx, 0x400, &this->actor); + Message_StartTextbox(globalCtx, 0x400, &this->actor); this->unk_284 = 0x400; } this->unk_26A = 2; @@ -1167,27 +1167,27 @@ void func_809C8BF0(EnSyatekiMan* this, GlobalContext* globalCtx) { if (((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) || (this->unk_280 == 50)) { if ((s32)(gSaveContext.save.unk_EF4 & 0xFFFF) < this->unk_280) { if (!(gSaveContext.save.weekEventReg[59] & 0x20)) { - func_801518B0(globalCtx, 0x407, &this->actor); + Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } else if (this->unk_280 == 50) { - func_801518B0(globalCtx, 0x405, &this->actor); + Message_StartTextbox(globalCtx, 0x405, &this->actor); this->unk_284 = 0x405; } else { - func_801518B0(globalCtx, 0x407, &this->actor); + Message_StartTextbox(globalCtx, 0x407, &this->actor); this->unk_284 = 0x407; } } else if (this->unk_280 == 50) { - func_801518B0(globalCtx, 0x406, &this->actor); + Message_StartTextbox(globalCtx, 0x406, &this->actor); this->unk_284 = 0x406; } gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | (this->unk_280 & 0xFFFF); this->unk_26A = 6; } else { if (CURRENT_DAY != 3) { - func_801518B0(globalCtx, 0x401, &this->actor); + Message_StartTextbox(globalCtx, 0x401, &this->actor); this->unk_284 = 0x401; } else { - func_801518B0(globalCtx, 0x403, &this->actor); + Message_StartTextbox(globalCtx, 0x403, &this->actor); this->unk_284 = 0x403; } this->unk_26A = 4; 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 6360f0f39..94f2f3495 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 @@ -5,8 +5,9 @@ */ #include "z_en_syateki_okuta.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiOkuta*)thisx) @@ -15,14 +16,18 @@ void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A36260(EnSyatekiOkuta* this); void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A362F8(EnSyatekiOkuta* this); void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36444(EnSyatekiOkuta* this); void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A364C0(EnSyatekiOkuta* this); void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx); void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx); +void func_80A36CB0(EnSyatekiOkuta* this); -#if 0 const ActorInit En_Syateki_Okuta_InitVars = { ACTOR_EN_SYATEKI_OKUTA, ACTORCAT_ENEMY, @@ -35,72 +40,483 @@ const ActorInit En_Syateki_Okuta_InitVars = { (ActorFunc)EnSyatekiOkuta_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A37570 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, -30, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A37B88[] = { +static AnimationInfo sAnimations[] = { + { &object_okuta_Anim_00044C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_003958, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_003B24, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_003EE4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_okuta_Anim_00466C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_okuta_Anim_004204, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +#include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; -#endif +Color_RGBA8 D_80A37B90 = { 255, 255, 255, 255 }; -extern ColliderCylinderInit D_80A37570; -extern InitChainEntry D_80A37B88[]; +Color_RGBA8 D_80A37B94 = { 150, 150, 150, 255 }; -extern UNK_TYPE D_0600466C; +Vec3f D_80A37B98 = { 0.0f, -0.5, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Init.s") +Color_RGBA8 D_80A37BA4 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Destroy.s") +Color_RGBA8 D_80A37BA8 = { 150, 150, 150, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36148.s") +void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + WaterBox* waterbox; + f32 ySurface; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361B0.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_okuta_Skel_0033D0, &object_okuta_Anim_00466C, this->jointTable, + this->morphTable, OBJECT_OKUTA_LIMB_MAX); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A361F4.s") + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &bgId, + &this->actor, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36260.s") + if (!(WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &ySurface, &waterbox)) || + (ySurface <= this->actor.floorHeight)) { + Actor_MarkForDeath(&this->actor); + } else { + this->actor.world.pos.y = this->actor.home.pos.y = ySurface; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362A8.s") + this->unk_2A4 = 0; + this->unk_2AA = 0; + func_80A36260(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A362F8.s") +void EnSyatekiOkuta_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36350.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36360.s") +void func_80A36148(Vec3f* pos, Vec3f* velocity, s16 scaleStep, GlobalContext* globalCtx) { + func_800B0DE0(globalCtx, pos, velocity, &gZeroVec3f, &D_80A37B90, &D_80A37B94, 400, scaleStep); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A363B4.s") +void func_80A361B0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EffectSsGSplash_Spawn(globalCtx, &this->actor.home.pos, NULL, NULL, 0, 800); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36444.s") +s32 func_80A361F4(EnSyatekiOkuta* this) { + s32 temp_a0; + s32 temp_a1; + s32 temp_v1; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36488.s") + temp_v1 = EN_SYATEKI_OKUTA_GET_F(&this->actor); + if ((temp_v1 == 1) || (temp_v1 == 4)) { + temp_a0 = syatekiMan->unk_190; + temp_a1 = (temp_v1 * 2) + 6; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A364C0.s") + if ((temp_a0 >> temp_a1) & 3) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36504.s") + if ((temp_a1 == 8) && ((temp_a0 >> 0xE) & 3)) { + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A3657C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A365EC.s") +void func_80A36260(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + this->actor.draw = NULL; + this->actionFunc = func_80A362A8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A368E0.s") +void func_80A362A8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Actor* actorIt = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36A90.s") + while (actorIt != NULL) { + if (actorIt->id == ACTOR_EN_SYATEKI_MAN) { + this->actor.parent = actorIt; + func_80A362F8(this); + break; + } else { + actorIt = actorIt->next; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36AF8.s") +void func_80A362F8(EnSyatekiOkuta* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &object_okuta_Anim_00466C, 0.0f); + this->actor.draw = NULL; + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80A36350; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Update.s") +void func_80A36350(EnSyatekiOkuta* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A36CB0.s") +void func_80A36360(EnSyatekiOkuta* this) { + this->actor.draw = EnSyatekiOkuta_Draw; + this->unk_2AA = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->actionFunc = func_80A363B4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A370EC.s") +void func_80A363B4(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((Animation_OnFrame(&this->skelAnime, 2.0f)) || (Animation_OnFrame(&this->skelAnime, 15.0f))) { + if (func_80A361F4(this)) { + return; + } else { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_JUMP); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/func_80A37294.s") + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A36444(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Okuta/EnSyatekiOkuta_Draw.s") +void func_80A36444(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80A36488; +} + +void func_80A36488(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26C >= 0x46) { + func_80A364C0(this); + } +} + +void func_80A364C0(EnSyatekiOkuta* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80A36504; +} + +void func_80A36504(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + func_80A361B0(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_LAND); + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A362F8(this); + } +} + +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_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actionFunc = func_80A365EC; +} + +void func_80A365EC(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + Vec3f sp84; + Vec3f sp78; + s32 pad; + s32 i; + + if (this->unk_2AA > 0) { + this->unk_2AA -= 15; + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_2A4 == 0) { + sp78.x = this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y + 40.0f; + sp78.z = this->actor.world.pos.z; + sp84.x = 0.0f; + sp84.y = -0.5f; + sp84.z = 0.0f; + func_80A36148(&sp78, &sp84, -20, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_OCTAROCK_DEAD2); + } + + this->unk_2A4++; + } + + if (Animation_OnFrame(&this->skelAnime, 15.0f)) { + func_80A361B0(this, globalCtx); + } + + if (this->unk_2A4 < 3) { + Actor_SetScale(&this->actor, ((this->unk_2A4 * 0.25f) + 1.0f) * 0.01f); + } else if (this->unk_2A4 < 6) { + Actor_SetScale(&this->actor, (1.5f - ((this->unk_2A4 - 2) * 0.2333f)) * 0.01f); + } else if (this->unk_2A4 < 11) { + Actor_SetScale(&this->actor, (((this->unk_2A4 - 5) * 0.04f) + 0.8f) * 0.01f); + } else { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.002f)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_COMMON_WATER_MID); + for (i = 0; i < 10; i++) { + sp84.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + sp84.y = Rand_ZeroOne() * 7.0f; + sp84.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, + &D_80A37BA8, Rand_S16Offset(100, 50), 25, 0); + } + + func_80A362F8(this); + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + } +} + +void func_80A368E0(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + this->collider.dim.height = + (sCylinderInit.dim.height - this->collider.dim.yShift) * this->unk_1D8.y * this->actor.scale.y * 100.0f; + this->collider.dim.radius = sCylinderInit.dim.radius * this->actor.scale.x * 100.0f; + + if (this->actionFunc == func_80A363B4) { + if ((this->unk_2A6 == 2) && func_80A361F4(this)) { + return; + } + + if (this->skelAnime.curFrame < (this->skelAnime.endFrame - 5.0f)) { + this->collider.dim.height *= 1.35f; + } + } + + if (this->unk_2A6 == 1) { + this->collider.dim.radius += 10; + this->collider.dim.height += 15; + } + + this->collider.dim.pos.x = this->actor.world.pos.x; + // jointTable->y is the y-translation of the skeleton root + this->collider.dim.pos.y = this->actor.world.pos.y + (this->skelAnime.jointTable->y * this->actor.scale.y); + this->collider.dim.pos.z = this->actor.world.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +s32 func_80A36A90(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + if ((this->actionFunc == func_80A365EC) || (this->actionFunc == func_80A36350)) { + return false; + } + + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + return true; + } + + func_80A368E0(this, globalCtx); + return false; +} + +void func_80A36AF8(EnSyatekiOkuta* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s16 temp_v1_2; + + if ((this->actionFunc != func_80A36488) && (this->actionFunc != func_80A363B4) && (syatekiMan->unk_26A == 1) && + (syatekiMan->unk_26C == 0)) { + temp_v1_2 = (syatekiMan->unk_190 >> (EN_SYATEKI_OKUTA_GET_F(&this->actor) * 2)) & 3; + if (temp_v1_2 > 0) { + Actor_SetScale(&this->actor, 0.01f); + this->unk_2A6 = temp_v1_2; + func_80A36360(this); + } + } +} + +void EnSyatekiOkuta_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiOkuta* this = THIS; + EnSyatekiMan* syatekiMan; + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_80A36350) { + SkelAnime_Update(&this->skelAnime); + } + + func_80A36AF8(this, globalCtx); + + if (func_80A36A90(this, globalCtx)) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + if (this->unk_2A6 == 1) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + globalCtx->interfaceCtx.unk_25C++; + syatekiMan->unk_280++; + syatekiMan->unk_26E = 1; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_ERROR); + syatekiMan->unk_26E = 2; + } + + func_80A3657C(this); + } else { + this->collider.base.acFlags &= ~AC_HIT; + } + + func_80A36CB0(this); +} + +void func_80A36CB0(EnSyatekiOkuta* this) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->actionFunc == func_80A363B4) { + if (curFrame < 8.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 10.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = ((curFrame - 7.0f) * 0.4f) + 1.0f; + } else if (curFrame < 14.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 9.0f) * 0.075f) + 1.0f; + this->unk_1D8.y = 1.8f - ((curFrame - 9.0f) * 0.25f); + } else { + this->unk_1D8.x = this->unk_1D8.z = 1.3f - ((curFrame - 13.0f) * 0.05f); + this->unk_1D8.y = ((curFrame - 13.0f) * 0.0333f) + 0.8f; + } + } else if (this->actionFunc == func_80A36488) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + this->unk_1D8.y = (sin_rad((M_PI / 16) * curFrame) * 0.2f) + 1.0f; + } else if (this->actionFunc == func_80A36504) { + if (curFrame < 3.0f) { + this->unk_1D8.y = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.y = (curFrame - 2.0f) + 1.0f; + } else { + this->unk_1D8.y = 2.0f - ((curFrame - 3.0f) * 0.333f); + } + this->unk_1D8.x = this->unk_1D8.z = 1.0f; + } else if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + if (curFrame >= 35.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } else if (curFrame < 4.0f) { + this->unk_1D8.x = this->unk_1D8.z = 1.0f - (curFrame * 0.0666f); + this->unk_1D8.y = (curFrame * 0.1666f) + 1.0f; + } else if (curFrame < 25.0f) { + this->unk_1D8.x = this->unk_1D8.z = ((curFrame - 4.0f) * 0.01f) + 0.8f; + this->unk_1D8.y = 1.5f - ((curFrame - 4.0f) * 0.025f); + } else if (curFrame < 27.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 24.0f) * 0.25f) + 1.0f; + } else if (curFrame < 30.0f) { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.5f - ((curFrame - 26.0f) * 0.233f); + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = ((curFrame - 29.0f) * 0.04f) + 0.8f; + } + } else { + this->unk_1D8.x = this->unk_1D8.y = this->unk_1D8.z = 1.0f; + } +} + +s32 func_80A370EC(EnSyatekiOkuta* this, f32 arg1, Vec3f* arg2) { + if (this->actionFunc == func_80A363B4) { + arg2->y = 1.0f; + arg2->z = 1.0f; + arg2->x = (sin_rad((M_PI / 16) * arg1) * 0.4f) + 1.0f; + } else if (this->actionFunc == func_80A365EC) { + if ((arg1 >= 35.0f) || (arg1 < 25.0f)) { + return false; + } + + if (arg1 < 27.0f) { + arg2->z = 1.0f; + arg2->x = arg2->y = ((arg1 - 24.0f) * 0.5f) + 1.0f; + } else if (arg1 < 30.0f) { + arg2->z = (arg1 - 26.0f) * 0.333f + 1.0f; + arg2->x = arg2->y = 2.0f - (arg1 - 26.0f) * 0.333f; + } else { + arg2->z = 2.0f - ((arg1 - 29.0f) * 0.2f); + arg2->x = arg2->y = 1.0f; + } + } else { + return false; + } + + return true; +} + +s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + s32 pad; + Vec3f sp20; + f32 curFrame; + EnSyatekiOkuta* this = THIS; + + curFrame = this->skelAnime.curFrame; + if (this->actionFunc == func_80A365EC) { + curFrame += this->unk_2A4; + } + + if (limbIndex == OBJECT_OKUTA_LIMB_0E) { + sp20 = this->unk_1D8; + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } else if ((limbIndex == OBJECT_OKUTA_LIMB_0F) && (func_80A370EC(this, curFrame, &sp20))) { + Matrix_Scale(sp20.x, sp20.y, sp20.z, MTXMODE_APPLY); + } + + return false; +} + +void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiOkuta* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_2A6 == 1) { + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + } else { + gSPSegment(POLY_OPA_DISP++, 0x08, ovl_En_Syateki_Okuta_DL_001640); + } + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiOkuta_OverrideLimbDraw, + NULL, &this->actor); + func_8012C2DC(globalCtx->state.gfxCtx); + if (this->actionFunc == func_80A365EC) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, + this->actor.world.pos.z + 20.0f, 0); + + if (this->unk_2AA >= 256) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 210, 64, 32, this->unk_2AA); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_2A6 == 2) { + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001A98); + } else { + gSPDisplayList(POLY_XLU_DISP++, ovl_En_Syateki_Okuta_DL_001B18); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h index f3f569eda..e083f26e1 100644 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h +++ b/src/overlays/actors/ovl_En_Syateki_Okuta/z_en_syateki_okuta.h @@ -2,16 +2,26 @@ #define Z_EN_SYATEKI_OKUTA_H #include "global.h" +#include "objects/object_okuta/object_okuta.h" + +#define EN_SYATEKI_OKUTA_GET_F(thisx) ((thisx)->params & 0xF) struct EnSyatekiOkuta; typedef void (*EnSyatekiOkutaActionFunc)(struct EnSyatekiOkuta*, GlobalContext*); typedef struct EnSyatekiOkuta { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnSyatekiOkutaActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x120]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiOkutaActionFunc actionFunc; + /* 0x18C */ ColliderCylinder collider; + /* 0x1DC */ Vec3f unk_1D8; + /* 0x1E4 */ Vec3s jointTable[OBJECT_OKUTA_LIMB_MAX]; + /* 0x244 */ Vec3s morphTable[OBJECT_OKUTA_LIMB_MAX]; + /* 0x2A4 */ s16 unk_2A4; + /* 0x2A6 */ s16 unk_2A6; + /* 0x2A8 */ UNK_TYPE1 unk_2A8[0x2]; + /* 0x2AA */ s16 unk_2AA; } EnSyatekiOkuta; // size = 0x2AC extern const ActorInit En_Syateki_Okuta_InitVars; 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 952861c83..ff6595044 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 @@ -5,8 +5,10 @@ */ #include "z_en_syateki_wf.h" +#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" +#include "objects/object_wf/object_wf.h" -#define FLAGS 0x08000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #define THIS ((EnSyatekiWf*)thisx) @@ -15,43 +17,91 @@ void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx); void EnSyatekiWf_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A201CC(EnSyatekiWf* this); void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A2030C(EnSyatekiWf* this); void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20378(EnSyatekiWf* this); void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20670(EnSyatekiWf* this); void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A20710(EnSyatekiWf* this); void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx); +void func_80A2079C(EnSyatekiWf* this); void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx); void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx); -#if 0 -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A20E74 = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 40, 60, 0, { 0, 0, 0 } }, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A20E50[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 17, { { 800, 0, 0 }, 25 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80A20EA0 = { - { COLTYPE_HIT5, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A20E50, // sJntSphElementsInit, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { 40, 60, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A20EB0 = { - { COLTYPE_HIT5, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT5, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, +}; + +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 15, 20, -15, { 0, 0, 0 } }, }; +static Vec3f D_80A20EDC = { 0.0f, 20.0f, 0.0f }; + +static Vec3f D_80A20EE8 = { 0.0f, 0.0f, 0.0f }; + const ActorInit En_Syateki_Wf_InitVars = { ACTOR_EN_SYATEKI_WF, ACTORCAT_ENEMY, @@ -64,60 +114,370 @@ const ActorInit En_Syateki_Wf_InitVars = { (ActorFunc)EnSyatekiWf_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A20FBC[] = { +static AnimationInfo sAnimations[] = { + { &object_wf_Anim_00A3CC, 2.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -1.0f }, + { &object_wf_Anim_005700, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &object_wf_Anim_005700, 1.0f, 0.0f, 4.0f, ANIMMODE_ONCE, 1.0f }, + { &object_wf_Anim_005700, 1.0f, 4.0f, 8.0f, ANIMMODE_ONCE, 1.0f }, + { &object_wf_Anim_004A90, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_wf_Anim_009A50, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f }, + { &object_wf_Anim_0053D0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_STOP), }; -#endif +static Vec3f D_80A20FC4 = { 0.0f, 0.5f, 0.0f }; -extern ColliderCylinderInit D_80A20E74; -extern ColliderJntSphElementInit D_80A20E50[1]; -extern ColliderJntSphInit D_80A20EA0; -extern ColliderCylinderInit D_80A20EB0; -extern InitChainEntry D_80A20FBC[]; +static Vec3f D_80A20FD0 = { 1200.0f, 0.0f, 0.0f }; -extern UNK_TYPE D_0600A3CC; +static TexturePtr sEyeTextures[] = { + object_wf_Tex_007AA8, + object_wf_Tex_0082A8, + object_wf_Tex_0084A8, + object_wf_Tex_0082A8, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Init.s") +void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSyatekiWf* this = THIS; + Path* path; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Destroy.s") + path = syatekiMan->path; + while (path->unk2 != 2) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A200E0.s") + for (i = 0; i < EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor); i++) { + path = &globalCtx->setupPathList[path->unk1]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A201CC.s") + if (path == NULL) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20284.s") + this->unk_2A0 = Lib_SegmentedToVirtual(path->points); + this->unk_2A4 = 1; + this->unk_2A6 = path->count; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2030C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_29C = 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; + this->actor.colChkInfo.health = 2; + this->actor.colChkInfo.cylRadius = 50; + this->actor.colChkInfo.cylHeight = 100; + this->eyeIndex = 0; + this->unk_2AC = 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20320.s") + Collider_InitCylinder(globalCtx, &this->unk_2B4); + Collider_SetCylinder(globalCtx, &this->unk_2B4, &this->actor, &sCylinderInit1); + Collider_InitCylinder(globalCtx, &this->unk_300); + Collider_SetCylinder(globalCtx, &this->unk_300, &this->actor, &sCylinderInit2); + Collider_InitJntSph(globalCtx, &this->unk_34C); + Collider_SetJntSph(globalCtx, &this->unk_34C, &this->actor, &sJntSphInit, &this->unk_36C); + this->unk_34C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20378.s") + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wf_Skel_0095D0, &object_wf_Anim_00A3CC, this->jointTable, + this->morphTable, 22); + Actor_SetScale(&this->actor, 0.01f); + this->actor.hintId = 0x4C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A203DC.s") + func_80A201CC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20670.s") +void EnSyatekiWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiWf* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A206DC.s") + Collider_DestroyCylinder(globalCtx, &this->unk_2B4); + Collider_DestroyCylinder(globalCtx, &this->unk_300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20710.s") +void func_80A200E0(EnSyatekiWf* this) { + Vec3f sp24; + s16 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2075C.s") + 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; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A2079C.s") +void func_80A201CC(EnSyatekiWf* this) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20800.s") + this->actor.speedXZ = 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; + syatekiMan->unk_276 &= ~(1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor)); + this->actionFunc = func_80A20284; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20858.s") +void func_80A20284(EnSyatekiWf* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A208F8.s") + if (this->actor.parent != NULL) { + syatekiMan = (EnSyatekiMan*)this->actor.parent; + if ((syatekiMan->unk_26A == 1) && (this->unk_298 == 1)) { + func_80A200E0(this); + func_80A2030C(this); + } else if (syatekiMan->unk_276 & (1 << EN_SYATEKI_WF_GET_PARAM_FF00(&this->actor))) { + this->unk_298 = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Update.s") +void func_80A2030C(EnSyatekiWf* this) { + this->actionFunc = func_80A20320; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20CF4.s") +void func_80A20320(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (this->unk_29C >= 11) { + Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_WOLFOS_APPEAR); + this->unk_29C = 0; + func_80A20378(this); + } else { + this->unk_29C++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/func_80A20D10.s") +void func_80A20378(EnSyatekiWf* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->actor.speedXZ = 10.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.draw = EnSyatekiWf_Draw; + this->actionFunc = func_80A203DC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Syateki_Wf/EnSyatekiWf_Draw.s") +void func_80A203DC(EnSyatekiWf* this, GlobalContext* globalCtx) { + Vec3f sp54; + f32 sp50; + s16 temp_v0; + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + if (syatekiMan->unk_26A != 1) { + func_80A201CC(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; + + if (this->actor.bgCheckFlags & 1) { + if (this->actor.bgCheckFlags & 8) { + if ((ABS(temp_v0) < 0x1555) && (this->actor.wallPoly != this->actor.floorPoly)) { + func_80A20670(this); + return; + } + } + + if (this->actor.bgCheckFlags & 4) { + 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); + + if (sp50 > 15.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2A8, 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; + } else { + this->actor.speedXZ = this->actor.speedXZ; + } + } + } else { + if (this->unk_2A4 < (this->unk_2A6 - 1)) { + if (this->unk_2A4 == EN_SYATEKI_WF_GET_PARAM_F0(&this->actor)) { + func_80A2079C(this); + } + + this->unk_2A4++; + } else { + this->unk_298 = 0; + this->unk_2A4 = 1; + func_80A201CC(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 10.0f, 3, 2.0f, 0, 0, 0); + } + } +} + +void func_80A20670(EnSyatekiWf* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_TEKU_JUMP); + this->actor.velocity.y = 20.0f; + this->actor.speedXZ = 5.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->actionFunc = func_80A206DC; +} + +void func_80A206DC(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (this->actor.bgCheckFlags & 2) { + func_80A20710(this); + } +} + +void func_80A20710(EnSyatekiWf* this) { + this->actor.speedXZ = 0.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->actionFunc = func_80A2075C; +} + +void func_80A2075C(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A20378(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, sAnimations, 5); + this->actionFunc = func_80A20800; +} + +void func_80A20800(EnSyatekiWf* this, GlobalContext* globalCtx) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_29A--; + if (this->unk_29A == 0) { + func_80A20378(this); + } + } +} + +void func_80A20858(EnSyatekiWf* this, GlobalContext* globalCtx) { + EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; + + this->unk_298 = 0; + this->actor.speedXZ = 0.0f; + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 5, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + syatekiMan->unk_280 += 100; + this->actionFunc = func_80A208F8; +} + +void func_80A208F8(EnSyatekiWf* this, GlobalContext* globalCtx) { + s32 pad; + + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80A201CC(this); + } else { + Vec3f sp68; + Vec3f sp5C = D_80A20FC4; + 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(globalCtx, &sp68, &sp5C, &sp5C, 0x64, 0, 2); + } + } +} + +void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnSyatekiWf* this = THIS; + + if (this->actionFunc != func_80A20284) { + SkelAnime_Update(&this->skelAnime); + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 32.0f, 30.0f, 60.0f, 5); + this->actionFunc(this, globalCtx); + + if (this->actor.bgCheckFlags & 3) { + 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; + this->actor.colChkInfo.health -= 2; + if (this->actor.colChkInfo.health == 0) { + func_801A3098(NA_BGM_GET_ITEM | 0x900); + func_80A20858(this, globalCtx); + } else { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_80A20EDC, &D_80A20EE8, 3, 0); + } + } + + Collider_UpdateCylinder(&this->actor, &this->unk_2B4); + if ((this->actionFunc != func_80A20284) && (this->actionFunc != func_80A208F8) && (this->actor.draw != NULL)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_300.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_2B4.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->unk_34C.base); + this->actor.focus.pos = this->actor.world.pos; + this->actor.focus.pos.y += 25.0f; + } + + if (this->eyeIndex == 0) { + if ((Rand_ZeroOne() < 0.2f) && ((globalCtx->gameplayFrames & 3) == 0) && (this->actor.colorFilterTimer == 0)) { + this->eyeIndex++; + } + } else { + this->eyeIndex = (this->eyeIndex + 1) & 3; + } +} + +s32 EnSyatekiWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + return false; +} + +void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnSyatekiWf* this = THIS; + Vec3f sp18; + + Collider_UpdateSpheres(limbIndex, &this->unk_34C); + if (limbIndex == OBJECT_WF_2_LIMB_06) { + Matrix_MultiplyVector3fByState(&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; + } +} + +void EnSyatekiWf_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSyatekiWf* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnSyatekiWf_OverrideLimbDraw, EnSyatekiWf_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->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 ff552ed19..23977fa02 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 @@ -3,15 +3,34 @@ #include "global.h" +#define EN_SYATEKI_WF_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_WF_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + struct EnSyatekiWf; typedef void (*EnSyatekiWfActionFunc)(struct EnSyatekiWf*, GlobalContext*); typedef struct EnSyatekiWf { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x150]; - /* 0x0294 */ EnSyatekiWfActionFunc actionFunc; - /* 0x0298 */ char unk_298[0x134]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[22]; + /* 0x20C */ Vec3s morphTable[22]; + /* 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; + /* 0x2B0 */ u8 eyeIndex; + /* 0x2B4 */ ColliderCylinder unk_2B4; + /* 0x300 */ ColliderCylinder unk_300; + /* 0x34C */ ColliderJntSph unk_34C; + /* 0x36C */ ColliderJntSphElement unk_36C; + /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC extern const ActorInit En_Syateki_Wf_InitVars; 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 d39849ee6..8ff08e32a 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -5,8 +5,10 @@ */ #include "z_en_tab.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_tab/object_tab.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTab*)thisx) @@ -18,7 +20,39 @@ void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BE127C(EnTab* this, GlobalContext* globalCtx); void func_80BE1348(EnTab* this, GlobalContext* globalCtx); -#if 0 +s32 D_80BE18D0[] = { + 0x0C000320, 0x0A00151B, 0x02093212, 0x010F0212, 0x00060003, 0x0400000E, 0x12000600, 0x020E0932, 0x12010105, + 0x0A001519, 0x02093215, 0x050D0215, 0x37050501, 0x050E1537, 0x0505020E, 0x09321505, 0x01050000, +}; + +s32 D_80BE1914[] = { + 0x003A0200, 0x080E2AF9, 0x0C113A02, 0x100E2AFA, 0x0C150900, 0x000E2AFB, + 0x0C003401, 0x00090F2A, 0xFD0C0F2A, 0xFE0C100F, 0x2AFC0C10, +}; + +s32 D_80BE1940[] = { + 0x003F0400, 0x080E2B3D, 0x0C113F04, 0x100E2B3E, 0x0C0F2AFA, 0x0C150900, + 0x000E2AFB, 0x0C003401, 0x00090F2A, 0xFD0C0F2A, 0xFE0C100F, 0x2AFC0C10, +}; + +s32 D_80BE1970[] = { 0x003A0100, 0x080E2AFF, 0x0C113A01, 0x100E2B00, 0x0C100000 }; + +s32 D_80BE1984[] = { 0x00500100, 0x080E2B3F, 0x0C115001, 0x100E2B40, 0x0C100000 }; + +s32 D_80BE1998[] = { 0x0E2B090C, 0x10000000 }; + +s32 D_80BE19A0[] = { + 0x0E2B0A0C, 0x05004E00, 0x00004E30, 0x2800050E, 0x2B0E0C10, 0x0E2B0B0C, 0x05000000, 0x08001008, 0x00140026, + 0x19000E08, 0x00C8000F, 0x19000631, 0x0E2B0D0C, 0x10320E2B, 0x0C0C1030, 0x1214FF38, 0x06009100, 0x00130091, + 0x0C103012, 0x14FFEC06, 0x00920000, 0x1300920C, 0x10300034, 0x0100050E, 0x2B0F0C10, 0x0E2B110C, 0x10000000, +}; + +s32 D_80BE1A0C[] = { + 0x0E2B0A0C, 0x05004E00, 0x00004E30, 0x2800050E, 0x2B0E0C10, 0x0E2B0B0C, 0x05000000, 0x08001008, 0x00140026, + 0x19000E08, 0x00C8000F, 0x19000631, 0x0E2B0D0C, 0x10320E2B, 0x0C0C1030, 0x1214FF38, 0x06009100, 0x00130091, + 0x0C103012, 0x14FFEC06, 0x00920000, 0x1300920C, 0x10300034, 0x0100050E, 0x2B100C10, 0x0E2B110C, 0x10000000, +}; + const ActorInit En_Tab_InitVars = { ACTOR_EN_TAB, ACTORCAT_NPC, @@ -31,75 +65,556 @@ const ActorInit En_Tab_InitVars = { (ActorFunc)EnTab_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE1A98 = { - { COLTYPE_HIT1, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT1, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 14, 62, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80BE1AC4 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +AnimationInfoS D_80BE1AD0[] = { + { &object_tab_Anim_000758, 1.0f, 0, -1, 0, 0 }, + { &object_tab_Anim_0086AC, 1.0f, 0, -1, 0, 0 }, +}; -extern ColliderCylinderInit D_80BE1A98; -extern CollisionCheckInfoInit2 D_80BE1AC4; +Vec3f D_80BE1AF0 = { -28.0f, -8.0f, -195.0f }; -extern UNK_TYPE D_06007F78; +Vec3s D_80BE1AFC = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE04E0.s") +Vec3f D_80BE1B04 = { 161.0f, 0.0f, -10.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0590.s") +Vec3s D_80BE1B10 = { 0, 0xC000, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE05BC.s") +Vec3f D_80BE1B18 = { 800.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0620.s") +TexturePtr D_80BE1B24[] = { + object_tab_Tex_006428, + object_tab_Tex_006928, + object_tab_Tex_006D28, + object_tab_Tex_006928, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0664.s") +EnGm* func_80BE04E0(EnTab* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; + Actor* tempActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE06DC.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, foundActor, actorCat, actorId); + if ((foundActor == NULL) || (((EnTab*)foundActor != this) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0778.s") + tempActor = foundActor->next; + if (tempActor == NULL) { + foundActor = NULL; + break; + } + foundActor = tempActor; + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE07A0.s") + return (EnGm*)foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE09A8.s") +void func_80BE0590(EnTab* this) { + this->skelAnime.playSpeed = this->unk_300; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0A98.s") +s32 func_80BE05BC(EnTab* this, s32 arg1) { + s32 phi_v0 = false; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0C04.s") + if (arg1 != this->unk_32C) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0D38.s") + if (phi_v0) { + this->unk_32C = arg1; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80BE1AD0, arg1); + this->unk_300 = this->skelAnime.playSpeed; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0D60.s") +void func_80BE0620(EnTab* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0E04.s") + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0F04.s") +void func_80BE0664(EnTab* this) { + if (DECR(this->unk_31C) == 0) { + this->unk_31E++; + if (this->unk_31E > 3) { + this->unk_31C = Rand_S16Offset(30, 30); + this->unk_31E = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE0FC4.s") +s32 func_80BE06DC(EnTab* this, GlobalContext* globalCtx) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1060.s") + if (this->unk_2FC & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + SubS_UpdateFlags(&this->unk_2FC, 0, 7); + ret = true; + this->unk_320 = 0; + this->unk_328 = NULL; + this->actor.child = &GET_PLAYER(globalCtx)->actor; + this->unk_2FC |= 8; + this->actionFunc = func_80BE1348; + } + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE10BC.s") +Actor* func_80BE0778(EnTab* this, GlobalContext* globalCtx) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1224.s") + if (this->unk_1D8 == 1) { + actor = this->actor.child; + } else { + actor = &GET_PLAYER(globalCtx)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE127C.s") +void func_80BE07A0(EnTab* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + s16 sp32; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1348.s") + Math_Vec3f_Copy(&sp40, &this->unk_1E0->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + sp32 = Math_Vec3f_Yaw(&sp34, &sp40); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Init.s") + Math_ApproachS(&this->unk_314, (sp32 - this->unk_318) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_314 = CLAMP(this->unk_314, -0x1FFE, 0x1FFE); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Destroy.s") + Math_ApproachS(&this->unk_318, (sp32 - this->unk_314) - this->actor.shape.rot.y, 4, 0x2AA8); + this->unk_318 = CLAMP(this->unk_318, -0x1C70, 0x1C70); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Update.s") + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + if (this->unk_1E0->id == ACTOR_PLAYER) { + sp40.y = ((Player*)this->unk_1E0)->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E0->focus.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1648.s") + Math_ApproachS(&this->unk_312, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_316, 4, 0x2AA8); + this->unk_312 = CLAMP(this->unk_312, -0x1554, 0x1554); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE16B4.s") + Math_ApproachS(&this->unk_316, Math_Vec3f_Pitch(&sp34, &sp40) - this->unk_312, 4, 0x2AA8); + this->unk_316 = CLAMP(this->unk_316, -0xE38, 0xE38); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/func_80BE1704.s") +void func_80BE09A8(EnTab* this, GlobalContext* globalCtx) { + this->unk_1E0 = func_80BE0778(this, globalCtx); + if ((this->unk_2FC & 8) && (this->unk_1E0 != 0) && (DECR(this->unk_324) == 0)) { + func_80BE07A0(this); + this->unk_316 = 0; + this->unk_318 = 0; + this->unk_2FC &= ~0x40; + this->unk_2FC |= 0x10; + } else if (this->unk_2FC & 0x10) { + this->unk_2FC &= ~0x10; + this->unk_312 = 0; + this->unk_314 = 0; + this->unk_316 = 0; + this->unk_318 = 0; + this->unk_324 = 20; + } else if (DECR(this->unk_324) == 0) { + this->unk_2FC |= 0x40; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tab/EnTab_Draw.s") +void func_80BE0A98(EnTab* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 sp20 = Message_GetState(&globalCtx->msgCtx); + + this->unk_308 += (this->unk_304 != 0.0f) ? 40.0f : -40.0f; + this->unk_308 = CLAMP(this->unk_308, 0.0f, 80.0f); + + Matrix_InsertTranslation(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); + + if ((&this->actor == player->targetActor) && + ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && + (this->unk_334 == 3)) { + if ((globalCtx->state.frames % 2) == 0) { + if (this->unk_304 != 0.0f) { + this->unk_304 = 0.0f; + } else { + this->unk_304 = 1.0f; + } + } + } else { + this->unk_304 = 0.0f; + } + this->unk_334 = sp20; +} + +s32 func_80BE0C04(EnTab* this, Actor* actor, f32 arg2) { + Vec3f sp44; + Vec3f sp38; + s32 ret = false; + f32 sp30; + s16 sp2E; + + if (actor != NULL) { + Math_Vec3f_Copy(&sp38, &this->actor.world.pos); + Math_Vec3f_Copy(&sp44, &actor->world.pos); + sp2E = Math_Vec3f_Yaw(&sp38, &sp44); + + if (this->unk_338) { + sp30 = arg2; + } else { + sp30 = arg2 * 0.5f; + } + if ((Math_Vec3f_DistXZ(&sp44, &sp38) < sp30) && (ABS_ALT(BINANG_SUB(sp2E, this->actor.shape.rot.y)) < 0x38E0)) { + ret = true; + } + + if (DECR(this->unk_322) == 0) { + this->unk_338 ^= true; + this->unk_322 = Rand_S16Offset(60, 60); + } + } + return ret; +} + +s32 func_80BE0D38(EnTab* this, GlobalContext* globalCtx) { + return Inventory_HasEmptyBottle(); +} + +s32 func_80BE0D60(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + s32 ret = false; + + this->unk_320++; + if (this->unk_320 == 1) { + globalCtx->setPlayerTalkAnim(globalCtx, &gameplay_keep_Linkanim_00D568, 2); + } else if (this->unk_320 > 20) { + globalCtx->setPlayerTalkAnim(globalCtx, NULL, 0); + this->unk_320 = 0; + ret = true; + } + return ret; +} + +s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (player->transformation == PLAYER_FORM_DEKU) { + return D_80BE1984; + } + + switch (this->unk_1D8) { + case 2: + this->unk_328 = func_80BE0D38; + if (Player_GetMask(globalCtx) != PLAYER_MASK_ROMANI) { + return D_80BE1998; + } + + if (gSaveContext.save.day == 3) { + return D_80BE1A0C; + } + return D_80BE19A0; + + case 1: + this->unk_328 = func_80BE0D60; + if (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI) { + return D_80BE1940; + } + + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + return D_80BE1970; + } + return D_80BE1914; + } + + return NULL; +} + +s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret = false; + EnGm* sp28 = func_80BE04E0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); + + if (sp28) { + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1AF0); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BE1AFC); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->actor.targetMode = 0; + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC |= (0x40 | 0x20); + this->unk_30C = 30; + this->unk_1E4 = sp28; + func_80BE05BC(this, 0); + ret = true; + } + return ret; +} + +s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 pad; + + Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); + Math_Vec3s_Copy(&this->actor.world.rot, &D_80BE1B10); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + this->actor.targetMode = 6; + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC |= (0x40 | 0x20); + this->unk_30C = 0x50; + func_80BE05BC(this, 1); + return true; +} + +s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { + s32 ret; + + this->unk_2FC = 0; + + switch (arg2->unk0) { + case 1: + ret = func_80BE0F04(this, globalCtx, arg2); + break; + + case 2: + ret = func_80BE0FC4(this, globalCtx, arg2); + break; + + default: + ret = false; + break; + } + return ret; +} + +s32 func_80BE10BC(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + f32 dist; + Actor* tempActor; + + switch (this->unk_1D8) { + case 1: + if ((player->stateFlags1 & 0x40) && !(globalCtx->msgCtx.currentTextId <= 0x2B00) && + (globalCtx->msgCtx.currentTextId < 0x2B08)) { + this->actor.child = &this->unk_1E4->actor; + this->unk_2FC |= 8; + } else { + dist = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_1E4->actor.world.pos); + + if ((gSaveContext.save.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || + !(dist < 160.0f)) { + tempActor = &GET_PLAYER(globalCtx)->actor; + this->actor.child = tempActor; + } else { + tempActor = &this->unk_1E4->actor; + this->actor.child = tempActor; + } + + if (func_80BE0C04(this, tempActor, 160.0f)) { + this->unk_2FC |= 8; + } else { + this->unk_2FC &= ~8; + } + } + break; + + case 2: + if (func_80BE0C04(this, &GET_PLAYER(globalCtx)->actor, 200.0f)) { + this->unk_2FC |= 8; + } else { + this->unk_2FC &= ~8; + } + break; + } + + return false; +} + +void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { + if ((this->unk_1D8 == 1) || (this->unk_1D8 == 2)) { + func_80BE10BC(this, globalCtx); + } + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { + u32* unk_14 = &gSaveContext.save.daySpeed; + struct_80133038_arg2 sp18; + + this->unk_31A = REG(15) + *unk_14; + + if (!func_80133038(globalCtx, D_80BE18D0, &sp18) || + ((this->unk_1D8 != sp18.unk0) && !func_80BE1060(this, globalCtx, &sp18))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + sp18.unk0 = 0; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + this->unk_1D8 = sp18.unk0; + func_80BE1224(this, globalCtx); +} + +void func_80BE1348(EnTab* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + + if (func_8010BF58(&this->actor, globalCtx, func_80BE0E04(this, globalCtx), this->unk_328, &this->unk_1DC)) { + SubS_UpdateFlags(&this->unk_2FC, 3, 7); + this->unk_2FC &= ~8; + this->unk_2FC |= 0x40; + this->unk_324 = 20; + this->unk_1DC = 0; + this->actionFunc = func_80BE127C; + } else if (this->unk_1E0 != 0) { + Math_Vec3f_Copy(&sp40, &this->unk_1E0->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&sp34, &sp40), 4, 0x2AA8); + } +} + +void EnTab_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 14.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tab_Skel_007F78, NULL, this->jointTable, this->morphTable, + 20); + this->unk_32C = -1; + func_80BE05BC(this, 0); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_SetScale(&this->actor, 0.01f); + + this->unk_1D8 = 0; + this->unk_328 = NULL; + this->unk_2FC = 0; + this->unk_2FC |= 0x40; + this->actor.gravity = -1.0f; + + this->actionFunc = func_80BE127C; + this->actionFunc(this, globalCtx); +} + +void EnTab_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnTab_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + f32 radius; + f32 height; + + func_80BE06DC(this, globalCtx); + + this->actionFunc(this, globalCtx); + + if (this->unk_1D8 != 0) { + func_80BE0590(this); + func_80BE0664(this); + func_80BE09A8(this, globalCtx); + + radius = this->collider.dim.radius + this->unk_30C; + height = this->collider.dim.height + 10; + + func_8013C964(&this->actor, globalCtx, radius, height, 0, this->unk_2FC & 7); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + func_80BE0620(this, globalCtx); + } +} + +s32 EnTab_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTab* this = THIS; + + if (limbIndex == 9) { + func_80BE0A98(this, globalCtx); + } + + if ((this->unk_32C == 1) && (limbIndex == 18)) { + *dList = NULL; + } + return false; +} + +void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTab* this = THIS; + + if (limbIndex == 9) { + Matrix_MultiplyVector3fByState(&D_80BE1B18, &this->actor.focus.pos); + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } +} + +void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnTab* this = THIS; + s32 phi_v0; + s32 phi_v1; + + if (!(this->unk_2FC & 0x40)) { + if (this->unk_2FC & 0x10) { + phi_v1 = 1; + } else { + phi_v1 = 0; + } + phi_v0 = 1; + } else { + phi_v1 = 0; + phi_v0 = 0; + } + + if (limbIndex == 9) { + func_8013AD9C(BINANG_ADD(this->unk_312 + this->unk_316, 0x4000), + BINANG_ADD(this->unk_314 + this->unk_318 + this->actor.shape.rot.y, 0x4000), this->unk_1E8, + this->unk_200, phi_v0, phi_v1); + Matrix_StatePop(); + Matrix_InsertTranslation(this->unk_1E8[0].x, this->unk_1E8[0].y, this->unk_1E8[0].z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_200[0].y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_200[0].x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_200[0].z, MTXMODE_APPLY); + Matrix_StatePush(); + } +} + +void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTab* this = THIS; + + if (this->unk_1D8 != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BE1B24[this->unk_31E])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTab_OverrideLimbDraw, EnTab_PostLimbDraw, + EnTab_TransformDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.h b/src/overlays/actors/ovl_En_Tab/z_en_tab.h index 45f6a057d..266949fe8 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.h +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.h @@ -2,16 +2,47 @@ #define Z_EN_TAB_H #include "global.h" +#include "overlays/actors/ovl_En_Gm/z_en_gm.h" struct EnTab; typedef void (*EnTabActionFunc)(struct EnTab*, GlobalContext*); +typedef s32 (*EnTabUnkFunc)(struct EnTab*, GlobalContext*); typedef struct EnTab { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; + /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnTabActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x1B0]; + /* 0x018C */ ColliderCylinder collider; + /* 0x01D8 */ u8 unk_1D8; + /* 0x01DC */ s32 unk_1DC; + /* 0x01E0 */ Actor* unk_1E0; + /* 0x01E4 */ EnGm* unk_1E4; + /* 0x01E8 */ Vec3f unk_1E8[2]; + /* 0x0200 */ Vec3s unk_200[2]; + /* 0x020C */ Vec3s jointTable[20]; + /* 0x0284 */ Vec3s morphTable[20]; + /* 0x02FC */ u16 unk_2FC; + /* 0x0300 */ f32 unk_300; + /* 0x0304 */ f32 unk_304; + /* 0x0308 */ f32 unk_308; + /* 0x030C */ s16 unk_30C; + /* 0x030E */ UNK_TYPE1 unk30E[4]; + /* 0x0312 */ s16 unk_312; + /* 0x0314 */ s16 unk_314; + /* 0x0316 */ s16 unk_316; + /* 0x0318 */ s16 unk_318; + /* 0x031A */ s16 unk_31A; + /* 0x031C */ s16 unk_31C; + /* 0x031E */ s16 unk_31E; + /* 0x0320 */ s16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0328 */ EnTabUnkFunc unk_328; + /* 0x032C */ s32 unk_32C; + /* 0x0330 */ UNK_TYPE1 unk330[4]; + /* 0x0334 */ s32 unk_334; + /* 0x0338 */ s32 unk_338; } EnTab; // size = 0x33C extern const ActorInit En_Tab_InitVars; diff --git a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c index f579719d2..35dc1ba30 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c @@ -6,7 +6,7 @@ #include "z_en_takaraya.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTakaraya*)thisx) diff --git a/src/overlays/actors/ovl_En_Talk/z_en_talk.c b/src/overlays/actors/ovl_En_Talk/z_en_talk.c index fcfa36a4d..4cf4ca407 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -6,7 +6,7 @@ #include "z_en_talk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTalk*)thisx) 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 97d6a5bda..47d78ae29 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 @@ -5,9 +5,8 @@ */ #include "z_en_talk_gibud.h" -#include "objects/object_rd/object_rd.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnTalkGibud*)thisx) @@ -18,8 +17,8 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx); void EnTalkGibud_SetupIdle(EnTalkGibud* this); void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx); -void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this); -void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx); +void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this); +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx); void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this); void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx); void EnTalkGibud_SetupGrab(EnTalkGibud* this); @@ -55,23 +54,6 @@ typedef struct { /* 0xC */ s16 isBottledItem; } EnTalkGibudRequestedItem; -typedef enum { - /* 0 */ EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK, - /* 1 */ EN_TALK_GIBUD_ANIMATION_GRAB_END, - /* 2 */ EN_TALK_GIBUD_ANIMATION_GRAB_START, - /* 3 */ EN_TALK_GIBUD_ANIMATION_LOOK_AWAY, - /* 4 */ EN_TALK_GIBUD_ANIMATION_CROUCH_WIPING_TEARS, - /* 5 */ EN_TALK_GIBUD_ANIMATION_CROUCH_CRYING, - /* 6 */ EN_TALK_GIBUD_ANIMATION_DEATH, - /* 7 */ EN_TALK_GIBUD_ANIMATION_DAMAGE, - /* 8 */ EN_TALK_GIBUD_ANIMATION_CROUCH_END, - /* 9 */ EN_TALK_GIBUD_ANIMATION_IDLE, - /* 10 */ EN_TALK_GIBUD_ANIMATION_WALK, - /* 11 */ EN_TALK_GIBUD_ANIMATION_DANCE_SQUAT, - /* 12 */ EN_TALK_GIBUD_ANIMATION_DANCE_PIROUETTE, - /* 13 */ EN_TALK_GIBUD_ANIMATION_DANCE_CLAP, -} EnTalkGibudAnimations; - typedef enum { /* 0 */ EN_TALK_GIBUD_REQUESTED_ITEM_MET, /* 1 */ EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO, @@ -91,6 +73,34 @@ typedef enum { /* 9 */ EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK, } EnTalkGibudRequestedItemIndex; +typedef enum { + /* 0 */ EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK, + /* 1 */ EN_TALK_GIBUD_ANIMATION_GRAB_END, + /* 2 */ EN_TALK_GIBUD_ANIMATION_GRAB_START, + /* 3 */ EN_TALK_GIBUD_ANIMATION_LOOK_BACK, + /* 4 */ EN_TALK_GIBUD_ANIMATION_CROUCH_WIPING_TEARS, + /* 5 */ EN_TALK_GIBUD_ANIMATION_CROUCH_CRYING, + /* 6 */ EN_TALK_GIBUD_ANIMATION_DEATH, + /* 7 */ EN_TALK_GIBUD_ANIMATION_DAMAGE, + /* 8 */ EN_TALK_GIBUD_ANIMATION_CROUCH_END, + /* 9 */ EN_TALK_GIBUD_ANIMATION_IDLE, + /* 10 */ EN_TALK_GIBUD_ANIMATION_WALK, + /* 11 */ EN_TALK_GIBUD_ANIMATION_DANCE_SQUAT, + /* 12 */ EN_TALK_GIBUD_ANIMATION_DANCE_PIROUETTE, + /* 13 */ EN_TALK_GIBUD_ANIMATION_DANCE_CLAP, +} EnTalkGibudAnimations; + +typedef enum { + /* 0 */ EN_TALK_GIBUD_TYPE_GIBDO, + /* 1 */ EN_TALK_GIBUD_TYPE_REDEAD, +} EnTalkGibudType; + +typedef enum { + /* 0 */ EN_TALK_GIBUD_GRAB_START, + /* 1 */ EN_TALK_GIBUD_GRAB_ATTACK, + /* 2 */ EN_TALK_GIBUD_GRAB_RELEASE, +} EnTalkGibudGrabState; + const ActorInit En_Talk_Gibud_InitVars = { ACTOR_EN_TALK_GIBUD, ACTORCAT_ENEMY, @@ -103,14 +113,21 @@ const ActorInit En_Talk_Gibud_InitVars = { (ActorFunc)EnTalkGibud_Draw, }; -static ActorAnimationEntry sAnimations[] = { - { &object_rd_Anim_006678, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_006B08, 0.5f, 0.0f, 0.0f, 3, 0.0f }, - { &object_rd_Anim_006EEC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0073A4, 0.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_007BBC, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_0081A8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_009298, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_009900, 1.0f, 0.0f, 0.0f, 2, -8.0f }, - { &object_rd_Anim_00A450, 1.0f, 0.0f, 0.0f, 2, -8.0f }, { &object_rd_Anim_00ABE0, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0113EC, 0.4f, 0.0f, 0.0f, 1, -8.0f }, { &object_rd_Anim_01216C, 1.0f, 0.0f, 0.0f, 0, -8.0f }, - { &object_rd_Anim_0118D8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, { &object_rd_Anim_011DB8, 1.0f, 0.0f, 0.0f, 0, -8.0f }, +static AnimationInfo sAnimations[] = { + { &gGibdoRedeadGrabAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadGrabEndAnim, 0.5f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 0.0f }, + { &gGibdoRedeadGrabStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadLookBackAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadWipingTearsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadSobbingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadDeathAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadDamageAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadStandUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, + { &gGibdoRedeadIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadWalkAnim, 0.4f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, -8.0f }, + { &gGibdoRedeadSquattingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadPirouetteAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gGibdoRedeadClappingDanceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -134,9 +151,9 @@ static ColliderCylinderInit sCylinderInit = { }; typedef enum { - /* 0x0 */ EN_TALK_GIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all - /* 0x1 */ EN_TALK_GIBUD_DMGEFF_STUN, // Stuns without applying any effect - /* 0x2 */ EN_TALK_GIBUD_DMGEFF_FIRE_ARROW, // Damages and changes a Gibdo into a Redead + /* 0x0 */ EN_TALK_GIBUD_DMGEFF_NONE, // Does not interact with the Gibdo/Redead at all + /* 0x1 */ EN_TALK_GIBUD_DMGEFF_STUN, // Stuns without applying any effect + /* 0x2 */ EN_TALK_GIBUD_DMGEFF_FIRE_ARROW, // Damages, applies a fire effect, and changes a Gibdo into a Redead /* 0x4 */ EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW = 0x4, // Damages and applies a light effect /* 0xC */ EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC = 0xC, // Stuns and applies an electric effect /* 0xD */ EN_TALK_GIBUD_DMGEFF_RECOIL, // Deals no damage, but displays hit mark and recoil animation @@ -213,24 +230,26 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 0; this->actor.hintId = 0x2D; this->actor.textId = 0; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_0053E8, &object_rd_Anim_00ABE0, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGibdoSkel, &gGibdoRedeadIdleAnim, this->jointTable, + this->morphTable, GIBDO_LIMB_MAX); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->playerStunWaitTimer = 0; this->grabState = EN_TALK_GIBUD_GRAB_START; this->grabWaitTimer = 0; this->itemActionParam = PLAYER_AP_NONE; - this->effectTimer = 0; - this->effectType = 0; + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->isTalking = false; this->type = EN_TALK_GIBUD_TYPE_GIBDO; this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX(thisx); this->switchFlag = EN_TALK_GIBUD_SWITCH_FLAG(thisx); - this->effectAlpha = 0.0f; - this->effectScale = 0.0f; + this->drawDmgEffAlpha = 0.0f; + this->drawDmgEffScale = 0.0f; for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { this->limbPos[i] = gZeroVec3f; @@ -239,6 +258,7 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->requestedItemIndex < EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION) { this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION; } + if (this->requestedItemIndex > EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK) { this->requestedItemIndex = EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK; } @@ -246,6 +266,7 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->switchFlag == 0xFF) { this->switchFlag = -1; } + if (this->switchFlag != -1 && Flags_GetSwitch(globalCtx, this->switchFlag)) { Actor_MarkForDeath(&this->actor); } @@ -260,7 +281,7 @@ void EnTalkGibud_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnTalkGibud_SetupIdle(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); this->actionFunc = EnTalkGibud_Idle; } @@ -270,18 +291,19 @@ void EnTalkGibud_SetupIdle(EnTalkGibud* this) { */ void EnTalkGibud_Idle(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer <= 150.0f && func_800B715C(globalCtx)) { - EnTalkGibud_SetupAttemptPlayerStun(this); + EnTalkGibud_SetupAttemptPlayerFreeze(this); } + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); } -void EnTalkGibud_SetupAttemptPlayerStun(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); - this->actionFunc = EnTalkGibud_AttemptPlayerStun; +void EnTalkGibud_SetupAttemptPlayerFreeze(EnTalkGibud* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + this->actionFunc = EnTalkGibud_AttemptPlayerFreeze; } -void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_AttemptPlayerFreeze(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 rot = this->actor.shape.rot.y + this->headRotation.y + this->upperBodyRotation.y; s16 yaw = BINANG_SUB(this->actor.yawTowardsPlayer, rot); @@ -293,17 +315,20 @@ void EnTalkGibud_AttemptPlayerStun(EnTalkGibud* this, GlobalContext* globalCtx) Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupWalkToPlayer(this); } + EnTalkGibud_TurnTowardsPlayer(this, globalCtx); } void EnTalkGibud_SetupWalkToPlayer(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; - if (this->actionFunc == EnTalkGibud_AttemptPlayerStun) { + + if (this->actionFunc == EnTalkGibud_AttemptPlayerFreeze) { this->playerStunWaitTimer = 80; } else { this->playerStunWaitTimer = 20; } + this->actionFunc = EnTalkGibud_WalkToPlayer; } @@ -313,10 +338,11 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xFA); this->actor.world.rot = this->actor.shape.rot; - Math_SmoothStepToS(&this->headRotation.y, 0, 1, 100, 0); - Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 100, 0); + Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x64, 0); + Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x64, 0); + if (EnTalkGibud_PlayerInRangeWithCorrectState(this, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x38E3)) { - if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { + if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { player->actor.freezeTimer = 0; if (gSaveContext.save.playerForm == PLAYER_FORM_GORON || gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { // If the Gibdo/Redead tries to grab Goron or Deku Link, it will fail to @@ -336,46 +362,43 @@ void EnTalkGibud_WalkToPlayer(EnTalkGibud* this, GlobalContext* globalCtx) { this->playerStunWaitTimer--; } } - } else if (this->grabWaitTimer == 0 && this->actor.xzDistToPlayer <= 45.0f) { + } else if ((this->grabWaitTimer == 0) && (this->actor.xzDistToPlayer <= 45.0f)) { EnTalkGibud_SetupWalkToHome(this); } else if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { EnTalkGibud_SetupWalkToHome(this); } + if (this->grabWaitTimer > 0) { this->grabWaitTimer--; } if (Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_RIZA_WALK); - } else if (!(globalCtx->gameplayFrames & 0x5F)) { + } else if (!(globalCtx->gameplayFrames & 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_CRY); } } void EnTalkGibud_SetupGrab(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_START); this->grabDamageTimer = 0; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_START; this->actionFunc = EnTalkGibud_Grab; } void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { - // This function needs to have two different temps for Player to match, - // but you don't have to necessarily use them both. This is just the most - // likely scenario; they got an Actor* pointer in the first temp, then - // casted it to Player* in the second temp. - Actor* playerActor = &GET_PLAYER(globalCtx)->actor; - Player* player = (Player*)playerActor; + Player* player2 = GET_PLAYER(globalCtx); + Player* player = player2; s32 inPositionToAttack; u16 damageSfxId; switch (this->grabState) { case EN_TALK_GIBUD_GRAB_START: inPositionToAttack = EnTalkGibud_MoveToIdealGrabPositionAndRotation(this, globalCtx); - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && inPositionToAttack == true) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && (inPositionToAttack == true)) { this->grabState = EN_TALK_GIBUD_GRAB_ATTACK; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_ATTACK); } break; @@ -396,13 +419,14 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - if (!(player->stateFlags2 & 0x80) || player->unk_B62 != 0) { - if (player->unk_B62 != 0 && (player->stateFlags2 & 0x80)) { + if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { + if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { player->stateFlags2 &= ~0x80; player->unk_AE8 = 100; } - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); - this->actor.flags |= 1; + + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_GRAB_END); + this->actor.flags |= ACTOR_FLAG_1; this->grabState = EN_TALK_GIBUD_GRAB_RELEASE; this->grabDamageTimer = 0; } @@ -421,16 +445,17 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupGrabFail(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); - this->actionFunc = EnTalkGibud_GrabFail; this->actor.speedXZ = -2.0f; + this->actionFunc = EnTalkGibud_GrabFail; } void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } + this->actor.world.rot.y = this->actor.yawTowardsPlayer; Math_SmoothStepToS(&this->headRotation.y, 0, 1, 0x12C, 0); Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 0x12C, 0); @@ -442,7 +467,7 @@ void EnTalkGibud_GrabFail(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_SetupTurnAwayAndShakeHead(EnTalkGibud* this) { this->headShakeTimer = 0; - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actionFunc = EnTalkGibud_TurnAwayAndShakeHead; } @@ -460,7 +485,7 @@ void EnTalkGibud_TurnAwayAndShakeHead(EnTalkGibud* this, GlobalContext* globalCt } void EnTalkGibud_SetupWalkToHome(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_WALK); this->actor.speedXZ = 0.4f; this->actionFunc = EnTalkGibud_WalkToHome; } @@ -474,6 +499,7 @@ void EnTalkGibud_WalkToHome(EnTalkGibud* this, GlobalContext* globalCtx) { } else { this->actor.speedXZ = 0.0f; } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 200, 10); this->actor.world.rot.y = this->actor.shape.rot.y; if (this->actor.world.rot.y == this->actor.home.rot.y) { @@ -495,11 +521,13 @@ void EnTalkGibud_SetupStunned(EnTalkGibud* this) { this->stunTimer = 10; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->effectTimer != 0) { + + if (this->drawDmgEffTimer != 0) { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } else { Actor_SetColorFilter(&this->actor, 0, 0xC8, 0, 0x28); } + this->actionFunc = EnTalkGibud_Stunned; } @@ -511,36 +539,40 @@ void EnTalkGibud_Stunned(EnTalkGibud* this, GlobalContext* globalCtx) { EnTalkGibud_SetupDamage(this); } } + if (this->stunTimer != 0) { this->stunTimer--; } } void EnTalkGibud_SetupDamage(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DAMAGE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DAMAGE); this->stunTimer = 0; this->grabWaitTimer = 0; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionFunc = EnTalkGibud_Damage; this->actor.speedXZ = -2.0f; + this->actionFunc = EnTalkGibud_Damage; } void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->actor.speedXZ < 0.0f) { this->actor.speedXZ += 0.15f; } + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_3F7 = -1; this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->effectTimer > 0 && this->effectType == 0 && this->type == EN_TALK_GIBUD_TYPE_GIBDO) { + if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { this->actor.hintId = 0x2A; - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } + if (EnTalkGibud_PlayerOutOfRange(this, globalCtx)) { EnTalkGibud_SetupWalkToHome(this); } else { @@ -550,8 +582,8 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDead(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); - this->actor.flags &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_DEATH); + this->actor.flags &= ~ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_DEAD); this->deathTimer = 0; this->actionFunc = EnTalkGibud_Dead; @@ -565,18 +597,19 @@ void EnTalkGibud_Dead(EnTalkGibud* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->upperBodyRotation.y, 0, 1, 250, 0); this->deathTimer++; } - if (this->deathTimer == 20 && this->effectTimer > 0 && this->effectType == 0 && - this->type == EN_TALK_GIBUD_TYPE_GIBDO) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_rd_Skel_010B88, NULL, this->jointTable, - this->morphTable, EN_TALK_GIBUD_LIMB_MAX); + + if ((this->deathTimer == 20) && (this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && + (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, + GIBDO_LIMB_MAX); this->type = EN_TALK_GIBUD_TYPE_REDEAD; } } void EnTalkGibud_SetupRevive(EnTalkGibud* this) { - Animation_Change(&this->skelAnime, &object_rd_Anim_009298, -1.0f, Animation_GetLastFrame(&object_rd_Anim_009298), + Animation_Change(&this->skelAnime, &gGibdoRedeadDeathAnim, -1.0f, Animation_GetLastFrame(&gGibdoRedeadDeathAnim), 0.0f, 2, -8.0f); - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_REVERSE); this->deathTimer = 0; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -593,54 +626,64 @@ void EnTalkGibud_Revive(EnTalkGibud* this, GlobalContext* globalCtx) { void EnTalkGibud_GetTextIdForRequestedItem(EnTalkGibud* this, GlobalContext* globalCtx) { switch (this->requestedItemIndex) { case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BLUE_POTION: - func_801518B0(globalCtx, 0x138C, &this->actor); + Message_StartTextbox(globalCtx, 0x138C, &this->actor); this->textId = 0x138C; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BEANS: - func_801518B0(globalCtx, 0x138D, &this->actor); + Message_StartTextbox(globalCtx, 0x138D, &this->actor); this->textId = 0x138D; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_SPRING_WATER: - func_801518B0(globalCtx, 0x138E, &this->actor); + Message_StartTextbox(globalCtx, 0x138E, &this->actor); this->textId = 0x138E; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_FISH: - func_801518B0(globalCtx, 0x138F, &this->actor); + Message_StartTextbox(globalCtx, 0x138F, &this->actor); this->textId = 0x138F; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BUGS: - func_801518B0(globalCtx, 0x1390, &this->actor); + Message_StartTextbox(globalCtx, 0x1390, &this->actor); this->textId = 0x1390; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_DEKU_NUTS: - func_801518B0(globalCtx, 0x1391, &this->actor); + Message_StartTextbox(globalCtx, 0x1391, &this->actor); this->textId = 0x1391; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BOMBS: - func_801518B0(globalCtx, 0x1392, &this->actor); + Message_StartTextbox(globalCtx, 0x1392, &this->actor); this->textId = 0x1392; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_HOT_SPRING_WATER: - func_801518B0(globalCtx, 0x1393, &this->actor); + Message_StartTextbox(globalCtx, 0x1393, &this->actor); this->textId = 0x1393; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_BIG_POE: - func_801518B0(globalCtx, 0x1394, &this->actor); + Message_StartTextbox(globalCtx, 0x1394, &this->actor); this->textId = 0x1394; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_INDEX_MILK: - func_801518B0(globalCtx, 0x1395, &this->actor); + Message_StartTextbox(globalCtx, 0x1395, &this->actor); this->textId = 0x1395; break; } } void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x1388: EnTalkGibud_GetTextIdForRequestedItem(this, globalCtx); break; + case 0x138C: case 0x138D: case 0x138E: @@ -652,7 +695,7 @@ void EnTalkGibud_GetNextTextBoxId(EnTalkGibud* this, GlobalContext* globalCtx) { case 0x1394: case 0x1395: // Prompts the player to choose an item - func_801518B0(globalCtx, 0xFF, &this->actor); + Message_StartTextbox(globalCtx, 0xFF, &this->actor); this->textId = 0xFF; break; } @@ -692,20 +735,23 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) player->actor.textId = 0x138A; this->textId = 0x138A; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_NOT_ENOUGH_AMMO: player->actor.textId = 0x138B; this->textId = 0x138B; break; + case EN_TALK_GIBUD_REQUESTED_ITEM_NOT_MET: player->actor.textId = 0x1389; this->textId = 0x1389; break; + default: break; } func_801477B4(globalCtx); } else if (this->itemActionParam < PLAYER_AP_NONE) { - func_801518B0(globalCtx, 0x1389, &this->actor); + Message_StartTextbox(globalCtx, 0x1389, &this->actor); this->textId = 0x1389; } } @@ -714,7 +760,7 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { this->isTalking = false; if (this->actionFunc != EnTalkGibud_Talk) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); } this->actionFunc = EnTalkGibud_PassiveIdle; } @@ -726,7 +772,7 @@ void EnTalkGibud_SetupPassiveIdle(EnTalkGibud* this) { void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->isTalking = true; - func_801518B0(globalCtx, 0x1388, &this->actor); + Message_StartTextbox(globalCtx, 0x1388, &this->actor); this->textId = 0x1388; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_AIM); EnTalkGibud_SetupTalk(this); @@ -762,11 +808,13 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { case 12: case 13: break; + case 5: EnTalkGibud_GetNextTextBoxId(this, globalCtx); break; + case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x138A) { // Remove the requested item/amount from the player's inventory requestedItem = &sRequestedItemTable[this->requestedItemIndex]; @@ -777,13 +825,14 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } player->stateFlags1 |= 0x20; player->stateFlags1 |= 0x20000000; - this->actor.flags |= 0x100000; + this->actor.flags |= ACTOR_FLAG_100000; EnTalkGibud_SetupDisappear(this); } else { EnTalkGibud_SetupPassiveIdle(this); } } break; + case 16: EnTalkGibud_CheckPresentedItem(this, globalCtx); break; @@ -792,8 +841,8 @@ void EnTalkGibud_Talk(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupDisappear(EnTalkGibud* this) { - Actor_ChangeAnimation(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); - this->actor.flags &= ~1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_TALK_GIBUD_ANIMATION_IDLE); + this->actor.flags &= ~ACTOR_FLAG_1; this->disappearanceTimer = 40; this->actionFunc = EnTalkGibud_Disappear; } @@ -844,8 +893,9 @@ void EnTalkGibud_FacePlayerWhenTalking(EnTalkGibud* this, GlobalContext* globalC s32 EnTalkGibud_PlayerInRangeWithCorrectState(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && !(player->stateFlags1 & 0x2C6080) && - !(player->stateFlags2 & 0x4080)) { + if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 150.0f) && + !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && + !(player->stateFlags2 & (0x4000 | 0x80))) { return true; } @@ -868,20 +918,20 @@ s32 EnTalkGibud_PlayerOutOfRange(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_CheckForGibdoMask(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->actionFunc != EnTalkGibud_Grab && this->actionFunc != EnTalkGibud_Dead && - this->actionFunc != EnTalkGibud_Disappear && this->actionFunc != EnTalkGibud_Revive && - this->actionFunc != EnTalkGibud_Damage && this->actionFunc != EnTalkGibud_Talk) { + if ((this->actionFunc != EnTalkGibud_Grab) && (this->actionFunc != EnTalkGibud_Dead) && + (this->actionFunc != EnTalkGibud_Disappear) && (this->actionFunc != EnTalkGibud_Revive) && + (this->actionFunc != EnTalkGibud_Damage) && (this->actionFunc != EnTalkGibud_Talk)) { if (this->actionFunc != EnTalkGibud_PassiveIdle) { if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x4 | 0x1); - this->actor.flags |= (0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_4 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_8 | ACTOR_FLAG_1); this->actor.hintId = 0xFF; this->actor.textId = 0; EnTalkGibud_SetupPassiveIdle(this); } } else if (Player_GetMask(globalCtx) != PLAYER_MASK_GIBDO) { - this->actor.flags &= ~(0x8 | 0x1); - this->actor.flags |= (0x4 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_8 | ACTOR_FLAG_1); + this->actor.flags |= (ACTOR_FLAG_4 | ACTOR_FLAG_1); if (this->type == EN_TALK_GIBUD_TYPE_REDEAD) { this->actor.hintId = 0x2A; } else { @@ -934,7 +984,8 @@ s32 EnTalkGibud_MoveToIdealGrabPositionAndRotation(EnTalkGibud* this, GlobalCont distanceFromTargetYOffset = Math_SmoothStepToF(&this->actor.shape.yOffset, -1500.0f, 1.0f, 150.0f, 0.0f); } - if (distanceFromTargetPos == 0.0f && ABS_ALT(distanceFromTargetAngle) < 100 && distanceFromTargetYOffset == 0.0f) { + if ((distanceFromTargetPos == 0.0f) && (ABS_ALT(distanceFromTargetAngle) < 100) && + (distanceFromTargetYOffset == 0.0f)) { return true; } @@ -948,13 +999,13 @@ void EnTalkGibud_PlayAnimation(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_MoveWithGravity(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->actionFunc == EnTalkGibud_WalkToPlayer || this->actionFunc == EnTalkGibud_WalkToHome || - this->actionFunc == EnTalkGibud_Damage) { + if ((this->actionFunc == EnTalkGibud_WalkToPlayer) || (this->actionFunc == EnTalkGibud_WalkToHome) || + (this->actionFunc == EnTalkGibud_Damage)) { Actor_MoveWithGravity(&this->actor); } } -void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_UpdateDamage(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (this->collider.base.acFlags & AC_HIT) { @@ -990,9 +1041,9 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 180; - this->effectType = 0; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 180; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_LIGHT_ARROW: @@ -1002,17 +1053,17 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) } else { EnTalkGibud_SetupDamage(this); } - this->effectTimer = 60; - this->effectType = 20; - this->effectAlpha = 1.0f; + this->drawDmgEffTimer = 60; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 1.0f; break; case EN_TALK_GIBUD_DMGEFF_ZORA_MAGIC: if (this->actionFunc != EnTalkGibud_Grab && (this->actionFunc != EnTalkGibud_Stunned || this->stunTimer == 0)) { - this->effectAlpha = 1.0f; - this->effectTimer = 40; - this->effectType = 30; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; EnTalkGibud_SetupStunned(this); } break; @@ -1026,18 +1077,18 @@ void EnTalkGibud_CheckDamageEffect(EnTalkGibud* this, GlobalContext* globalCtx) } } -void EnTalkGibud_CheckCollision(EnTalkGibud* this, GlobalContext* globalCtx) { +void EnTalkGibud_UpdateCollision(EnTalkGibud* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if (this->actionFunc != EnTalkGibud_Dead && this->actionFunc != EnTalkGibud_Disappear && - this->actionFunc != EnTalkGibud_Revive && - (this->actionFunc != EnTalkGibud_Grab || this->grabState == EN_TALK_GIBUD_GRAB_RELEASE)) { + if ((this->actionFunc != EnTalkGibud_Dead) && (this->actionFunc != EnTalkGibud_Disappear) && + (this->actionFunc != EnTalkGibud_Revive) && + ((this->actionFunc != EnTalkGibud_Grab) || (this->grabState == EN_TALK_GIBUD_GRAB_RELEASE))) { if (this->isTalking != true) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if ((this->actionFunc != EnTalkGibud_Damage || - (player->unk_ADC != 0 && player->unk_ADD != this->unk_3F7)) && - (this->actionFunc != EnTalkGibud_Stunned || this->stunTimer == 0)) { + if (((this->actionFunc != EnTalkGibud_Damage) || + ((player->unk_ADC != 0) && (player->unk_ADD != this->unk_3F7))) && + ((this->actionFunc != EnTalkGibud_Stunned) || (this->stunTimer == 0))) { CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } } @@ -1067,14 +1118,15 @@ void EnTalkGibud_MoveGrabbedPlayerAwayFromWall(EnTalkGibud* this, GlobalContext* } void EnTalkGibud_UpdateEffect(EnTalkGibud* this, GlobalContext* globalCtx) { - if (this->effectTimer > 0) { - this->effectTimer--; + if (this->drawDmgEffTimer > 0) { + this->drawDmgEffTimer--; } - if (this->effectTimer < 20) { - Math_SmoothStepToF(&this->effectScale, 0.0f, 0.5f, 0.03f, 0.0f); - this->effectAlpha = this->effectTimer * 0.05f; + + if (this->drawDmgEffTimer < 20) { + Math_SmoothStepToF(&this->drawDmgEffScale, 0.0f, 0.5f, 0.03f, 0.0f); + this->drawDmgEffAlpha = this->drawDmgEffTimer * 0.05f; } else { - Math_SmoothStepToF(&this->effectScale, 0.5f, 0.1f, 0.02f, 0.0f); + Math_SmoothStepToF(&this->drawDmgEffScale, 0.5f, 0.1f, 0.02f, 0.0f); } } @@ -1082,13 +1134,16 @@ void EnTalkGibud_Update(Actor* thisx, GlobalContext* globalCtx) { EnTalkGibud* this = THIS; EnTalkGibud_CheckForGibdoMask(this, globalCtx); - EnTalkGibud_CheckDamageEffect(this, globalCtx); + EnTalkGibud_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + EnTalkGibud_PlayAnimation(this, globalCtx); EnTalkGibud_MoveWithGravity(this, globalCtx); - EnTalkGibud_CheckCollision(this, globalCtx); + EnTalkGibud_UpdateCollision(this, globalCtx); EnTalkGibud_MoveGrabbedPlayerAwayFromWall(this, globalCtx); EnTalkGibud_UpdateEffect(this, globalCtx); + this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 50.0f; } @@ -1097,9 +1152,9 @@ s32 EnTalkGibud_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** Actor* thisx, Gfx** gfx) { EnTalkGibud* this = THIS; - if (limbIndex == EN_TALK_GIBUD_LIMB_UPPER_BODY_ROOT) { + if (limbIndex == GIBDO_LIMB_UPPER_BODY_ROOT) { rot->y += this->upperBodyRotation.y; - } else if (limbIndex == EN_TALK_GIBUD_LIMB_HEAD_ROOT) { + } else if (limbIndex == GIBDO_LIMB_HEAD_ROOT) { rot->y += this->headRotation.y; } @@ -1110,15 +1165,14 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi Gfx** gfx) { EnTalkGibud* this = THIS; - if ((this->effectTimer != 0) && - ((limbIndex == EN_TALK_GIBUD_LIMB_LEFT_THIGH) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_LOWER_LEG) || - (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_FOOT) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_THIGH) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_LOWER_LEG) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_FOOT) || - (limbIndex == EN_TALK_GIBUD_LIMB_TORSO) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || - (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_FOREARM) || (limbIndex == EN_TALK_GIBUD_LIMB_LEFT_HAND) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || - (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_FOREARM) || (limbIndex == EN_TALK_GIBUD_LIMB_RIGHT_HAND) || - (limbIndex == EN_TALK_GIBUD_LIMB_HEAD) || (limbIndex == EN_TALK_GIBUD_LIMB_PELVIS))) { + if ((this->drawDmgEffTimer != 0) && + ((limbIndex == GIBDO_LIMB_LEFT_THIGH) || (limbIndex == GIBDO_LIMB_LEFT_SHIN) || + (limbIndex == GIBDO_LIMB_LEFT_FOOT) || (limbIndex == GIBDO_LIMB_RIGHT_THIGH) || + (limbIndex == GIBDO_LIMB_RIGHT_SHIN) || (limbIndex == GIBDO_LIMB_RIGHT_FOOT) || + (limbIndex == GIBDO_LIMB_TORSO) || (limbIndex == GIBDO_LIMB_LEFT_SHOULDER_AND_UPPER_ARM) || + (limbIndex == GIBDO_LIMB_LEFT_FOREARM) || (limbIndex == GIBDO_LIMB_LEFT_HAND) || + (limbIndex == GIBDO_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM) || (limbIndex == GIBDO_LIMB_RIGHT_FOREARM) || + (limbIndex == GIBDO_LIMB_RIGHT_HAND) || (limbIndex == GIBDO_LIMB_HEAD) || (limbIndex == GIBDO_LIMB_PELVIS))) { Matrix_GetStateTranslation(&this->limbPos[this->limbIndex]); this->limbIndex++; } @@ -1149,9 +1203,10 @@ void EnTalkGibud_Draw(Actor* thisx, GlobalContext* globalCtx) { this->skelAnime.dListCount, EnTalkGibud_OverrideLimbDraw, EnTalkGibud_PostLimbDraw, &this->actor, POLY_XLU_DISP); } - if (this->effectTimer > 0) { - func_800BE680(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->effectScale, 0.5f, - this->effectAlpha, this->effectType); + + if (this->drawDmgEffTimer > 0) { + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, 0.5f, this->drawDmgEffAlpha, this->drawDmgEffType); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h index 2c154ea89..b2d5b06b8 100644 --- a/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h +++ b/src/overlays/actors/ovl_En_Talk_Gibud/z_en_talk_gibud.h @@ -2,51 +2,11 @@ #define Z_EN_TALK_GIBUD_H #include "global.h" +#include "objects/object_rd/object_rd.h" #define EN_TALK_GIBUD_REQUESTED_ITEM_INDEX(thisx) ((thisx)->params & 0xF) #define EN_TALK_GIBUD_SWITCH_FLAG(thisx) (((thisx)->params & 0xFF0) >> 4) -typedef enum { - /* 0 */ EN_TALK_GIBUD_TYPE_GIBDO, - /* 1 */ EN_TALK_GIBUD_TYPE_REDEAD, -} EnTalkGibudType; - -typedef enum { - /* 0 */ EN_TALK_GIBUD_GRAB_START, - /* 1 */ EN_TALK_GIBUD_GRAB_ATTACK, - /* 2 */ EN_TALK_GIBUD_GRAB_RELEASE, -} EnTalkGibudGrabState; - -typedef enum { - /* 0 */ EN_TALK_GIBUD_LIMB_NONE, - /* 1 */ EN_TALK_GIBUD_LIMB_ROOT, // Root of Left Leg Root, Right Leg Root, Upper Body Root, and Pelvis - /* 2 */ EN_TALK_GIBUD_LIMB_LEFT_LEG_ROOT, - /* 3 */ EN_TALK_GIBUD_LIMB_LEFT_THIGH, - /* 4 */ EN_TALK_GIBUD_LIMB_LEFT_LOWER_LEG, - /* 5 */ EN_TALK_GIBUD_LIMB_LEFT_FOOT_ROOT, - /* 6 */ EN_TALK_GIBUD_LIMB_LEFT_FOOT, - /* 7 */ EN_TALK_GIBUD_LIMB_RIGHT_LEG_ROOT, - /* 8 */ EN_TALK_GIBUD_LIMB_RIGHT_THIGH, - /* 9 */ EN_TALK_GIBUD_LIMB_RIGHT_LOWER_LEG, - /* 10 */ EN_TALK_GIBUD_LIMB_RIGHT_FOOT_ROOT, - /* 11 */ EN_TALK_GIBUD_LIMB_RIGHT_FOOT, - /* 12 */ EN_TALK_GIBUD_LIMB_UPPER_BODY_ROOT, - /* 13 */ EN_TALK_GIBUD_LIMB_UPPER_BODY, // Root of Torso - /* 14 */ EN_TALK_GIBUD_LIMB_TORSO, // Root of Left Arm Root, Right Arm Root, and Head Root - /* 15 */ EN_TALK_GIBUD_LIMB_LEFT_ARM_ROOT, - /* 16 */ EN_TALK_GIBUD_LIMB_LEFT_SHOULDER_AND_UPPER_ARM, - /* 17 */ EN_TALK_GIBUD_LIMB_LEFT_FOREARM, - /* 18 */ EN_TALK_GIBUD_LIMB_LEFT_HAND, - /* 19 */ EN_TALK_GIBUD_LIMB_RIGHT_ARM_ROOT, - /* 20 */ EN_TALK_GIBUD_LIMB_RIGHT_SHOULDER_AND_UPPER_ARM, - /* 21 */ EN_TALK_GIBUD_LIMB_RIGHT_FOREARM, - /* 22 */ EN_TALK_GIBUD_LIMB_RIGHT_HAND, - /* 23 */ EN_TALK_GIBUD_LIMB_HEAD_ROOT, - /* 24 */ EN_TALK_GIBUD_LIMB_HEAD, - /* 25 */ EN_TALK_GIBUD_LIMB_PELVIS, - /* 26 */ EN_TALK_GIBUD_LIMB_MAX, -} EnTalkGibudLimbs; - struct EnTalkGibud; typedef void (*EnTalkGibudActionFunc)(struct EnTalkGibud*, GlobalContext*); @@ -61,27 +21,27 @@ typedef struct EnTalkGibud { /* 0x290 */ s32 requestedItemIndex; /* 0x294 */ s32 itemActionParam; /* 0x298 */ s32 switchFlag; - /* 0x29C */ f32 effectAlpha; - /* 0x2A0 */ f32 effectScale; - /* 0x2A4 */ Vec3s jointTable[EN_TALK_GIBUD_LIMB_MAX]; - /* 0x340 */ Vec3s morphTable[EN_TALK_GIBUD_LIMB_MAX]; + /* 0x29C */ f32 drawDmgEffAlpha; + /* 0x2A0 */ f32 drawDmgEffScale; + /* 0x2A4 */ Vec3s jointTable[GIBDO_LIMB_MAX]; + /* 0x340 */ Vec3s morphTable[GIBDO_LIMB_MAX]; /* 0x3DC */ s16 textId; /* 0x3DE */ Vec3s headRotation; /* 0x3E4 */ Vec3s upperBodyRotation; /* 0x3EA */ union { - s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero - s16 grabDamageTimer; - s16 headShakeTimer; - s16 stunTimer; - s16 deathTimer; - s16 disappearanceTimer; - }; + s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero + s16 grabDamageTimer; + s16 headShakeTimer; + s16 stunTimer; + s16 deathTimer; + s16 disappearanceTimer; + }; /* 0x3EC */ s16 grabState; /* 0x3EE */ s16 grabWaitTimer; // Cannot grab the player if this is non-zero - /* 0x3F0 */ s16 effectTimer; + /* 0x3F0 */ s16 drawDmgEffTimer; /* 0x3F2 */ s16 type; /* 0x3F4 */ s16 isTalking; - /* 0x3F6 */ u8 effectType; + /* 0x3F6 */ u8 drawDmgEffType; /* 0x3F7 */ s8 unk_3F7; // related to player->unk_ADD } EnTalkGibud; // size = 0x3F8 diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c index 1b2e04472..b7e5588f7 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -6,7 +6,7 @@ #include "z_en_tanron1.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron1*)thisx) @@ -15,7 +15,9 @@ void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx); +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx); + const ActorInit En_Tanron1_InitVars = { ACTOR_EN_TANRON1, ACTORCAT_ENEMY, @@ -28,18 +30,387 @@ const ActorInit En_Tanron1_InitVars = { (ActorFunc)EnTanron1_Draw, }; -#endif +static u64 sPad = { 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Init.s") +#include "overlays/ovl_En_Tanron1/ovl_En_Tanron1.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Destroy.s") +void EnTanron1_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB4E50.s") + this->actor.flags &= ~ACTOR_FLAG_1; + if (!ENTANRON1_GET_100(&this->actor)) { + this->unk_144 = 0; + } else { + this->actor.params = 200; + this->unk_144 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Update.s") +void EnTanron1_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/EnTanron1_Draw.s") +void func_80BB4E50(EnTanron1Struct* arg0, Vec3f* arg1, s16 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5318.s") + for (i = 0; i < 200; i++, arg0++) { + if (arg0->unk_24 == 0) { + arg0->unk_24 = 1; + arg0->unk_2C = 0.0f; + arg0->unk_00 = *arg1; + arg0->unk_18 = arg0->unk_1C = 0; + arg0->unk_1A = arg2; + arg0->unk_26 = Rand_ZeroFloat(100.0f); + arg0->unk_28 = 0; + if (Rand_ZeroOne() < 0.5f) { + arg0->unk_2A = 0xC00; + } else { + arg0->unk_2A = -0xC00; + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron1/func_80BB5AAC.s") +void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + Actor* temp_a0; + Player* player = GET_PLAYER(globalCtx); + s16 i; + EnTanron1Struct* ptr = &this->unk_160[0]; + Vec3f temp; + f32 phi_f18; + s32 pad; + + if (this->unk_148 != 0) { + this->unk_148--; + } + + switch (this->unk_144) { + case 0: + for (i = 0; i < this->actor.params; i++) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, Rand_ZeroFloat(0x10000)); + } + this->unk_144 = 200; + break; + + case 1: + this->unk_14C.x = player->actor.world.pos.x; + this->unk_14C.y = player->actor.world.pos.y + 60.0f; + this->unk_14C.z = player->actor.world.pos.z; + if (this->unk_148 != 0) { + func_80BB4E50(this->unk_160, &this->actor.world.pos, this->actor.world.rot.y); + } + this->unk_158 = 0x1000; + this->unk_15C = 150.0f; + break; + + case 100: + phi_f18 = 10.0f; + + while (phi_f18 < 1000.0f) { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; + while (temp_a0 != NULL) { + if (temp_a0->id != ACTOR_OBJ_SYOKUDAI) { + temp_a0 = temp_a0->next; + continue; + } + + temp.x = this->unk_14C.x - temp_a0->world.pos.x; + temp.y = (this->unk_14C.y - temp_a0->world.pos.y) + 70.0f; + temp.z = this->unk_14C.z - temp_a0->world.pos.z; + + if (sqrtf(SQXYZ(temp)) < phi_f18) { + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 70.0f; + this->unk_14C.z = temp_a0->world.pos.z; + goto end; + } + temp_a0 = temp_a0->next; + } + phi_f18 += 20.0f; + } + end: + break; + + case 200: + this->unk_14C = this->actor.world.pos; + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + break; + + case 250: + for (i = 0; i < ARRAY_COUNT(this->unk_160); i++, ptr++) { + if ((ptr->unk_24 != 0) && (ptr->unk_28 < 8)) { + ptr->unk_28 = 8; + ptr->unk_24 = 2; + } + } + this->unk_144 = 1; + break; + } + + if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { + this->unk_14C.x = player->swordInfo[0].tip.x; + this->unk_14C.y = player->swordInfo[0].tip.y; + this->unk_14C.z = player->swordInfo[0].tip.z; + + this->unk_158 = 0x5000; + this->unk_15C = 50.0f; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + } else { + temp_a0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_a0 != NULL) { + if (temp_a0->params == 1) { + temp_a0 = temp_a0->next; + continue; + } + + this->unk_14C.x = temp_a0->world.pos.x; + this->unk_14C.y = temp_a0->world.pos.y + 50.0f; + this->unk_14C.z = temp_a0->world.pos.z; + + this->unk_15C = 150.0f; + this->unk_158 = 0x1000; + if (this->unk_144 != 1) { + this->unk_144 = 100; + } + break; + } + } + func_80BB5318(this, globalCtx); +} + +void EnTanron1_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron1* this = THIS; + + func_80BB5AAC(this, globalCtx); +} + +void func_80BB5318(EnTanron1* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + EnTanron1Struct* ptr = NULL; + f32 phi_f28 = 0.0f; + Vec3f* phi_s2 = NULL; + Vec3f temp; + s16 spBA = 0; + s16 spB8 = 0; + Vec3f* spB4 = NULL; + f32 spB0; + Vec3f spA4; + WaterBox* spA0; + f32 sp9C; + CollisionPoly* sp98; + Actor* temp_v0; + s16 i; + f32 temp_f30 = this->unk_15C; + + if (player->unk_ADC != 0) { + phi_s2 = &player->swordInfo[0].tip; + if (player->swordAnimation >= 30) { + phi_f28 = 2500.0f; + } else { + phi_f28 = 400.0f; + } + } + + temp_v0 = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + while (temp_v0 != NULL) { + if (temp_v0->params != 1) { + temp_v0 = temp_v0->next; + continue; + } + phi_s2 = &temp_v0->world.pos; + phi_f28 = 40000.0f; + break; + } + + ptr = &this->unk_160[0]; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 0) { + ptr->unk_26++; + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; + + if (ptr->unk_24 == 0) { + } else { + spB4 = &ptr->unk_00; + if (ptr->unk_28 == 0) { + spBA++; + ptr->unk_2C = Math_SinS(ptr->unk_26 * 0x5000) * 1.2f; + if ((ptr->unk_26 & 3) == 0) { + temp.x = ptr->unk_30 + (this->unk_14C.x - ptr->unk_00.x); + temp.y = ptr->unk_34 + (this->unk_14C.y - ptr->unk_00.y); + temp.z = ptr->unk_38 + (this->unk_14C.z - ptr->unk_00.z); + + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + if ((ptr->unk_26 & 0xF) == 0) { + ptr->unk_30 = randPlusMinusPoint5Scaled(temp_f30); + ptr->unk_34 = randPlusMinusPoint5Scaled(temp_f30 * 0.5f); + ptr->unk_38 = randPlusMinusPoint5Scaled(temp_f30); + } + + temp.x = player->actor.world.pos.x - ptr->unk_00.x; + temp.y = (player->actor.world.pos.y + 40.0f) - ptr->unk_00.y; + temp.z = player->actor.world.pos.z - ptr->unk_00.z; + + if ((SQXYZ(temp) < 400.0f) && (player->transformation != PLAYER_FORM_DEKU)) { + func_800B8D10(globalCtx, &this->actor, 0.0f, 0, 0.0f, 1, 1); + } + } + + Math_ApproachS(&ptr->unk_1A, ptr->unk_20, 2, this->unk_158); + Math_ApproachS(&ptr->unk_18, ptr->unk_1E, 2, this->unk_158); + Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_18, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(6.0f, &ptr->unk_0C); + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + + if (phi_f28 >= 100000.0f) { + ptr->unk_28 = 1; + } else { + ptr->unk_28 = 6; + } + ptr->unk_24 = 2; + spB8++; + } + } + } else if (ptr->unk_28 < 9) { + ptr->unk_18 += 0x3000; + ptr->unk_1A += 0x5000; + ptr->unk_30 = 0.0f; + ptr->unk_34 = 0.0f; + ptr->unk_28++; + } else { + ptr->unk_1A += ptr->unk_2A; + Math_ApproachS(&ptr->unk_18, 0, 0xA, 0x1000); + Matrix_RotateY(ptr->unk_1A, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(ptr->unk_30, &spA4); + + ptr->unk_0C.x = spA4.x; + ptr->unk_0C.z = spA4.z; + ptr->unk_0C.y = -2.0f; + + if (phi_s2 != NULL) { + temp.x = phi_s2->x - ptr->unk_00.x; + temp.y = phi_s2->y - ptr->unk_00.y; + temp.z = phi_s2->z - ptr->unk_00.z; + + if (SQXYZ(temp) < phi_f28) { + ptr->unk_20 = Math_Atan2S(temp.x, temp.z); + ptr->unk_1E = Math_Atan2S(temp.y, sqrtf(SQXZ(temp))); + + Matrix_RotateY(ptr->unk_20, MTXMODE_NEW); + Matrix_InsertXRotation_s(-ptr->unk_1E, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(-20.0f, &ptr->unk_0C); + + ptr->unk_3C = ptr->unk_00.y - 1000.0f; + ptr->unk_30 = 5.0f; + } + } + + if (ptr->unk_00.y <= (ptr->unk_3C + 5.0f)) { + ptr->unk_00.y = (ptr->unk_3C + 5.0f); + Math_ApproachZeroF(&ptr->unk_30, 1.0f, 0.3f); + Math_ApproachS(&ptr->unk_2A, 0, 1, 0x100); + ptr->unk_28++; + if (ptr->unk_28 > 50) { + ptr->unk_24 = 0; + } + } else { + Math_ApproachF(&ptr->unk_30, ptr->unk_34, 1.0f, 0.5f); + if ((ptr->unk_26 & 0xF) == 0) { + if (Rand_ZeroOne() < 0.5f) { + ptr->unk_34 = randPlusMinusPoint5Scaled(12.0f); + } + ptr->unk_3C = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp98, &ptr->unk_00); + sp9C = ptr->unk_00.y; + WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, ptr->unk_00.x, ptr->unk_00.z, &sp9C, + &spA0); + if ((sp9C < ptr->unk_00.y) && (ptr->unk_3C < sp9C)) { + ptr->unk_3C = sp9C; + } + } + } + } + } + } + } + + if (spB4 != NULL) { + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, spB4, &this->unk_3360, &spB0); + if (spB8 >= (s16)(KREG(39) + 20)) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_DEAD); + } else if (spBA >= 20) { + Audio_PlaySfxAtPos(&this->unk_3360, NA_SE_EN_MB_MOTH_FLY - SFX_FLAG); + } + } +} + +void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { + EnTanron1Struct* ptrBase = &this->unk_160[0]; + s16 i; + u8 flag = 0; + EnTanron1Struct* ptr = ptrBase; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 == 1) { + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + flag++; + } + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.2f, ptr->unk_2C, 1.2f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + } + + flag = 0; + ptr = ptrBase; + for (i = 0; i < this->actor.params; i++, ptr++) { + if (ptr->unk_24 != 2) { + continue; + } + + if (!flag) { + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001888); + gDPLoadTextureBlock(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001428, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 4, 5, G_TX_NOLOD, G_TX_NOLOD); + flag++; + } + + Matrix_InsertTranslation(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); + Matrix_RotateY(ptr->unk_1A, MTXMODE_APPLY); + Matrix_InsertXRotation_s(ptr->unk_18 * -1, MTXMODE_APPLY); + Matrix_Scale(1.0f, ptr->unk_2C, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ovl_En_Tanron1_DL_001900); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h index b32810084..d8e96537f 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h @@ -5,9 +5,38 @@ struct EnTanron1; +#define ENTANRON1_GET_100(thisx) ((thisx)->params & 0x100) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 unk_1E; + /* 0x20 */ s16 unk_20; + /* 0x22 */ UNK_TYPE1 unk_22[0x2]; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s16 unk_28; + /* 0x2A */ s16 unk_2A; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; + /* 0x3C */ f32 unk_3C; +} EnTanron1Struct; // size = 0x40 + typedef struct EnTanron1 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x3228]; + /* 0x0144 */ u8 unk_144; + /* 0x0145 */ UNK_TYPE1 pad145[3]; + /* 0x0148 */ s16 unk_148; + /* 0x014C */ Vec3f unk_14C; + /* 0x0158 */ s16 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ EnTanron1Struct unk_160[200]; + /* 0x3360 */ Vec3f unk_3360; } EnTanron1; // size = 0x336C extern const ActorInit En_Tanron1_InitVars; 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 be89681f1..e391669e5 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -5,8 +5,11 @@ */ #include "z_en_tanron2.h" +#include "overlays/actors/ovl_Boss_04/z_boss_04.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_boss04/object_boss04.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron2*)thisx) @@ -15,12 +18,18 @@ void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BB69C0(EnTanron2* this); void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx); void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx); +void func_80BB6F64(EnTanron2* this); void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx); void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx); +void func_80BB7B90(Actor* thisx, GlobalContext* globalCtx); + +Boss04* D_80BB8450; +f32 D_80BB8454; +EnTanron2* D_80BB8458[82]; -#if 0 const ActorInit En_Tanron2_InitVars = { ACTOR_EN_TANRON2, ACTORCAT_BOSS, @@ -33,8 +42,7 @@ const ActorInit En_Tanron2_InitVars = { (ActorFunc)EnTanron2_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80BB8170 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -69,54 +77,607 @@ static DamageTable D_80BB8170 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB8190 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xFFFFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xFFFFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 50, -25, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB81BC = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7FFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7FFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 22, 42, -21, { 0, 0, 0 } }, }; -#endif +Color_RGBA8 D_80BB81E8 = { 255, 255, 255, 255 }; +Color_RGBA8 D_80BB81EC = { 255, 100, 100, 255 }; -extern DamageTable D_80BB8170; -extern ColliderCylinderInit D_80BB8190; -extern ColliderCylinderInit D_80BB81BC; +void EnTanron2_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron2* this = THIS; -extern UNK_TYPE D_06003450; + D_80BB8450 = (Boss04*)this->actor.parent; + this->actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Init.s") + if (this->actor.params == 100) { + this->actor.update = func_80BB7B90; + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 5); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Destroy.s") + this->actor.flags |= ACTOR_FLAG_200; + Actor_SetScale(&this->actor, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB69C0.s") + this->actor.draw = NULL; + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB69FC.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6B80.s") + if ((KREG(64) != 0) || (gSaveContext.eventInf[6] & 1)) { + func_80BB69C0(this); + } else { + func_80BB6F64(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6BD8.s") + this->unk_14A = Rand_ZeroFloat(0x10000); + this->unk_14C = Rand_ZeroFloat(800.0f) + 1400.0f; + if (Rand_ZeroOne() < 0.5f) { + this->unk_14C = -this->unk_14C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6F64.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 60.0f, 60.0f, 4); + this->actor.floorHeight += 20.0f; + this->unk_148 = Rand_ZeroFloat(32.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB6F78.s") +void EnTanron2_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB71C8.s") +void func_80BB69C0(EnTanron2* this) { + this->actionFunc = func_80BB69FC; + this->unk_160 = 0.0f; + this->unk_15C = 0.0f; + this->collider1.dim.radius = 25; + this->collider1.dim.height = 46; + this->collider1.dim.yShift = -23; + this->unk_158 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7398.s") +void func_80BB69FC(EnTanron2* this, GlobalContext* globalCtx) { + f32 sp34; + f32 sp30; + f32 sp2C; + Vec3f* temp_s1 = &D_80BB8450->unk_2E4[this->actor.params]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7408.s") + if (this->unk_15C == 1.0f) { + Math_Vec3f_Copy(&this->actor.world.pos, temp_s1); + } else { + sp34 = Math_SmoothStepToF(&this->actor.world.pos.x, temp_s1->x, this->unk_15C, this->unk_160, 0.0f); + sp30 = Math_SmoothStepToF(&this->actor.world.pos.y, temp_s1->y, this->unk_15C, this->unk_160, 0.0f); + sp2C = Math_SmoothStepToF(&this->actor.world.pos.z, temp_s1->z, this->unk_15C, this->unk_160, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7578.s") + if ((this->unk_158 == 0) && ((sp34 + sp30 + sp2C) < 2.0f)) { + this->unk_158 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_B_SLIME_EAT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Update.s") + Math_ApproachF(&this->unk_15C, 1.0f, 1.0f, 0.02f); + Math_ApproachF(&this->unk_160, 20.0f, 1.0f, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/func_80BB7B90.s") + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron2/EnTanron2_Draw.s") +void func_80BB6B80(EnTanron2* this) { + this->actionFunc = func_80BB6BD8; + this->actor.speedXZ = 0.0f; + this->actor.velocity.z = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.velocity.x = 0.0f; + this->unk_158 = 0; + this->unk_159 = 1; + this->actor.flags |= ACTOR_FLAG_1; + this->collider1.dim.radius = 30; + this->collider1.dim.height = 50; + this->collider1.dim.yShift = -25; +} + +void func_80BB6BD8(EnTanron2* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + f32 sp2C; + f32 sp28; + + if (this->unk_14E == 0) { + 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; + this->actor.velocity.y = this->actor.velocity.y - 2.0f; + + 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); + + sp2C = D_80BB8450->unk_6BC.x - this->actor.world.pos.x; + sp28 = D_80BB8450->unk_6BC.z - this->actor.world.pos.z; + + switch (this->unk_158) { + case 0: + if (Rand_ZeroOne() > 0.2f) { + sp32 = Rand_ZeroFloat(65536.0f); + } else { + sp32 = Math_Atan2S(sp2C, sp28); + } + this->actor.speedXZ = 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; + } + break; + + case 2: + 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; + if ((this->unk_152 == 0) && (D_80BB8450->unk_1F6 == 0)) { + this->unk_158 = 1; + } + break; + } + Matrix_RotateY(sp32, MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(this->actor.speedXZ, &this->actor.velocity); + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; + this->unk_14E = 5; + } + + if (this->unk_150 != 0) { + Math_ApproachF(&this->actor.scale.x, 0.75f, 0.5f, 1.0f); + Math_ApproachF(&this->actor.scale.y, 1.2f, 0.5f, 1.0f); + } else { + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); + } + } else { + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + if (this->unk_14E == 1) { + sp2C = D_80BB8450->unk_6BC.x - this->actor.world.pos.x; + sp28 = D_80BB8450->unk_6BC.z - this->actor.world.pos.z; + + if ((this->unk_158 != 0) && ((SQ(sp2C) + SQ(sp28)) < 14400.0f)) { + func_80BB69C0(this); + } else { + this->unk_150 = 10; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + } + } + } +} + +void func_80BB6F64(EnTanron2* this) { + this->actionFunc = func_80BB6F78; +} + +void func_80BB6F78(EnTanron2* this, GlobalContext* globalCtx) { + switch (this->unk_158) { + case 0: + if (D_80BB8450->unk_708 == 13) { + this->unk_158 = 10; + this->unk_14E = Rand_ZeroFloat(50.0f); + } + break; + + case 10: + if (this->unk_14E == 0) { + this->unk_150 = 10; + this->unk_158 = 1; + } + break; + + case 1: + if (this->unk_14E == 0) { + this->actor.world.pos.y += this->actor.velocity.y; + this->actor.velocity.y = this->actor.velocity.y - 2.0f; + + 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); + if (D_80BB8450->unk_6F8 > 0.1f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER_L); + } + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 12.0f; + this->unk_14E = 5; + } + + if (this->unk_150 != 0) { + Math_ApproachF(&this->actor.scale.x, 0.75f, 0.5f, 1.0f); + Math_ApproachF(&this->actor.scale.y, 1.2f, 0.5f, 1.0f); + } else { + Math_ApproachF(&this->actor.scale.x, 1.0f, 0.1f, 0.2f); + Math_ApproachF(&this->actor.scale.y, 1.0f, 0.1f, 0.2f); + } + } else { + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + + if (this->unk_14E == 1) { + if (D_80BB8450->unk_708 == 3) { + func_80BB6B80(this); + this->unk_158 = 1; + this->unk_159 = 0; + } else { + this->unk_150 = 0xA; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_JUMP1); + } + } + } + break; + } +} + +void func_80BB71C8(EnTanron2* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spA8; + Vec3f sp9C; + Vec3f sp90; + + for (i = 0; i < 15; i++) { + Matrix_InsertYRotation_f(Rand_ZeroFloat(6.2831855f), MTXMODE_NEW); + Matrix_RotateStateAroundXAxis(Rand_ZeroFloat(6.2831855f)); + Matrix_GetStateTranslationAndScaledZ(Rand_ZeroFloat(10.0f) + 5.0f, &spA8); + sp90.x = this->actor.world.pos.x + spA8.x; + sp90.y = this->actor.world.pos.y + spA8.y; + sp90.z = this->actor.world.pos.z + spA8.z; + + sp9C.x = spA8.x * -0.03f; + sp9C.y = spA8.y * -0.03f; + sp9C.z = spA8.z * -0.03f; + + EffectSsDtBubble_SpawnCustomColor(globalCtx, &sp90, &spA8, &sp9C, &D_80BB81E8, &D_80BB81EC, + Rand_ZeroFloat(100.0f) + 200.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); + } +} + +void func_80BB7398(EnTanron2* this, GlobalContext* globalCtx) { + this->actionFunc = func_80BB7408; + if ((s8)this->actor.colChkInfo.health <= 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_IKURA_DEAD); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + } +} + +void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx) { + 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; + this->actor.velocity.y -= 2.0f; + + if (this->actor.world.pos.y <= this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + if ((s8)this->actor.colChkInfo.health <= 0) { + Actor_MarkForDeath(&this->actor); + func_80BB71C8(this, globalCtx); + D_80BB8450->unk_6F6--; + D_80BB8450->unk_2E2 += 4; + D_80BB8450->unk_2E0 += 4; + } else { + this->actor.velocity.x *= 0.5f; + this->actor.velocity.z *= 0.5f; + Math_ApproachF(&this->actor.scale.x, 1.2f, 0.75f, 1.5f); + Math_ApproachF(&this->actor.scale.y, 0.75f, 0.75f, 1.5f); + if ((this->actor.velocity.x < 0.1f) && (this->actor.velocity.z < 0.1f)) { + func_80BB6B80(this); + this->unk_158 = 1; + } + } + } +} + +void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { + ColliderInfo* acHitInfo; + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s32 pad2; + s32 pad3; + u8 damage; + + if (this->unk_154 == 0) { + if (this->collider1.base.acFlags & AC_HIT) { + this->collider1.base.acFlags &= ~AC_HIT; + acHitInfo = this->collider1.info.acHitInfo; + if (acHitInfo->toucher.dmgFlags & 0x80) { + func_80BB6B80(this); + this->unk_158 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + if ((player->unk_730 != 0) && (&this->actor != player->unk_730)) { + player->unk_730 = &this->actor; + globalCtx->actorCtx.targetContext.arrowPointedActor = &this->actor; + globalCtx->actorCtx.targetContext.targetedActor = &this->actor; + } + } else { + this->unk_154 = 15; + if (this->actionFunc != func_80BB69FC) { + Matrix_RotateY(this->actor.yawTowardsPlayer, MTXMODE_NEW); + if ((acHitInfo->toucher.dmgFlags & 0x300000) != 0) { + this->unk_154 = 10; + Matrix_GetStateTranslationAndScaledZ(-10.0f, &this->actor.velocity); + } else { + this->unk_156 = 15; + Matrix_GetStateTranslationAndScaledZ(-20.0f, &this->actor.velocity); + damage = this->actor.colChkInfo.damage; + this->actor.colChkInfo.health -= damage; + func_80BB7398(this, globalCtx); + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); + goto block_18; + } + } + } + } + + if ((this->actionFunc == func_80BB69FC) && + ((D_80BB8450->unk_1F6 == 1) || ((D_80BB8450->unk_1F7 != 0) && (Rand_ZeroOne() < 0.1f)))) { + if (D_80BB8450->unk_1F7 != 0) { + D_80BB8450->unk_1F7--; + } + + block_18: + func_80BB6B80(this); + this->unk_158 = 2; + Matrix_RotateY(Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z), + MTXMODE_NEW); + Matrix_GetStateTranslationAndScaledZ(10.0f, &this->actor.velocity); + this->unk_152 = Rand_ZeroFloat(100.0f) + 200.0f; + } else if (D_80BB8450->unk_1F6 == 10) { + Actor_MarkForDeath(&this->actor); + func_80BB71C8(this, globalCtx); + } +} + +void EnTanron2_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTanron2* this = THIS; + s32 pad2[2]; + Input* input; + + this->unk_148++; + Actor_SetFocus(&this->actor, 0.0f); + + if (this->unk_14E != 0) { + this->unk_14E--; + } + + if (this->unk_150 != 0) { + this->unk_150--; + } + + if (this->unk_152 != 0) { + this->unk_152--; + } + + if (this->unk_154 != 0) { + this->unk_154--; + } + + if (this->unk_156 != 0) { + this->unk_156--; + } + + this->actionFunc(this, globalCtx); + + if (this->actionFunc != func_80BB69FC) { + if ((this->actor.world.pos.x < (D_80BB8450->unk_6D8 + 20.0f)) || + ((D_80BB8450->unk_6DC - 20.0f) < this->actor.world.pos.x)) { + this->actor.world.pos.x = this->actor.prevPos.x; + this->actor.velocity.x *= -1.0f; + } + + if ((this->actor.world.pos.z < (D_80BB8450->unk_6E0 + 20.0f)) || + ((D_80BB8450->unk_6E4 - 20.0f) < this->actor.world.pos.z)) { + this->actor.world.pos.z = this->actor.prevPos.z; + this->actor.velocity.z *= -1.0f; + } + } + + this->unk_14A += this->unk_14C; + func_80BB7578(this, globalCtx); + + if (this->unk_159 != 0) { + if (this->actor.xzDistToPlayer < 100.0f) { + if (this->unk_15A == 0) { + Collider_UpdateCylinder(&this->actor, &this->collider2); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } else { + this->unk_15A--; + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider1); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (!(this->unk_148 & 0x1F)) { + if ((this->actionFunc != func_80BB69FC) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { + this->unk_15B = 1; + } else { + this->unk_15B = 0; + } + + if (this->actionFunc == func_80BB69FC) { + s16 atan = Math_Atan2S(this->actor.world.pos.x - D_80BB8450->unk_6BC.x, + this->actor.world.pos.z - D_80BB8450->unk_6BC.z); + + if (ABS_ALT(BINANG_SUB(D_80BB8450->actor.yawTowardsPlayer, atan)) > 0x3000) { + this->unk_159 = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + this->unk_159 = 1; + this->actor.flags |= ACTOR_FLAG_1; + } + } + } + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_2000) && (this->actor.xzDistToPlayer < 80.0f)) { + this->actor.flags &= ~ACTOR_FLAG_2000; + this->unk_15A = 25; + this->unk_159 = 1; + } + + input = CONTROLLER3(globalCtx); + if (CHECK_BTN_ALL(input->press.button, BTN_L)) { + this->unk_158 = 1; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_R)) { + func_80BB6B80(this); + } +} + +void func_80BB7B90(Actor* thisx, GlobalContext* globalCtx) { + EnTanron2* this = THIS; + + D_80BB8454 = (Math_SinS(globalCtx->gameplayFrames * 0x3000) * 0.1f) + 1.0f; + if (D_80BB8450->unk_1F6 == 11) { + Actor_MarkForDeath(&this->actor); + } +} + +void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 i; + s32 j; + s32 found; + Actor* tanron2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_003450); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 150); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + + for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { + D_80BB8458[i] = NULL; + } + + found = 0; + while (tanron2 != NULL) { + if (tanron2->params < 100) { + D_80BB8458[found] = (EnTanron2*)tanron2; + found++; + } + tanron2 = tanron2->next; + } + + for (j = 0; j < found - 1; j++) { + for (i = 0; i < found - 1; i++) { + if (D_80BB8458[i + 1] != NULL) { + if (D_80BB8458[i]->actor.projectedPos.z < D_80BB8458[i + 1]->actor.projectedPos.z) { + SWAP(EnTanron2*, D_80BB8458[i], D_80BB8458[i + 1]); + } + } + } + } + + for (i = 0; i < ARRAY_COUNT(D_80BB8458); i++) { + if (D_80BB8458[i] != NULL) { + Matrix_InsertTranslation(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, + D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_0034C8); + } + } + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 150); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004510); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (tanron2 != NULL) { + if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0)) { + Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight, tanron2->world.pos.z, + MTXMODE_NEW); + Matrix_Scale(0.6f, 0.0f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_004550); + } + tanron2 = tanron2->next; + } + + func_8012C974(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + + tanron2 = globalCtx->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (tanron2 != NULL) { + if ((tanron2->params < 100) && (((EnTanron2*)tanron2)->unk_15B != 0) && + (tanron2->world.pos.y <= tanron2->floorHeight)) { + Matrix_InsertTranslation(tanron2->world.pos.x, D_80BB8450->actor.floorHeight + 2.0f, tanron2->world.pos.z, + MTXMODE_NEW); + Matrix_Scale(D_80BB8454, 0.0f, D_80BB8454, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_0377B0); + } + tanron2 = tanron2->next; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h index 5e9512c7c..755bb4ff4 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h @@ -10,7 +10,22 @@ typedef void (*EnTanron2ActionFunc)(struct EnTanron2*, GlobalContext*); typedef struct EnTanron2 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTanron2ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xB4]; + /* 0x0148 */ s16 unk_148; + /* 0x014A */ s16 unk_14A; + /* 0x014C */ s16 unk_14C; + /* 0x014E */ s16 unk_14E; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ s16 unk_152; + /* 0x0154 */ s16 unk_154; + /* 0x0156 */ s16 unk_156; + /* 0x0158 */ u8 unk_158; + /* 0x0159 */ u8 unk_159; + /* 0x015A */ u8 unk_15A; + /* 0x015B */ u8 unk_15B; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ ColliderCylinder collider1; + /* 0x01B0 */ ColliderCylinder collider2; } EnTanron2; // size = 0x1FC extern const ActorInit En_Tanron2_InitVars; 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 ba49ab93e..15d307326 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Boss_03/z_boss_03.h" #include "objects/object_boss03/object_boss03.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron3*)thisx) @@ -86,12 +86,12 @@ static ColliderCylinderInit sUnusedCylinderInit = { }; void EnTanron3_CreateEffect(GlobalContext* globalCtx, Vec3f* effectPos) { - UnkTanron3Effect* effectPtr = (UnkTanron3Effect*)globalCtx->specialEffects; + GyorgEffect* effectPtr = globalCtx->specialEffects; s16 i; - for (i = 0; i < 150; i++, effectPtr++) { - if ((effectPtr->type == 0) || (effectPtr->type == 1)) { - effectPtr->type = 2; + for (i = 0; i < GYORG_EFFECT_COUNT; i++, effectPtr++) { + if ((effectPtr->type == GYORG_EFFECT_NONE) || (effectPtr->type == GYORG_EFFECT_BUBBLE)) { + effectPtr->type = GYORG_EFFECT_DROPLET; effectPtr->pos = *effectPos; effectPtr->velocity = *sZeroVec; effectPtr->accel = *sZeroVec; @@ -117,14 +117,14 @@ void EnTanron3_Init(Actor* thisx, GlobalContext* globalCtx) { this->morphTable, GYORG_SMALL_FISH_LIMB_MAX); Actor_SetScale(&this->actor, 0.02f); EnTanron3_SetupLive(this, globalCtx); - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->currentRotationAngle = Rand_ZeroFloat(500000.0f); this->waterSurfaceYPos = 430.0f; sGyorg = (Boss03*)this->actor.parent; } void EnTanron3_Destroy(Actor* thisx, GlobalContext* globalCtx) { - sGyorg->unk_252--; + sGyorg->numSpawnedSmallFish--; } void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h index 9d67154df..5f984e2ef 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.h @@ -10,17 +10,6 @@ typedef void (*EnTanron3ActionFunc)(struct EnTanron3*, GlobalContext*); #define TANRON3_WORK_TIMER_MAX 3 -typedef struct { - /* 0x00 */ u8 type; - /* 0x02 */ s16 unk_02; - /* 0x04 */ Vec3f pos; - /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f accel; - /* 0x28 */ char unk_28[0xC]; - /* 0x34 */ Vec3f unk_34; - /* 0x40 */ char unk_40[0x4]; -} UnkTanron3Effect; - typedef struct EnTanron3 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; 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 45330247d..969a87cf6 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.c @@ -1,12 +1,12 @@ /* * File: z_en_tanron4.c * Overlay: ovl_En_Tanron4 - * Description: Flock of Seagulls + * Description: Seagull */ #include "z_en_tanron4.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnTanron4*)thisx) @@ -15,7 +15,22 @@ void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnTanron4_SetupFlyNearHome(EnTanron4* this); +void EnTanron4_SetupFlyNearActor(EnTanron4* this); + +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx); +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx); + +typedef enum { + /* 0 */ SEAGULL_FLY_FLAP, + /* 1 */ SEAGULL_FLY_GLIDE, +} SeagullFlyState; + +typedef enum { + /* 0 */ SEAGULL_TIMER_FLY_STATE, + /* 1 */ SEAGULL_TIMER_CHOOSE_TARGET, +} SeagullTimers; + const ActorInit En_Tanron4_InitVars = { ACTOR_EN_TANRON4, ACTORCAT_ITEMACTION, @@ -28,22 +43,241 @@ const ActorInit En_Tanron4_InitVars = { (ActorFunc)EnTanron4_Draw, }; -#endif +void EnTanron4_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron4* this = THIS; -extern UNK_TYPE D_06000168; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gSeagullSkel, &gSeagullFlapAnim, this->jointTable, + this->morphTable, OBJECT_TANRON4_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Init.s") + thisx->flags &= ~ACTOR_FLAG_1; + thisx->speedXZ = 3.0f + KREG(48); + thisx->uncullZoneForward = 10000.0f + KREG(70); + this->randRollTimer = Rand_ZeroFloat(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Destroy.s") + if (thisx->params == SEAGULL_FOLLOW_ACTOR) { + EnTanron4_SetupFlyNearActor(this); + } else { + EnTanron4_SetupFlyNearHome(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DC0.s") + // spawn number of seagulls specified by params + if (thisx->params >= 0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE3DFC.s") + for (i = 0; i < thisx->params; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON4, + thisx->world.pos.x + randPlusMinusPoint5Scaled(500.0f), + thisx->world.pos.y + randPlusMinusPoint5Scaled(100.0f), + thisx->world.pos.z + randPlusMinusPoint5Scaled(500.0f), 0, Rand_ZeroFloat(65536.0f), 0, + SEAGULL_CLONE); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE4268.s") + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { + this->timeInfluence = 1500.0f; + thisx->world.pos.y += 1500.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/func_80BE42A4.s") +void EnTanron4_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Update.s") +void EnTanron4_SetupFlyNearHome(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearHome; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron4/EnTanron4_Draw.s") +void EnTanron4_FlyNearHome(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + + // `timeInfluence` controls both the height of the seagulls and when they are visible. + // They fly higher in the sky as the night goes on, and they disapear as dawn approaches. + if ((gSaveContext.save.time > CLOCK_TIME(20, 0)) || (gSaveContext.save.time < CLOCK_TIME(4, 0))) { + Math_ApproachF(&this->timeInfluence, 1500.0f, 1.0f, 1.0f); + } else { + Math_ApproachZeroF(&this->timeInfluence, 1.0f, 1.0f); + } + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = (this->targetPos.y + this->timeInfluence) - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = this->actor.home.pos.x + randPlusMinusPoint5Scaled(500.0f); + this->targetPos.y = this->actor.home.pos.y + randPlusMinusPoint5Scaled(100.0f); + this->targetPos.z = this->actor.home.pos.z + randPlusMinusPoint5Scaled(500.0f); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_SetupFlyNearActor(EnTanron4* this) { + this->actionFunc = EnTanron4_FlyNearActor; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, 0.0f); +} + +void EnTanron4_FlyNearActor(EnTanron4* this, GlobalContext* globalCtx) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 distToTarget; + s16 xRot; + s16 yRot; + s16 zRot; + Actor* targetActor = this->actor.parent; + + xDiff = this->targetPos.x - this->actor.world.pos.x; + yDiff = this->targetPos.y - this->actor.world.pos.y; + zDiff = this->targetPos.z - this->actor.world.pos.z; + + distToTarget = sqrtf(SQ(xDiff) + SQ(zDiff)); + + if ((this->timers[SEAGULL_TIMER_CHOOSE_TARGET] == 0) || (distToTarget < 100.0f)) { + this->targetPos.x = targetActor->world.pos.x + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + this->targetPos.y = targetActor->world.pos.y + KREG(80) + 100.0f + randPlusMinusPoint5Scaled(100.0f + KREG(81)); + this->targetPos.z = targetActor->world.pos.z + randPlusMinusPoint5Scaled(200.0f + KREG(82)); + + this->timers[SEAGULL_TIMER_CHOOSE_TARGET] = Rand_ZeroFloat(100.0f) + 60.0f; + this->step = 0; + } + + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, distToTarget); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + SkelAnime_Update(&this->skelAnime); + + switch (this->flyState) { + case SEAGULL_FLY_FLAP: + if ((this->timers[SEAGULL_TIMER_FLY_STATE] == 0) && + (Animation_OnFrame(&this->skelAnime, 2.0f + KREG(42)))) { + this->flyState = SEAGULL_FLY_GLIDE; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 50.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -15.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + this->skelAnime.playSpeed = 0.0f; + } + break; + + case SEAGULL_FLY_GLIDE: + if (((this->randRollTimer % 8) == 0) && (Rand_ZeroOne() < 0.5f)) { + this->rollTarget = randPlusMinusPoint5Scaled(3000.0f + KREG(44)); + } + + if (this->timers[SEAGULL_TIMER_FLY_STATE] == 0) { + this->flyState = SEAGULL_FLY_FLAP; + this->timers[SEAGULL_TIMER_FLY_STATE] = Rand_ZeroFloat(50.0f) + 70.0f; + Animation_MorphToLoop(&this->skelAnime, &gSeagullFlapAnim, -10.0f + KREG(43)); + this->skelAnime.curFrame = 2.0f + KREG(42); + } + break; + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + + Math_ApproachS(&this->roll, this->rollTarget, 3, 0x3E8 + KREG(45)); +} + +void EnTanron4_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + Actor_SetScale(&this->actor, 0.001f * KREG(16) + 0.01f); + + if (KREG(63) == 0) { + s32 i; + + this->randRollTimer++; + + for (i = 0; i < ARRAY_COUNT(this->timers); i++) { + if (this->timers[i] != 0) { + this->timers[i]--; + } + } + + this->actionFunc(this, globalCtx); + + Actor_UpdateVelocityWithoutGravity(&this->actor); + Actor_UpdatePos(&this->actor); + } +} + +void EnTanron4_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron4* this = THIS; + + if (this->timeInfluence < 1400.0f) { + Matrix_InsertZRotation_s(this->roll, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, NULL, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h index abbcc6633..250a62cf1 100644 --- a/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h +++ b/src/overlays/actors/ovl_En_Tanron4/z_en_tanron4.h @@ -2,17 +2,32 @@ #define Z_EN_TANRON4_H #include "global.h" +#include "assets/objects/object_tanron4/object_tanron4.h" struct EnTanron4; typedef void (*EnTanron4ActionFunc)(struct EnTanron4*, GlobalContext*); typedef struct EnTanron4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xE8]; + /* 0x000 */ Actor actor; + /* 0x144 */ s16 randRollTimer; + /* 0x146 */ s16 timers[2]; + /* 0x14A */ u8 flyState; + /* 0x14C */ Vec3f targetPos; + /* 0x158 */ s16 step; + /* 0x15A */ s16 roll; + /* 0x15C */ s16 rollTarget; + /* 0x160 */ f32 timeInfluence; + /* 0x164 */ SkelAnime skelAnime; + /* 0x1A8 */ Vec3s jointTable[OBJECT_TANRON4_LIMB_MAX]; + /* 0x1EA */ Vec3s morphTable[OBJECT_TANRON4_LIMB_MAX]; /* 0x022C */ EnTanron4ActionFunc actionFunc; } EnTanron4; // size = 0x230 +// other than these magic values, params is the number of desired seagulls in the flock +#define SEAGULL_CLONE -1 +#define SEAGULL_FOLLOW_ACTOR 100 + extern const ActorInit En_Tanron4_InitVars; #endif // Z_EN_TANRON4_H 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 f79aea937..ada39da61 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -5,8 +5,11 @@ */ #include "z_en_tanron5.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_boss02/object_boss02.h" +#include "overlays/actors/ovl_Boss_02/z_boss_02.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTanron5*)thisx) @@ -15,7 +18,11 @@ void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx); void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx); +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx); + +s32 D_80BE5D80 = 0; + const ActorInit En_Tanron5_InitVars = { ACTOR_EN_TANRON5, ACTORCAT_BOSS, @@ -28,32 +35,493 @@ const ActorInit En_Tanron5_InitVars = { (ActorFunc)EnTanron5_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE5DA4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ALL, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ALL, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY | AC_TYPE_OTHER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 70, 450, 0, { 0, 0, 0 } }, }; -#endif +f32 D_80BE5DD0 = 1.0f; -extern ColliderCylinderInit D_80BE5DA4; +Vec2s D_80BE5DD4[] = { + { 0x4B0, 0x9C4 }, { -0x4B0, 0x9C4 }, { 0x4B0, -0x9C4 }, { -0x4B0, -0x9C4 }, { 0x9C4, 0x4B0 }, + { -0x9C4, 0x4B0 }, { 0x9C4, -0x4B0 }, { -0x9C4, -0x4B0 }, { 0x3E8, 0x3E8 }, { -0x3E8, 0x3E8 }, + { 0x3E8, -0x3E8 }, { -0x3E8, -0x3E8 }, { 0x000, -0x3E8 }, { 0x000, 0x3E8 }, { 0x3E8, 0x000 }, + { -0x3E8, 0x000 }, { 0x000, -0x7D0 }, { 0x000, 0x7D0 }, { 0x7D0, 0x000 }, { -0x7D0, 0x000 }, +}; -extern UNK_TYPE D_06007A88; -extern UNK_TYPE D_06007D18; +Gfx* D_80BE5E24[] = { + object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, + object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, + object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, object_boss02_DL_007D18, + object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, + object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, object_boss02_DL_006FD0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4930.s") +f32 D_80BE5E74[] = { + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, + 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, 0.09f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE4A2C.s") +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ u8 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ UNK_TYPE1 unk28[0x4]; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ UNK_TYPE1 unk2E[0x6]; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} EnTanron5Effect; // size = 0x3C -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Init.s") +void func_80BE4930(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Destroy.s") + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Update.s") + effect->unk_00 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5818.s") + effect->unk_0C = randPlusMinusPoint5Scaled(10.0f); + effect->unk_10 = Rand_ZeroFloat(2.0f) + 3.0f; + effect->unk_14 = randPlusMinusPoint5Scaled(10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/EnTanron5_Draw.s") + effect->unk_18.y = -0.15f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tanron5/func_80BE5C10.s") + effect->unk_2C = Rand_ZeroFloat(100.0f) + 200.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void func_80BE4A2C(EnTanron5Effect* effect, Vec3f* arg1, f32 arg2) { + s16 i; + + for (i = 0; i < 150; i++, effect++) { + if (effect->unk_24 == 0) { + effect->unk_24 = 2; + + effect->unk_00 = *arg1; + + effect->unk_0C = randPlusMinusPoint5Scaled(30.0f); + effect->unk_10 = Rand_ZeroFloat(7.0f); + effect->unk_14 = randPlusMinusPoint5Scaled(30.0f); + + effect->unk_18.y = -0.3f; + effect->unk_18.x = 0.0f; + effect->unk_18.z = 0.0f; + + effect->unk_2C = Rand_ZeroFloat(70.0f) + 150.0f; + effect->unk_26 = 0; + effect->unk_34 = arg2; + effect->unk_38 = 2.0f * arg2; + break; + } + } +} + +void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80++; + if (D_80BE5D80 > 60) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->unk_198 = randPlusMinusPoint5Scaled(0x2000); + this->unk_19A = randPlusMinusPoint5Scaled(0x2000); + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_107) { + Actor_SetScale(&this->actor, (Rand_ZeroFloat(0.025f) + 0.085f) * D_80BE5DD0); + } else { + 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.velocity.y = (Rand_ZeroFloat(10.0f) + 15.0f) * D_80BE5DD0; + this->actor.gravity = -2.5f * D_80BE5DD0; + this->actor.terminalVelocity = -1000.0f * D_80BE5DD0; + this->actor.update = func_80BE5818; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + this->actor.draw = func_80BE5C10; + this->unk_1A0 = Rand_ZeroFloat(1.999f); + Actor_SetScale(&this->actor, D_80BE5DD0 * 0.03f); + this->unk_144 = 250; + this->actor.shape.rot.x = this->actor.shape.rot.y = this->actor.shape.rot.z = 0; + } else { + this->unk_148 = object_boss02_DL_007A88; + this->unk_144 = 150; + } + } else if (ENTANRON5_GET(&this->actor) == ENTANRON5_0) { + EnTanron5* child; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80BE5E74); i++) { + child = + (EnTanron5*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, D_80BE5DD4[i].x, + this->actor.world.pos.y, D_80BE5DD4[i].z, 0, Rand_ZeroFloat(0x10000), 0, i + 1); + + child->actor.parent = this->actor.parent; + child->unk_19C = D_80BE5E74[i]; + + Actor_SetScale(&child->actor, child->unk_19C); + + child->unk_148 = D_80BE5E24[i]; + if (child->unk_148 == object_boss02_DL_006FD0) { + child->actor.shape.rot.y = 0; + } + + Collider_InitAndSetCylinder(globalCtx, &child->collider, &child->actor, &sCylinderInit); + } + + Actor_MarkForDeath(&this->actor); + } else { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + this->actor.world.pos.y = this->actor.floorHeight + -20.0f; + } +} + +void EnTanron5_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_100) { + D_80BE5D80--; + } +} + +void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTanron5* this = THIS; + Boss02* boss02 = (Boss02*)this->actor.parent; + Player* player = GET_PLAYER(globalCtx2); + s32 i; + s32 phi_v0; + s32 spC4; + Vec3f spB8; + + if (this->unk_1A0 >= 3) { + this->unk_1A0++; + Actor_SetScale(&this->actor, 0.0f); + if (this->unk_1A0 >= 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } else { + // required + } + + if (this->unk_144 != 0) { + this->unk_144--; + } + + if (boss02->actor.update != NULL) { + D_80BE5DD0 = boss02->unk_01AC; + } else { + D_80BE5DD0 = 1.0f; + } + + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + + if (this->unk_148 == object_boss02_DL_007D18) { + this->collider.dim.radius = 65.0f * D_80BE5DD0; + this->collider.dim.height = 380.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 0) { + this->collider.dim.radius = 85.0f * D_80BE5DD0; + this->collider.dim.height = 200.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 1) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 100.0f * D_80BE5DD0; + } else if (this->unk_1A0 == 2) { + this->collider.dim.radius = 95.0f * D_80BE5DD0; + this->collider.dim.height = 30.0f * D_80BE5DD0; + } + + if (this->unk_144 == 0) { + if (this->collider.base.acFlags & AC_HIT) { + ColliderInfo* acHitInfo = this->collider.info.acHitInfo; + Actor* ac = this->collider.base.ac; + + this->collider.base.acFlags &= ~AC_HIT; + spC4 = 10; + + if (Play_InCsMode(globalCtx)) { + this->unk_144 = 1; + } else { + this->unk_144 = 5; + spC4 = (s32)Rand_ZeroFloat(2.99f) + 10; + } + + if ((KREG(19) != 0) || ((acHitInfo->toucher.dmgFlags & 0x05000202) && (D_80BE5DD0 < 0.5f)) || + (ac->id == ACTOR_BOSS_02)) { + if (this->unk_148 == object_boss02_DL_007D18) { + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + spB8.y += D_80BE5DD0 * 300.0f; + + for (i = 3; i < spC4; i++) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, spB8.x, spB8.y, spB8.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + } + + for (i = 0; i < 6; i++) { + func_80BE4A2C(globalCtx->specialEffects, &spB8, Rand_ZeroFloat(3.0f) + 6.0f); + } + + this->actor.world.pos.y -= D_80BE5DD0 * 130.0f; + } else { + f32 spAC; + f32 spA8; + Vec3f sp9C; + + if (this->unk_1A0 == 0) { + spAC = 180.0f; + this->unk_19C *= 1.4f; + } else if (this->unk_1A0 == 1) { + spAC = 230.0f; + this->unk_19C *= 1.37f; + } else if (this->unk_1A0 == 2) { + spAC = 780.0f; + this->unk_19C *= 1.5f; + } + + this->actor.world.pos.y -= D_80BE5DD0 * spAC; + Actor_SetScale(&this->actor, this->unk_19C * D_80BE5DD0); + Math_Vec3f_Copy(&spB8, &this->actor.world.pos); + + for (i = 0; i < spC4; i++) { + if (this->unk_1A0 == 0) { + spA8 = 100.0f; + spAC = 180.0f; + } else if (this->unk_1A0 == 1) { + spA8 = 200.0f; + spAC = 100.0f; + } else if (this->unk_1A0 == 2) { + spA8 = 250.0f; + spAC = 50.0f; + } + + sp9C.x = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.x; + sp9C.z = (randPlusMinusPoint5Scaled(spA8) * D_80BE5DD0) + spB8.z; + sp9C.y = this->actor.floorHeight + (spAC * D_80BE5DD0); + + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_TANRON5, sp9C.x, sp9C.y, sp9C.z, + Rand_ZeroFloat(0x10000), Rand_ZeroFloat(0x10000), 0, i + 100); + + if (i < 8) { + func_80BE4A2C(globalCtx->specialEffects, &sp9C, Rand_ZeroFloat(3.0f) + 6.0f); + } + } + } + + if (Rand_ZeroOne() < 0.333f) { + phi_v0 = 0x4000; + } else if (Rand_ZeroOne() < 0.5f) { + phi_v0 = -0x8000; + } else { + phi_v0 = -0x4000; + } + + this->actor.shape.rot.y += phi_v0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BIG_BOMB_EXPLOSION); + func_800BC848(&this->actor, globalCtx, 4, 4); + this->unk_1A0++; + } else { + Vec3f sp90; + ColliderInfo* info = this->collider.info.acHitInfo; + + sp90.x = info->bumper.hitPos.x; + sp90.y = info->bumper.hitPos.y; + sp90.z = info->bumper.hitPos.z; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_REFLECT_SW); + CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp90); + } + } + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->unk_148 == object_boss02_DL_006FD0) { + this->collider.dim.pos.y = this->actor.floorHeight; + } + + if ((this->unk_148 == object_boss02_DL_007D18) || (D_80BE5DD0 < 0.5f)) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } else { + f32 xDiff = player->actor.world.pos.x - this->actor.world.pos.x; + f32 yDiff = player->actor.world.pos.z - this->actor.world.pos.z; + + if ((fabsf(xDiff) < 120.0f) && (fabsf(yDiff) < 120.0f)) { + if (fabsf(yDiff) < fabsf(xDiff)) { + if (xDiff > 0.0f) { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x + 120.0f; + } else { + player->actor.prevPos.x = player->actor.world.pos.x = this->actor.world.pos.x - 120.0f; + } + } else if (yDiff > 0.0f) { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z + 120.0f; + } else { + player->actor.prevPos.z = player->actor.world.pos.z = this->actor.world.pos.z - 120.0f; + } + } + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_80BE5818(Actor* thisx, GlobalContext* globalCtx2) { + f32 sp6C; + s32 i; + Vec3f sp5C; + EnTanron5* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + if ((ENTANRON5_GET(&this->actor) < ENTANRON5_110) && (this->unk_1A0 != 0)) { + this->unk_1A0++; + this->actor.world.pos.y -= 2.0f * D_80BE5DD0; + if (this->unk_1A0 == 40) { + Actor_MarkForDeath(&this->actor); + } + return; + } + + if (DECR(this->unk_144) == 0) { + Actor_MarkForDeath(&this->actor); + } + + if (this->actor.speedXZ > 0.02f) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 150.0f, 100.0f, 4); + } + + if (ENTANRON5_GET(&this->actor) < ENTANRON5_110) { + this->actor.shape.rot.x += this->unk_198; + this->actor.shape.rot.y += this->unk_19A; + sp6C = 1225.0f; + + if (this->actor.bgCheckFlags & 1) { + if (ENTANRON5_GET(&this->actor) < ENTANRON5_108) { + Math_Vec3f_Copy(&sp5C, &this->actor.world.pos); + sp5C.y = this->actor.floorHeight; + + for (i = 0; i < 4; i++) { + func_80BE4930(globalCtx->specialEffects, &sp5C, Rand_ZeroFloat(1.0f) + 2.0f); + } + this->unk_1A0++; + } else { + Actor_MarkForDeath(&this->actor); + } + } + } else { + sp6C = 400.0f; + this->unk_198 += 0x2000; + if (this->actor.bgCheckFlags & 1) { + this->unk_198 = 0; + this->actor.speedXZ = 0.0f; + } + } + + if (this->unk_1A1 == 0) { + if ((D_80BE5DD0 > 0.5f) && + ((ENTANRON5_GET(&this->actor) < ENTANRON5_108) || (ENTANRON5_GET(&this->actor) >= ENTANRON5_110))) { + Player* player = GET_PLAYER(globalCtx); + Vec3f temp; + + temp.x = player->actor.world.pos.x - this->actor.world.pos.x; + temp.y = (player->actor.world.pos.y + 10.0f) - this->actor.world.pos.y; + temp.z = player->actor.world.pos.z - this->actor.world.pos.z; + + if (SQXYZ(temp) < sp6C) { + if (ENTANRON5_GET(&this->actor) >= ENTANRON5_110) { + if (this->unk_1A0 == 0) { + Item_Give(globalCtx, ITEM_ARROWS_10); + } else { + Item_Give(globalCtx, ITEM_MAGIC_LARGE); + } + Actor_MarkForDeath(&this->actor); + play_sound(NA_SE_SY_GET_ITEM); + } else { + this->unk_1A1 = 20; + func_800B8D50(globalCtx, NULL, 5.0f, this->actor.world.rot.y, 0.0f, 8); + } + } + } + } else { + this->unk_1A1--; + } +} + +void EnTanron5_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + + if ((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->unk_148); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { + EnTanron5* this = THIS; + TexturePtr texture; + s32 phi_v0; + + if ((this->unk_144 > 50) || (this->unk_144 & 1)) { + phi_v0 = true; + } else { + phi_v0 = false; + } + + if (((-500.0f * D_80BE5DD0) < this->actor.projectedPos.z) && phi_v0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_1A0 == 0) { + texture = gameplay_keep_Tex_05BEF0; + } else { + texture = gameplay_keep_Tex_0617C0; + } + + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(texture)); + + Matrix_InsertTranslation(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_198, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h index c19bb1ded..576309694 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h @@ -5,9 +5,24 @@ struct EnTanron5; +#define ENTANRON5_GET(thisx) ((thisx)->params) + +#define ENTANRON5_0 0 +#define ENTANRON5_100 100 +#define ENTANRON5_107 107 +#define ENTANRON5_108 108 +#define ENTANRON5_110 110 + typedef struct EnTanron5 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x0144 */ s16 unk_144; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ ColliderCylinder collider; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ u8 unk_1A0; + /* 0x01A1 */ u8 unk_1A1; } EnTanron5; // size = 0x1A4 extern const ActorInit En_Tanron5_InitVars; 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 c34d2e5b5..bb57ff92f 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -6,7 +6,7 @@ #include "z_en_tanron6.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnTanron6*)thisx) 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 2f13b6640..7f99833b4 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -5,8 +5,9 @@ */ #include "z_en_test.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTest*)thisx) @@ -15,7 +16,6 @@ void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test_InitVars = { ACTOR_EN_TEST, ACTORCAT_ITEMACTION, @@ -28,22 +28,247 @@ const ActorInit En_Test_InitVars = { (ActorFunc)EnTest_Draw, }; -#endif +void func_80862B70(EnTestStruct* arg0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862B70.s") + for (i = 0; i < 20; i++) { + EnTestStruct* ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862CBC.s") + ptr->unk_00 = false; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14.x = 0.0f; + ptr->unk_14.y = 0.0f; + ptr->unk_14.z = 0.0f; + ptr->unk_20.x = 0.0f; + ptr->unk_20.y = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_2C = 0.001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36.x = 0; + ptr->unk_36.y = 0; + ptr->unk_36.z = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80862EDC.s") +void func_80862CBC(EnTestStruct* arg0, Vec3f* arg1) { + EnTestStruct* ptr; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_80863048.s") + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Init.s") + if (!ptr->unk_00) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Destroy.s") + ptr->unk_00 = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Update.s") + ptr->unk_08.x = (Math_CosS(sp26) * 20.0f) + arg1->x; + ptr->unk_08.y = arg1->y; + ptr->unk_08.z = (Math_SinS(sp26) * 20.0f) + arg1->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/func_808634B8.s") + sp20 = Rand_ZeroOne(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test/EnTest_Draw.s") + ptr->unk_14.x = Math_CosS(sp26) * 13.0f * sp20; + ptr->unk_14.y = (Rand_ZeroOne() * 5.0f) + 8.0f; + ptr->unk_14.z = (Math_SinS(sp26) * 13.0f) * sp20; + + ptr->unk_20.x = 0.0f; + ptr->unk_20.z = 0.0f; + ptr->unk_20.y = -2.0f; + + ptr->unk_2C = (Rand_ZeroOne() * 0.0004f) + 0.0004f; + + ptr->unk_30.x = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.y = Rand_ZeroOne() * 0x7FFE; + ptr->unk_30.z = Rand_ZeroOne() * 0x7FFE; + + ptr->unk_36.x = Rand_ZeroOne() * 0x2000; + ptr->unk_36.y = Rand_ZeroOne() * 0x2000; + ptr->unk_36.z = Rand_ZeroOne() * 0x2000; + + ptr->unk_04 = 10; + break; + } + } +} + +void func_80862EDC(EnTestStruct* arg0) { + s32 i; + EnTestStruct* ptr; + + for (i = 0; i < 20; i++) { + ptr = &arg0[i]; + + if (ptr->unk_00) { + ptr->unk_04--; + if (ptr->unk_04 < 0) { + ptr->unk_00 = false; + } + + ptr->unk_08.x += ptr->unk_14.x; + ptr->unk_08.y += ptr->unk_14.y; + ptr->unk_08.z += ptr->unk_14.z; + + ptr->unk_14.x += ptr->unk_20.x; + ptr->unk_14.y += ptr->unk_20.y; + ptr->unk_14.z += ptr->unk_20.z; + + ptr->unk_30.x += ptr->unk_36.x; + ptr->unk_30.y += ptr->unk_36.y; + ptr->unk_30.z += ptr->unk_36.z; + } + } +} + +void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { + EnTestStruct* ptr; + s32 i; + Mtx* mtx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0; i < 20; i++) { + ptr = &arg1[i]; + + if (!ptr->unk_00) { + continue; + } + + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + + mtx = Matrix_NewMtx(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest* this = THIS; + MtxF sp38; + s32 sp34; + + this->unk_209 = 0; + this->unk_174 = 0; + + if (thisx->params > 0) { + Actor_SetScale(thisx, thisx->params / 100000.0f); + this->unk_20A = 0; + } else { + thisx->floorPoly = NULL; + thisx->world.pos.y += 10.0f; + thisx->floorHeight = + BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &thisx->floorPoly, &sp34, &thisx->world.pos); + + if ((thisx->floorPoly == NULL) || (thisx->floorHeight == BGCHECK_Y_MIN)) { + Actor_MarkForDeath(thisx); + return; + } + + thisx->world.pos.y = thisx->floorHeight; + func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); + func_8018219C(&sp38, &thisx->shape.rot, 1); + thisx->world.rot = thisx->shape.rot; + this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); + } + + func_80183430(&this->skeletonInfo, &gameplay_keep_Blob_06EB70, &gameplay_keep_Blob_06BB0C, this->unk_178, + this->unk_1C0, NULL); + func_801834A8(&this->skeletonInfo, &gameplay_keep_Blob_06BB0C); + this->skeletonInfo.frameCtrl.unk_10 = 9.0f; + func_80862B70(this->unk_20C); +} + +void EnTest_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + + func_8018349C(&this->skeletonInfo); +} + +void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + s32 i; + + this->unk_208 = this->skeletonInfo.frameCtrl.unk_10; + + if (func_80183DE0(&this->skeletonInfo) && (this->actor.parent == NULL) && (this->actor.params != -1)) { + this->unk_209++; + if (this->unk_209 > 20) { + Actor_MarkForDeath(&this->actor); + } + } + + if ((this->actor.params != -1) && (this->unk_208 >= 2)) { + if (!(this->unk_174 & 1)) { + this->unk_174 |= 1; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + func_80862CBC(this->unk_20C, &this->actor.world.pos); + } + } + } + func_80862EDC(this->unk_20C); +} + +s32 EnTest_OverrideKeyframeDraw(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, + u8* flags, Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((this->actor.params == -1) && ((limbIndex == 1) || (limbIndex == 2))) { + *dList = NULL; + } + + if ((this->actor.params == -2) && (limbIndex == 3)) { + *dList = NULL; + } + + if (limbIndex == 3) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, ((20 - this->unk_209) * 255.0f) / 20.0f); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + return true; +} + +void EnTest_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest* this = THIS; + Mtx* sp28; + s32 sp2C = this->unk_208 - 1; + + if (sp2C >= 29) { + sp2C = 29; + } + + if ((this->unk_20A == 15) || (this->unk_20A == 14)) { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B730), sp2C); + } else { + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); + } + + sp28 = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + + if (sp28 != NULL) { + func_8012C2DC(globalCtx->state.gfxCtx); + func_8018450C(globalCtx, &this->skeletonInfo, sp28, EnTest_OverrideKeyframeDraw, NULL, thisx); + func_80863048(globalCtx, this->unk_20C); + } +} 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 32015ecb1..bcb0c4a1e 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -5,9 +5,27 @@ struct EnTest; +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ Vec3s unk_30; + /* 0x36 */ Vec3s unk_36; +} EnTestStruct; // size = 0x3C + typedef struct EnTest { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x578]; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ s32 unk_174; + /* 0x178 */ Vec3s unk_178[12]; + /* 0x1C0 */ s16 unk_1C0[36]; + /* 0x208 */ u8 unk_208; + /* 0x209 */ u8 unk_209; + /* 0x20A */ u8 unk_20A; + /* 0x20C */ EnTestStruct unk_20C[20]; } EnTest; // size = 0x6BC extern const ActorInit En_Test_InitVars; 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 9beb86263..c16a4133d 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -6,7 +6,7 @@ #include "z_en_test2.h" -#define FLAGS 0x00000090 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80) #define THIS ((EnTest2*)thisx) 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 63d0cf954..ce9a8f3c9 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -6,7 +6,7 @@ #include "z_en_test3.h" -#define FLAGS 0x04000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) #define THIS ((EnTest3*)thisx) 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 a4afa9204..4606c4edb 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -8,7 +8,7 @@ #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" -#define FLAGS 0x00100030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000) #define THIS ((EnTest4*)thisx) @@ -369,7 +369,7 @@ void EnTest4_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((globalCtx->unk_18B4A == 0) && (func_801690CC(globalCtx) == 0) && (globalCtx->numSetupActors <= 0) && + if ((globalCtx->unk_18B4A == 0) && !Play_InCsMode(globalCtx) && (globalCtx->numSetupActors <= 0) && (globalCtx->roomCtx.unk31 == 0) && (func_8016A168() == 0)) { s16 temp_a2; u16 temp_a0 = D_80A43364[this->unk_144]; @@ -399,13 +399,13 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { func_80A41FA4(this, globalCtx); } else { gSaveContext.screenScale = 0.0f; - func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, - &player->unk_3C0, player->unk_3CC); - func_80169EFC(globalCtx); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_DOWN, Entrance_CreateIndexFromSpawn(0), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + func_80169EFC(&globalCtx->state); if (player->stateFlags1 & 0x800000) { EnHorse* rideActor = (EnHorse*)player->rideActor; - if ((rideActor->unk_150 == 0) || (rideActor->unk_150 == 2)) { + if ((rideActor->type == HORSE_EPONA) || (rideActor->type == HORSE_2)) { if (CURRENT_DAY < 3) { D_801BDA9C = 1; } else { @@ -440,16 +440,16 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { if ((this->nextBellTime == CLOCK_TIME(0, 0)) && ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (globalCtx->sceneNum == SCENE_CLOCKTOWER))) { - s32 phi_v0; + s32 playerParams; u32 entranceIndex = gSaveContext.save.entranceIndex; if ((globalCtx->actorCtx.unk5 & 2)) { - phi_v0 = 0xCFF; + playerParams = 0xCFF; } else { - phi_v0 = 0xBFF; + playerParams = 0xBFF; } - func_80169DCC(globalCtx, 1, entranceIndex, player->unk_3CE, phi_v0, &player->unk_3C0, - player->unk_3CC); + Play_SetRespawnData(&globalCtx->state, RESTART_MODE_RETURN, entranceIndex, player->unk_3CE, + playerParams, &player->unk_3C0, player->unk_3CC); if ((globalCtx->sceneNum == SCENE_TENMON_DAI) || (globalCtx->sceneNum == SCENE_00KEIKOKU)) { globalCtx->nextEntranceIndex = 0x5400; 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 81e92103b..4a93cf5e8 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -6,7 +6,7 @@ #include "z_en_test5.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTest5*)thisx) 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 04365b5dd..de1a18241 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -5,8 +5,9 @@ */ #include "z_en_test6.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02200030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) #define THIS ((EnTest6*)thisx) @@ -15,14 +16,31 @@ void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx); +struct EnTest6Struct; + +typedef void (*EnTest6StructFunc)(EnTest6*, GlobalContext*, struct EnTest6Struct*); + +typedef struct EnTest6Struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ EnTest6StructFunc unk_14; +} EnTest6Struct; // size = 0x18 + +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr); +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); void func_80A9156C(EnTest6* this, GlobalContext* globalCtx); +void func_80A91690(EnTest6* this, GlobalContext* globalCtx); void func_80A91760(EnTest6* this, GlobalContext* globalCtx); +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx); void func_80A92188(EnTest6* this, GlobalContext* globalCtx); void func_80A92950(EnTest6* this, GlobalContext* globalCtx); -void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc); +EnTest6Struct D_80A94910[12]; -#if 0 const ActorInit En_Test6_InitVars = { ACTOR_EN_TEST6, ACTORCAT_ITEMACTION, @@ -35,50 +53,1268 @@ const ActorInit En_Test6_InitVars = { (ActorFunc)EnTest6_Draw, }; -#endif +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, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90730.s") +TexturePtr D_80A9402C[] = { + NULL, + gameplay_keep_Tex_05B6F0, + gameplay_keep_Tex_05CEF0, + gameplay_keep_Tex_0607C0, + gameplay_keep_Tex_060FC0, + gameplay_keep_Tex_061FC0, + gameplay_keep_Tex_061FE0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C08.s") +Color_RGB8 D_80A94048 = { 230, 230, 220 }; +Color_RGB8 D_80A9404C = { 120, 120, 100 }; +Color_RGB8 D_80A94050 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C34.s") +s16 D_80A94054 = 500; +s16 D_80A94058 = 1500; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90C54.s") +Vec3f D_80A9405C = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D20.s") +Color_RGB8 D_80A94068 = { 225, 230, 225 }; +Color_RGB8 D_80A9406C = { 120, 120, 100 }; +Color_RGB8 D_80A94070 = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90D34.s") +s16 D_80A94074 = 940; +s16 D_80A94078 = 2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A90FC0.s") +void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 phi_s0; + f32 phi_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_SetupAction.s") + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Init.s") + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + func_80A91690(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Destroy.s") + case ENTEST6_26: + func_80A920C8(this, globalCtx); + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9156C.s") + phi_s0 = 0; + phi_f24 = -900.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91690.s") + if (gSaveContext.eventInf[7] & 1) { + for (i = 0; i < 6; i++) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + } + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 6; + phi_s0 |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A916F0.s") + if (gSaveContext.eventInf[7] & 0x10) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; + } + phi_s0 |= 0x10; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A91760.s") + if (gSaveContext.eventInf[7] & 2) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + if (!(phi_s0 & 1)) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; + } + phi_s0 |= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A920C8.s") + if (gSaveContext.eventInf[7] & 4) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; + } + phi_s0 |= 4; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92118.s") + if (gSaveContext.eventInf[7] & 8) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { + D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92188.s") + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_10 = ((2.0f * Rand_ZeroOne()) - 1.0f) * 80.0f; + D_80A94910[i].unk_0C = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + phi_f24; + D_80A94910[i].unk_04 = -10.0f; + if (D_80A94910[i].unk_00 < 5) { + D_80A94910[i].unk_14 = func_80A90D34; + } else { + D_80A94910[i].unk_14 = func_80A90FC0; + } + phi_f24 += 50.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Update.s") +void func_80A90C08(s16 arg0) { + func_8016566C(arg0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A92950.s") +void func_80A90C34(void) { + func_80165690(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A93298.s") +void func_80A90C54(GlobalContext* globalCtx, f32 arg1) { + globalCtx->envCtx.fillScreen = 1; + globalCtx->envCtx.screenFillColor[0] = 250; + globalCtx->envCtx.screenFillColor[1] = 250; + globalCtx->envCtx.screenFillColor[2] = 250; + globalCtx->envCtx.screenFillColor[3] = 255.0f * arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A9369C.s") +void func_80A90D20(GlobalContext* globalCtx) { + globalCtx->envCtx.fillScreen = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/func_80A939E8.s") +void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test6/EnTest6_Draw.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (ptr->unk_00 != 0) { + Matrix_InsertTranslation(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(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + } + + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(globalCtx->state.frames * 512, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 210, 210, 230, 128); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) { + s32 pad; + Gfx* gfx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 2); + Gfx* gfx2 = gfx; + Hilite* sp70; + Vec3f sp64; + + sp64.x = ptr->unk_08 * ptr->unk_04; + sp64.y = ptr->unk_0C; + sp64.z = ptr->unk_10 * ptr->unk_04; + + sp70 = func_800BCBF4(&sp64, globalCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (gfx != NULL) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetTileSize(gfx++, 1, sp70->h.x1 & 0xFFFF, sp70->h.y1 & 0xFFFF, (sp70->h.x1 + 60) & 0xFFFF, + (sp70->h.y1 + 60) & 0xFFFF); + gSPEndDisplayList(gfx); + + gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); + + Matrix_InsertTranslation(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A9402C[ptr->unk_00])); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + } + + Matrix_InsertTranslation(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(globalCtx->state.frames * 256, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, 4.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 220, 220, 230, 192); + gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 0); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054A90); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_SetupAction(EnTest6* this, EnTest6ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} + +void EnTest6_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + if (((ENTEST6_GET(&this->actor) == ENTEST6_24) || (ENTEST6_GET(&this->actor) == ENTEST6_25) || + (ENTEST6_GET(&this->actor) == ENTEST6_26)) && + (globalCtx->playerActorCsIds[8] == -1)) { + Actor_MarkForDeath(&this->actor); + return; + } + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + Lights_PointNoGlowSetInfo(&this->lights[i].info, this->actor.world.pos.x, (s32)this->actor.world.pos.y - 20, + this->actor.world.pos.z, 255, 255, 180, -1); + this->lights[i].node = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lights[i].info); + } + + this->unk_286 = 0; + this->unk_274 = 0; + this->unk_278 = 0; + this->unk_276 = 99; + func_80A90730(this, globalCtx); + EnTest6_SetupAction(this, func_80A9156C); +} + +void EnTest6_Destroy(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest6* this = THIS; + s32 i; + + globalCtx->envCtx.lightSettings.ambientColor[0] = 0; + globalCtx->envCtx.lightSettings.ambientColor[1] = 0; + globalCtx->envCtx.lightSettings.ambientColor[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[0] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[1] = 0; + globalCtx->envCtx.lightSettings.diffuseColor2[2] = 0; + globalCtx->envCtx.lightSettings.fogColor[0] = 0; + globalCtx->envCtx.lightSettings.fogColor[1] = 0; + globalCtx->envCtx.lightSettings.fogColor[2] = 0; + globalCtx->envCtx.lightSettings.fogNear = 0; + globalCtx->envCtx.lightSettings.fogFar = 0; + globalCtx->envCtx.fillScreen = 0; + + for (i = 0; i < ARRAY_COUNT(this->lights); i++) { + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lights[i].node); + } +} + +void func_80A9156C(EnTest6* this, GlobalContext* globalCtx) { + switch (ENTEST6_GET(&this->actor)) { + case ENTEST6_24: + case ENTEST6_25: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A91760); + } + break; + + case ENTEST6_26: + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + this->unk_284 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + EnTest6_SetupAction(this, func_80A92188); + } + break; + + default: + gSaveContext.save.daysElapsed = 0; + gSaveContext.save.day = false; + gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; + EnTest6_SetupAction(this, func_80A92950); + break; + } +} + +void func_80A91690(EnTest6* this, GlobalContext* globalCtx) { + this->unk_274 = 90; + this->unk_27A = 100; + this->unk_286 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + play_sound(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + play_sound(NA_SE_SY_TIME_CONTROL_NORMAL); + } +} + +void func_80A916F0(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + s16 temp_s0; + Player* player = GET_PLAYER(globalCtx); + Camera* sp78; + Vec3f sp6C; + Vec3f sp60; + Vec3f sp54; + s32 i; + f32 sp4C; + Camera* temp_s3 = Play_GetCamera(globalCtx, this->unk_284); + + sp78 = Play_GetCamera(globalCtx, CAM_ID_MAIN); + + switch (this->unk_274) { + 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; + break; + + case 91: + this->unk_15C += this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + + if (this->unk_27A == 90) { + this->unk_282 = 0; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C = 0x200; + this->unk_150 = 0.0f; + sp4C = -100.0f; + } else { + this->unk_27C = 0x570; + this->unk_150 = 110.0f; + sp4C = 100.0f; + } + this->unk_14C = 1.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + this->unk_20C[i].x = player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = player->actor.world.pos.z; + } + + this->unk_254 = ZeldaArena_Malloc(sizeof(Vec3f) * 64); + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.x + + ((temp_s3->at.x - temp_s3->eye.x) * 0.2f); + (*this->unk_254)[i].y = (((2.0f * Rand_ZeroOne()) - 1.0f) * 120.0f) + temp_s3->eye.y + + ((temp_s3->at.y - temp_s3->eye.y) * 0.2f) + sp4C; + (*this->unk_254)[i].z = (((2.0f * Rand_ZeroOne()) - 1.0f) * 40.0f) + temp_s3->eye.z + + ((temp_s3->at.z - temp_s3->eye.z) * 0.2f); + } + } + func_80A90C08(0x78); + Distortion_SetType(0x20); + Distortion_SetCountdown(80); + globalCtx->unk_18844 = 1; + this->unk_274 = 95; + } + break; + + case 95: + if (this->unk_27A > 80) { + this->unk_282 += 25; + } + + if (this->unk_27A < 20) { + this->unk_282 -= 25; + } + + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054 + this->unk_282, D_80A94058 + this->unk_282, this->unk_15C); + + this->unk_278 -= this->unk_27C; + temp_s0 = this->unk_278; + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + this->unk_27C += 8; + this->unk_150 += this->unk_14C; + } else { + this->unk_27C -= 8; + this->unk_150 -= this->unk_14C; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + temp_s0 += 0x10000 / ARRAY_COUNT(this->unk_20C); + if (player) {} + this->unk_20C[i].x = (Math_SinS(temp_s0) * this->unk_150) + player->actor.world.pos.x; + this->unk_20C[i].y = player->actor.world.pos.y; + this->unk_20C[i].z = (Math_CosS(temp_s0) * this->unk_150) + player->actor.world.pos.z; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + (*this->unk_254)[i].x += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + (*this->unk_254)[i].y += 1.0f; + } else { + if (1) {} + (*this->unk_254)[i].y -= 1.0f; + } + (*this->unk_254)[i].z += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + } + } + + if (this->unk_27A == 10) { + this->unk_14C = 0.1f; + func_80A90C34(); + Distortion_ClearType(0x20); + globalCtx->unk_18844 = 0; + if (this->unk_254 != NULL) { + ZeldaArena_Free(this->unk_254); + } + this->unk_274 = 99; + } + break; + + case 99: + this->unk_15C -= this->unk_14C; + func_800FD59C(globalCtx, &D_80A9404C, this->unk_15C); + func_800FD5E0(globalCtx, &D_80A94050, this->unk_15C); + func_800FD654(globalCtx, &D_80A94048, this->unk_15C); + func_800FD698(globalCtx, D_80A94054, D_80A94058, this->unk_15C); + break; + } + + if (this->unk_286 != 0) { + func_800B7298(globalCtx, NULL, 7); + } else { + if (this->unk_27A == 90) { + func_800B7298(globalCtx, NULL, 0x42); + } + + if (this->unk_27A == 70) { + func_800B7298(globalCtx, NULL, 0x52); + } + + if (this->unk_27A == 30) { + func_800B7298(globalCtx, NULL, 0x51); + } + + if (this->unk_27A == 5) { + func_800B7298(globalCtx, NULL, 0x4A); + } + } + + if (this->unk_27A > 80) { + temp_s3->fov += (90.0f - temp_s3->fov) / (this->unk_27A - 80); + } else if (this->unk_27A > 60) { + sp4C = 1.0f / (this->unk_27A - 60); + + sp6C.x = temp_s3->at.x + ((player->actor.world.pos.x - temp_s3->at.x) * sp4C); + sp6C.y = temp_s3->at.y + (((player->actor.focus.pos.y - temp_s3->at.y) - 20.0f) * sp4C); + sp6C.z = temp_s3->at.z + ((player->actor.world.pos.z - temp_s3->at.z) * sp4C); + + sp54.x = (Math_SinS(player->actor.world.rot.y) * 80.0f) + sp6C.x; + sp54.y = sp6C.y + 20.0f; + sp54.z = (Math_CosS(player->actor.world.rot.y) * 80.0f) + sp6C.z; + sp4C *= 0.75f; + + VEC3F_LERPIMPDST(&sp60, &temp_s3->eye, &sp54, sp4C); + + Play_CameraSetAtEye(globalCtx, this->unk_284, &sp6C, &sp60); + } else if ((this->unk_27A < 11) && (this->unk_27A > 0)) { + temp_s3->fov += (sp78->fov - temp_s3->fov) / this->unk_27A; + } + + if (this->unk_286 != 0) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + temp_s3->fov += (sp78->fov - temp_s3->fov) * 0.05f; + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 1; + } + } else if ((this->unk_27A <= 60) && (this->unk_27A > 40) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + if (ENTEST6_GET(&this->actor) == ENTEST6_25) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_SLOW); + } else if (ENTEST6_GET(&this->actor) == ENTEST6_24) { + func_801A75E8(NA_SE_SY_TIME_CONTROL_NORMAL); + } + } + + if (DECR(this->unk_27A) == 0) { + func_80A916F0(this, globalCtx); + globalCtx->msgCtx.ocarinaMode = 4; + } +} + +void func_80A920C8(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_27A = 120; + this->unk_286 = 0; + this->unk_160 = 0.0f; + this->actor.home.pos = player->actor.world.pos; + this->actor.home.rot = player->actor.shape.rot; +} + +void func_80A92118(EnTest6* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.freezeTimer = 0; + globalCtx->unk_18844 = 0; + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + func_800B7298(globalCtx, NULL, 6); + func_80A90C34(); + Distortion_ClearType(0x20); + Actor_MarkForDeath(&this->actor); +} + +void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { + Input* input = CONTROLLER1(globalCtx); + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + s32 pad; + s16 sp46; + s16 sp44; + + if (this->unk_27A > 115) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A > 90) { + this->unk_160 -= 0.05f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A == 90) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } + + if (this->unk_27A == 1) { + this->unk_160 = 0.0f; + func_80A90D20(globalCtx); + } else if (this->unk_27A < 17) { + this->unk_160 -= 0.06666666f; + func_80A90C54(globalCtx, this->unk_160); + } else if (this->unk_27A < 22) { + this->unk_160 += 0.2f; + func_80A90C54(globalCtx, this->unk_160); + } + + if (this->unk_27A == 115) { + func_800FD59C(globalCtx, &D_80A9406C, 1.0f); + func_800FD5E0(globalCtx, &D_80A94070, 1.0f); + func_800FD654(globalCtx, &D_80A94068, 1.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 1.0f); + globalCtx->unk_18844 = 1; + } + + if (this->unk_27A == 15) { + func_800FD59C(globalCtx, &D_80A9406C, 0.0f); + func_800FD5E0(globalCtx, &D_80A94070, 0.0f); + func_800FD654(globalCtx, &D_80A94068, 0.0f); + func_800FD698(globalCtx, D_80A94074, D_80A94078, 0.0f); + globalCtx->unk_18844 = 0; + } + + if (this->unk_286 >= 20) { + func_800FD59C(globalCtx, &D_80A9406C, this->unk_160); + func_800FD5E0(globalCtx, &D_80A94070, this->unk_160); + func_800FD654(globalCtx, &D_80A94068, this->unk_160); + func_800FD698(globalCtx, D_80A94074, D_80A94078, this->unk_160); + globalCtx->unk_18844 = 0; + } + + func_800B8F98(&player->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); + + switch (this->unk_27A) { + case 119: + func_80A90C08(0x32); + break; + + case 115: + func_80A90C08(0x14); + Distortion_SetType(0x20); + Distortion_SetCountdown(90); + this->unk_274 = 2; + break; + + case 110: + func_801A3098(0x4A); + break; + + case 38: + case 114: + this->unk_274 = 1; + break; + + case 76: + this->unk_274 = 3; + break; + + case 61: + func_80A90C08(0x96); + this->unk_274 = 4; + break; + + case 51: + func_80A90C08(0xB4); + this->unk_274 = 5; + break; + + case 14: + case 15: + func_80A90C08(0x32); + Distortion_ClearType(0x20); + this->unk_274 = 0; + break; + + case 1: + func_80A90C34(); + if (gSaveContext.eventInf[5] & 4) { + this->unk_274 = 9; + } + break; + } + + func_80A92950(this, globalCtx); + + if (this->unk_27A == 115) { + sp44 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + camera = Play_GetCamera(globalCtx, sp44); + + this->unk_258 = camera->at; + this->unk_264 = camera->eye; + this->unk_270 = camera->fov; + func_8016119C(camera, &this->unk_18C); + } + + if ((this->unk_27A <= 115) && (this->unk_27A >= 16)) { + func_80161998(D_80A93E80, &this->unk_18C); + } else if (this->unk_27A < 16) { + sp46 = ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8]); + + Play_CameraSetAtEyeUp(globalCtx, sp46, &this->unk_258, &this->unk_264, &D_80A9405C); + Play_CameraSetFov(globalCtx, sp46, this->unk_270); + Play_CameraSetRoll(globalCtx, sp46, 0); + } + + switch (this->unk_27A) { + case 116: + player->actor.freezeTimer = 2; + player->actor.shape.rot.x = 0; + player->actor.shape.rot.y = 0; + player->actor.world.pos.x = 0.0f; + player->actor.world.pos.y = 0.0f; + player->actor.world.pos.z = 0.0f; + player->actor.home.pos.x = 0.0f; + player->actor.home.pos.y = 0.0f; + player->actor.home.pos.z = 0.0f; + break; + + case 98: + func_800B7298(globalCtx, NULL, 0x40); + break; + + case 68: + func_800B7298(globalCtx, NULL, 0x41); + break; + + case 52: + func_800B7298(globalCtx, NULL, 0x58); + break; + + case 43: + func_800B7298(globalCtx, NULL, 0x72); + break; + + case 38: + func_800B7298(globalCtx, NULL, 7); + break; + + case 14: + player->actor.freezeTimer = 5; + player->actor.world.pos = player->actor.home.pos = this->actor.home.pos; + player->actor.shape.rot = this->actor.home.rot; + player->actor.focus.rot.y = player->actor.shape.rot.y; + player->currentYaw = player->actor.shape.rot.y; + player->unk_ABC = 0.0f; + player->unk_AC0 = 0.0f; + player->actor.shape.yOffset = 0.0f; + break; + } + + if ((this->unk_286 > 0) && (this->unk_286 < 20)) { + func_80A90C54(globalCtx, this->unk_286 * 0.05f); + this->unk_286++; + if (this->unk_286 >= 20) { + this->unk_27A = 15; + this->unk_160 = 0.9333333f; + } + } else if ((this->unk_27A < 96) && (this->unk_27A > 50) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + this->unk_286 = 1; + this->unk_27A = 39; + Audio_QueueSeqCmd(0x111400FF); + } + + if (DECR(this->unk_27A) == 0) { + func_80A92118(this, globalCtx); + } +} + +void EnTest6_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_80A92950(EnTest6* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f0; + s32 i; + s32 temp_v0; + + if (Cutscene_CheckActorAction(globalCtx, 0x1F9)) { + temp_v0 = Cutscene_GetActorActionIndex(globalCtx, 0x1F9); + this->unk_274 = globalCtx->csCtx.actorActions[temp_v0]->action; + + switch (this->unk_274) { + case 1: + break; + + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 150.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 = globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 = 38; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 480.0f; + } + break; + + case 3: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + + } else { + this->unk_280 += 6; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 = -32.0f; + } + this->unk_150 += this->unk_158; + break; + + case 4: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 4; + } + break; + + case 5: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_280 += (s16)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_280 -= 8; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_158 += 20.0f; + } + + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_154 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_154 = 100.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.y != 0) { + this->unk_14C = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.y; + } else { + this->unk_14C = 20.0f; + } + + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.z != 0) { + this->unk_150 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.z; + } else { + this->unk_150 = 300.0f; + } + this->unk_158 = 0.0f; + break; + + case 7: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 = (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 = -5.0f; + } + this->unk_154 += this->unk_158; + break; + + case 8: + if (globalCtx->csCtx.actorActions[temp_v0]->startPos.x != 0) { + this->unk_158 += (u32)globalCtx->csCtx.actorActions[temp_v0]->startPos.x; + } else { + this->unk_158 += 2.0f; + } + + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + gSaveContext.respawnFlag = -0x63; + gSaveContext.eventInf[2] |= 0x80; + } else { + gSaveContext.respawnFlag = 2; + } + globalCtx->msgCtx.ocarinaMode = 4; + return; + } + } else { + switch (this->unk_274) { + case 2: + this->unk_276 = 0; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_280 = 38; + this->unk_154 = 150.0f; + this->unk_150 = 480.0f; + + case 1: + break; + + case 3: + this->unk_158 = -32.0f; + this->unk_280 += 6; + this->unk_150 += -32.0f; + break; + + case 4: + this->unk_280 -= 4; + break; + + case 5: + this->unk_280 -= 8; + this->unk_158 += 20.0f; + this->unk_150 += this->unk_158; + if (this->unk_150 > 3500.0f) { + this->unk_150 = 3500.0f; + this->unk_274 = 0; + } + break; + + case 6: + this->unk_276 = 1; + this->unk_278 = 0; + this->unk_27C = 0; + player->actor.shape.shadowDraw = NULL; + this->unk_154 = 100.0f; + this->unk_14C = 20.0f; + this->unk_150 = 300.0f; + this->unk_158 = 0.0f; + break; + + case 7: + this->unk_158 = -5.0f; + this->unk_154 += -5.0f; + break; + + case 8: + this->unk_158 += 2.0f; + this->unk_154 += this->unk_158; + if (this->unk_154 > 10000.0f) { + this->unk_154 = 10000.0f; + this->unk_274 = 0; + } + break; + + case 0: + default: + this->unk_276 = 99; + return; + + case 9: + if (gSaveContext.save.time > CLOCK_TIME(12, 0)) { + Play_SetRespawnData(&globalCtx->state, 1, ((void)0, gSaveContext.save.entranceIndex & 0xFFFF), + player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + this->unk_276 = 99; + globalCtx->sceneLoadFlag = 0x14; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; + globalCtx->unk_1887F = 2; + gSaveContext.respawnFlag = 2; + globalCtx->msgCtx.ocarinaMode = 4; + } + return; + } + } + + if (this->unk_276 == 1) { + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + D_80A94910[i].unk_08 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_10 += 2.0f * ((2.0f * Rand_ZeroOne()) - 1.0f); + D_80A94910[i].unk_0C += 3.0f; + + if (player->actor.world.pos.y < D_80A94910[i].unk_0C) { + temp_f0 = D_80A94910[i].unk_0C - player->actor.world.pos.y; + if (temp_f0 > 550.0f) { + temp_f0 = 1.0f; + } else { + temp_f0 = temp_f0 / 550.0f; + } + D_80A94910[i].unk_04 = SQ(temp_f0); + } else { + D_80A94910[i].unk_04 = -10.0f; + } + } + } + this->unk_278++; +} + +void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { + s16 temp_s3; + s16 temp_s4; + f32 phi_f24; + s16 phi_s2; + s32 i; + f32 cos; + f32 sin; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + phi_f24 = 0.0f; + + temp_s3 = this->unk_27C; + temp_s4 = (s32)(Math_SinS(globalCtx->state.frames) * 12000.0f) + temp_s3 + 0x4E20; + phi_s2 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 *= (this->unk_154 / 200.0f); + this->unk_27C += (s16)this->unk_154; + this->unk_27E = (s16)((this->unk_154 / 200.0f) * 256.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_s3 += 0x1000; + cos = Math_CosS(temp_s3) * this->unk_150; + sin = Math_SinS(temp_s3) * this->unk_150; + Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + temp_s4 += 0x1000; + cos = Math_CosS(temp_s4) * this->unk_150; + sin = Math_SinS(temp_s4) * this->unk_150; + Matrix_InsertTranslation(cos, phi_f24, sin, MTXMODE_NEW); + Matrix_InsertXRotation_s(0x4000, MTXMODE_APPLY); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-phi_s2, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 255, 255, 255, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_f24 -= this->unk_14C; + phi_s2 += this->unk_27E; + } + + POLY_OPA_DISP = this->unk_148; + + for (i = 0; i < ARRAY_COUNT(D_80A94910); i++) { + if (D_80A94910[i].unk_04 > 0.0f) { + D_80A94910[i].unk_14(this, globalCtx, &D_80A94910[i]); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { + EnTest6* this = THIS; + GlobalContext* globalCtx = globalCtx2; + f32 temp_f20; + f32 temp_f22; + f32 phi_f26; + s16 phi_s2; + s16 sp78; + s32 i; + Player* player = GET_PLAYER(globalCtx); + s32 pad; + + if (this) {} + OPEN_DISPS(globalCtx->state.gfxCtx); + + this->unk_148 = POLY_OPA_DISP; + this->unk_27C += (s16)this->unk_154; + this->unk_27E = this->unk_27C * 2; + sp78 = (globalCtx->state.frames & 0x3C) * 1024; + phi_s2 = this->unk_27C + 0x4000; + + switch (player->transformation) { + default: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_DEKU: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_GORON: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_ZORA: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + + case PLAYER_FORM_FIERCE_DEITY: + phi_f26 = player->actor.world.pos.y + 40.0f; + break; + } + + for (i = 0; i < 51; i++) { + temp_f20 = Math_CosS(phi_s2) * this->unk_150; + temp_f22 = Math_SinS(phi_s2) * this->unk_150; + Matrix_InsertZRotation_s(this->unk_27E, MTXMODE_NEW); + Matrix_InsertTranslation(phi_f26, temp_f20, temp_f22, MTXMODE_APPLY); + Matrix_Scale(0.85f, 0.85f, 0.85f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(phi_s2, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp78, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, this->unk_280, this->unk_280, this->unk_280, 255); + gDPSetEnvColor(this->unk_148++, 235, 238, 235, 255); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + phi_s2 += 0x505; + } + + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 100, 250, 100, 200); + + POLY_OPA_DISP = this->unk_148; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + Player* player = GET_PLAYER(globalCtx); + f32 temp_f20; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + switch (this->unk_274) { + case 91: + case 93: + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 245, 245, 200, this->unk_282); + break; + + case 95: + this->unk_148 = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(this->unk_20C); i++) { + Matrix_InsertTranslation(this->unk_20C[i].x, this->unk_20C[i].y, this->unk_20C[i].z, MTXMODE_NEW); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-0x4000, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_278, MTXMODE_APPLY); + + gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(this->unk_148++, 0, 0xFF, 28, 28, 28, 255); + gDPSetEnvColor(this->unk_148++, 245, 245, 200, this->unk_282); + gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + + POLY_XLU_DISP = this->unk_148; + } + + if (this->unk_254 != NULL) { + for (i = 0; i < ARRAY_COUNT(this->unk_254[0]); i++) { + temp_f20 = Rand_ZeroOne() * 0.0025f; + Matrix_InsertTranslation((*this->unk_254)[i].x, (*this->unk_254)[i].y, (*this->unk_254)[i].z, + MTXMODE_NEW); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); + gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_278 + (i << 2), MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + } + } + Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, + player->actor.world.pos.z); + Lights_PointSetColorAndRadius(&this->lights[0].info, 250, 250, 100, this->unk_282); + break; + + case 90: + case 92: + case 94: + case 96: + case 97: + case 98: + case 99: + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnTest6_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTest6* this = THIS; + + if (this->unk_274 != 0) { + switch (this->unk_276) { + case 1: + func_80A93298(this, globalCtx); + break; + + case 0: + func_80A9369C(thisx, globalCtx); + break; + + case 2: + func_80A939E8(this, globalCtx); + break; + } + } +} diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.h b/src/overlays/actors/ovl_En_Test6/z_en_test6.h index 9cee7cf1d..0c1aab3b0 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.h +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.h @@ -7,10 +7,46 @@ struct EnTest6; typedef void (*EnTest6ActionFunc)(struct EnTest6*, GlobalContext*); +#define ENTEST6_GET(thisx) ((thisx)->params) + +enum { + /* 24 */ ENTEST6_24 = 24, + /* 25 */ ENTEST6_25, + /* 26 */ ENTEST6_26, +}; + +typedef struct { + /* 0x00 */ LightNode* node; + /* 0x04 */ LightInfo info; +} EnTest6Light; + typedef struct EnTest6 { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTest6ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x140]; + /* 0x0148 */ Gfx* unk_148; + /* 0x014C */ f32 unk_14C; + /* 0x0150 */ f32 unk_150; + /* 0x0154 */ f32 unk_154; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ EnTest6Light lights[2]; + /* 0x018C */ DbCameraUnkStruct unk_18C; + /* 0x020C */ Vec3f unk_20C[6]; + /* 0x0254 */ Vec3f (*unk_254)[64]; + /* 0x0258 */ Vec3f unk_258; + /* 0x0264 */ Vec3f unk_264; + /* 0x0270 */ f32 unk_270; + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ s16 unk_276; + /* 0x0278 */ s16 unk_278; + /* 0x027A */ s16 unk_27A; + /* 0x027C */ s16 unk_27C; + /* 0x027E */ s16 unk_27E; + /* 0x0280 */ s16 unk_280; + /* 0x0282 */ s16 unk_282; + /* 0x0284 */ s16 unk_284; + /* 0x0286 */ s16 unk_286; } EnTest6; // size = 0x288 extern const ActorInit En_Test6_InitVars; 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 81ab55e27..c5fda21f0 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -5,8 +5,9 @@ */ #include "z_en_test7.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02300030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_100000 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) #define THIS ((EnTest7*)thisx) @@ -15,11 +16,24 @@ void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx); void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); - void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc); +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx); +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx); +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx); +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx); +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Test7_InitVars = { ACTOR_EN_TEST7, ACTORCAT_ITEMACTION, @@ -32,80 +46,936 @@ const ActorInit En_Test7_InitVars = { (ActorFunc)EnTest7_Draw, }; -#endif +void EnTest7_SetupAction(EnTest7* this, EnTest7ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_SetupAction.s") +void func_80AF082C(EnTest7* this, EnTest7UnkFunc func) { + this->unk_1E58 = func; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF082C.s") +void func_80AF0838(EnTest7Struct2* arg0) { + EnTest7Struct2* ptr = arg0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0838.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0984.s") + ptr->unk_00 = 0; + ptr->unk_04 = 0; + ptr->unk_08.x = 0.0f; + ptr->unk_08.y = 0.0f; + ptr->unk_08.z = 0.0f; + ptr->unk_14 = 0.0f; + ptr->unk_18 = 0.0f; + ptr->unk_1C = 0.0f; + ptr->unk_20 = 0.0f; + ptr->unk_24 = 0.0f; + ptr->unk_28 = 0.0f; + ptr->unk_2C = 0.00001f; + ptr->unk_30.x = 0; + ptr->unk_30.y = 0; + ptr->unk_30.z = 0; + ptr->unk_36 = 0; + ptr->unk_38 = 0; + ptr->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0C30.s") +void func_80AF0984(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + s16 sp26 = Rand_ZeroOne() * 0xFFFF; + f32 sp20; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f0_3; + f32 temp_f4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF0CDC.s") + arg0->unk_08 = *arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF10D8.s") + if (arg2 != 0) { + Math_CosS(sp26); + arg0->unk_08.x = arg0->unk_08.x; + arg0->unk_08.y += (Rand_ZeroOne() * 100.0f) - 20.0f; + Math_SinS(sp26); + arg0->unk_08.z = arg0->unk_08.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF118C.s") + sp20 = (Rand_ZeroOne() * 4.0f) + 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF14FC.s") + arg0->unk_14 = Math_CosS(sp26) * sp20; + arg0->unk_18 = Rand_ZeroOne(); + arg0->unk_1C = Math_SinS(sp26) * sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1730.s") + arg0->unk_20 = 0.0f; + arg0->unk_24 = 0.0f; + arg0->unk_28 = 0.0f; + arg0->unk_2C = 0.25f; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_04 = 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Init.s") + if (Rand_ZeroOne() < 0.9f) { + arg0->unk_00 = 1; + arg0->unk_30.x = Rand_ZeroOne() * 0x10000; + arg0->unk_30.y = Rand_ZeroOne() * 0x10000; + arg0->unk_30.z = Rand_ZeroOne() * 0x10000; + arg0->unk_36 = 0; + arg0->unk_38 = 0; + arg0->unk_3A = 0; + } else { + arg0->unk_00 = 2; + arg0->unk_30.x = 0; + arg0->unk_30.y = 0; + arg0->unk_30.z = Rand_ZeroOne() * 5000.0f; + arg0->unk_36 = 0; + arg0->unk_38 = (Rand_ZeroOne() * 8000.0f) + 2000.0f; + if (Rand_ZeroOne() > 0.5f) { + arg0->unk_38 = -arg0->unk_38; + } + arg0->unk_3A = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Destroy.s") +void func_80AF0C30(EnTest7Struct2* arg0, Vec3f* arg1, s32 arg2) { + static s32 D_80AF3410 = 0; + s32 i; + s32 phi_t0 = false; + EnTest7Struct2* ptr; + s32 idx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF19A8.s") + for (i = 0, ptr = arg0; i < 100; i++, ptr++) { + if (ptr->unk_00 == 0) { + func_80AF0984(ptr, arg1, arg2); + D_80AF3410 = i; + phi_t0 = true; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1A2C.s") + if (!phi_t0) { + idx = D_80AF3410 + 1; + if (idx >= 100) { + idx = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1B68.s") + func_80AF0984(&arg0[idx], arg1, arg2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1CA0.s") +Vec3f D_80AF3414 = { 0.0f, 1.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1E44.s") +Vec3f D_80AF3420 = { 0.0f, 0.0f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF1F48.s") +void func_80AF0CDC(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + static MtxF D_80AF38B0; + static Vec3f D_80AF38F0; + static f32 D_80AF38FC; + static Vec3f D_80AF3900; + s32 sp2C; + s32 sp28; + s32 sp24; + s16 temp_v0_2; + s16 temp_v0_3; + s32 temp_v0; + f32 phi_f8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2030.s") + sp2C = arg1->unk_04 % 41; + sp24 = 0; + sp28 = (arg1->unk_04 + 0x1B58) % 41; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF21E8.s") + SkinMatrix_SetRotateRPY(&D_80AF38B0, arg1->unk_30.x, arg1->unk_30.y, arg1->unk_30.z); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3414, &D_80AF38F0); + SkinMatrix_Vec3fMtxFMultXYZ(&D_80AF38B0, &D_80AF3420, &D_80AF3900); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2318.s") + if (arg1->unk_30.x < 0x3448) { + arg1->unk_30.x += 0x384; + } else if (arg1->unk_30.x >= 0x4BB9) { + arg1->unk_30.x -= 0x384; + } else { + arg1->unk_30.x = (Math_SinS((sp2C * 65535.0f) / 41.0f) * 2000.0f) + 16384.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2350.s") + if (arg1->unk_30.y < -0xBB8) { + arg1->unk_30.y += 0x384; + } else if (arg1->unk_30.y > 0xBB8) { + arg1->unk_30.y -= 0x384; + } else { + sp24 = 1; + arg1->unk_30.y = Math_SinS((sp28 * 65535.0f) / 41.0f) * 2000.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF24D8.s") + if (sp24 == 1) { + if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.5f; + arg1->unk_18 += (D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += (D_80AF38F0.z * 0.5f); + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.5f; + arg1->unk_18 += (-D_80AF38F0.y * 0.5f) + 0.08f; + arg1->unk_1C += -D_80AF38F0.z * 0.5f; + } + } else if (D_80AF38F0.y < 0.0f) { + arg1->unk_14 += D_80AF38F0.x * 0.2f; + arg1->unk_18 += (D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += D_80AF38F0.z * 0.2f; + } else { + arg1->unk_14 += -D_80AF38F0.x * 0.2f; + arg1->unk_18 += (-D_80AF38F0.y * 0.2f) + 0.08f; + arg1->unk_1C += (-D_80AF38F0.z * 0.2f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2654.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2808.s") +void func_80AF10D8(GlobalContext* globalCtx, EnTest7Struct2* arg1) { + arg1->unk_30.y += arg1->unk_38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2854.s") + arg1->unk_20 = Rand_Centered(); + arg1->unk_24 = Rand_Centered() + -0.01f; + arg1->unk_28 = Rand_Centered(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2938.s") + arg1->unk_14 += arg1->unk_20; + arg1->unk_18 += arg1->unk_24; + arg1->unk_1C += arg1->unk_28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF29C0.s") + arg1->unk_08.x += arg1->unk_14; + arg1->unk_08.y += arg1->unk_18; + arg1->unk_08.z += arg1->unk_1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2AE8.s") +void func_80AF118C(GlobalContext* globalCtx, EnTest7Struct2* arg1, EnTest7* this, s32 arg3, s32 arg4) { + s32 pad[4]; + EnTest7Struct2* ptr; + s16 phi_s1; + s32 i; + f32 temp_f28; + Vec3f sp8C; + f32 temp_f0; + f32 temp_f22; + f32 temp_f24; + f32 temp_f26; + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2BAC.s") + for (i = 0, ptr = arg1; i < (s32)(ARRAY_COUNT(this->unk_15C) * sizeof(this->unk_15C[0])); + i += sizeof(this->unk_15C[0]), ptr++) { + arg1 = ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2C48.s") + if (arg1->unk_00 == 0) { + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2DB4.s") + if (arg1->unk_00 == 1) { + func_80AF0CDC(globalCtx, arg1); + } else { + func_80AF10D8(globalCtx, arg1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2EC8.s") + if (arg3) { + temp_f22 = arg1->unk_08.x - this->actor.world.pos.x; + temp_f24 = arg1->unk_08.z - this->actor.world.pos.z; + temp_f0 = SQ(temp_f22) + SQ(temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF2F98.s") + phi_s1 = -10000; + if (temp_f0 > SQ(20.0f)) { + phi_s1 /= ((temp_f0 - SQ(20.0f)) * 0.00125f) + 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF30F4.s") + temp_f26 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + temp_f28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Update.s") + arg1->unk_08.x = this->actor.world.pos.x + temp_f26; + arg1->unk_08.z = this->actor.world.pos.z + temp_f28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/func_80AF31D0.s") + temp_f22 = arg1->unk_14; + temp_f24 = arg1->unk_1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test7/EnTest7_Draw.s") + arg1->unk_14 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_1C = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + + temp_f22 = arg1->unk_20; + temp_f24 = arg1->unk_28; + + arg1->unk_20 = (temp_f22 * Math_CosS(phi_s1)) - (Math_SinS(phi_s1) * temp_f24); + arg1->unk_28 = (temp_f22 * Math_SinS(phi_s1)) + (Math_CosS(phi_s1) * temp_f24); + } + + if (arg4) { + sp8C.x = arg1->unk_08.x - this->actor.world.pos.x; + sp8C.y = arg1->unk_08.y - (this->actor.world.pos.y + 40.0f); + sp8C.z = arg1->unk_08.z - this->actor.world.pos.z; + + temp_f2 = 1.0f - (0.5f / ((Math3D_Vec3fMagnitude(&sp8C) / 500.0f) + 1.0f)); + + sp8C.x *= temp_f2; + sp8C.y *= temp_f2; + sp8C.z *= temp_f2; + + arg1->unk_08.x = this->actor.world.pos.x + sp8C.x; + arg1->unk_08.y = this->actor.world.pos.y + sp8C.y + 40.0f; + arg1->unk_08.z = this->actor.world.pos.z + sp8C.z; + } + } +} + +void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { + s32 pad[3]; + GlobalContext* globalCtx = globalCtx2; + Mtx* temp_v0; + EnTest7Struct2* ptr; + s32 i; + MtxF sp6C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C1C0(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + for (i = 0, ptr = arg1; i < 0x1770; i += 0x3C, ptr++) { + if (ptr->unk_00 == 0) { + continue; + } + + if ((ptr->unk_08.x > 30000.0f) || (ptr->unk_08.x < -30000.0f) || (ptr->unk_08.y > 30000.0f) || + (ptr->unk_08.y < -30000.0f) || (ptr->unk_08.z > 30000.0f) || (ptr->unk_08.z < -30000.0f)) { + ptr->unk_00 = 0; + continue; + } + + Matrix_InsertTranslation(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); + + if (ptr->unk_00 == 1) { + Matrix_InsertRotation(ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z, MTXMODE_APPLY); + } else { + SkinMatrix_SetRotateYRP(&sp6C, ptr->unk_30.x, ptr->unk_30.y, ptr->unk_30.z); + Matrix_InsertMatrix(&sp6C, MTXMODE_APPLY); + } + + Matrix_Scale(ptr->unk_2C, ptr->unk_2C, ptr->unk_2C, MTXMODE_APPLY); + if (ptr->unk_00 == 2) { + Matrix_InsertTranslation(0.0f, 30.0f, 0.0f, MTXMODE_APPLY); + } + + temp_v0 = Matrix_NewMtx(globalCtx->state.gfxCtx); + if (temp_v0 != NULL) { + gSPMatrix(POLY_OPA_DISP++, temp_v0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_081628); + } + } + + if (ptr) {} + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80AF1730(EnTest7Struct* arg0) { + arg0->unk_00 = 0.0f; + arg0->unk_04 = 0.0f; + arg0->unk_08 = 1.0f; + arg0->unk_0C = 1.0f; + arg0->unk_10 = 0; +} + +void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnTest7* this = THIS; + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + + this->actor.world.rot.y = this->actor.shape.rot.y = player->actor.shape.rot.y; + this->unk_144 = 0; + this->unk_1E54 = 0; + this->unk_1E8E = player->actor.shape.rot.y; + this->unk_1E90 = player->actor.scale.x; + this->unk_1E94 = player->actor.scale.z; + + func_80183430(&this->unk_18CC, &gameplay_keep_Blob_085640, &gameplay_keep_Blob_083534, this->unk_18FC, + this->unk_1BA8, 0); + func_801834A8(&this->unk_18CC, &gameplay_keep_Blob_083534); + func_80AF0838(this->unk_15C); + func_80AF1730(&this->unk_148); + + if (ENTEST7_GET(&this->actor) == ENTEST7_MINUS1) { + func_80AF082C(this, func_80AF2938); + EnTest7_SetupAction(this, NULL); + } else { + func_80AF082C(this, func_80AF19A8); + EnTest7_SetupAction(this, func_80AF2854); + func_801A2E54(NA_BGM_SONG_OF_SOARING); + } + + if (globalCtx->playerActorCsIds[8] == -1) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + player2->stateFlags1 |= 0x20; + Lights_PointNoGlowSetInfo(&this->lightInfo, (Math_SinS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.x, + player->actor.world.pos.y + 10.0f, + (Math_CosS(this->unk_1E8E) * 90.0f) + player->actor.world.pos.z, 255, 255, 255, 255); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); +} + +void EnTest7_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + ActorCutscene_Stop(globalCtx->playerActorCsIds[8]); + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); +} + +void func_80AF19A8(EnTest7* this, GlobalContext* globalCtx) { + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF1A2C); + globalCtx->unk_18844 = 1; + } +} + +void func_80AF1A2C(EnTest7* this, GlobalContext* globalCtx) { + Color_RGB8 sp34 = { 64, 0, 0 }; + Color_RGB8 sp30 = { 220, 220, 255 }; + f32 sp2C = this->unk_1E54 / 10.0f; + + func_800FD59C(globalCtx, &sp30, sp2C); + func_800FD654(globalCtx, &sp34, sp2C); + func_800FD698(globalCtx, 2000, 4000, sp2C); + + if (this->unk_1E54 >= 10) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E78 = camera->fov; + + func_80AF082C(this, func_80AF1CA0); + this->unk_144 |= 0x20; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_OPEN); + func_8016566C(0x78); + } +} + +void func_80AF1B68(EnTest7* this, GlobalContext* globalCtx) { + this->unk_144 |= 2; + + if (this->unk_148.unk_04 < 11.0f) { + this->unk_148.unk_04 = this->unk_148.unk_04 + 0.3f; + this->unk_148.unk_08 = ((this->unk_148.unk_00 * -0.45f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_00 * -0.29999998f) / 11.0f) + 0.7f; + } + + if (this->unk_148.unk_00 < 11.0f) { + this->unk_148.unk_00 += 1.0f; + if (this->unk_148.unk_00 > 6.0f) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_144 &= ~1; + player->actor.draw = NULL; + } + } else if (this->unk_1E54 >= 87) { + func_80AF082C(this, func_80AF1F48); + this->unk_144 &= -9; + this->unk_148.unk_10 -= 0x2EE0; + } else { + this->unk_148.unk_10 -= 0x2EE0; + } +} + +void func_80AF1CA0(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + + if (func_80183DE0(&this->unk_18CC)) { + func_80AF082C(this, func_80AF1E44); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 60.0f) { + func_80AF1B68(this, globalCtx); + } + + if ((this->unk_18CC.frameCtrl.unk_10 > 20.0f) && !(this->unk_144 & 0x40)) { + this->unk_144 |= 0x40; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_CLOSE); + } + + if (this->unk_18CC.frameCtrl.unk_10 > 42.0f) { + if (!(this->unk_144 & 0x80)) { + this->unk_144 |= 0x80; + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_ROLL); + } + + if (Rand_ZeroOne() < 0.3f) { + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + f32 rand = Rand_ZeroOne(); + + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_144 |= 8; + } + } else { + this->unk_144 |= 1; + } +} + +void func_80AF1E44(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp34; + Camera* camera; + f32 rand; + + func_80AF1B68(this, globalCtx); + + if (Rand_ZeroOne() < 0.3f) { + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + rand = Rand_ZeroOne(); + sp34.x = ((camera->eye.x - this->actor.world.pos.x) * rand) + this->actor.world.pos.x; + sp34.y = ((camera->eye.y - this->actor.world.pos.y) * rand) + this->actor.world.pos.y; + sp34.z = ((camera->eye.z - this->actor.world.pos.z) * rand) + this->actor.world.pos.z; + func_80AF0C30(this->unk_15C, &sp34, 1); + } + + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp34, 1); + this->unk_18FC[1].y += 0x2EE0; +} + +void func_80AF1F48(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + s32 temp = this->unk_1E54 - 86; + f32 temp_f0 = temp / 10.0f; + Vec3f sp20; + + this->unk_144 |= 0x10; + + this->unk_148.unk_08 = (-0.15f * temp_f0) + 0.25f; + this->unk_148.unk_0C = (-0.3f * temp_f0) + 0.4f; + this->unk_148.unk_10 -= 0x2EE0; + + this->unk_144 |= 4; + + if (this->unk_1E54 >= 96) { + func_80AF082C(this, func_80AF2030); + this->unk_144 &= ~0x10; + } + Math_Vec3f_Copy(&sp20, &this->actor.world.pos); + func_80AF0C30(this->unk_15C, &sp20, 1); +} + +void func_80AF2030(EnTest7* this, GlobalContext* globalCtx) { + s32 temp = this->unk_1E54 - 96; + f32 four = 4; + f32 sp1C = 1.0f - (temp / four); + Camera* camera; + f32 temp_f2; + f32 temp_f4; + + this->unk_148.unk_08 = ((temp * -0.1f) / four) + 0.1f; + this->unk_148.unk_0C = ((temp * 5.9f) / four) + 0.1f; + this->unk_148.unk_10 -= 0x2EE0; + this->actor.world.pos.y += 100.0f; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + camera->eye.x = ((camera->eye.x - this->unk_1E60.x) * sp1C) + this->unk_1E60.x; + camera->eye.y = ((camera->eye.y - this->unk_1E60.y) * sp1C) + this->unk_1E60.y; + camera->eye.z = ((camera->eye.z - this->unk_1E60.z) * sp1C) + this->unk_1E60.z; + camera->fov = ((camera->fov - this->unk_1E78) * sp1C) + this->unk_1E78; + + if (this->unk_1E54 >= 100) { + MREG(64) = 1; + MREG(65) = 255; + MREG(66) = 255; + MREG(67) = 255; + MREG(68) = 255; + globalCtx->unk_18844 = 0; + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF21E8); + func_80165690(); + } +} + +void func_80AF21E8(EnTest7* this, GlobalContext* globalCtx) { + s32 sp2C = this->unk_1E54 - 100; + f32 sp1C; + Color_RGB8 sp24 = { 64, 0, 0 }; + Color_RGB8 sp20 = { 220, 220, 255 }; + + if (MREG(64) != 0) { + Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_VANISH); + MREG(64) = 0; + MREG(65) = 0; + MREG(66) = 0; + MREG(67) = 0; + MREG(68) = 0; + } + + sp1C = 1.0f - (sp2C / 10.0f); + func_800FD59C(globalCtx, &sp20, sp1C); + func_800FD654(globalCtx, &sp24, sp1C); + func_800FD698(globalCtx, 2000, 4000, sp1C); + + if (this->unk_1E54 >= 110) { + func_80AF082C(this, func_80AF2318); + } +} + +void func_80AF2318(EnTest7* this, GlobalContext* globalCtx) { + if (this->unk_1E54 >= 130) { + func_80AF082C(this, func_80AF2350); + } +} + +u16 D_80AF343C[] = { + 0x68B0, 0x6A60, 0xB230, 0x9A80, 0xD890, 0x3E40, 0x8640, 0x84A0, 0x2040, 0xAA30, +}; + +void func_80AF2350(EnTest7* this, GlobalContext* globalCtx) { + Vec3f sp2C; + + if (this) {} + + Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); + + if (Rand_ZeroOne() < 0.1f) { + func_80AF0C30(this->unk_15C, &sp2C, 1); + } + + this->unk_148.unk_10 -= 0x2EE0; + + if (globalCtx->sceneNum == SCENE_SECOM) { + globalCtx->nextEntranceIndex = 0x2060; + } else if (ENTEST7_GET(&this->actor) == ENTEST7_26) { + func_80169F78(&globalCtx->state); + gSaveContext.respawn[2].playerParams = (gSaveContext.respawn[2].playerParams & 0xFF) | 0x600; + gSaveContext.respawnFlag = -6; + } else { + globalCtx->nextEntranceIndex = D_80AF343C[ENTEST7_GET(&this->actor) - ENTEST7_1C]; + if ((globalCtx->nextEntranceIndex == 0x84A0) && (gSaveContext.save.weekEventReg[20] & 2)) { + globalCtx->nextEntranceIndex = 0xCA0; + } else if ((globalCtx->nextEntranceIndex == 0x9A80) && (gSaveContext.save.weekEventReg[33] & 0x80)) { + globalCtx->nextEntranceIndex = 0xAE80; + } + } + + globalCtx->sceneLoadFlag = 0x14; + globalCtx->unk_1887F = 2; + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; +} + +void func_80AF24D8(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f sp3C; + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + pos = &player->actor.world.pos; + camera->player = NULL; + + sp3C.x = ((180.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->x; + sp3C.y = (Math_SinS(0xFA0) * 180.0f) + pos->y; + sp3C.z = ((180.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xFA0)) + pos->z; + + camera->eye.x = ((sp3C.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp3C.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp3C.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; + camera->at.y += 1.4444444f; +} + +void func_80AF2654(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Vec3f* pos; + Player* player = GET_PLAYER(globalCtx); + Camera* camera; + Vec3f sp30; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + camera->player = NULL; + + pos = &player->actor.world.pos; + + sp30.x = ((80.0f * Math_SinS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->x; + sp30.y = (Math_SinS(0xBB8) * 80.0f) + pos->y; + sp30.z = ((80.0f * Math_CosS(this->unk_1E8E)) * Math_CosS(0xBB8)) + pos->z; + + camera->eye.x = ((sp30.x - camera->eye.x) * arg2) + camera->eye.x; + camera->eye.y = ((sp30.y - camera->eye.y) * arg2) + camera->eye.y; + camera->eye.z = ((sp30.z - camera->eye.z) * arg2) + camera->eye.z; + + camera->at.x = ((pos->x - camera->at.x) * arg2) + camera->at.x; + camera->at.y = (((pos->y + 40.0f) - camera->at.y) * arg2) + camera->at.y; + camera->at.z = ((pos->z - camera->at.z) * arg2) + camera->at.z; + + camera->fov = ((this->unk_1E78 - camera->fov) * arg2) + camera->fov; +} + +void func_80AF2808(EnTest7* this, GlobalContext* globalCtx, f32 arg2) { + Player* player = GET_PLAYER(globalCtx); + + player->actor.shape.rot.y += 0x2EE0; + player->actor.scale.x = ((0.0f - this->unk_1E90) * arg2) + this->unk_1E90; + player->actor.scale.z = ((0.0f - this->unk_1E94) * arg2) + this->unk_1E94; +} + +void func_80AF2854(EnTest7* this, GlobalContext* globalCtx) { + f32 temp; + f32 sixteen = 16.0f; + + if ((this->unk_1E54 >= 12) && (this->unk_1E54 < 31)) { + temp = (this->unk_1E54 - 12) / 18.0f; + func_80AF24D8(this, globalCtx, temp); + } else if ((this->unk_1E54 >= 79) && (this->unk_1E54 < 96)) { + temp = (this->unk_1E54 - 79) / sixteen; + func_80AF2654(this, globalCtx, temp); + } + + if ((this->unk_1E54 >= 42) && (this->unk_1E54 < 69)) { + temp = (this->unk_1E54 - 42) / 26.0f; + func_80AF2808(this, globalCtx, temp); + } +} + +void func_80AF2938(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_1E98 = player->actor.draw; + player->actor.draw = NULL; + player->stateFlags2 |= 0x20000000; + this->unk_144 |= 2; + this->unk_148.unk_04 = 30.0f; + if (globalCtx->roomCtx.currRoom.unk3 != 1) { + func_80AF082C(this, func_80AF2AE8); + } else { + func_80AF082C(this, func_80AF2EC8); + } +} + +s16 D_80AF3450[] = { 0, 0x31C7 }; + +f32 D_80AF3454 = 3500.0f; + +void func_80AF29C0(EnTest7* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + Camera* temp_s0 = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + temp_s0->at.x = ((D_80AF3454 * Math_SinS(D_80AF3450[0]) * Math_CosS(D_80AF3450[1]))) + pos->x; + temp_s0->at.y = (Math_SinS(D_80AF3450[1]) * D_80AF3454) + pos->y; + temp_s0->at.z = ((D_80AF3454 * Math_CosS(D_80AF3450[0])) * Math_CosS(D_80AF3450[1])) + pos->z; + + this->actor.world.pos.x = temp_s0->at.x; + this->actor.world.pos.y = temp_s0->at.y - 40.0f; + this->actor.world.pos.z = temp_s0->at.z; +} + +void func_80AF2AE8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + return; + } + + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2C48); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + + func_80AF29C0(this, globalCtx); +} + +void func_80AF2BAC(EnTest7* this, GlobalContext* globalCtx, Vec3f* arg2, f32 arg3) { + f32 x; + f32 y; + f32 z; + Camera* camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->player = NULL; + x = ((camera->at.x - arg2->x) * arg3) + arg2->x; + y = ((camera->at.y - arg2->y) * arg3) + arg2->y; + z = ((camera->at.z - arg2->z) * arg3) + arg2->z; + + camera->at.x = x; + camera->at.y = y; + camera->at.z = z; +} + +void func_80AF2C48(EnTest7* this, GlobalContext* globalCtx) { + f32 sp24 = (40 - this->unk_1E54) / 40.0f; + Camera* camera; + + this->unk_148.unk_00 = 11.0f; + this->unk_144 |= 4; + this->unk_148.unk_08 = 0.05f; + this->unk_148.unk_0C = 0.05f; + this->unk_148.unk_10 += 0x2EE0; + + this->actor.world.pos.x = ((this->actor.world.pos.x - this->actor.home.pos.x) * sp24) + this->actor.home.pos.x; + 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; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + func_80AF2BAC(this, globalCtx, &this->actor.home.pos, sp24); + + camera->at.x = this->actor.world.pos.x; + camera->at.y = this->actor.world.pos.y + 40.0f; + camera->at.z = this->actor.world.pos.z; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + if (this->unk_1E54 >= 40) { + this->unk_144 &= ~4; + func_80AF082C(this, func_80AF2F98); + } +} + +void func_80AF2DB4(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + Player* player = GET_PLAYER(globalCtx); + Vec3f* pos = &player->actor.world.pos; + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + + camera->eye.x = (Math_SinS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->x; + camera->eye.y = pos->y + 108.8042f; + camera->eye.z = (Math_CosS(-player->actor.shape.rot.y) * 200.0f * -0.83907f) + pos->z; + + camera->at.x = pos->x; + camera->at.y = pos->y + 40.0f; + camera->at.z = pos->z; +} + +void func_80AF2EC8(EnTest7* this, GlobalContext* globalCtx) { + Camera* camera; + + if (!ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[8])) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); + } else { + ActorCutscene_Start(globalCtx->playerActorCsIds[8], NULL); + func_80AF082C(this, func_80AF2F98); + + camera = Play_GetCamera(globalCtx, ActorCutscene_GetCurrentCamera(globalCtx->playerActorCsIds[8])); + this->unk_1E60 = camera->eye; + this->unk_1E6C = camera->at; + this->unk_1E54 = 40; + + func_80AF2DB4(this, globalCtx); + } +} + +void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Player* player2 = GET_PLAYER(globalCtx); + Vec3f sp2C; + + func_800B9010(&this->actor, NA_SE_PL_WARP_WING_ROLL_2 - SFX_FLAG); + + sp2C = this->actor.world.pos; + + func_80AF0C30(this->unk_15C, &sp2C, 1); + func_80AF0C30(this->unk_15C, &sp2C, 1); + this->unk_148.unk_04 = 70 - this->unk_1E54; + if (this->unk_1E54 > 70) { + func_80AF082C(this, func_80AF30F4); + } + + if (this->unk_148.unk_04 > 11.0f) { + f32 temp = this->unk_148.unk_04 - 11.0f; + + this->unk_148.unk_08 = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_0C = ((-0.35f * temp) / 19.0f) + 0.4f; + this->unk_148.unk_10 += 0x2EE0; + } else { + player2->actor.draw = this->unk_1E98; + this->unk_148.unk_00 = this->unk_148.unk_04; + this->unk_148.unk_08 = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + this->unk_148.unk_0C = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; + player->stateFlags2 &= ~0x20000000; + } +} + +void func_80AF30F4(EnTest7* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->unk_1E54 > 90) { + player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~0x20000000; + Actor_MarkForDeath(&this->actor); + } +} + +void EnTest7_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTest7* this = THIS; + + this->unk_1E58(this, globalCtx); + + if (this->actionFunc != NULL) { + this->actionFunc(this, globalCtx); + } + + this->unk_1E54++; + + func_80AF118C(globalCtx, this->unk_15C, this, (this->unk_144 & 8) != 0, (this->unk_144 & 0x10) != 0); +} + +s32 func_80AF31D0(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, + Actor* thisx, Vec3f* scale, Vec3s* rot, Vec3f* pos) { + EnTest7* this = THIS; + Vec3f sp18; + + if ((*dList != NULL) && (Rand_ZeroOne() < 0.03f)) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &sp18); + func_80AF0C30(this->unk_15C, &sp18, 0); + } + return true; +} + +void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + EnTest7* this = THIS; + s32 sp40; + + if (this->unk_144 & 1) { + Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_18CC.unk_18->unk_1)); + + if (mtx != NULL) { + func_8018450C(globalCtx, &this->unk_18CC, mtx, func_80AF31D0, NULL, &this->actor); + } else { + return; + } + } + + if (this->unk_144 & 2) { + Matrix_StatePush(); + Matrix_InsertTranslation(0.0f, 4000.0f, 0.0f, MTXMODE_APPLY); + Matrix_InsertRotation(0, this->unk_148.unk_10, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_148.unk_08 * 100.0f, this->unk_148.unk_0C * 100.0f, this->unk_148.unk_08 * 100.0f, + MTXMODE_APPLY); + sp40 = this->unk_148.unk_00; + AnimatedMat_DrawStep(globalCtx, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_0815D0), sp40); + Gfx_DrawDListXlu(globalCtx, gameplay_keep_DL_080FC8); + Matrix_StatePop(); + } + + func_80AF14FC(globalCtx, this->unk_15C); + + if (this->unk_144 & 4) { + func_800F9824(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, this->actor.world.pos, + 70.0f, 5.0f, 0, 0); + } +} diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.h b/src/overlays/actors/ovl_En_Test7/z_en_test7.h index 0973b4245..a074c7875 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.h +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.h @@ -6,12 +6,60 @@ struct EnTest7; typedef void (*EnTest7ActionFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkFunc)(struct EnTest7*, GlobalContext*); +typedef void (*EnTest7UnkDrawFunc)(Actor*, GlobalContext*); + +#define ENTEST7_GET(thisx) ((thisx)->params) + +#define ENTEST7_MINUS1 -1 +#define ENTEST7_26 0x26 +#define ENTEST7_1C 0x1C + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 unk_10; +} EnTest7Struct; // size >= 0x14 + +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ Vec3f unk_08; + /* 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 */ Vec3s unk_30; + /* 0x36 */ s16 unk_36; + /* 0x38 */ s16 unk_38; + /* 0x3A */ s16 unk_3A; +} EnTest7Struct2; // size = 0x3C typedef struct EnTest7 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D18]; + /* 0x0144 */ s32 unk_144; + /* 0x0148 */ EnTest7Struct unk_148; + /* 0x015C */ EnTest7Struct2 unk_15C[100]; + /* 0x18CC */ SkeletonInfo unk_18CC; + /* 0x18FC */ Vec3s unk_18FC[114]; + /* 0x1BA8 */ s16 unk_1BA8[342]; + /* 0x1E54 */ s32 unk_1E54; + /* 0x1E58 */ EnTest7UnkFunc unk_1E58; /* 0x1E5C */ EnTest7ActionFunc actionFunc; - /* 0x1E60 */ char unk_1E60[0x3C]; + /* 0x1E60 */ Vec3f unk_1E60; + /* 0x1E6C */ Vec3f unk_1E6C; + /* 0x1E78 */ f32 unk_1E78; + /* 0x1E7C */ LightNode* lightNode; + /* 0x1E80 */ LightInfo lightInfo; + /* 0x1E8E */ s16 unk_1E8E; + /* 0x1E90 */ f32 unk_1E90; + /* 0x1E94 */ f32 unk_1E94; + /* 0x1E98 */ EnTest7UnkDrawFunc unk_1E98; } EnTest7; // size = 0x1E9C extern const ActorInit En_Test7_InitVars; 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 c53e096f0..fe3aadc7b 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -6,7 +6,7 @@ #include "z_en_tg.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTg*)thisx) 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 952743c89..cfb1f5180 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 "z_en_thiefbird.h" #include "objects/object_thiefbird/object_thiefbird.h" -#define FLAGS 0x80001205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200 | ACTOR_FLAG_1000 | ACTOR_FLAG_80000000) #define THIS ((EnThiefbird*)thisx) @@ -168,7 +168,7 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { D_80C1392C = 1; Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); Actor_MarkForDeath(&this->actor); - } else if ((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) { + } else if (STOLEN_ITEM_1 != STOLEN_ITEM_NONE) { Actor_MarkForDeath(&this->actor); } else { func_80C11538(this); @@ -213,7 +213,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { s32 itemId1; s16 itemId2 = 0; - for (; slotId < ARRAY_COUNT(gSaveContext.save.inventory.items); slotId++) { + for (; slotId < 24; slotId++) { if ((gSaveContext.save.inventory.items[slotId] >= ITEM_BOTTLE) && (gSaveContext.save.inventory.items[slotId] <= ITEM_POTION_BLUE)) { isItemFound = true; @@ -223,7 +223,7 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { } if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - phi_a3 = CUR_EQUIP_VALUE_VOID(EQUIP_SWORD); + phi_a3 = GET_CUR_EQUIP_VALUE(EQUIP_SWORD); if (INV_CONTENT(ITEM_SWORD_GREAT_FAIRY) == ITEM_SWORD_GREAT_FAIRY) { phi_a3 += 4; } @@ -240,8 +240,8 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { if (isItemFound) { Inventory_DeleteItem(itemId2, slotId); this->unk_3E8 = object_thiefbird_DL_0033B0; - if (!Message_GetState(&globalCtx->msgCtx)) { - func_801518B0(globalCtx, 0xF4, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Message_StartTextbox(globalCtx, 0xF4, NULL); } itemId1 = ITEM_BOTTLE; } else if (phi_a3 != 0) { @@ -264,17 +264,17 @@ s32 func_80C10B0C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_3E8 = D_80C13680[phi_a3 - 1]; } - if (!Message_GetState(&globalCtx->msgCtx)) { - func_801518B0(globalCtx, 0xF5, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0) { + Message_StartTextbox(globalCtx, 0xF5, NULL); } } else { return false; } - if (!((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18)) { - gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & 0xFFFFFF) | ((itemId1 & 0xFF) << 0x18); + if (STOLEN_ITEM_1 == STOLEN_ITEM_NONE) { + SET_STOLEN_ITEM_1(itemId1); } else { - gSaveContext.save.stolenItems = (gSaveContext.save.stolenItems & 0xFF00FFFF) | ((itemId1 & 0xFF) << 0x10); + SET_STOLEN_ITEM_2(itemId1); } return true; @@ -443,20 +443,20 @@ void func_80C11338(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11454(EnThiefbird* this) { - this->unk_18C = 10; - this->unk_3D8 = 0.5f; - this->unk_3DC = 0.75f; - this->unk_3D4 = 1.0f; - this->actor.flags &= ~0x200; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; + this->actor.flags &= ~ACTOR_FLAG_200; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } void func_80C114C0(EnThiefbird* this, GlobalContext* globalCtx) { - if (this->unk_18C == 10) { - this->unk_18C = 0; - this->unk_3D4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_350, 11, 2, 0.2f, 0.2f); - this->actor.flags |= 0x200; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.2f, 0.2f); + this->actor.flags |= ACTOR_FLAG_200; } } @@ -570,8 +570,7 @@ void func_80C1193C(EnThiefbird* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && - (!((gSaveContext.save.stolenItems & 0xFF000000) >> 0x18) || - !((gSaveContext.save.stolenItems & 0xFF0000) >> 0x10)) && + ((STOLEN_ITEM_1 == STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 == STOLEN_ITEM_NONE)) && (Rand_ZeroOne() < 0.5f) && func_80C10B0C(this, globalCtx)) { func_80C1242C(this); } else if (func_80C10E98(globalCtx)) { @@ -600,7 +599,7 @@ void func_80C11C60(EnThiefbird* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_DEAD); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 40); this->collider.base.acFlags &= ~AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_192 = 0x1C00; this->actionFunc = func_80C11D14; } @@ -611,7 +610,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -631,7 +630,7 @@ void func_80C11D14(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C11DC0(EnThiefbird* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = func_80C11DF0; this->actor.gravity = -0.5f; } @@ -646,8 +645,8 @@ void func_80C11DF0(EnThiefbird* this, GlobalContext* globalCtx) { } if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) { - for (i = 0; i < ARRAY_COUNT(this->unk_350); i++) { - func_800B3030(globalCtx, &this->unk_350[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 0x8C, 0, 0); } SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); @@ -713,7 +712,7 @@ void func_80C1215C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if (this->unk_18C == 10) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { if (this->unk_18E < 38) { func_80C114C0(this, globalCtx); this->actor.speedXZ = 4.0f; @@ -778,7 +777,7 @@ void func_80C12378(EnThiefbird* this, GlobalContext* globalCtx) { void func_80C1242C(EnThiefbird* this) { Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000278, 2.0f, 0.0f, 0.0f, 0, -4.0f); - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->collider.base.acFlags |= AC_ON; this->actionFunc = func_80C124B0; this->actor.speedXZ = 12.0f; @@ -823,7 +822,7 @@ void func_80C124B0(EnThiefbird* this, GlobalContext* globalCtx) { } void func_80C126A8(EnThiefbird* this) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->collider.base.acFlags &= ~AC_ON; this->actionFunc = func_80C126D8; } @@ -841,7 +840,7 @@ void func_80C12744(EnThiefbird* this) { Animation_Change(&this->skelAnime, &object_thiefbird_Anim_000604, 1.0f, 0.0f, 0.0f, 1, -4.0f); this->unk_190 = 0; this->collider.base.acFlags |= AC_ON; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->actionFunc = func_80C127F4; this->actor.speedXZ = 4.0f; this->skelAnime.playSpeed = 3.0f; @@ -877,10 +876,10 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &this->unk_3EC->actor), 3, 0x2000, 0x100); } - temp_v0 = Math_Vec3f_Pitch(&this->unk_350[9], &this->unk_3EC->actor.world.pos); + 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->unk_350[9]); + 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)) { @@ -907,7 +906,7 @@ void func_80C127F4(EnThiefbird* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.x, -0x800, 4, 0x800, 0x80); if (this->unk_194 == 0) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; func_80C11538(this); } } @@ -925,7 +924,7 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_194 = 0; for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { - if (this->collider.elements[i].info.bumperFlags & 2) { + if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) { break; } } @@ -933,22 +932,22 @@ void func_80C12B1C(EnThiefbird* this, GlobalContext* globalCtx) { if (this->actor.colChkInfo.damageEffect == 3) { func_80C11454(this); } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_18C = 20; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; if (i != ARRAY_COUNT(this->colliderElements)) { sph = &this->collider.elements[i]; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, sph->info.bumper.hitPos.x, sph->info.bumper.hitPos.y, sph->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); } } else if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_18C = 0; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 5) { - this->unk_18C = 0x1E; - this->unk_3D8 = 0.5f; - this->unk_3D4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_SMALL; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; } if (this->unk_3E8 != 0) { @@ -1020,12 +1019,12 @@ void EnThiefbird_Update(Actor* thisx, GlobalContext* globalCtx2) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_3D4 > 0.0f) { - if (this->unk_18C != 10) { - Math_StepToF(&this->unk_3D4, 0.0f, 0.05f); - this->unk_3D8 = (this->unk_3D4 + 1.0f) * 0.25f; - this->unk_3D8 = CLAMP_MAX(this->unk_3D8, 0.5f); - } else if (!Math_StepToF(&this->unk_3DC, 0.5f, 0.0125f)) { + 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.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1099,11 +1098,11 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi idx = D_80C13698[limbIndex]; if (idx != -1) { if (idx == 9) { - Matrix_GetStateTranslationAndScaledX(1000.0f, &this->unk_350[idx]); + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[idx]); } else { - Matrix_GetStateTranslation(&this->unk_350[idx]); + Matrix_GetStateTranslation(&this->limbPos[idx]); if ((idx == 3) || (idx == 5)) { - Matrix_GetStateTranslationAndScaledX(2000.0f, &this->unk_350[idx + 1]); + Matrix_GetStateTranslationAndScaledX(2000.0f, &this->limbPos[idx + 1]); } } } @@ -1151,7 +1150,7 @@ void EnThiefbird_Draw(Actor* thisx, GlobalContext* globalCtx) { func_800AE5A0(globalCtx); } func_80C13354(this, globalCtx); - func_800BE680(globalCtx, &this->actor, this->unk_350, 11, this->unk_3D8, this->unk_3DC, this->unk_3D4, - this->unk_18C); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); Math_Vec3s_ToVec3f(&this->actor.focus.pos, &this->collider.elements[1].dim.worldSphere.center); } diff --git a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h index 5581f1155..990b4b2c5 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.h @@ -21,7 +21,7 @@ typedef struct EnThiefbird { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnThiefbirdActionFunc actionFunc; - /* 0x018C */ u8 unk_18C; + /* 0x018C */ u8 drawDmgEffType; /* 0x018E */ s16 unk_18E; /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; @@ -31,10 +31,10 @@ typedef struct EnThiefbird { /* 0x0208 */ Vec3s morphTable[17]; /* 0x0270 */ ColliderJntSph collider; /* 0x0290 */ ColliderJntSphElement colliderElements[3]; - /* 0x0350 */ Vec3f unk_350[11]; - /* 0x03D4 */ f32 unk_3D4; - /* 0x03D8 */ f32 unk_3D8; - /* 0x03DC */ f32 unk_3DC; + /* 0x0350 */ Vec3f limbPos[11]; + /* 0x03D4 */ f32 drawDmgEffAlpha; + /* 0x03D8 */ f32 drawDmgEffScale; + /* 0x03DC */ f32 drawDmgEffFrozenSteamScale; /* 0x03E0 */ f32 unk_3E0; /* 0x03E4 */ Gfx* unk_3E4; /* 0x03E8 */ Gfx* unk_3E8; 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 db71ae58d..cd0403c71 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 @@ -6,7 +6,7 @@ #include "z_en_time_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTimeTag*)thisx) 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 ba37818aa..7839e4585 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -7,7 +7,7 @@ #include "z_en_tite.h" #include "objects/object_tite/object_tite.h" -#define FLAGS 0x00000205 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_200) #define THIS ((EnTite*)thisx) @@ -161,7 +161,7 @@ void EnTite_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == ENTITE_MINUS_3) { this->actor.params = ENTITE_MINUS_2; this->unk_2BE = 240; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.shape.yOffset = -3000.0f; this->actor.shape.shadowDraw = NULL; func_80895A10(this); @@ -242,15 +242,15 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { u32 surface = func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((surface == COLPOLY_SURFACE_GROUND) || (surface == COLPOLY_SURFACE_SAND)) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800BBFB0(globalCtx, &this->unk_2D0[i], 1.0f, 2, 80, 15, 1); + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { + func_800BBFB0(globalCtx, &this->limbPos[i], 1.0f, 2, 80, 15, 1); } } else if (surface == COLPOLY_SURFACE_SNOW) { Vec3f* ptr; - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { + for (i = 5; i < ARRAY_COUNT(this->limbPos); i++) { for (j = 0; j < 2; j++) { - ptr = &this->unk_2D0[i]; + ptr = &this->limbPos[i]; sp7C.x = ptr->x + randPlusMinusPoint5Scaled(1.0f); sp7C.y = ptr->y + randPlusMinusPoint5Scaled(1.0f); sp7C.z = ptr->z + randPlusMinusPoint5Scaled(1.0f); @@ -264,23 +264,23 @@ void func_80893BCC(EnTite* this, GlobalContext* globalCtx) { } void func_80893DD4(EnTite* this) { - this->unk_2BB = 10; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider.base.colType = COLTYPE_HIT3; this->unk_2BC = 80; - this->unk_2C8 = 0.5f; - this->unk_2CC = 0.75f; - this->unk_2C4 = 1.0f; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffFrozenSteamScale = 0.75f; + this->drawDmgEffAlpha = 1.0f; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); - this->actor.flags &= ~0x200; + this->actor.flags &= ~ACTOR_FLAG_200; } void func_80893E54(EnTite* this, GlobalContext* globalCtx) { - if (this->unk_2BB == 10) { - this->unk_2BB = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider.base.colType = COLTYPE_HIT6; - this->unk_2C4 = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2D0, 9, 2, 0.2f, 0.2f); - this->actor.flags |= 0x200; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 9, 2, 0.2f, 0.2f); + this->actor.flags |= ACTOR_FLAG_200; } } @@ -350,7 +350,7 @@ void func_8089408C(EnTite* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.shape.shadowDraw = ActorShadow_DrawCircle; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.velocity.y = 10.0f; } else { this->actor.velocity.y = 8.0f; @@ -382,7 +382,7 @@ void func_808942B4(EnTite* this, GlobalContext* globalCtx) { } } } else if (!(this->collider.base.atFlags & AT_HIT)) { - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); } else { this->collider.base.atFlags &= ~AT_HIT; @@ -633,8 +633,8 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->collider.base.acFlags &= ~AC_ON; this->actor.colorFilterTimer = 0; SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EN_TEKU_DEAD); - this->actor.flags &= ~1; - this->actor.flags |= 0x10; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; this->unk_2BA = 1; Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, this->unk_2BE); this->unk_2BC = 25; @@ -643,8 +643,8 @@ void func_80895020(EnTite* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; ptr = &this->unk_33C[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { - Math_Vec3f_Diff(&this->unk_2D0[i], &this->actor.world.pos, &sp74); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++, ptr++) { + Math_Vec3f_Diff(&this->limbPos[i], &this->actor.world.pos, &sp74); temp_f0 = Math3D_Vec3fMagnitude(&sp74); if (temp_f0 > 1.0f) { temp_f0 = 1.2f / temp_f0; @@ -664,14 +664,14 @@ void func_808951B8(EnTite* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 4, 0x1000, 0x400); if (this->unk_2BC == 0) { - for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++) { - func_800B3030(globalCtx, &this->unk_2D0[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->unk_2D0[i], 11, NA_SE_EN_EXTINCT); + for (i = 0; i < ARRAY_COUNT(this->limbPos); i++) { + func_800B3030(globalCtx, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->limbPos[i], 11, NA_SE_EN_EXTINCT); } Actor_MarkForDeath(&this->actor); } else { for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { - Math_Vec3f_Sum(&this->unk_2D0[i], &this->unk_33C[i], &this->unk_2D0[i]); + Math_Vec3f_Sum(&this->limbPos[i], &this->unk_33C[i], &this->limbPos[i]); this->unk_33C[i].y += this->actor.gravity; } } @@ -778,7 +778,7 @@ void func_80895738(EnTite* this, GlobalContext* globalCtx) { } else if (this->unk_2BC > 0) { this->unk_2BC--; Math_StepToF(&this->actor.speedXZ, 10.0f, 0.3f); - this->actor.flags |= 0x1000000; + this->actor.flags |= ACTOR_FLAG_1000000; CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); if (!func_80893A34(this, globalCtx)) { this->unk_2BC = 0; @@ -921,7 +921,7 @@ void func_80895E28(EnTite* this, GlobalContext* globalCtx) { func_800B0DE0(globalCtx, &sp44, &sp38, &D_80896B44, &D_80896B3C, &D_80896B40, 500, 50); if (Math_StepToF(&this->actor.shape.yOffset, 0.0f, 200.0f)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.world.rot.y = this->actor.shape.rot.y; this->collider.base.acFlags |= AC_ON; func_808945EC(this); @@ -940,7 +940,8 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { Actor_SetDropFlag(&this->actor, &this->collider.info); - if ((this->unk_2BB != 10) || !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + !(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { func_80893E54(this, globalCtx); if (this->actor.shape.yOffset < 0.0f) { func_80895DE8(this); @@ -956,9 +957,9 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { this->unk_2BC = 40; Actor_SetColorFilter(&this->actor, 0, 200, 0, 40); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); - this->unk_2BB = 32; - this->unk_2C8 = 0.5f; - this->unk_2C4 = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + this->drawDmgEffScale = 0.5f; + this->drawDmgEffAlpha = 2.0f; func_80894DD0(this); return; } @@ -982,13 +983,13 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_2BB = 0; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_2BB = 0x14; - this->unk_2C4 = 4.0f; - this->unk_2C8 = 0.5f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.5f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1013,7 +1014,7 @@ void func_80895FF8(EnTite* this, GlobalContext* globalCtx) { } else if ((this->actor.bgCheckFlags & 1) && (this->collider.base.acFlags & AC_ON) && (this->actor.colChkInfo.health != 0) && (globalCtx->actorCtx.unk2 != 0) && (this->actor.xyzDistToPlayerSq < SQ(200.0f))) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; if (this->actor.shape.yOffset < 0.0f) { this->actor.shape.yOffset = 0.0f; this->actor.shape.shadowDraw = ActorShadow_DrawCircle; @@ -1031,8 +1032,8 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { Vec3f sp48; if (this->actor.bgCheckFlags & 0x40) { - for (i = 5; i < ARRAY_COUNT(this->unk_2D0); i++) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[i]); + 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(globalCtx, &sp48, 0, 220, 0); } @@ -1040,7 +1041,7 @@ void func_808963B4(EnTite* this, GlobalContext* globalCtx) { s32 temp = globalCtx->gameplayFrames & 7; if (!(temp & 1) && (this->actor.depthInWater < 10.0f)) { - Math_Vec3f_Copy(&sp48, &this->unk_2D0[5 + (temp >> 1)]); + Math_Vec3f_Copy(&sp48, &this->limbPos[5 + (temp >> 1)]); sp48.y = this->actor.world.pos.y + this->actor.depthInWater; EffectSsGRipple_Spawn(globalCtx, &sp48, 0, 220, 0); } @@ -1083,12 +1084,12 @@ void EnTite_Update(Actor* thisx, GlobalContext* globalCtx) { } CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - if (this->unk_2C4 > 0.0f) { - if (this->unk_2BB != 10) { - Math_StepToF(&this->unk_2C4, 0.0f, 0.05f); - this->unk_2C8 = (this->unk_2C4 + 1.0f) * 0.25f; - this->unk_2C8 = CLAMP_MAX(this->unk_2C8, 0.5f); - } else if (!Math_StepToF(&this->unk_2CC, 0.5f, 0.0125f)) { + 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.25f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.5f); + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.5f, 0.0125f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1120,14 +1121,14 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V if (this->unk_2BA == 0) { idx = D_80896B70[limbIndex]; if (idx != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[idx]); + Matrix_GetStateTranslation(&this->limbPos[idx]); if (idx >= 1) { - Matrix_GetStateTranslationAndScaledX(2500.0f, &this->unk_2D0[idx + 4]); + Matrix_GetStateTranslationAndScaledX(2500.0f, &this->limbPos[idx + 4]); } } } else if (this->unk_2BA > 0) { if (D_80896B8C[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2D0[D_80896B8C[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_80896B8C[limbIndex]]); } if (limbIndex == 24) { @@ -1137,9 +1138,9 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V OPEN_DISPS(globalCtx->state.gfxCtx); matrix = Matrix_GetCurrentState(); - matrix->wx = this->unk_2D0[D_80896B8C[limbIndex]].x; - matrix->wy = this->unk_2D0[D_80896B8C[limbIndex]].y; - matrix->wz = this->unk_2D0[D_80896B8C[limbIndex]].z; + matrix->wx = this->limbPos[D_80896B8C[limbIndex]].x; + matrix->wy = this->limbPos[D_80896B8C[limbIndex]].y; + matrix->wz = this->limbPos[D_80896B8C[limbIndex]].z; Matrix_InsertZRotation_s(this->actor.world.rot.z, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -1172,8 +1173,8 @@ void EnTite_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnTite_OverrideLimbDraw, EnTite_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2D0, ARRAY_COUNT(this->unk_2D0), this->unk_2C8, this->unk_2CC, - this->unk_2C4, this->unk_2BB); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), this->drawDmgEffScale, + this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, this->drawDmgEffType); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 91bbfc7c2..24f3bd630 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.h +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.h @@ -24,14 +24,14 @@ typedef struct EnTite { /* 0x02B8 */ u8 unk_2B8; /* 0x02B9 */ u8 unk_2B9; /* 0x02BA */ s8 unk_2BA; - /* 0x02BB */ u8 unk_2BB; + /* 0x02BB */ u8 drawDmgEffType; /* 0x02BC */ s16 unk_2BC; /* 0x02BE */ s16 unk_2BE; /* 0x02C0 */ s32 unk_2C0; - /* 0x02C4 */ f32 unk_2C4; - /* 0x02C8 */ f32 unk_2C8; - /* 0x02CC */ f32 unk_2CC; - /* 0x02D0 */ Vec3f unk_2D0[9]; + /* 0x02C4 */ f32 drawDmgEffAlpha; + /* 0x02C8 */ f32 drawDmgEffScale; + /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; + /* 0x02D0 */ Vec3f limbPos[9]; /* 0x033C */ Vec3f unk_33C[9]; /* 0x03A8 */ Gfx* unk_3A8; /* 0x03AC */ ColliderSphere collider; 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 f740a8029..9f9bed14c 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/object_tk/object_tk.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTk*)thisx) @@ -108,11 +108,11 @@ static u32 D_80AEF85C[] = { 0xFF000000, }; -static struct_80B8E1A8 D_80AEF868[] = { - { &object_tk_Anim_001FA8, 1.0f, 0, -10.0f }, { &object_tk_Anim_001FA8, 2.0f, 0, -10.0f }, - { &object_tk_Anim_0030A4, 1.0f, 0, -10.0f }, { &object_tk_Anim_001144, 1.0f, 2, -10.0f }, - { &object_tk_Anim_003724, 1.0f, 2, -10.0f }, { &object_tk_Anim_003FB8, 1.0f, 0, -10.0f }, - { &object_tk_Anim_0020C8, 1.0f, 0, -10.0f }, { &object_tk_Anim_003B10, 1.0f, 0, -10.0f }, +static AnimationSpeedInfo D_80AEF868[] = { + { &object_tk_Anim_001FA8, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_001FA8, 2.0f, ANIMMODE_LOOP, -10.0f }, + { &object_tk_Anim_0030A4, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_001144, 1.0f, ANIMMODE_ONCE, -10.0f }, + { &object_tk_Anim_003724, 1.0f, ANIMMODE_ONCE, -10.0f }, { &object_tk_Anim_003FB8, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &object_tk_Anim_0020C8, 1.0f, ANIMMODE_LOOP, -10.0f }, { &object_tk_Anim_003B10, 1.0f, ANIMMODE_LOOP, -10.0f }, }; static s32 D_80AEF8E8[2] = { 0, 0 }; @@ -218,7 +218,7 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_2B0 == 1) || (this->unk_2B0 == 3)) { - this->actor.flags &= ~(0x8 | 0x1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.update = func_80AEF2C8; this->actor.draw = NULL; return; @@ -246,9 +246,9 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.gravity = -1.0f; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags |= 0x10; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); - func_8013E3B8(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + 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)); switch (this->unk_2B0) { case 4: @@ -285,7 +285,7 @@ void EnTk_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80AECA3C(EnTk* this, GlobalContext* globalCtx) { this->unk_316 = 0; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AECA90; } @@ -303,7 +303,7 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; this->unk_3CC = 0xFF; this->unk_2DC = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->actionFunc = func_80AECB6C; } @@ -331,7 +331,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { } if (this->unk_2CA & 0x10) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); sp48 = 1.0f; sp44 = 22.0f; } else { @@ -359,9 +359,9 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { if (!temp4 && (this->unk_3CC != 0)) { this->actor.draw = NULL; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } else if (temp4 && (this->unk_3CC == 0)) { - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.draw = EnTk_Draw; } @@ -369,7 +369,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { func_80AECE0C(this, globalCtx); if (this->unk_3CE & 8) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.draw = NULL; } } @@ -383,7 +383,7 @@ void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { } s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { - EnDoor* sp4C4; + EnDoor* door; f32 spA0[265]; Vec3f sp94; Vec3f sp88; @@ -436,7 +436,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { this->unk_3D4 = sp7C; } - sp4C4 = NULL; + door = NULL; if (!(this->unk_2CA & 0xC00)) { door1 = NULL; label: @@ -447,7 +447,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; - sp4C4 = (EnDoor*)door1; + door = (EnDoor*)door1; break; } } @@ -460,7 +460,7 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); if (door2 != NULL) { if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { - sp4C4 = (EnDoor*)door2; + door = (EnDoor*)door2; break; } door2 = door2->next; @@ -468,19 +468,19 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { } while (door2 != NULL); } - if ((sp4C4 != NULL) && (this->unk_2CA & 0x400)) { + if ((door != NULL) && (this->unk_2CA & 0x400)) { Vec3f sp5C; - Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &sp4C4->actor.world.pos); - sp4C4->unk_1A7 = 2; + Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &door->dyna.actor.world.pos); + door->unk_1A7 = 2; if (sp5C.z < -20.0f) { this->unk_2CA &= ~0x400; this->unk_2CA |= 0x800; } } - if (sp4C4 != NULL) { - if ((this->unk_2CA & 0x800) && (sp4C4->unk_1A7 == 0)) { + if (door != NULL) { + if ((this->unk_2CA & 0x800) && (door->unk_1A7 == 0)) { this->unk_2CA &= ~0x800; } } @@ -507,7 +507,7 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar u16 phi_a1; s32 idx = arg2->unk0 - 1; - this->unk_3C8 = func_8013BB34(globalCtx, params, D_80AEF8E8[idx + 1]); + this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); if (this->unk_3C8 == 0) { return false; } @@ -529,44 +529,44 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } void func_80AED4F8(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AED610; } void func_80AED544(EnTk* this, GlobalContext* globalCtx) { if (!(gSaveContext.save.weekEventReg[31] & 0x10)) { - func_801518B0(globalCtx, 0x13FE, &this->actor); + Message_StartTextbox(globalCtx, 0x13FE, &this->actor); gSaveContext.save.weekEventReg[31] |= 0x10; } else if (gSaveContext.save.time < CLOCK_TIME(9, 0)) { - func_801518B0(globalCtx, 0x13FF, &this->actor); + Message_StartTextbox(globalCtx, 0x13FF, &this->actor); } else if (gSaveContext.save.time < CLOCK_TIME(12, 0)) { - func_801518B0(globalCtx, 0x1400, &this->actor); + Message_StartTextbox(globalCtx, 0x1400, &this->actor); } else if (gSaveContext.save.time < CLOCK_TIME(15, 0)) { - func_801518B0(globalCtx, 0x1401, &this->actor); + Message_StartTextbox(globalCtx, 0x1401, &this->actor); } else { - func_801518B0(globalCtx, 0x1402, &this->actor); + Message_StartTextbox(globalCtx, 0x1402, &this->actor); } } void func_80AED610(EnTk* this, GlobalContext* globalCtx) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } switch (Message_GetState(&globalCtx->msgCtx)) { case 0: if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer - 0x1555, 0x71C)) { if (Player_GetMask(globalCtx) == PLAYER_MASK_CAPTAIN) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); - func_801518B0(globalCtx, 0x13FD, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + Message_StartTextbox(globalCtx, 0x13FD, &this->actor); } else if (CURRENT_DAY != 2) { func_80AED544(this, globalCtx); } else if (!Flags_GetSwitch(globalCtx, ENTK_GET_7F0(&this->actor))) { - func_801518B0(globalCtx, 0x1403, &this->actor); + Message_StartTextbox(globalCtx, 0x1403, &this->actor); } else if (gSaveContext.save.weekEventReg[60] & 2) { func_80AED544(this, globalCtx); } else { - func_801518B0(globalCtx, 0x1413, &this->actor); + Message_StartTextbox(globalCtx, 0x1413, &this->actor); } break; } @@ -579,11 +579,11 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x13FD: this->unk_2CA |= 0x10; - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->skelAnime.playSpeed = 10.0f; this->actionFunc = func_80AECB6C; break; @@ -619,7 +619,7 @@ void func_80AED610(EnTk* this, GlobalContext* globalCtx) { case 0x1411: case 0x1412: default: - func_8013E1C8(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 0, &this->unk_2D4); this->actionFunc = func_80AECB6C; break; } @@ -633,10 +633,10 @@ void func_80AED898(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; if (this->unk_2CA & 0x1000) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } this->actionFunc = func_80AED940; } @@ -666,7 +666,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { } if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } if (!(this->unk_2CA & 0x40)) { @@ -689,7 +689,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->unk_2CA &= ~0x80; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; globalCtx->msgCtx.msgMode = 0; globalCtx->msgCtx.unk11F10 = 0; func_80AEDE10(this, globalCtx); @@ -706,12 +706,13 @@ void func_80AEDBEC(EnTk* this, GlobalContext* globalCtx) { this->actor.params = -1; this->unk_2E8 = 0; this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->actionFunc = func_80AEDC4C; } void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { - if ((this->actor.params >= 0) && func_8013E2D4(&this->actor, this->cutscenes[1], this->actor.params, 0)) { + 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(globalCtx, 0x1411); func_80AEDCBC(this, globalCtx); @@ -720,7 +721,7 @@ void func_80AEDC4C(EnTk* this, GlobalContext* globalCtx) { void func_80AEDCBC(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 10.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 5, &this->unk_2D4); + 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); Math_Vec3s_Copy(&this->actor.world.rot, &this->unk_2F8); @@ -739,8 +740,8 @@ void func_80AEDD4C(EnTk* this, GlobalContext* globalCtx) { void func_80AEDDA0(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); - this->actor.flags |= 0x10000; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + this->actor.flags |= ACTOR_FLAG_10000; this->unk_2CA |= 0x80; this->actionFunc = func_80AED940; } @@ -768,13 +769,13 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { break; case 4: - func_801518B0(globalCtx, 0x140F, &this->actor); - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + Message_StartTextbox(globalCtx, 0x140F, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; case 3: - func_801518B0(globalCtx, 0x1410, &this->actor); - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + Message_StartTextbox(globalCtx, 0x1410, &this->actor); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); break; } break; @@ -789,7 +790,7 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { if ((this->unk_2D4 == 4) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 7, &this->unk_2D4); } switch (Message_GetState(&globalCtx->msgCtx)) { @@ -805,16 +806,16 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { !Math_SmoothStepToS(&this->unk_31C, 0, 3, 0x71C, 10) && (this->actor.shape.rot.y == (s16)(this->actor.yawTowardsPlayer - 0x1555))) { if (this->unk_2E6 == 0x1404) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 4, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } - func_801518B0(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); } break; case 0x1414: - func_801518B0(globalCtx, this->unk_2E6, &this->actor); + Message_StartTextbox(globalCtx, this->unk_2E6, &this->actor); break; } break; @@ -827,8 +828,8 @@ void func_80AEDF5C(EnTk* this, GlobalContext* globalCtx) { case 4: case 5: case 6: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1404: this->unk_2CA |= 0x1000; func_80AED898(this, globalCtx); @@ -899,7 +900,7 @@ void func_80AEE2A8(EnTk* this, GlobalContext* globalCtx) { } void func_80AEE2C0(EnTk* this, GlobalContext* globalCtx) { - if (func_8013E2D4(&this->actor, this->cutscenes[0], 0x7C, 0)) { + if (SubS_StartActorCutscene(&this->actor, this->cutscenes[0], 0x7C, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { func_80AEE374(this, globalCtx); } } @@ -943,7 +944,7 @@ void func_80AEE414(EnTk* this, GlobalContext* globalCtx) { void func_80AEE478(EnTk* this, GlobalContext* globalCtx) { this->unk_310 = 2; - func_8013E1C8(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 3, &this->unk_2D4); this->actionFunc = func_80AEE4D0; } @@ -995,12 +996,12 @@ void func_80AEE6B8(EnTk* this, GlobalContext* globalCtx) { ActorCutscene_Stop(this->cutscenes[0]); func_801477B4(globalCtx); func_80AEDBEC(this, globalCtx); - } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 3; func_80AEDE10(this, globalCtx); this->unk_2CA &= ~0x20; } - } else if (func_8013E2D4(&this->actor, 0x7C, this->cutscenes[0], 0)) { + } else if (SubS_StartActorCutscene(&this->actor, 0x7C, this->cutscenes[0], SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { this->unk_310 = 4; func_80AEDE10(this, globalCtx); } @@ -1042,7 +1043,7 @@ s32 func_80AEE86C(EnTk* this, GlobalContext* globalCtx) { (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)) && - !func_801690CC(globalCtx)) { + !Play_InCsMode(globalCtx)) { Math_Vec3f_Copy(&this->unk_300, &sp28); ret = true; } @@ -1136,7 +1137,7 @@ void func_80AEEB88(EnTk* this, GlobalContext* globalCtx) { } this->unk_2C6 = 100; - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); this->unk_30C = func_80AEED38; } @@ -1177,9 +1178,9 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { } if (this->unk_2CA & 0x200) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp64); } @@ -1188,15 +1189,15 @@ void func_80AEED38(EnTk* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; } - if (!Message_GetState(&globalCtx->msgCtx) && !func_801690CC(globalCtx) && (this->unk_2C6-- <= 0)) { - func_801518B0(globalCtx, 0x140C, NULL); + if (Message_GetState(&globalCtx->msgCtx) == 0 && !Play_InCsMode(globalCtx) && (this->unk_2C6-- <= 0)) { + Message_StartTextbox(globalCtx, 0x140C, NULL); this->unk_2CA |= 0x4000; this->unk_2C6 = 200; } } void func_80AEF048(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); this->unk_30C = func_80AEF094; } @@ -1204,9 +1205,9 @@ void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { f32 sp2C; if (this->unk_2CA & 0x200) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); } else { - func_8013E1C8(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 1, &this->unk_2D4); func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &this->actor.speedXZ, &sp2C); } @@ -1218,7 +1219,7 @@ void func_80AEF094(EnTk* this, GlobalContext* globalCtx) { void func_80AEF15C(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF1B4; } @@ -1226,7 +1227,7 @@ void func_80AEF1B4(EnTk* this, GlobalContext* globalCtx) { } void func_80AEF1C4(EnTk* this, GlobalContext* globalCtx) { - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF210; } @@ -1235,7 +1236,7 @@ void func_80AEF210(EnTk* this, GlobalContext* globalCtx) { void func_80AEF220(EnTk* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; - func_8013E1C8(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, D_80AEF868, 2, &this->unk_2D4); this->unk_30C = func_80AEF278; } diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.c b/src/overlays/actors/ovl_En_Torch/z_en_torch.c index b5c891af0..fc06cff18 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.c +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.c @@ -21,7 +21,7 @@ static u8 sChestContents[] = { 0x02, 0x04, 0x05, 0x06, 0x36, 0x3A, 0x14, 0x14 }; void EnTorch_Init(Actor* thisx, GlobalContext* globalCtx) { EnTorch* this = THIS; - s8 returnData = gSaveContext.respawn[3].data; + s8 returnData = gSaveContext.respawn[RESPAWN_MODE_UNK_3].data; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOX, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 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 50ff93937..c6931fac5 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -7,7 +7,7 @@ #include "z_en_torch2.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTorch2*)thisx) @@ -32,9 +32,22 @@ const ActorInit En_Torch2_InitVars = { }; static ColliderCylinderInit sCylinderInit = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1 | OC1_TYPE_2, - OC2_TYPE_2, COLSHAPE_CYLINDER }, - { ELEMTYPE_UNK2, { 0x00100000, 0, 0 }, { 0xF7CFFFFF, 0, 0 }, TOUCH_NONE, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON }, + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1 | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0, 0 }, + { 0xF7CFFFFF, 0, 0 }, + TOUCH_NONE, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 60, 0, { 0, 0, 0 } }, }; @@ -62,9 +75,9 @@ void EnTorch2_Init(Actor* thisx, GlobalContext* globalCtx) { // params: which form Link is in (e.g. human, deku, etc.) params = this->actor.params; if (params != TORCH2_PARAM_DEKU) { - this->actor.flags |= 0x4000000; // Can press switch + this->actor.flags |= ACTOR_FLAG_4000000; // Can press switch if (params == TORCH2_PARAM_GORON) { - this->actor.flags |= 0x20000; // Can press heavy switches + this->actor.flags |= ACTOR_FLAG_20000; // Can press heavy switches } } this->framesUntilNextState = 20; @@ -74,7 +87,8 @@ void EnTorch2_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnTorch2* this = THIS; Collider_DestroyCylinder(globalCtx, &this->collider); - func_80169DCC(globalCtx, this->actor.params + 3, 0xFF, 0, 0xBFF, &this->actor.world.pos, this->actor.shape.rot.y); + Play_SetRespawnData(&globalCtx->state, this->actor.params + RESPAWN_MODE_GORON - 1, 0xFF, 0, 0xBFF, + &this->actor.world.pos, this->actor.shape.rot.y); globalCtx->actorCtx.unk254[this->actor.params] = 0; } @@ -146,10 +160,9 @@ void EnTorch2_UpdateDeath(Actor* thisx, GlobalContext* globalCtx) { } } -void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_Draw(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; EnTorch2* this = THIS; - - GlobalContext* unused = globalCtx; Gfx* gfx = sShellDLists[thisx->params]; OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h index 70e5cd7cf..744a7975c 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h @@ -14,19 +14,19 @@ typedef struct EnTorch2 { } EnTorch2; // size = 0x194 typedef enum { - TORCH2_PARAM_HUMAN, - TORCH2_PARAM_GORON, - TORCH2_PARAM_ZORA, - TORCH2_PARAM_DEKU, - TORCH2_PARAM_FIERCE_DEITY, + /* 0 */ TORCH2_PARAM_HUMAN, + /* 1 */ TORCH2_PARAM_GORON, + /* 2 */ TORCH2_PARAM_ZORA, + /* 3 */ TORCH2_PARAM_DEKU, + /* 4 */ TORCH2_PARAM_FIERCE_DEITY, } EnTorch2Param; typedef enum { - TORCH2_STATE_INITIALIZED, - TORCH2_STATE_FADING_IN, - TORCH2_STATE_SOLID, - TORCH2_STATE_IDLE, - TORCH2_STATE_DYING, + /* 0 */ TORCH2_STATE_INITIALIZED, + /* 1 */ TORCH2_STATE_FADING_IN, + /* 2 */ TORCH2_STATE_SOLID, + /* 3 */ TORCH2_STATE_IDLE, + /* 4 */ TORCH2_STATE_DYING, } EnTorch2State; extern const ActorInit En_Torch2_InitVars; 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 8ca0e45dd..f12baac71 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -7,7 +7,7 @@ #include "z_en_toto.h" #include "objects/object_zm/object_zm.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnToto*)thisx) @@ -184,14 +184,15 @@ void EnToto_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->actor, sInitChain); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - if (globalCtx->sceneNum == 0x15 && (gSaveContext.save.time >= 0x4000 && gSaveContext.save.time < 0xE555)) { + if (globalCtx->sceneNum == SCENE_MILK_BAR && + (gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < CLOCK_TIME(21, 30))) { Actor_MarkForDeath(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zm_Skel_00A978, - ((globalCtx->sceneNum == 0x12) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), + ((globalCtx->sceneNum == SCENE_SONCHONOIE) ? &object_zm_Anim_003AA8 : &object_zm_Anim_00C880), this->jointTable, this->morphTable, 18); func_80BA36C0(this, globalCtx, 0); this->actor.shape.rot.x = 0; @@ -206,7 +207,7 @@ void EnToto_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime) && this->actionFuncIndex == 1 && this->skelAnime.animation != &object_zm_Anim_000C80) { - if (globalCtx->msgCtx.unk11F04 != 0x2A98 && globalCtx->msgCtx.unk11F04 != 0x2A99) { + if (globalCtx->msgCtx.currentTextId != 0x2A98 && globalCtx->msgCtx.currentTextId != 0x2A99) { if (this->unk2B4 & 1 || Rand_ZeroOne() > 0.5f) { this->unk2B4 = (this->unk2B4 + 1) & 3; } @@ -219,7 +220,7 @@ void func_80BA383C(EnToto* this, GlobalContext* globalCtx) { void func_80BA3930(EnToto* this, GlobalContext* globalCtx) { AnimationHeader* animationHeader = &object_zm_Anim_00C880; - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { animationHeader = &object_zm_Anim_003AA8; } Animation_MorphToLoop(&this->skelAnime, animationHeader, -4.0f); @@ -241,7 +242,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { func_80BA383C(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { func_80BA36C0(this, globalCtx, 1); - if (globalCtx->sceneNum != 0x12) { + if (globalCtx->sceneNum != SCENE_SONCHONOIE) { Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); } else if (player->transformation == PLAYER_FORM_DEKU) { Flags_SetSwitch(globalCtx, this->actor.home.rot.x); @@ -250,16 +251,18 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { return; } - if ((globalCtx->sceneNum == 0x15 && !(gSaveContext.save.time >= 0x4000 && gSaveContext.save.time < 0xED02)) || - (globalCtx->sceneNum != 0x15 && func_80BA397C(this, 0x2000))) { + //! @TODO: 0xED02 nor 0xED01 match CLOCK_TIME macro + if ((globalCtx->sceneNum == SCENE_MILK_BAR && + !(gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < 0xED02)) || + (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { if (this->unk2B6 != 0) { this->text = D_80BA5044; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, EXCH_ITEM_NONE); } else { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 50.0f); - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { if (player->transformation == PLAYER_FORM_DEKU) { if (!Flags_GetSwitch(globalCtx, this->actor.home.rot.x)) { this->text = D_80BA5068; @@ -283,7 +286,7 @@ void func_80BA39C8(EnToto* this, GlobalContext* globalCtx) { } void func_80BA3BFC(EnToto* this, GlobalContext* globalCtx) { - if (globalCtx->sceneNum == 0x12) { + if (globalCtx->sceneNum == SCENE_SONCHONOIE) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_000C80, -4.0f); this->unk2B4 = 0; } else { @@ -379,7 +382,7 @@ s32 func_80BA3FB0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA3FCC(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { - func_801518B0(globalCtx, this->text->textId, NULL); + Message_StartTextbox(globalCtx, this->text->textId, NULL); return 1; } return 0; @@ -405,7 +408,7 @@ s32 func_80BA407C(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA40D4(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { return 1; } return 0; @@ -419,7 +422,7 @@ s32 func_80BA4128(EnToto* this, GlobalContext* globalCtx) { } s32 func_80BA415C(EnToto* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 4 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 4 && Message_ShouldAdvance(globalCtx)) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F230(); } else { @@ -436,7 +439,7 @@ s32 func_80BA4204(EnToto* this, GlobalContext* globalCtx) { if (DECR(this->unk2B1) == 0) { if (!ENTOTO_WEEK_EVENT_FLAGS) { temp_v1_2 = &D_80BA50DC[gSaveContext.save.playerForm - 1]; - func_801518B0(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); + Message_StartTextbox(globalCtx, (this->text->unk0 == 6) ? temp_v1_2->unk0 : temp_v1_2->unk4, NULL); } return 1; } @@ -503,7 +506,6 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); EnTotoUnkStruct2* temp_s0; s32 i; - u16 tmp; func_80BA3C88(this); if (player->actor.world.pos.z > -270.0f) { @@ -527,8 +529,8 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { if (this->unk2B1 < 10) { this->unk2B1++; if (this->unk2B1 >= 10) { - tmp = gSaveContext.save.playerForm; // Needed for regalloc possible FAKE MATCH - func_801518B0(globalCtx, D_80BA50DC[tmp - 1].unk2, NULL); + Message_StartTextbox(globalCtx, + D_80BA50DC[((void)0, gSaveContext.save.playerForm) - 1].unk2, NULL); } } return 0; @@ -674,11 +676,10 @@ s32 func_80BA4C44(EnToto* this, GlobalContext* globalCtx) { } void func_80BA4CB4(EnToto* this, GlobalContext* globalCtx) { - CsCmdActorAction* action; + CsCmdActorAction* action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 525)]; - action = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x20D)]; - if (this->unk2B5 != action->unk0) { - this->unk2B5 = action->unk0; + if (this->unk2B5 != action->action) { + this->unk2B5 = action->action; if (this->unk2B5 != 4) { if (this->unk2B5 == 3) { Animation_MorphToPlayOnce(&this->skelAnime, &object_zm_Anim_001DF0, -4.0f); @@ -707,7 +708,7 @@ void EnToto_Update(Actor* thisx, GlobalContext* globalCtx) { EnToto* this = THIS; s32 pad; - if (func_800EE29C(globalCtx, 0x20D)) { + if (Cutscene_CheckActorAction(globalCtx, 0x20D)) { func_80BA4CB4(this, globalCtx); } else { D_80BA51B8[this->actionFuncIndex](this, globalCtx); 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 e36dae75a..4499948dc 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.c +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.c @@ -8,7 +8,7 @@ #include "objects/object_trt/object_trt.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnTrt*)thisx) @@ -22,11 +22,11 @@ void EnTrt_Update(Actor* thisx, GlobalContext* globalCtx); void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx); void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx); -s32 EnTrt_ReturnItemToShelf(EnTrt* this); void EnTrt_ResetItemPosition(EnTrt* this); +void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); +s32 EnTrt_ReturnItemToShelf(EnTrt* this); s32 EnTrt_FacingShopkeeperDialogResult(EnTrt* this, GlobalContext* globalCtx); s32 EnTrt_TakeItemOffShelf(EnTrt* this); -void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx); void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx); void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx); @@ -64,12 +64,17 @@ void EnTrt_Blink(EnTrt* this); void EnTrt_OpenEyes2(EnTrt* this); void EnTrt_NodOff(EnTrt* this); -static ActorAnimationEntryS sAnimations[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00EE98, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_0030EC, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00D52C, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_001EF4, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_002CB0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt_InitVars = { @@ -92,17 +97,17 @@ static ShopItem sShop[] = { { SI_POTION_BLUE, { -12, 32, -36 } }, }; -void EnTrt_ChangeAnim(SkelAnime* skelAnime, ActorAnimationEntryS* animations, s32 idx) { +void EnTrt_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animations, s32 idx) { f32 frameCount; animations += idx; if (animations->frameCount < 0) { - frameCount = Animation_GetLastFrame(animations->animationSeg); + frameCount = Animation_GetLastFrame(animations->animation); } else { frameCount = animations->frameCount; } - Animation_Change(skelAnime, animations->animationSeg, animations->playbackSpeed, animations->frame, frameCount, - animations->mode, animations->transitionRate); + Animation_Change(skelAnime, animations->animation, animations->playSpeed, animations->startFrame, frameCount, + animations->mode, animations->morphFrames); } s32 EnTrt_TestItemSelected(GlobalContext* globalCtx) { @@ -184,7 +189,7 @@ u16 EnTrt_GetItemTextId(EnTrt* this) { u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { EnGirlA* item = this->items[this->cursorIdx]; - if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.save.weekEventReg[0x35] & 0x10)) { + if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.save.weekEventReg[53] & 0x10)) { this->textId = 0x881; return 0x881; } @@ -307,7 +312,7 @@ void EnTrt_Hello(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } - if (talkState == 5 && func_80147624(globalCtx)) { + if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { play_sound(NA_SE_SY_MESSAGE_PASS); if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { EnTrt_StartShopping(globalCtx, this); @@ -325,17 +330,17 @@ void EnTrt_GetMushroom(EnTrt* this, GlobalContext* globalCtx) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { player->stateFlags2 &= ~0x20000000; } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x883: this->textId = 0x884; - func_801518B0(globalCtx, this->textId, &this->actor); - gSaveContext.save.weekEventReg[0x35] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[53] |= 8; func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); break; case 0x888: this->textId = 0x889; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); break; case 0x889: if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { @@ -365,7 +370,7 @@ void EnTrt_PayForMushroom(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x886: this->textId = 0x887; @@ -380,9 +385,9 @@ void EnTrt_Goodbye(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x88F) { - if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[0xC] & 0x10)) { + if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -393,32 +398,32 @@ void EnTrt_SetupTryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.save.weekEventReg[0x55] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[85] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { - if (gSaveContext.save.weekEventReg[0xC] & 8) { + if (gSaveContext.save.weekEventReg[12] & 8) { this->textId = 0x83D; EnTrt_SetupStartShopping(globalCtx, this, 0); - } else if (gSaveContext.save.weekEventReg[0x54] & 0x40) { + } else if (gSaveContext.save.weekEventReg[84] & 0x40) { this->textId = 0x83B; if (Inventory_HasItemInBottle(ITEM_POTION_RED)) { EnTrt_SetupStartShopping(globalCtx, this, false); } else { this->actionFunc = EnTrt_TryToGiveRedPotion; } - } else if (gSaveContext.save.weekEventReg[0x10] & 0x10) { + } else if (gSaveContext.save.weekEventReg[16] & 0x10) { this->timer = 30; this->textId = 0x838; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; this->actionFunc = EnTrt_Surprised; return; - } else if (gSaveContext.save.weekEventReg[0x11] & 1) { + } else if (gSaveContext.save.weekEventReg[17] & 1) { this->textId = 0x835; EnTrt_SetupStartShopping(globalCtx, this, false); } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } } } @@ -428,13 +433,13 @@ void EnTrt_GiveRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; - if (!(gSaveContext.save.weekEventReg[0xC] & 0x10)) { - gSaveContext.save.weekEventReg[0xC] |= 0x10; + if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { + gSaveContext.save.weekEventReg[12] |= 0x10; } - gSaveContext.save.weekEventReg[0x54] |= 0x40; + gSaveContext.save.weekEventReg[84] |= 0x40; player->stateFlags2 &= ~0x20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; - } else if (gSaveContext.save.weekEventReg[0xC] & 0x10) { + } else if (gSaveContext.save.weekEventReg[12] & 0x10) { Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); } else { Actor_PickUp(&this->actor, globalCtx, GI_BOTTLE_POTION_RED, 300.0f, 300.0f); @@ -445,7 +450,7 @@ void EnTrt_GivenRedPotionForKoume(EnTrt* this, GlobalContext* globalCtx) { //! @bug: player is set to NULL not PLAYER Player* player = NULL; - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); @@ -470,11 +475,11 @@ void EnTrt_EndConversation(EnTrt* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } else if (talkState == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -516,7 +521,7 @@ void EnTrt_FaceShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } else if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); if (!EnTrt_TestEndInteraction(this, globalCtx, CONTROLLER1(globalCtx))) { - if ((!func_80147624(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && + if ((!Message_ShouldAdvance(globalCtx) || !EnTrt_FacingShopkeeperDialogResult(this, globalCtx)) && (this->stickAccumX > 0)) { cursorIdx = EnTrt_SetCursorIndexFromNeutral(this, 2); if (cursorIdx != CURSOR_INVALID) { @@ -702,7 +707,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { if (EnTrt_TakeItemOffShelf(this)) { if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && func_80147624(globalCtx)) { + if (!EnTrt_TestCancelOption(this, globalCtx, CONTROLLER1(globalCtx)) && Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: EnTrt_HandleCanBuyItem(globalCtx, this); @@ -714,7 +719,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { break; } } - } else if (talkState == 5 && func_80147624(globalCtx)) { + } else if (talkState == 5 && Message_ShouldAdvance(globalCtx)) { if (!Inventory_HasEmptyBottle()) { play_sound(NA_SE_SY_ERROR); EnTrt_SetupCannotBuy(globalCtx, this, 0x846); @@ -727,7 +732,7 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; item->boughtFunc(globalCtx, item); - gSaveContext.save.weekEventReg[0x35] |= 0x10; + gSaveContext.save.weekEventReg[53] |= 0x10; } } } @@ -736,14 +741,14 @@ void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - if ((gSaveContext.save.weekEventReg[0x55] & 8) && !(gSaveContext.save.weekEventReg[0x54] & 0x40)) { + if ((gSaveContext.save.weekEventReg[85] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { this->textId = 0x88F; } else if (!(this->flags & ENTRT_MET)) { this->textId = 0x834; } else { this->textId = 0x83E; } - if (!(gSaveContext.save.weekEventReg[0x35] & 8)) { + if (!(gSaveContext.save.weekEventReg[53] & 8)) { this->talkOptionTextId = 0x845; } else if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->talkOptionTextId = 0x882; @@ -781,7 +786,7 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = 40; EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 1); - this->animationIdx = 1; + this->animationIndex = 1; this->actionFunc = EnTrt_IdleAwake; this->blinkFunc = EnTrt_OpenThenCloseEyes; } @@ -827,7 +832,7 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(150, 100); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 2); - this->animationIdx = 2; + this->animationIndex = 2; this->sleepSoundTimer = 10; this->actor.textId = 0; this->actionFunc = EnTrt_IdleSleeping; @@ -847,10 +852,10 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); } } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - if (this->animationIdx != 5) { + if (this->animationIndex != 5) { if (curFrame == animLastFrame) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 3); - this->animationIdx = 3; + this->animationIndex = 3; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -864,12 +869,12 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); - func_801518B0(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->animationIndex = 5; switch (this->textId) { case 0x834: - if (!(gSaveContext.save.weekEventReg[0xC] & 8) && !(gSaveContext.save.weekEventReg[0x54] & 0x40) && - !(gSaveContext.save.weekEventReg[0x10] & 0x10) && !(gSaveContext.save.weekEventReg[0x11] & 1)) { + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + !(gSaveContext.save.weekEventReg[16] & 0x10) && !(gSaveContext.save.weekEventReg[17] & 1)) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; @@ -906,7 +911,7 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } else if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { if (DECR(this->timer) == 0) { EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 4); - this->animationIdx = 4; + this->animationIndex = 4; this->blinkFunc = EnTrt_OpenEyes2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; @@ -915,8 +920,8 @@ void EnTrt_Surprised(EnTrt* this, GlobalContext* globalCtx) { } else if (DECR(this->timer) == 0) { this->timer = Rand_S16Offset(40, 20); EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 5); - func_801518B0(globalCtx, this->textId, &this->actor); - this->animationIdx = 5; + Message_StartTextbox(globalCtx, this->textId, &this->actor); + this->animationIndex = 5; this->actionFunc = EnTrt_TryToGiveRedPotionAfterSurprised; } } @@ -925,8 +930,8 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt u8 talkState = Message_GetState(&globalCtx->msgCtx); this->blinkFunc = EnTrt_Blink; - if (talkState == 6 && func_80147624(globalCtx)) { - if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[0xC] & 0x10)) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { + if (Inventory_HasEmptyBottle() || !(gSaveContext.save.weekEventReg[12] & 0x10)) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; @@ -935,15 +940,15 @@ void EnTrt_TryToGiveRedPotionAfterSurprised(EnTrt* this, GlobalContext* globalCt } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.save.weekEventReg[0x55] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[85] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } } void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { if (this->textId == 0x83C) { if (Inventory_HasEmptyBottle()) { if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING) { @@ -956,13 +961,13 @@ void EnTrt_TryToGiveRedPotion(EnTrt* this, GlobalContext* globalCtx) { } else { this->tmpTextId = this->textId; this->textId = 0x88E; - gSaveContext.save.weekEventReg[0x55] |= 8; - func_801518B0(globalCtx, this->textId, &this->actor); + gSaveContext.save.weekEventReg[85] |= 8; + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { this->textId = 0x83C; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } } } @@ -1010,7 +1015,7 @@ void EnTrt_ItemGiven(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupEndInteraction(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { EnTrt_EndInteraction(globalCtx, this); } } @@ -1020,15 +1025,15 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); } else { if ((player->actor.world.pos.x >= -50.0f && player->actor.world.pos.x <= 50.0f) && (player->actor.world.pos.z >= -19.0f && player->actor.world.pos.z <= 30.0f)) { func_800B8614(&this->actor, globalCtx, 200.0f); } } - if (talkState == 6 && func_80147624(globalCtx)) { - if (gSaveContext.save.weekEventReg[0x14] & 2) { + if (talkState == 6 && Message_ShouldAdvance(globalCtx)) { + if (gSaveContext.save.weekEventReg[20] & 2) { globalCtx->nextEntranceIndex = 0xC50; } else { globalCtx->nextEntranceIndex = 0x8450; @@ -1040,7 +1045,7 @@ void EnTrt_ShopkeeperGone(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = this->tmpActionFunc; func_80151938(globalCtx, EnTrt_GetItemTextId(this)); } @@ -1049,7 +1054,7 @@ void EnTrt_CannotBuy(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_CanBuy(EnTrt* this, GlobalContext* globalCtx) { EnGirlA* item; - if (Message_GetState(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx)) { this->shopItemSelectedTween = 0.0f; EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; @@ -1069,7 +1074,7 @@ void EnTrt_BuyItemWithFanfare(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_SetupItemGiven(EnTrt* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { this->actionFunc = EnTrt_ItemGiven; if (this->cutsceneState == ENTRT_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -1089,7 +1094,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { if (talkState == 4) { Interface_SetDoAction(globalCtx, DO_ACTION_DECIDE); - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1099,7 +1104,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { func_8019F208(); player->actor.shape.rot.y = BINANG_ROT180(player->actor.shape.rot.y); player->stateFlags2 |= 0x20000000; - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); EnTrt_SetupStartShopping(globalCtx, this, true); func_800B85E0(&this->actor, globalCtx, 400.0f, EXCH_ITEM_MINUS1); break; @@ -1112,7 +1117,7 @@ void EnTrt_ContinueShopping(EnTrt* this, GlobalContext* globalCtx) { } } } else if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { EnTrt_ResetItemPosition(this); item = this->items[this->cursorIdx]; item->restockFunc(globalCtx, item); @@ -1216,10 +1221,7 @@ void EnTrt_UpdateCursorAnim(EnTrt* this) { void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { f32 arrowAnimTween = this->arrowAnimTween; f32 stickAnimTween = this->stickAnimTween; - - // Possbily fake temps - s32 maxColor = 255; - f32 tmp; + s32 maxColor = 255; // POSSIBLY FAKE if (this->arrowAnimState == 0) { arrowAnimTween += 0.05f; @@ -1246,31 +1248,33 @@ void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { stickAnimTween = 0.0f; this->stickAnimState = 0; } - - tmp = 155.0f * arrowAnimTween; - this->stickAnimTween = stickAnimTween; this->stickLeftPrompt.arrowColor.r = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.g = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); - this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100, arrowAnimTween); + this->stickLeftPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickLeftPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowColor.r = (maxColor - ((s32)tmp)) & 0xFF; - this->stickRightPrompt.arrowColor.g = (255 - ((s32)tmp)) & 0xFF; + this->stickRightPrompt.arrowTexX = 290.0f; + + this->stickRightPrompt.arrowColor.r = COL_CHAN_MIX(maxColor, 155.0f, arrowAnimTween); + this->stickRightPrompt.arrowColor.g = COL_CHAN_MIX(255, 155.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.b = COL_CHAN_MIX(0, -100.0f, arrowAnimTween); this->stickRightPrompt.arrowColor.a = COL_CHAN_MIX(200, 50.0f, arrowAnimTween); - this->stickRightPrompt.arrowTexX = 290.0f; this->stickLeftPrompt.arrowTexX = 33.0f; this->stickRightPrompt.stickTexX = 274.0f; this->stickRightPrompt.stickTexX += 8.0f * stickAnimTween; + this->stickLeftPrompt.stickTexX = 49.0f; this->stickLeftPrompt.stickTexX -= 8.0f * stickAnimTween; - this->stickLeftPrompt.arrowTexY = this->stickRightPrompt.arrowTexY = 91.0f; - this->stickLeftPrompt.stickTexY = this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + + this->stickRightPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.stickTexY = 95.0f; } void EnTrt_OpenEyes(EnTrt* this) { @@ -1358,7 +1362,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { s32 itemGiven; if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { func_80151938(globalCtx, 0xFF); } else { @@ -1369,7 +1373,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { itemGiven = func_80123810(globalCtx); if (itemGiven > EXCH_ITEM_NONE) { if (itemGiven == EXCH_ITEM_1E) { - if (gSaveContext.save.weekEventReg[0x35] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; @@ -1393,7 +1397,7 @@ void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } else { this->textId = 0x886; } - func_801518B0(globalCtx, this->textId, &this->actor); + Message_StartTextbox(globalCtx, this->textId, &this->actor); this->actionFunc = EnTrt_Goodbye; } } @@ -1438,7 +1442,7 @@ void EnTrt_LookToShopkeeperFromShelf(EnTrt* this, GlobalContext* globalCtx) { void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_trt_Skel_00FEF0, &object_trt_Anim_00FD34, NULL, NULL, 0); - if (!(gSaveContext.save.weekEventReg[0xC] & 8) && !(gSaveContext.save.weekEventReg[0x54] & 0x40) && + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && gSaveContext.save.day >= 2) { this->actor.draw = NULL; } else { @@ -1447,9 +1451,6 @@ void EnTrt_InitShopkeeper(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { - u32 maxcolor = 255; - EnTrt* this2; - EnTrt_GetCutscenes(this, globalCtx); this->cutscene = this->lookForwardCutscene; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); @@ -1457,7 +1458,7 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->actor.colChkInfo.cylRadius = 50; this->timer = Rand_S16Offset(40, 20); - if (!(gSaveContext.save.weekEventReg[0xC] & 8) && !(gSaveContext.save.weekEventReg[0x54] & 0x40) && + if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && gSaveContext.save.day >= 2) { this->textId = 0x84A; this->actionFunc = EnTrt_ShopkeeperGone; @@ -1467,58 +1468,55 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_IdleSleeping; } + this->cursorPos.y = this->cursorPos.x = 100.0f; this->stickAccumY = 0; this->stickAccumX = 0; + this->cursorIdx = 0; - this->cursorPos.y = this->cursorPos.x = 100.0f; this->cursorPos.z = 1.2f; this->cursorColor.r = 0; this->cursorColor.g = 80; - this->cursorColor.b = maxcolor; - this->cursorColor.a = maxcolor; + this->cursorColor.b = 255; + this->cursorColor.a = 255; this->cursorAnimTween = 0.0f; this->cursorAnimState = 0; this->drawCursor = 0; - this2 = this; - this->stickLeftPrompt.stickColor.r = 200; - this2->stickLeftPrompt.stickColor.g = 200; - this2->stickLeftPrompt.stickColor.b = 200; - this2->stickLeftPrompt.stickColor.a = 180; - this2->stickLeftPrompt.stickTexX = 49.0f; - this2->stickLeftPrompt.stickTexY = 95.0f; - this2->stickLeftPrompt.arrowColor.r = maxcolor; - this2->stickLeftPrompt.arrowColor.g = maxcolor; - this2->stickLeftPrompt.arrowColor.b = 0; - this2->stickLeftPrompt.arrowColor.a = 200; - this2->stickLeftPrompt.arrowTexX = 33.0f; - this2->stickLeftPrompt.arrowTexY = 91.0f; - this2->stickLeftPrompt.texZ = 1.0f; - this2->stickLeftPrompt.isEnabled = false; + this->stickLeftPrompt.stickColor.g = 200; + this->stickLeftPrompt.stickColor.b = 200; + this->stickLeftPrompt.stickColor.a = 180; + this->stickLeftPrompt.stickTexX = 49.0f; + this->stickLeftPrompt.stickTexY = 95.0f; + this->stickLeftPrompt.arrowColor.r = 255; + this->stickLeftPrompt.arrowColor.g = 255; + this->stickLeftPrompt.arrowColor.b = 0; + this->stickLeftPrompt.arrowColor.a = 200; + this->stickLeftPrompt.arrowTexX = 33.0f; + this->stickLeftPrompt.arrowTexY = 91.0f; + this->stickLeftPrompt.texZ = 1.0f; + this->stickLeftPrompt.isEnabled = false; - if (1) {} + this->stickRightPrompt.stickColor.r = 200; + this->stickRightPrompt.stickColor.g = 200; + this->stickRightPrompt.stickColor.b = 200; + this->stickRightPrompt.stickColor.a = 180; + this->stickRightPrompt.stickTexX = 274.0f; + this->stickRightPrompt.stickTexY = 95.0f; + this->stickRightPrompt.arrowColor.r = 255; + this->stickRightPrompt.arrowColor.g = 0; + this->stickRightPrompt.arrowColor.b = 0; + this->stickRightPrompt.arrowColor.a = 200; + this->stickRightPrompt.arrowTexX = 290.0f; + this->stickRightPrompt.arrowTexY = 91.0f; + this->stickRightPrompt.texZ = 1.0f; + this->stickRightPrompt.isEnabled = false; - this2->stickRightPrompt.stickColor.r = 200; - this2->stickRightPrompt.stickColor.g = 200; - this2->stickRightPrompt.stickColor.b = 200; - this2->stickRightPrompt.stickColor.a = 180; - this2->stickRightPrompt.stickTexX = 274.0f; - this2->stickRightPrompt.stickTexY = 95.0f; - this2->stickRightPrompt.arrowColor.r = maxcolor; - this2->stickRightPrompt.arrowColor.g = 0; - this2->stickRightPrompt.arrowColor.b = 0; - this2->stickRightPrompt.arrowColor.a = 200; - this2->stickRightPrompt.arrowTexX = 290.0f; - this2->stickRightPrompt.arrowTexY = 91.0f; - this2->stickRightPrompt.texZ = 1.0f; - this2->stickRightPrompt.isEnabled = false; - - this2->arrowAnimTween = 0.0f; - this2->stickAnimTween = 0.0f; - this2->arrowAnimState = 0; - this2->stickAnimState = 0; - this2->shopItemSelectedTween = 0.0f; + this->arrowAnimTween = 0.0f; + this->stickAnimTween = 0.0f; + this->arrowAnimState = 0; + this->stickAnimState = 0; + this->shopItemSelectedTween = 0.0f; this->actor.gravity = 0.0f; Actor_SetScale(&this->actor, sActorScale); @@ -1526,11 +1524,11 @@ void EnTrt_InitShop(EnTrt* this, GlobalContext* globalCtx) { this->blinkTimer = 20; this->eyeTextureIdx = 0; this->blinkFunc = EnTrt_EyesClosed; - if (gSaveContext.save.weekEventReg[0x35] & 8) { + if (gSaveContext.save.weekEventReg[53] & 8) { this->flags |= ENTRT_GIVEN_MUSHROOM; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; } void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { @@ -1541,7 +1539,10 @@ void EnTrt_GetCutscenes(EnTrt* this, GlobalContext* globalCtx) { } void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z, u8 drawCursor) { - s32 ulx, uly, lrx, lry; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; f32 w; s32 dsdx; s32 pad; @@ -1551,8 +1552,8 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z func_8012C654(globalCtx->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, this->cursorColor.r, this->cursorColor.g, this->cursorColor.b, this->cursorColor.a); - gDPLoadTextureBlock_4b(OVERLAY_DISP++, gameplay_keep_Tex_01F740, G_IM_FMT_IA, 16, 16, 0, - G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gSelectionCursorTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); w = 16.0f * z; ulx = (x - w) * 4.0f; uly = (y - w + -12.0f) * 4.0f; @@ -1567,11 +1568,16 @@ void EnTrt_DrawCursor(GlobalContext* globalCtx, EnTrt* this, f32 x, f32 y, f32 z void EnTrt_DrawTextRec(GlobalContext* globalCtx, s32 r, s32 g, s32 b, s32 a, f32 x, f32 y, f32 z, s32 s, s32 t, f32 dx, f32 dy) { f32 unk; - s32 ulx, uly, lrx, lry; - f32 w, h; - s32 dsdx, dtdy; + s32 ulx; + s32 uly; + s32 lrx; + s32 lry; + f32 w; + f32 h; + s32 dsdx; + s32 dtdy; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); @@ -1597,21 +1603,15 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { s32 drawStickRightPrompt = this->stickLeftPrompt.isEnabled; s32 drawStickLeftPrompt = this->stickRightPrompt.isEnabled; - ((void)"../z_en_trt.c"); // Unreferenced + (void)"../z_en_trt.c"; OPEN_DISPS(globalCtx->state.gfxCtx); if (drawStickRightPrompt || drawStickLeftPrompt) { func_8012C654(globalCtx->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F8C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 191, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 23 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.arrowColor.r, this->stickLeftPrompt.arrowColor.g, this->stickLeftPrompt.arrowColor.b, this->stickLeftPrompt.arrowColor.a, @@ -1624,15 +1624,9 @@ void EnTrt_DrawStickDirectionPrompt(GlobalContext* globalCtx, EnTrt* this) { this->stickRightPrompt.arrowTexX, this->stickRightPrompt.arrowTexY, this->stickRightPrompt.texZ, 0, 0, 1.0f, 1.0f); } - gDPSetTextureImage(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, gameplay_keep_Tex_01F7C0); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPLoadSync(OVERLAY_DISP++); - gDPLoadBlock(OVERLAY_DISP++, G_TX_LOADTILE, 0, 0, 127, 1024); - gDPPipeSync(OVERLAY_DISP++); - gDPSetTile(OVERLAY_DISP++, G_IM_FMT_IA, G_IM_SIZ_8b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOLOD); - gDPSetTileSize(OVERLAY_DISP++, G_TX_RENDERTILE, 0, 0, 15 * 4, 15 * 4); + gDPLoadTextureBlock(OVERLAY_DISP++, gControlStickTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); if (drawStickRightPrompt) { EnTrt_DrawTextRec(globalCtx, this->stickLeftPrompt.stickColor.r, this->stickLeftPrompt.stickColor.g, this->stickLeftPrompt.stickColor.b, this->stickLeftPrompt.stickColor.a, 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 2df343dfc..eb243317b 100644 --- a/src/overlays/actors/ovl_En_Trt/z_en_trt.h +++ b/src/overlays/actors/ovl_En_Trt/z_en_trt.h @@ -41,7 +41,7 @@ typedef struct EnTrt { /* 0x3F0 */ Color_RGBAu32 cursorColor; /* 0x400 */ u8 drawCursor; /* 0x402 */ s16 timer; - /* 0x404 */ s16 animationIdx; + /* 0x404 */ s16 animationIndex; /* 0x406 */ u16 textId; /* 0x408 */ u16 tmpTextId; /* 0x40A */ u16 talkOptionTextId; 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 5ef7eddc7..8ed15ca3d 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -26,12 +26,17 @@ void func_80AD4FE4(EnTrt2* this, GlobalContext* globalCtx); void func_80AD5234(EnTrt2* this, GlobalContext* globalCtx); void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx); -static ActorAnimationEntryS sAnimations[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00EE98, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_0030EC, 1.0f, 0, -1, 2, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, 2, 0 }, { &object_trt_Anim_00D52C, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_001EF4, 1.0f, 0, -1, 0, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, 0, 0 }, { &object_trt_Anim_002CB0, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS sAnimations[] = { + { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; const ActorInit En_Trt2_InitVars = { @@ -103,18 +108,18 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -void func_80AD3380(SkelAnime* skelAnime, ActorAnimationEntryS* animation, s32 arg2) { +void func_80AD3380(SkelAnime* skelAnime, AnimationInfoS* animation, s32 arg2) { f32 phi_f0; animation += arg2; if (animation->frameCount < 0) { - phi_f0 = Animation_GetLastFrame(animation->animationSeg); + phi_f0 = Animation_GetLastFrame(animation->animation); } else { phi_f0 = animation->frameCount; } - Animation_Change(skelAnime, animation->animationSeg, animation->playbackSpeed, animation->frame, phi_f0, - animation->mode, animation->transitionRate); + Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f0, + animation->mode, animation->morphFrames); } void func_80AD341C(EnTrt2* this, GlobalContext* globalCtx) { @@ -198,7 +203,7 @@ void func_80AD36EC(EnTrt2* this, GlobalContext* globalCtx) { this->unk_1E4 = 0; this->unk_3D9 = 1; this->actor.velocity.y = 0.0f; - this->path = func_8013D648(globalCtx, this->path->unk1, -1); + this->path = SubS_GetPathByIndex(globalCtx, this->path->unk1, -1); ActorCutscene_Stop(this->unk_3DA); this->unk_3DA = ActorCutscene_GetAdditionalCutscene(this->unk_3DA); ActorCutscene_SetIntentToPlay(this->unk_3DA); @@ -325,9 +330,9 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { func_80AD46F8(this); if (this->unk_3D8) { - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3D8 = false; - } else if ((sp27 == 5) && func_80147624(globalCtx)) { + } else if ((sp27 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80AD3380(&this->skelAnime, sAnimations, 6); @@ -337,7 +342,7 @@ void func_80AD3CEC(EnTrt2* this, GlobalContext* globalCtx) { void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); if (this->unk_3A8 == 0x838) { this->unk_3B2 = 11; @@ -354,7 +359,7 @@ void func_80AD3DA4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (Inventory_HasEmptyBottle()) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; @@ -362,7 +367,7 @@ void func_80AD3E34(EnTrt2* this, GlobalContext* globalCtx) { } else { gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } @@ -372,18 +377,18 @@ void func_80AD3EF0(EnTrt2* this, GlobalContext* globalCtx) { u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); if (temp_v0 == 6) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { if ((Inventory_HasEmptyBottle() && !(gSaveContext.save.weekEventReg[84] & 0x40)) || !(gSaveContext.save.weekEventReg[12] & 0x10)) { this->unk_3B2 = 12; } else { gSaveContext.save.weekEventReg[85] |= 0x10; this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); this->unk_3B2 = 10; } } - } else if ((temp_v0 == 5) && func_80147624(globalCtx)) { + } else if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; this->unk_3B2 = 12; @@ -406,7 +411,7 @@ void func_80AD3FF4(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD40AC(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 6) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { func_800B85E0(&this->actor, globalCtx, 400.0f, -1); this->unk_3B2 = 13; } @@ -423,7 +428,7 @@ void func_80AD4110(EnTrt2* this, GlobalContext* globalCtx) { } void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { if (this->unk_3A8 == 0x84B) { func_80AD349C(this); func_80AD3DA4(this, globalCtx); @@ -432,11 +437,11 @@ void func_80AD417C(EnTrt2* this, GlobalContext* globalCtx) { globalCtx->msgCtx.unk12023 = 4; if (this->unk_3A8 == 0x84C) { func_80AD3380(&this->skelAnime, sAnimations, 6); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3B2 = 18; } else if (this->unk_3A8 == 0x88F) { this->unk_3A8 = 0x88E; - func_801518B0(globalCtx, this->unk_3A8, &this->actor); + Message_StartTextbox(globalCtx, this->unk_3A8, &this->actor); } else { this->actor.textId = 0; this->unk_3B2 = 15; @@ -509,7 +514,7 @@ void func_80AD4550(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B2 = 17; } - if ((sp23 == 5) && func_80147624(globalCtx)) { + if ((sp23 == 5) && Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; } @@ -703,7 +708,7 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_10; Actor_SetObjectDependency(globalCtx, &this->actor); Actor_SetScale(&this->actor, 0.008f); - this->path = func_8013D648(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(globalCtx, ENTRT2_GET_FC00(&this->actor), 0x3F); this->unk_3AE = Rand_S16Offset(100, 50); this->unk_3B0 = 10; this->unk_3A8 = 0; @@ -899,7 +904,7 @@ void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } } -void EnTrt2_UnkDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTrt2_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { EnTrt2* this = THIS; if (limbIndex == 21) { @@ -929,7 +934,7 @@ void func_80AD56E8(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnTrt2_OverrideLimbDraw, EnTrt2_PostLimbDraw, - EnTrt2_UnkDraw, &this->actor); + EnTrt2_TransformLimbDraw, &this->actor); CLOSE_DISPS(globalCtx->state.gfxCtx); } 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 2541301c5..ea0e8ae44 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -7,7 +7,7 @@ #include "z_en_tru.h" #include "objects/object_tru/object_tru.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTru*)thisx) @@ -106,15 +106,23 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 20, 0, 0, MASS_IMMOVABLE }; -static ActorAnimationEntryS D_80A8B2D8[] = { - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_00F9A0, 1.0f, 0, -1, 0, -4 }, - { &object_tru_Anim_0108AC, 1.0f, 0, -1, 2, -4 }, { &object_tru_Anim_009348, 1.0f, 0, -1, 2, 0 }, - { &object_tru_Anim_00EEDC, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_015CA0, 1.0f, 0, -1, 0, 0 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_014728, 1.0f, 0, -1, 2, 0 }, - { &object_tru_Anim_01B5C4, 1.0f, 0, -1, 2, 0 }, { &object_tru_Anim_007FA0, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_016B4C, 1.0f, 0, -1, 0, -4 }, { &object_tru_Anim_011F88, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_003698, 1.0f, 0, -1, 2, -4 }, - { &object_tru_Anim_002BD8, 1.0f, 0, -1, 0, 0 }, { &object_tru_Anim_00446C, 1.0f, 0, -1, 0, 0 }, +static AnimationInfoS D_80A8B2D8[] = { + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static Vec3f D_80A8B3D8 = { 0.0f, 24.0f, 16.0f }; @@ -418,7 +426,7 @@ s32 func_80A86924(EnTru* this, s32 arg1) { if (arg1 != this->unk_37C) { this->unk_37C = arg1; - ret = func_8013BC6C(&this->skelAnime, D_80A8B2D8, arg1); + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A8B2D8, arg1); this->unk_358 = this->skelAnime.playSpeed; } @@ -679,7 +687,7 @@ s32 func_80A872AC(EnTru* this, GlobalContext* globalCtx) { this->unk_390 = 0; this->unk_364 = 0; this->unk_354 = func_80A871E0(this, globalCtx); - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); this->actionFunc = func_80A881E0; ret = true; } @@ -714,8 +722,8 @@ s32 func_80A87400(EnTru* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 30.0f, 0.2f, 1000.0f); if (this->path != NULL) { - sp4C = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); - if (func_8013BD40(&this->actor, this->path, this->unk_384)) { + sp4C = Lib_SegmentedToVirtual(this->path->points); + if (SubS_HasReachedPoint(&this->actor, this->path, this->unk_384)) { if (this->unk_384 > this->unk_384 + 1) { this->unk_384 = this->path->count - 2; ret = true; @@ -799,42 +807,33 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { } s32 func_80A8777C(Actor* thisx, GlobalContext* globalCtx) { - s32 temp_v0; + EnTru* this = THIS; s32 ret = 0; - - temp_v0 = Message_GetState(&globalCtx->msgCtx); + s32 temp_v0 = Message_GetState(&globalCtx->msgCtx); switch (temp_v0) { - default: - if (temp_v0 != 0x10) { - break; - } - if (0) { - - case 4: - case 5: - if (!func_80147624(globalCtx)) { - break; + case 4: + case 5: + if (Message_ShouldAdvance(globalCtx)) { + case 16: + temp_v0 = func_80123810(globalCtx); + if ((temp_v0 == 35) || (temp_v0 == 36)) { + this->unk_34E |= 8; + if (temp_v0 == 35) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (temp_v0 < 0) { + ret = 3; + } else if (temp_v0 != 0) { + ret = 2; } + break; } - - temp_v0 = func_80123810(globalCtx); - if ((temp_v0 == 35) || (temp_v0 == 36)) { - ((EnTru*)thisx)->unk_34E |= 8; - if (temp_v0 == 35) { - ((EnTru*)thisx)->unk_390 = 1; - } else { - ((EnTru*)thisx)->unk_390 = 2; - } - ((EnTru*)thisx)->unk_378 = func_80A87880; - ((EnTru*)thisx)->unk_364 = 0; - ret = 1; - } else if (temp_v0 < 0) { - ret = 3; - } else if (temp_v0 != 0) { - ret = 2; - } - break; } return ret; @@ -931,12 +930,12 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { case 1: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - sp3E = BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx))); + sp3E = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); Math_Vec3f_Copy(&sp4C, &gZeroVec3f); sp4C.z = 40.0f; Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, sp3E, &sp4C, &sp40); func_80A85620(this->unk_394, &sp40, 2.0f, 0.08f, 60.0f); - func_8016A268(globalCtx, 1, 160, 160, 160, 0); + func_8016A268(&globalCtx->state, 1, 160, 160, 160, 0); this->unk_370 = 20; this->unk_372 = 10; this->unk_364++; @@ -1027,7 +1026,7 @@ s32 func_80A87DC0(Actor* thisx, GlobalContext* globalCtx) { } if (ret == true) { - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->actor.draw = NULL; this->unk_378 = NULL; this->unk_34E = 0; @@ -1040,15 +1039,15 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { if (this->actor.draw != NULL) { if ((this->unk_34E & 0x80) || (gSaveContext.save.weekEventReg[16] & 0x10)) { if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } } else if (this->unk_34E & 0x40) { if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } if ((this->unk_37C == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -1062,13 +1061,13 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { } } else if (!(gSaveContext.save.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && (this->actor.xzDistToPlayer < 140.0f)) { - func_8013AED4(&this->unk_34E, 4, 7); + SubS_UpdateFlags(&this->unk_34E, 4, 7); this->unk_34E |= 0x1040; this->unk_362 = Rand_S16Offset(40, 20); } else if (func_80A873B8(this)) { - func_8013AED4(&this->unk_34E, 3, 7); + SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); } } } @@ -1094,11 +1093,11 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { func_80A86924(this, 6); } - func_8013AED4(&this->unk_34E, 0, 7); + SubS_UpdateFlags(&this->unk_34E, 0, 7); this->unk_34E &= ~(0x1000 | 0x8); this->unk_34E |= 0x10; this->actor.shape.rot.y = this->actor.world.rot.y; - this->actor.flags &= ~0x100; + this->actor.flags &= ~ACTOR_FLAG_100; this->unk_1E8 = 0; this->actionFunc = func_80A87FD0; } @@ -1119,7 +1118,7 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); this->unk_37C = -1; func_80A86924(this, 0); - this->path = func_8013BEDC(globalCtx, this->actor.params & 0xFF, 255, &this->unk_384); + this->path = SubS_GetDayDependentPath(globalCtx, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } 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 4127fcdff..d1090cec4 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -8,6 +8,8 @@ struct EnTru; typedef void (*EnTruActionFunc)(struct EnTru*, GlobalContext*); typedef s32 (*EnTruUnkFunc)(Actor*, GlobalContext*); +#define ENTRU_GET_PATH(thisx) ((thisx)->params & 0xFF) + typedef struct { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 unk_01; 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 2d956d494..e191cc3cd 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 @@ -5,8 +5,9 @@ */ #include "z_en_tru_mt.h" +#include "overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnTruMt*)thisx) @@ -19,7 +20,6 @@ void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx); void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx); void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, ACTORCAT_NPC, @@ -32,15 +32,27 @@ const ActorInit En_Tru_Mt_InitVars = { (ActorFunc)EnTruMt_Draw, }; -// static ColliderSphereInit sSphereInit = { -static ColliderSphereInit D_80B77510 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_SPHERE, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderSphereInit sSphereInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_SPHERE, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 22 }, 100 }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B7753C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0x0), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -75,58 +87,492 @@ static DamageTable D_80B7753C = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -#endif +static AnimationInfoS D_80B7755C[] = { + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderSphereInit D_80B77510; -extern DamageTable D_80B7753C; +Vec3f D_80B7765C = { 3000.0f, -800.0f, 0.0f }; -extern UNK_TYPE D_060004C8; -extern UNK_TYPE D_0601AA60; +Vec3f D_80B77668 = { 0.0f, 0.0f, -3000.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76030.s") +s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { + s16 endFrame; + s16 startFrame; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76110.s") + if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B7755C))) { + endFrame = D_80B7755C[arg1].frameCount; + if (endFrame < 0) { + endFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76188.s") + startFrame = D_80B7755C[arg1].startFrame; + if (startFrame < 0) { + startFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B761FC.s") + Animation_Change(skelAnime, D_80B7755C[arg1].animation, D_80B7755C[arg1].playSpeed, startFrame, endFrame, + D_80B7755C[arg1].mode, D_80B7755C[arg1].morphFrames); + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76368.s") +void func_80B76110(EnTruMt* this) { + if (DECR(this->unk_34E) == 0) { + this->unk_34C++; + if (this->unk_34C >= 3) { + this->unk_34E = Rand_S16Offset(30, 30); + this->unk_34C = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B763C4.s") +void func_80B76188(EnTruMt* this) { + this->unk_38E.x = Math_CosS(this->unk_38A) * this->unk_38C; + this->unk_38A += 0x1555; + Math_SmoothStepToS(&this->unk_38C, 0, 4, 0x3E8, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76440.s") +s32 func_80B761FC(EnTruMt* this, GlobalContext* globalCtx) { + this->collider.dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.dim.worldSphere.center.y = this->actor.world.pos.y + 16.0f; + this->collider.dim.worldSphere.center.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76540.s") + if ((this->collider.base.acFlags & AC_HIT) && (this->actor.colChkInfo.damageEffect == 0xF)) { + if (!(((EnJcMato*)this->actor.child)->collider.base.acFlags & AC_HIT) && + (this->actor.child->colChkInfo.damageEffect != 0xF)) { + this->collider.base.acFlags &= ~AC_HIT; + if (this->unk_3A4 == 0) { + this->unk_3A4 = 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE); + } else { + this->unk_3A4 = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DAMAGE2); + } + globalCtx->interfaceCtx.unk_25E = 1; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); + return true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76600.s") + if (this->unk_38C >= 0xB7) { + func_80B76188(this); + } else { + this->unk_38E.x = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B7679C.s") + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B768F0.s") +s32 func_80B76368(EnTruMt* this, GlobalContext* globalCtx) { + Actor* bgActor = globalCtx->actorCtx.actorLists[ACTORCAT_BG].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76924.s") + while (bgActor != NULL) { + if (bgActor->id == ACTOR_BG_INGATE) { + this->unk_394 = bgActor->shape.rot.y; + this->unk_398 = bgActor->world.pos; + return true; + } + bgActor = bgActor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76980.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76A64.s") +s32 func_80B763C4(EnTruMt* this, GlobalContext* globalCtx) { + Actor* foundActor; + Actor* actor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76BB8.s") + while (true) { + foundActor = SubS_FindActor(globalCtx, actor, ACTORCAT_NPC, ACTOR_EN_TRU_MT); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76C38.s") + if (foundActor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Init.s") + if ((EnTruMt*)foundActor != this) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Destroy.s") + foundActor = foundActor->next; + if (foundActor == NULL) { + break; + } + actor = foundActor; + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Update.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B76ED4.s") +void func_80B76440(EnTruMt* this, GlobalContext* globalCtx) { + if (func_80B76368(this, globalCtx)) { + s16 temp_v1 = this->unk_394 - Math_Vec3f_Yaw(&this->unk_398, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77008.s") + if ((temp_v1 <= -0x2000) || (temp_v1 >= 0x2000)) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer < 300.0f) { + Math_ApproachF(&this->actor.speedXZ, 7.0f, 0.2f, 1.0f); + } else if (this->actor.xzDistToPlayer > 500.0f) { + Math_ApproachF(&this->actor.speedXZ, 2.5f, 0.2f, 1.0f); + } else { + Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 1.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77078.s") +f32 func_80B76540(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { + s32 pad; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/func_80B77354.s") + if (path != NULL) { + Vec3s* temp_v1 = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru_Mt/EnTruMt_Draw.s") + temp_v1 = &temp_v1[arg1]; + sp20.x = temp_v1->x; + sp20.y = temp_v1->y; + sp20.z = temp_v1->z; + } + arg3->y = Math_Vec3f_Yaw(arg2, &sp20); + arg3->x = Math_Vec3f_Pitch(arg2, &sp20); + + return sp20.y - arg2->y; +} + +s32 func_80B76600(EnTruMt* this, Path* path, s32 arg2) { + Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); + s32 sp58 = path->count; + s32 idx = arg2; + s32 sp50 = false; + f32 phi_f12; + f32 phi_f14; + f32 sp44; + f32 sp40; + f32 sp3C; + Vec3f sp30; + + Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); + + if (idx == 0) { + phi_f12 = sp5C[1].x - sp5C[0].x; + phi_f14 = sp5C[1].z - sp5C[0].z; + } else if (idx == (sp58 - 1)) { + phi_f12 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; + phi_f14 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; + } else { + phi_f12 = sp5C[idx + 1].x - sp5C[idx - 1].x; + 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); + if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { + sp50 = true; + } + + return sp50; +} + +void func_80B7679C(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f sp40; + Vec3f sp34; + + Math_SmoothStepToS(&this->unk_34A, (this->actor.yawTowardsPlayer - this->actor.shape.rot.y) - 0x4000, 4, 0x38E0, 1); + this->unk_34A = CLAMP(this->unk_34A, -0x38E0, 0x38E0); + + sp40 = player->actor.world.pos; + sp40.y = player->bodyPartsPos[7].y + 3.0f; + + sp34 = this->actor.world.pos; + sp34.y += 30.0f; + + Math_SmoothStepToS(&this->unk_348, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x1C70, 1); + this->unk_348 = CLAMP(this->unk_348, -0x1C70, 0x1C70); +} + +s32 func_80B768F0(EnTruMt* this, GlobalContext* globalCtx) { + if (this->unk_328 & 0x10) { + func_80B7679C(this, globalCtx); + } + return true; +} + +void func_80B76924(EnTruMt* this) { + this->unk_38E.z = Math_SinS(this->unk_388) * 30.0f * (0x10000 / 360.0f); + this->unk_388 += 0x400; +} + +void func_80B76980(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (gSaveContext.unk_3F3C >= 10) { + Message_StartTextbox(globalCtx, 0x87F, &this->actor); + gSaveContext.eventInf[3] |= 0x40; + gSaveContext.eventInf[4] |= 1; + player->stateFlags3 &= ~0x400; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_80B76BB8; + } else if (gSaveContext.eventInf[4] & 1) { + 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); + gSaveContext.eventInf[3] |= 0x80; + } + } +} + +void func_80B76A64(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3s sp34; + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; + + if (this->path != NULL) { + func_80B76540(this->path, this->unk_36C, &this->actor.world.pos, &sp34); + Math_SmoothStepToS(&this->actor.world.rot.y, sp34.y, 4, 0x3E8, 1); + this->actor.shape.rot.y = this->actor.world.rot.y; + Math_SmoothStepToS(&this->actor.shape.rot.x, sp34.x, 4, 0x3E8, 1); + + this->actor.world.rot.x = -this->actor.shape.rot.x; + this->actor.shape.rot.z = CLAMP(this->actor.world.rot.y, -0x1770, 0x1770); + this->actor.world.rot.z = this->actor.shape.rot.z; + + 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; + return; + } + this->unk_36C++; + } + func_80B76440(this, globalCtx); + } +} + +void func_80B76BB8(EnTruMt* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 5) { + if (Message_ShouldAdvance(globalCtx)) { + globalCtx->nextEntranceIndex = 0xA810; + globalCtx->unk_1887F = 3; + gSaveContext.nextTransition = 3; + globalCtx->sceneLoadFlag = 0x14; + } + } +} + +void func_80B76C38(EnTruMt* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80B76924(this); + func_80B76980(this, globalCtx); + player->stateFlags3 |= 0x400; +} + +void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTruMt* this = THIS; + + if (!(gSaveContext.eventInf[3] & 0x20)) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (func_80B763C4(this, globalCtx)) { + Actor_MarkForDeath(&this->actor); + return; + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, + OBJECT_TRU_LIMB_MAX); + + Collider_InitSphere(globalCtx, &this->collider); + Collider_SetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit); + + this->collider.dim.worldSphere.radius = 22; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FF(&this->actor), 0x3F); + this->actor.targetMode = 0; + + Actor_SetScale(&this->actor, 0.008f); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + this->unk_328 = 0; + this->actor.room = -1; + this->path = SubS_GetPathByIndex(globalCtx, ENTRUMT_GET_FC00(&this->actor), 0x3F); + func_80B76030(&this->skelAnime, 14); + this->actionFunc = func_80B76A64; +} + +void EnTruMt_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + Collider_DestroySphere(globalCtx, &this->collider); +} + +void EnTruMt_Update(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + + func_80B768F0(this, globalCtx); + SkelAnime_Update(&this->skelAnime); + + this->actionFunc(this, globalCtx); + + func_80B76110(this); + Actor_SetFocus(&this->actor, 34.0f); + + if (!(gSaveContext.eventInf[4] & 1)) { + func_80B761FC(this, globalCtx); + } + + Actor_MoveWithoutGravity(&this->actor); +} + +void func_80B76ED4(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4) { + Vec3f sp7C; + Vec3f sp70 = gZeroVec3f; + Vec3s sp68; + MtxF sp28; + + Matrix_MultiplyVector3fByState(&sp70, &sp7C); + Matrix_CopyCurrentState(&sp28); + func_8018219C(&sp28, &sp68, 0); + + *arg2 = sp7C; + + if (arg4 != 0) { + sp68.x += arg0; + sp68.y += arg1; + Math_SmoothStepToS(&arg3->x, sp68.x, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->y, sp68.y, 4, 0x1FFE, 1); + Math_SmoothStepToS(&arg3->z, sp68.z, 4, 0x1FFE, 1); + } else { + arg3->x = sp68.x; + arg3->y = sp68.y; + arg3->z = sp68.z; + } +} + +s32 EnTruMt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->unk_35C); + } + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_MultiplyVector3fByState(&D_80B7765C, &this->unk_350); + } + return false; +} + +void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnTruMt* this = THIS; + MtxF* sp54; + s32 phi_v0; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + if (this->unk_328 & 0x10) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } + func_80B76ED4(this->unk_348, this->unk_34A, &this->unk_33C, &this->unk_336, phi_v0); + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + } + + if (limbIndex == OBJECT_TRU_LIMB_0E) { + func_8012C28C(globalCtx->state.gfxCtx); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_MultiplyVector3fByState(&D_80B77668, &this->unk_370); + Matrix_InsertTranslation(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_38E.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_38E.x, MTXMODE_APPLY); + Matrix_Scale(0.008f, 0.008f, 0.008f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + sp54 = Matrix_GetCurrentState(); + if ((this->actor.child == NULL) || (this->actor.child->update == NULL)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->wx, sp54->wy, + sp54->wz, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + this->unk_38E.z, -1); + } else if (!((EnJcMato*)this->actor.child)->hitFlag) { + this->actor.child->world.pos.x = sp54->wx; + this->actor.child->world.pos.y = sp54->wy; + this->actor.child->world.pos.z = sp54->wz; + + this->actor.child->world.rot = this->unk_38E; + this->actor.child->world.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + + this->actor.child->shape.rot = this->actor.child->world.rot; + } + } +} + +void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnTruMt* this = THIS; + + if (limbIndex == OBJECT_TRU_LIMB_15) { + Matrix_InsertTranslation(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateY(this->unk_336.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_336.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->unk_336.z, MTXMODE_APPLY); + } +} + +void EnTruMt_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnTruMt* this = THIS; + TexturePtr sp48[] = { + object_tru_Tex_018FA0, + object_tru_Tex_0197A0, + object_tru_Tex_019FA0, + }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sp48[this->unk_34C])); + + SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnTruMt_OverrideLimbDraw, EnTruMt_PostLimbDraw, + EnTruMt_TransformLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h index 793958ed7..049c11ecd 100644 --- a/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h +++ b/src/overlays/actors/ovl_En_Tru_Mt/z_en_tru_mt.h @@ -2,15 +2,43 @@ #define Z_EN_TRU_MT_H #include "global.h" +#include "objects/object_tru/object_tru.h" struct EnTruMt; typedef void (*EnTruMtActionFunc)(struct EnTruMt*, GlobalContext*); +#define ENTRUMT_GET_FF(thisx) ((thisx)->params & 0xFF) +#define ENTRUMT_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) + typedef struct EnTruMt { /* 0x0000 */ Actor actor; /* 0x0144 */ EnTruMtActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x260]; + /* 0x0148 */ SkelAnime skelAnime; + /* 0x018C */ ColliderSphere collider; + /* 0x01E4 */ Vec3s jointTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0286 */ Vec3s morphTable[OBJECT_TRU_LIMB_MAX]; + /* 0x0328 */ u16 unk_328; + /* 0x032A */ UNK_TYPE1 unk32A[0xC]; + /* 0x0336 */ Vec3s unk_336; + /* 0x033C */ Vec3f unk_33C; + /* 0x0348 */ s16 unk_348; + /* 0x034A */ s16 unk_34A; + /* 0x034C */ s16 unk_34C; + /* 0x034E */ s16 unk_34E; + /* 0x0350 */ Vec3f unk_350; + /* 0x035C */ Vec3f unk_35C; + /* 0x0368 */ Path* path; + /* 0x036C */ s32 unk_36C; + /* 0x0370 */ Vec3f unk_370; + /* 0x037C */ UNK_TYPE1 unk37C[0xC]; + /* 0x0388 */ s16 unk_388; + /* 0x038A */ s16 unk_38A; + /* 0x038C */ s16 unk_38C; + /* 0x038E */ Vec3s unk_38E; + /* 0x0394 */ s16 unk_394; + /* 0x0398 */ Vec3f unk_398; + /* 0x03A4 */ u8 unk_3A4; } EnTruMt; // size = 0x3A8 extern const ActorInit En_Tru_Mt_InitVars; 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 4205bf035..5e5459fa5 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -5,8 +5,9 @@ */ #include "z_en_tsn.h" +#include "objects/object_tsn/object_tsn.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnTsn*)thisx) @@ -15,7 +16,18 @@ void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx); void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx); +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx); +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx); + const ActorInit En_Tsn_InitVars = { ACTOR_EN_TSN, ACTORCAT_NPC, @@ -28,58 +40,597 @@ const ActorInit En_Tsn_InitVars = { (ActorFunc)EnTsn_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE1190 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80AE11BC = { 0.0f, 0.0f, 0.0f }; -extern ColliderCylinderInit D_80AE1190; +TexturePtr D_80AE11C8[] = { object_tsn_Tex_0073B8, object_tsn_Tex_0085B8 }; -extern UNK_TYPE D_06001198; -extern UNK_TYPE D_060092FC; +EnTsn* func_80ADFCA0(GlobalContext* globalCtx) { + Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCA0.s") + while (npc != NULL) { + if ((npc->id == ACTOR_EN_TSN) && !ENTSN_GET_100(npc)) { + return (EnTsn*)npc; + } + npc = npc->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFCEC.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Init.s") +void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { + this->actionFunc = func_80AE0C88; + this->actor.update = func_80AE0F84; + this->actor.destroy = NULL; + this->actor.draw = NULL; + this->actor.targetMode = 7; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Destroy.s") + switch (ENTSN_GET_F(&this->actor)) { + case ENTSN_F_0: + if (gSaveContext.save.weekEventReg[26] & 8) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.textId = 0x106E; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80ADFF84.s") + case ENTSN_F_1: + if (gSaveContext.save.weekEventReg[26] & 4) { + this->actor.textId = 0x1091; + } else { + this->actor.textId = 0x108A; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0010.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_0) { + this->actionFunc = func_80AE0D78; + } else { + Actor_MarkForDeath(&this->actor); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0304.s") + this->unk_1D8 = func_80ADFCA0(globalCtx); + this->unk_220 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0418.s") + if (this->unk_1D8 == NULL) { + Actor_MarkForDeath(&this->actor); + } else if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_1) { + func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, 6); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0460.s") +void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04C4.s") + if (ENTSN_GET_100(&this->actor)) { + func_80ADFCEC(this, globalCtx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE04FC.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tsn_Skel_008AB8, &object_tsn_Anim_0092FC, NULL, NULL, 0); + Animation_PlayLoop(&this->skelAnime, &object_tsn_Anim_0092FC); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0698.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_220 = 0; + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0704.s") + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0C88.s") +void EnTsn_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D10.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0D78.s") +void func_80ADFF84(EnTsn* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Update.s") + if (gSaveContext.save.weekEventReg[26] & 8) { + textId = 0x107E; + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[25] & 0x80) { + textId = 0x1083; + } else { + textId = 0x107F; + } + } else if (gSaveContext.save.weekEventReg[26] & 1) { + textId = 0x1089; + } else { + textId = 0x1084; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0F84.s") + Message_StartTextbox(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE0FA8.s") +void func_80AE0010(EnTsn* this, GlobalContext* globalCtx) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x107F: + case 0x1080: + case 0x1081: + case 0x1082: + case 0x1083: + case 0x1084: + case 0x1085: + case 0x1086: + case 0x1087: + case 0x1088: + case 0x1089: + case 0x1093: + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/func_80AE1024.s") + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x107F: + case 0x1081: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tsn/EnTsn_Draw.s") + case 0x1080: + func_80151938(globalCtx, globalCtx->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); + gSaveContext.save.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1083: + gSaveContext.save.weekEventReg[25] |= 0x80; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1084: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_000964, -10.0f); + break; + + case 0x1085: + case 0x1086: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1089: + case 0x1093: + gSaveContext.save.weekEventReg[26] |= 1; + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + + case 0x1087: + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_001198, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1088: + gSaveContext.save.weekEventReg[26] |= 1; + if (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) { + func_801477B4(globalCtx); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + } else { + func_80151938(globalCtx, 0x1093); + Animation_MorphToLoop(&this->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + } + break; + + case 0x107E: + func_801477B4(globalCtx); + this->actionFunc = func_80AE0304; + this->actor.textId = 0; + break; + } + } +} + +void func_80AE0304(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0010; + this->unk_220 |= 1; + if (this->actor.textId == 0) { + func_80ADFF84(this, globalCtx); + } + } else if ((this->actor.xzDistToPlayer < 150.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 160.0f); + this->unk_220 |= 1; + } else { + this->unk_220 &= ~1; + } + if (ENTSN_GET_Z(&this->actor)) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.home.rot.y, 6, 0x1838, 0x64); + } + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void func_80AE0418(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + Message_StartTextbox(globalCtx, 0x107D, NULL); + Actor_MarkForDeath(&this->actor); + } +} + +void func_80AE0460(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + ENTSN_SET_Z(&this->unk_1D8->actor, false); + this->actionFunc = func_80AE0418; + } else { + Actor_PickUp(&this->actor, globalCtx, GI_95, 2000.0f, 1000.0f); + } +} + +void func_80AE04C4(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + this->actionFunc = func_80AE0C88; + } +} + +void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { + s32 sp24; + Player* player = GET_PLAYER(globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == 0x10) { + sp24 = func_80123810(globalCtx); + if (sp24 != 0) { + gSaveContext.save.weekEventReg[26] |= 2; + } + + if (sp24 > 0) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0704; + if (sp24 == 19) { + if (CHECK_QUEST_ITEM(QUEST_UNK_19)) { + if (func_8013A4C4(1 | 8)) { + player->actor.textId = 0x107B; + return; + } + + if (func_8013A4C4(1 | 2 | 8)) { + player->actor.textId = 0x10A9; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 == 13) { + player->actor.textId = 0x1075; + return; + } + + player->actor.textId = 0x1078; + this->unk_220 |= 8; + return; + } + + if (sp24 < 0) { + func_80151938(globalCtx, 0x1078); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + this->actionFunc = func_80AE0704; + } + } +} + +void func_80AE0698(EnTsn* this, GlobalContext* globalCtx) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0C88; + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + ENTSN_SET_Z(&this->unk_1D8->actor, false); +} + +void func_80AE0704(EnTsn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + + if ((this->unk_220 & 8) && (globalCtx->msgCtx.currentTextId == 0x1078)) { + this->unk_220 &= ~8; + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_001198, -10.0f); + } + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 2: + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x106E: + if (gSaveContext.save.weekEventReg[25] & 0x40) { + func_80151938(globalCtx, 0x1074); + } else { + func_80151938(globalCtx, 0x106F); + } + this->unk_220 |= 2; + gSaveContext.save.weekEventReg[25] |= 0x40; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + this->unk_220 |= 4; + break; + + case 0x106F: + case 0x1070: + case 0x1071: + case 0x1072: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1076: + case 0x1079: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x107A: + func_80151938(globalCtx, 0x10A6); + break; + + case 0x1075: + case 0x1078: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x107C: + if (Inventory_HasEmptyBottle()) { + gSaveContext.save.weekEventReg[26] |= 8; + func_801477B4(globalCtx); + this->actionFunc = func_80AE0460; + func_80AE0460(this, globalCtx); + this->unk_220 &= ~2; + this->actor.focus.pos = this->actor.world.pos; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.flags &= ~ACTOR_FLAG_100; + REMOVE_QUEST_ITEM(QUEST_UNK_19); + } else { + func_80151938(globalCtx, 0x10A8); + } + break; + + case 0x1073: + case 0x1074: + func_80151938(globalCtx, 0xFF); + this->actionFunc = func_80AE04FC; + break; + + case 0x107B: + player->exchangeItemId = 0; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + break; + + case 0x1077: + case 0x10A6: + case 0x10A8: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + + case 0x108A: + case 0x1091: + gSaveContext.save.weekEventReg[26] |= 4; + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + this->unk_220 |= 2; + this->actor.textId = 0x1091; + break; + + case 0x108B: + case 0x108C: + case 0x108D: + case 0x108E: + case 0x108F: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1092: + if (gSaveContext.save.weekEventReg[26] & 8) { + func_80AE0698(this, globalCtx); + } else { + func_80151938(globalCtx, 0x10A7); + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_000964, -10.0f); + } + break; + + case 0x10A7: + Animation_MorphToLoop(&this->unk_1D8->skelAnime, &object_tsn_Anim_0092FC, -10.0f); + func_80AE0698(this, globalCtx); + break; + + case 0x1090: + func_80AE0698(this, globalCtx); + break; + + case 0x10A9: + func_80AE0698(this, globalCtx); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80AE04C4; + break; + } + } + } + + if (this->unk_220 & 2) { + if (this->unk_1D8 != NULL) { + Math_SmoothStepToF(&this->actor.focus.pos.x, this->unk_1D8->actor.focus.pos.x, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.y, this->unk_1D8->actor.focus.pos.y, 0.8f, 100.0f, 5.0f); + Math_SmoothStepToF(&this->actor.focus.pos.z, this->unk_1D8->actor.focus.pos.z, 0.8f, 100.0f, 5.0f); + } + } + + if (this->unk_220 & 4) { + if (this->actor.cutscene == -1) { + 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); + this->unk_220 &= ~4; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } +} + +void func_80AE0C88(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0704; + if ((this->actor.textId == 0x108A) || (this->actor.textId == 0x1091)) { + this->unk_220 |= 4; + ENTSN_SET_Z(&this->unk_1D8->actor, true); + } + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void func_80AE0D10(EnTsn* this, GlobalContext* globalCtx) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80AE0D78; + ActorCutscene_Stop(this->actor.cutscene); + } +} + +void func_80AE0D78(EnTsn* this, GlobalContext* globalCtx) { + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80AE0D10; + this->unk_220 |= 4; + } else if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 1000.0f); + } +} + +void EnTsn_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 4); + SkelAnime_Update(&this->skelAnime); + + if (this->unk_220 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_222, &this->unk_228, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_222.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_222.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_228.y, 0, 6, 0x1838, 0x64); + } + + if (DECR(this->unk_230) == 0) { + this->unk_230 = Rand_S16Offset(60, 60); + } + + if ((this->unk_230 == 1) || (this->unk_230 == 3)) { + this->unk_22E = 1; + } else { + this->unk_22E = 0; + } +} + +void func_80AE0F84(Actor* thisx, GlobalContext* globalCtx) { + EnTsn* this = THIS; + + this->actionFunc(this, globalCtx); +} + +s32 EnTsn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + s16 shifted = this->unk_222.x >> 1; + + if (limbIndex == 15) { + rot->x += this->unk_222.y; + rot->z += shifted; + } + + if (limbIndex == 8) { + rot->x += this->unk_228.y; + rot->z += shifted; + } + return false; +} + +void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTsn* this = THIS; + Vec3f sp18 = D_80AE11BC; + + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&sp18, &this->actor.focus.pos); + } +} + +void EnTsn_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnTsn* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C5B0(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AE11C8[this->unk_22E])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnTsn_OverrideLimbDraw, EnTsn_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h index 6b7810cf6..64df6ac42 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h @@ -7,11 +7,26 @@ struct EnTsn; typedef void (*EnTsnActionFunc)(struct EnTsn*, GlobalContext*); +#define ENTSN_GET_F(thisx) ((thisx)->params & 0xF) +#define ENTSN_GET_100(thisx) ((thisx)->params & 0x100) +#define ENTSN_GET_Z(thisx) ((thisx)->home.rot.z) +#define ENTSN_SET_Z(thisx, state) ((thisx)->home.rot.z = state) + +#define ENTSN_F_0 0 +#define ENTSN_F_1 1 + typedef struct EnTsn { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ SkelAnime skelAnime; /* 0x01D4 */ EnTsnActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x5C]; + /* 0x01D8 */ struct EnTsn* unk_1D8; + /* 0x01DC */ UNK_TYPE1 unk1DC[0x44]; + /* 0x0220 */ u16 unk_220; + /* 0x0222 */ Vec3s unk_222; + /* 0x0228 */ Vec3s unk_228; + /* 0x022E */ s16 unk_22E; + /* 0x0230 */ s16 unk_230; } EnTsn; // size = 0x234 extern const ActorInit En_Tsn_InitVars; 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 c2d9e8d64..18476aa4e 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 @@ -238,7 +238,7 @@ void EnTuboTrap_Idle(EnTuboTrap* this, GlobalContext* globalCtx) { if ((startingRotation == 0) || (this->actor.playerHeightRel <= (startingRotation * 10.0f))) { func_800BC154(globalCtx, &globalCtx->actorCtx, &this->actor, ACTORCAT_ENEMY); currentHeight = this->actor.world.pos.y; - this->actor.flags |= 0x11; // always update and can target + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_10); // always update and can target transformationHeight = sTransformationHeight[player->transformation]; 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 aa1b3e1d4..c2cae36c3 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -6,7 +6,7 @@ #include "z_en_twig.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnTwig*)thisx) diff --git a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c index 84d9a8356..170cc6edb 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -6,7 +6,7 @@ #include "z_en_viewer.h" -#define FLAGS 0x00200030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000) #define THIS ((EnViewer*)thisx) 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 b1fcfad5e..6103cb577 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -5,8 +5,11 @@ */ #include "z_en_vm.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_vm/object_vm.h" -#define FLAGS 0x00000405 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) #define THIS ((EnVm*)thisx) @@ -15,7 +18,17 @@ void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnVm_Update(Actor* thisx, GlobalContext* globalCtx); void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808CC420(EnVm* this); +void func_808CC490(EnVm* this, GlobalContext* globalCtx); +void func_808CC5C4(EnVm* this); +void func_808CC610(EnVm* this, GlobalContext* globalCtx); +void func_808CC788(EnVm* this); +void func_808CC820(EnVm* this, GlobalContext* globalCtx); +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx); +void func_808CCB08(EnVm* this); +void func_808CCB50(EnVm* this, GlobalContext* globalCtx); +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx); + const ActorInit En_Vm_InitVars = { ACTOR_EN_VM, ACTORCAT_ENEMY, @@ -28,40 +41,72 @@ const ActorInit En_Vm_InitVars = { (ActorFunc)EnVm_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808CD4C0[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 2, { { 0, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 10, { { 0, 2300, 0 }, 33 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808CD508 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, D_808CD4C0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 2, + sJntSphElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[1] = { -static ColliderTrisElementInit D_808CD518[1] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_808CD554 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 1, D_808CD518, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 1, + sTrisElementsInit, }; -// static DamageTable sDamageTable = { -static DamageTable D_808CD564 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0xF), @@ -96,62 +141,418 @@ static DamageTable D_808CD564 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808CD584 = { 2, 25, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 100, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808CD5AC[] = { +TexturePtr D_808CD58C[] = { + gameplay_keep_Tex_03F300, gameplay_keep_Tex_03FB00, gameplay_keep_Tex_040300, gameplay_keep_Tex_040B00, + gameplay_keep_Tex_041300, gameplay_keep_Tex_041B00, gameplay_keep_Tex_042300, gameplay_keep_Tex_042B00, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_CONTINUE), ICHAIN_S8(hintId, 57, ICHAIN_STOP), }; -#endif +s32 D_808CD5B8 = false; -extern ColliderJntSphElementInit D_808CD4C0[2]; -extern ColliderJntSphInit D_808CD508; -extern ColliderTrisElementInit D_808CD518[1]; -extern ColliderTrisInit D_808CD554; -extern DamageTable D_808CD564; -extern CollisionCheckInfoInit D_808CD584; -extern InitChainEntry D_808CD5AC[]; +Color_RGBA8 D_808CD5BC = { 0, 0, 255, 0 }; -extern UNK_TYPE D_06000068; +Color_RGBA8 D_808CD5C0 = { 255, 255, 255, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Init.s") +void EnVm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; + s32 i; + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Destroy.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &object_vm_Skel_003F60, &object_vm_Anim_000068, this->jointTable, + this->morphTable, 11); + Collider_InitAndSetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); + Collider_InitAndSetJntSph(globalCtx, &this->colliderJntSph, &this->actor, &sJntSphInit, + this->colliderJntSphElements); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC420.s") + params = ENVM_GET_FF00(thisx); + if ((params == ENVM_FF00_FF) || (params == ENVM_FF00_0)) { + params = ENVM_FF00_5; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC490.s") + this->unk_21C = params * 40.0f; + thisx->params &= 0xFF; + this->actor.bgCheckFlags |= 0x400; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC5C4.s") + if (!D_808CD5B8) { + for (i = 0; i < ARRAY_COUNT(D_808CD58C); i++) { + D_808CD58C[i] = Lib_SegmentedToVirtual(D_808CD58C[i]); + } + D_808CD5B8 = true; + } + func_808CC420(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC610.s") +void EnVm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnVm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC788.s") + Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CC820.s") +void func_808CC420(EnVm* this) { + f32 lastFrame = Animation_GetLastFrame(&object_vm_Anim_000068); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCA10.s") + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + this->actionFunc = func_808CC490; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCAA4.s") +void func_808CC490(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp22; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB08.s") + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + this->unk_218 -= 0x1F4; + func_800B9010(&this->actor, NA_SE_EN_BIMOS_ROLL_HEAD - SFX_FLAG); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCB50.s") + if (this->actor.xzDistToPlayer <= this->unk_21C) { + if ((this->actor.playerHeightRel <= 80.0f) && (this->actor.playerHeightRel >= -160.0f)) { + sp22 = BINANG_SUB(this->actor.yawTowardsPlayer - this->unk_218, this->actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCBE4.s") + temp_v0 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + if (temp_v0 > 0x1B91) { + temp_v0 = 0x1B91; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCCF0.s") + if ((ABS_ALT(sp22) <= 0x2710) && (temp_v0 >= 0xE38) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + func_808CC5C4(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CCDE4.s") +void func_808CC5C4(EnVm* this) { + Animation_PlayLoopSetSpeed(&this->skelAnime, &object_vm_Anim_000068, 2.0f); + this->unk_214 = 10; + this->actionFunc = func_808CC610; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Update.s") +void func_808CC610(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp3A; + s16 sp38; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD020.s") + SkelAnime_Update(&this->skelAnime); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/func_808CD08C.s") + sp38 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp38 = CLAMP_MAX(sp38, 0x1B91); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Vm/EnVm_Draw.s") + sp3A = BINANG_ADD((s32)((this->unk_21C - this->actor.xzDistToPlayer) * 60.0f), 4000); + sp3A = CLAMP_MAX(sp3A, 0x1000); + + Math_SmoothStepToS(&this->unk_216, sp38, 10, 4000, 0); + + if ((sp38 < 0xAAA) || (sp3A <= 0)) { + func_808CC420(this); + } else if (Math_ScaledStepToS(&this->unk_218, BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y), + sp3A)) { + this->unk_214--; + if (this->unk_214 == 0) { + EffectSsDeadDd_Spawn(globalCtx, &this->unk_228, &gZeroVec3f, &gZeroVec3f, &D_808CD5BC, &D_808CD5C0, 150, + -25, 16, 20); + func_808CC788(this); + } + } +} + +void func_808CC788(EnVm* this) { + Actor_PlaySfxAtPos(&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; + this->colliderTris.base.atFlags &= ~AT_HIT; + this->actionFunc = func_808CC820; +} + +void func_808CC820(EnVm* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s16 sp32; + f32 temp_f2; + + if (SkelAnime_Update(&this->skelAnime)) { + this->skelAnime.curFrame = this->skelAnime.startFrame; + } + + sp32 = Math_Vec3f_Pitch(&this->actor.focus.pos, &player->actor.world.pos); + sp32 = CLAMP_MAX(sp32, 0x1B91); + + if (this->colliderTris.base.atFlags & AT_HIT) { + this->colliderTris.base.atFlags &= ~AT_HIT; + this->unk_214 = 0; + if (this->unk_220 > 0.01f) { + this->unk_220 = 0.01f; + } + } + + if ((this->unk_216 < 0xAAA) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || (this->unk_214 == 0)) { + this->unk_214 = 0; + if (Math_StepToF(&this->unk_220, 0.0f, 0.003f)) { + this->unk_210 = 0; + this->unk_224 = 0.0f; + func_808CC420(this); + } + } else { + this->unk_214--; + if (this->unk_214 <= 300) { + Math_ApproachS(&this->unk_218, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 0xA, 0xDAC); + Math_ApproachS(&this->unk_216, sp32, 0xA, 0xDAC); + + temp_f2 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &player->actor.world.pos) + 40.0f; + if (this->unk_224 < temp_f2) { + Math_StepToF(&this->unk_224, temp_f2, 40.0f); + } + + Math_StepToF(&this->unk_220, 0.01f, 0.012f); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + + if (this->unk_210 == 0) { + this->unk_210 = 1; + } + } + } +} + +void func_808CCA10(EnVm* this) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + this->unk_214 = 100; + this->unk_210 = 0; + this->unk_224 = 0.0f; + this->unk_220 = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->actionFunc = func_808CCAA4; +} + +void func_808CCAA4(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + SkelAnime_Update(&this->skelAnime); + if (this->unk_214 == 0) { + func_808CCB08(this); + } else { + this->unk_214--; + } +} + +void func_808CCB08(EnVm* this) { + Animation_PlayOnce(&this->skelAnime, &object_vm_Anim_000068); + this->unk_214 = -1; + this->actionFunc = func_808CCB50; +} + +void func_808CCB50(EnVm* this, GlobalContext* globalCtx) { + Math_ApproachS(&this->unk_216, 0, 0xA, 0x5DC); + + if (this->unk_214 > 0) { + this->unk_214--; + } else if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_214 == -1) { + this->unk_214 = 10; + this->skelAnime.curFrame = 0.0f; + this->skelAnime.playSpeed = 2.0f; + } else { + func_808CC420(this); + } + } +} + +void func_808CCBE4(EnVm* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &object_vm_Anim_000068, -1.0f, Animation_GetLastFrame(&object_vm_Anim_000068), + 0.0f, ANIMMODE_ONCE, 0.0f); + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 33); + this->unk_214 = 33; + this->unk_220 = 0.0f; + this->unk_224 = 0.0f; + this->actor.shape.yOffset = (this->actor.world.pos.y - this->actor.focus.pos.y) * 71.428566f; + 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->unk_210 = 0; + this->actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_808CCCF0; +} + +void func_808CCCF0(EnVm* this, GlobalContext* globalCtx) { + this->unk_216 += 0x5DC; + this->unk_218 += 0x9C4; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 20.0f, 40.0f, 7); + + this->unk_214--; + if (this->unk_214 == 1) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x6FF, 0); + + if (bomb != NULL) { + bomb->timer = 0; + } + } else if (this->unk_214 == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xB0); + Actor_MarkForDeath(&this->actor); + } +} + +void func_808CCDE4(EnVm* this, GlobalContext* globalCtx) { + s32 i; + s16 temp_v0; + + if (this->colliderJntSph.base.acFlags & AC_HIT) { + this->colliderJntSph.base.acFlags &= ~AC_HIT; + + for (i = 0; i < ARRAY_COUNT(this->colliderJntSphElements); i++) { + if (this->colliderJntSph.elements[i].info.bumperFlags & BUMP_HIT) { + break; + } + } + + if (i != ARRAY_COUNT(this->colliderJntSphElements)) { + func_800BE5CC(&this->actor, &this->colliderJntSph, i); + if (this->actor.colChkInfo.damageEffect == 0) { + func_808CCBE4(this, globalCtx); + } else if ((i == 0) && (this->actionFunc != func_808CCAA4)) { + temp_v0 = (this->actor.world.rot.y - this->actor.shape.rot.y) - this->unk_218; + if (ABS_ALT(temp_v0) > 0x6000) { + func_808CCA10(this); + } + } + } + } +} + +void EnVm_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + + func_808CCDE4(this, globalCtx); + + if (this->unk_210 == 2) { + func_800B31BC(globalCtx, &this->unk_234, 20, -1, 155, 10); + if ((globalCtx->gameplayFrames % 2) != 0) { + func_800BBFB0(globalCtx, &this->unk_234, 6.0f, 1, 120, 20, 1); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BIMOS_LAZER_GND - SFX_FLAG); + } + + if (this->unk_224 > 0.0f) { + func_800B9010(&this->actor, NA_SE_EN_BIMOS_LAZER - SFX_FLAG); + } + + this->actionFunc(this, globalCtx); + + this->unk_212 += 12; + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + if (this->actionFunc != func_808CCCF0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +s32 EnVm_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnVm* this = THIS; + + if (limbIndex == OBJECT_VM_LIMB_02) { + rot->x += this->unk_216; + rot->y += this->unk_218; + } else if ((limbIndex == OBJECT_VM_LIMB_0A) && (this->actionFunc == func_808CCCF0)) { + *dList = NULL; + } + return false; +} + +void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnVm* this = THIS; + Vec3f sp5C; + Vec3f sp50; + CollisionPoly* sp4C; + s32 sp48; + + Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); + + if (limbIndex == OBJECT_VM_LIMB_02) { + sp4C = NULL; + + Matrix_GetStateTranslation(&this->actor.focus.pos); + Matrix_GetStateTranslationAndScaledZ(1600.0f, &this->unk_228); + Matrix_GetStateTranslationAndScaledZ(this->unk_224 * 71.428566f, &this->unk_234); + + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.focus.pos, &this->unk_234, &sp5C, &sp4C, true, + true, false, true, &sp48)) { + this->unk_224 = Math_Vec3f_DistXYZ(&this->actor.focus.pos, &sp5C) - 5.0f; + this->unk_210 = 2; + Math_Vec3f_Copy(&this->unk_234, &sp5C); + } else if (this->unk_210 != 0) { + this->unk_210 = 1; + } + + sp50.x = this->unk_234.x + (Math_CosS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + sp50.y = this->unk_234.y; + sp50.z = this->unk_234.z - (Math_SinS(this->actor.shape.rot.y + this->unk_218) * 5.0f); + + Collider_SetTrisVertices(&this->colliderTris, 0, &this->actor.focus.pos, &this->unk_234, &sp50); + } +} + +void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnVm* this = THIS; + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 25]); + + POLY_OPA_DISP = &gfx[1]; + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnVm_OverrideLimbDraw, + EnVm_PostLimbDraw, &this->actor); + + if (this->unk_210 == 2) { + gfx = POLY_XLU_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 60]); + gDPSetColorDither(&gfx[1], G_CD_DISABLE); + + Matrix_InsertTranslation(this->unk_234.x, this->unk_234.y + 10.0f, this->unk_234.z, MTXMODE_NEW); + Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); + + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(&gfx[3], 0, 0, 255, 255, 255, 168); + gDPSetEnvColor(&gfx[4], 0, 0, 255, 0); + gSPSegment(&gfx[5], 0x08, D_808CD58C[globalCtx->gameplayFrames & 7]); + gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); + + POLY_XLU_DISP = &gfx[7]; + } + + if (this->unk_224 > 0.0f) { + gfx = POLY_OPA_DISP; + + gSPSegment(&gfx[0], 0x08, func_8012CB28(globalCtx->state.gfxCtx, 0, this->unk_212)); + + Matrix_InsertTranslation(this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, + MTXMODE_NEW); + Matrix_InsertRotation(this->unk_216, this->unk_218 + this->actor.shape.rot.y, 0, MTXMODE_APPLY); + Matrix_Scale(this->unk_220, this->unk_220, this->unk_224 * 0.0015f, MTXMODE_APPLY); + + gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], object_vm_DL_002728); + + POLY_OPA_DISP = &gfx[3]; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.h b/src/overlays/actors/ovl_En_Vm/z_en_vm.h index ad5c43abb..1901ac34a 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.h +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.h @@ -7,11 +7,32 @@ struct EnVm; typedef void (*EnVmActionFunc)(struct EnVm*, GlobalContext*); +#define ENVM_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + +#define ENVM_FF00_0 0 +#define ENVM_FF00_5 5 +#define ENVM_FF00_FF 0xFF + typedef struct EnVm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC8]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[11]; + /* 0x01CA */ Vec3s morphTable[11]; /* 0x020C */ EnVmActionFunc actionFunc; - /* 0x0210 */ char unk_210[0x14C]; + /* 0x0210 */ u8 unk_210; + /* 0x0212 */ s16 unk_212; + /* 0x0214 */ s16 unk_214; + /* 0x0216 */ s16 unk_216; + /* 0x0218 */ s16 unk_218; + /* 0x021C */ f32 unk_21C; + /* 0x0220 */ f32 unk_220; + /* 0x0224 */ f32 unk_224; + /* 0x0228 */ Vec3f unk_228; + /* 0x0234 */ Vec3f unk_234; + /* 0x0240 */ ColliderJntSph colliderJntSph; + /* 0x0260 */ ColliderJntSphElement colliderJntSphElements[2]; + /* 0x02E0 */ ColliderTris colliderTris; + /* 0x0300 */ ColliderTrisElement colliderTrisElements[1]; } EnVm; // size = 0x35C extern const ActorInit En_Vm_InitVars; 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 05078f541..1b88d692b 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -5,8 +5,10 @@ */ #include "z_en_wallmas.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnWallmas*)thisx) @@ -15,22 +17,32 @@ void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80874BE4(EnWallmas* this, GlobalContext* globalCtx); -void func_80874DE8(EnWallmas* this, GlobalContext* globalCtx); -void func_80874FD8(EnWallmas* this, GlobalContext* globalCtx); -void func_80875054(EnWallmas* this, GlobalContext* globalCtx); -void func_80875108(EnWallmas* this, GlobalContext* globalCtx); -void func_8087520C(EnWallmas* this, GlobalContext* globalCtx); -void func_808752CC(EnWallmas* this, GlobalContext* globalCtx); -void func_80875484(EnWallmas* this, GlobalContext* globalCtx); -void func_8087556C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875638(EnWallmas* this, GlobalContext* globalCtx); -void func_8087571C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875910(EnWallmas* this, GlobalContext* globalCtx); -void func_8087596C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875A0C(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupStand(EnWallmas* this); +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupWalk(EnWallmas* this); +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupJumpToCeiling(EnWallmas* this); +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupReturnToCeiling(EnWallmas* this); +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupCooldown(EnWallmas* this); +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this); +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Wallmas_InitVars = { ACTOR_EN_WALLMAS, ACTORCAT_ENEMY, @@ -43,147 +55,704 @@ const ActorInit En_Wallmas_InitVars = { (ActorFunc)EnWallmas_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80876360 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8087638C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 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(1, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ WALLMASTER_DMGEFF_NONE, + /* 0x1 */ WALLMASTER_DMGEFF_STUN, + /* 0x2 */ WALLMASTER_DMGEFF_FIRE_ARROW, + /* 0x3 */ WALLMASTER_DMGEFF_ICE_ARROW, + /* 0x4 */ WALLMASTER_DMGEFF_LIGHT_ARROW, + /* 0x5 */ WALLMASTER_DMGEFF_ZORA_MAGIC, + /* 0xF */ WALLMASTER_DMGEFF_HOOKSHOT = 0xF +} EnWallmasDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, WALLMASTER_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, WALLMASTER_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808763AC = { 3, 30, 40, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808763B4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 48, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), }; -#endif +static f32 sYOffsetPerForm[] = { 50.0f, 55.0f, 50.0f, 20.0f, 30.0f }; -extern ColliderCylinderInit D_80876360; -extern DamageTable D_8087638C; -extern CollisionCheckInfoInit D_808763AC; -extern InitChainEntry D_808763B4[]; +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the limbPos array. An index of -1 indicates that the limb is not part + * of the limbPos array. + */ +static s8 sLimbIndexToLimbPosIndex[] = { + -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, -1, 3, -1, 4, -1, -1, 5, -1, -1, -1, 6, 7, -1, 8, +}; -extern UNK_TYPE D_06000590; -extern UNK_TYPE D_06000EA4; -extern UNK_TYPE D_060019CC; -extern UNK_TYPE D_0600299C; -extern UNK_TYPE D_060041F4; -extern UNK_TYPE D_06008688; -extern UNK_TYPE D_06009244; -extern UNK_TYPE D_06009520; -extern UNK_TYPE D_06009DB0; -extern UNK_TYPE D_0600A054; +void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.5f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Destroy.s") + this->switchFlag = WALLMASTER_GET_SWITCH_FLAG(thisx); + this->actor.params &= 0xFF; + this->detectionRadius = this->actor.shape.rot.x * 40.0f * 0.1f; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + if (this->detectionRadius <= 0.0f) { + this->detectionRadius = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874A88.s") + Actor_SetFocus(&this->actor, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B04.s") + if (WALLMASTER_IS_FROZEN(&this->actor)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, this->actor.world.rot.x, + (this->actor.world.rot.y + 0x5900), this->actor.world.rot.z, 0xFF50); + this->actor.params &= ~0x80; + EnWallmas_SetupReturnToCeiling(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B88.s") + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874BE4.s") + EnWallmas_ProximityOrSwitchInit(this); + } else if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + EnWallmas_ProximityOrSwitchInit(this); + } else { + EnWallmas_TimerInit(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874D1C.s") +void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874DE8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874F14.s") + if (this->actor.parent != NULL) { + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874FD8.s") + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875014.s") +void EnWallmas_Freeze(EnWallmas* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; + this->collider.base.colType = 3; + 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_Wallmas/func_80875054.s") +void EnWallmas_ThawIfFrozen(EnWallmas* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->collider.base.colType = 0; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808750B8.s") +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875108.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_20; + this->timer = 130; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.draw = EnWallmas_Draw; + this->actionFunc = EnWallmas_WaitToDrop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808751C4.s") +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087520C.s") + this->actor.world.pos = *playerPos; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.floorPoly = player->actor.floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875248.s") + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808752CC.s") + if ((player->stateFlags1 & 0x08100000) || (player->stateFlags2 & 0x80) || (player->unk_B5E > 0) || + (player->actor.freezeTimer > 0) || !(player->actor.bgCheckFlags & 1) || + ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) && + (Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos) > (120.f + this->detectionRadius)))) { + func_801A75E8(NA_SE_EN_FALL_AIM); + this->timer = 130; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808753F0.s") + if (this->timer == 80) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_AIM); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875484.s") + if (this->timer == 0) { + EnWallmas_SetupDrop(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875518.s") +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087556C.s") + Animation_Change(&this->skelAnime, &gWallmasterLungeAnim, 0.0f, 20.0f, + Animation_GetLastFrame(&gWallmasterLungeAnim), ANIMMODE_ONCE, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808755A8.s") + this->yTarget = player->actor.world.pos.y; + this->actor.world.pos.y = player->actor.world.pos.y + 300.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_20; + this->actionFunc = EnWallmas_Drop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875638.s") +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808756AC.s") + if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { + EnWallmas_SetupReturnToCeiling(this); + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + (this->actor.xzDistToPlayer < 30.0f) && (this->actor.playerHeightRel < -5.0f) && + (-(f32)(player->cylinder.dim.height + 10) < this->actor.playerHeightRel)) { + EnWallmas_SetupTakePlayer(this, globalCtx); + } else if (this->actor.world.pos.y <= this->yTarget) { + this->actor.world.pos.y = this->yTarget; + this->actor.velocity.y = 0.0f; + EnWallmas_SetupLand(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087571C.s") +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808758C8.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); + this->actionFunc = EnWallmas_Land; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875910.s") +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupStand(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087596C.s") +void EnWallmas_SetupStand(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStandUpAnim); + this->actionFunc = EnWallmas_Stand; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808759B8.s") +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupWalk(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A0C.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A74.s") +void EnWallmas_SetupWalk(EnWallmas* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 3.0f); + this->actor.speedXZ = 3.0f; + this->actionFunc = EnWallmas_Walk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Update.s") +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupJumpToCeiling(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875F04.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + 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); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808760A4.s") +void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); + this->actor.speedXZ = 0.0f; + this->actionFunc = EnWallmas_JumpToCeiling; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80876118.s") +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Draw.s") +void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { + this->timer = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); + this->actionFunc = EnWallmas_ReturnToCeiling; +} + +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (this->skelAnime.curFrame > 20.0f) { + this->actor.world.pos.y += 30.0f; + this->timer += 9; + this->actor.flags &= ~ACTOR_FLAG_2000; + } + + if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + if (this->actor.playerHeightRel < -900.0f) { + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_TIMER_ONLY) || + (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius)) { + EnWallmas_TimerInit(this, globalCtx); + } else { + EnWallmas_ProximityOrSwitchInit(this); + } + } +} + +void EnWallmas_SetupDamage(EnWallmas* this, s32 arg1) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); + + if (arg1) { + func_800BE504(&this->actor, &this->collider); + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 10.0f; + this->actionFunc = EnWallmas_Damage; +} + +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDie(this, globalCtx); + } else { + EnWallmas_SetupCooldown(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); +} + +void EnWallmas_SetupCooldown(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnWallmas_Cooldown; +} + +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} + +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 250, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->actionFunc = EnWallmas_Die; +} + +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { + Actor_SetScale(&this->actor, 0.01f); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Actor_MarkForDeath(&this->actor); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; +} + +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); + this->timer = -30; + this->actionFunc = EnWallmas_TakePlayer; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->yTarget = this->actor.playerHeightRel; + func_800B724C(globalCtx, &this->actor, 18); +} + +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_CATCH); + } + + if (SkelAnime_Update(&this->skelAnime)) { + player->actor.world.pos.x = this->actor.world.pos.x; + player->actor.world.pos.z = this->actor.world.pos.z; + + if (this->timer < 0) { + this->actor.world.pos.y += 2.0f; + } else { + this->actor.world.pos.y += 10.0f; + } + + player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)]; + if (this->timer == -30) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_TAKEN_AWAY); + } + + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + this->timer += 2; + } else { + Math_StepToF(&this->actor.world.pos.y, + sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)] + player->actor.world.pos.y, 5.0f); + } + + Math_StepToF(&this->actor.world.pos.x, player->actor.world.pos.x, 3.0f); + Math_StepToF(&this->actor.world.pos.z, player->actor.world.pos.z, 3.0f); + + if (this->timer == 30) { + play_sound(NA_SE_OC_ABYSS); + func_80169FDC(&globalCtx->state); + } +} + +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this) { + this->timer = 0; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + this->actionFunc = EnWallmas_WaitForProximity; + } else { + this->actionFunc = EnWallmas_WaitForSwitchFlag; + } +} + +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius) { + EnWallmas_TimerInit(this, globalCtx); + } +} + +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnWallmas_TimerInit(this, globalCtx); + this->timer = 81; + } +} + +void EnWallmas_SetupStun(EnWallmas* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + func_800BE504(&this->actor, &this->collider); + this->actionFunc = EnWallmas_Stun; +} + +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnWallmas_ThawIfFrozen(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDamage(this, false); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + EnWallmas_SetupReturnToCeiling(this); + } + } +} + +void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&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); + } + + EnWallmas_ThawIfFrozen(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect != WALLMASTER_DMGEFF_HOOKSHOT) { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ICE_ARROW) { + EnWallmas_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + 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); + 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); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + EnWallmas_SetupStun(this); + } else { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_FIRE_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + EnWallmas_SetupDamage(this, true); + } + } + } + } +} + +void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWallmas* this = THIS; + + EnWallmas_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_WaitForProximity) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + if ((this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer)) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actionFunc != EnWallmas_Drop) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 0x1DU); + } + + if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((this->actionFunc != EnWallmas_Damage) && (this->actor.bgCheckFlags & 1) && + (this->actor.freezeTimer == 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + Actor_SetFocus(&this->actor, 25.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.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { + s32 pad; + f32 xzScale; + MtxF mf; + Gfx* gfx; + + if ((this->actor.floorPoly != NULL) && ((this->timer < 81) || (this->actionFunc == EnWallmas_Stun))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 44]); + gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); + func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + &mf); + Matrix_InsertMatrix(&mf, MTXMODE_NEW); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + xzScale = this->actor.scale.x * 50.0f; + } else { + xzScale = CLAMP_MAX(80 - this->timer, 80) * 0.00625f; + } + + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[3], gCircleShadowDL); + + POLY_OPA_DISP = &gfx[4]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnWallmas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnWallmas* this = THIS; + + if (limbIndex == WALLMASTER_LIMB_ROOT) { + if (this->actionFunc != EnWallmas_TakePlayer) { + pos->z -= 1600.0f; + } else { + pos->z -= (1600.0f * (this->skelAnime.endFrame - this->skelAnime.curFrame)) / this->skelAnime.endFrame; + } + } + + return false; +} + +void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnWallmas* this = THIS; + Gfx* gfx; + + if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + } + + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + Matrix_StatePush(); + Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateY(0x2AAA, MTXMODE_APPLY); + Matrix_InsertZRotation_s(0xAAA, MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], gWallmasterLittleFingerDL); + + POLY_OPA_DISP = &gfx[2]; + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; + + if (this->actionFunc != EnWallmas_WaitToDrop) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnWallmas_OverrideLimbDraw, EnWallmas_PostLimbDraw, + &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + + EnWallmas_DrawShadow(this, globalCtx); +} 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 1bd6fbe83..06d4d24d1 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -2,16 +2,54 @@ #define Z_EN_WALLMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" + +#define WALLMASTER_GET_TYPE(thisx) ((thisx)->params) +#define WALLMASTER_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0xFF) +#define WALLMASTER_IS_FROZEN(thisx) ((thisx)->params & 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 + * whether or not to drop; they just set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_PROXIMITY: These Wallmasters ensure that the player in within a certain + * distance of their current position (as dictated by detectionRadius); once the player + * enters that range, they set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_FLAG: These Wallmasters wait for a certain switch flag to be activated, + * as specified in their params. Once this switch is activated, they set an 81-frame timer + * and drop once it reaches 0. + * + * While in the "waiting to drop" state, all Wallmaster variations can be forced to reset the + * timer to 130 frames if the player enters certain states (e.g., if the player is no longer + * touching the ground). Additionally, WALLMASTER_TYPE_PROXIMITY-type Wallmasters will reset + * the timer to 130 frames if the player strays too far from the Wallmaster's current position. + */ +typedef enum { + /* 0x00 */ WALLMASTER_TYPE_TIMER_ONLY, + /* 0x01 */ WALLMASTER_TYPE_PROXIMITY, + /* 0x02 */ WALLMASTER_TYPE_FLAG +} WallmasterType; struct EnWallmas; typedef void (*EnWallmasActionFunc)(struct EnWallmas*, GlobalContext*); typedef struct EnWallmas { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnWallmasActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnWallmasActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 switchFlag; + /* 0x192 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x228 */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x2C0 */ f32 yTarget; + /* 0x2C4 */ f32 detectionRadius; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D4 */ Vec3f limbPos[11]; + /* 0x358 */ ColliderCylinder collider; } EnWallmas; // size = 0x3A4 extern const ActorInit En_Wallmas_InitVars; 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 2a38c9042..51ef3ef38 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 @@ -7,7 +7,7 @@ #include "z_en_warp_uzu.h" #include "objects/object_warp_uzu/object_warp_uzu.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnWarpUzu*)thisx) @@ -112,8 +112,8 @@ void func_80A66278(EnWarpUzu* this, GlobalContext* globalCtx) { void func_80A66384(EnWarpUzu* this, GlobalContext* globalCtx) { globalCtx->nextEntranceIndex = 0x22A0; - gSaveContext.respawn[0].entranceIndex = globalCtx->nextEntranceIndex; - func_80169EFC(globalCtx); + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = globalCtx->nextEntranceIndex; + func_80169EFC(&globalCtx->state); gSaveContext.respawnFlag = -2; this->actionFunc = EnWarpUzu_DoNothing; } 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 1f376ace3..5759b0a9b 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 @@ -2,26 +2,28 @@ * File: z_en_warp_tag.c * Overlay: ovl_En_Warp_tag * Description: Warp to Trial Entrance + * if GoronTrial, has model: Uses GAMEPLAY_DANGEON_KEEP object assigned in EnWarptag_Init */ #include "z_en_warp_tag.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS 0x0A000011 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_8000000) #define THIS ((EnWarptag*)thisx) void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx); +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_809C085C(EnWarptag* this, GlobalContext* globalCtx); -void func_809C08E0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C09A0(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0A20(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0AB4(EnWarptag* this, GlobalContext* globalCtx); -void func_809C0E30(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx); +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Warp_tag_InitVars = { ACTOR_EN_WARP_TAG, ACTORCAT_ITEMACTION, @@ -34,32 +36,238 @@ const ActorInit En_Warp_tag_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809C1008[] = { +// this appears to be unused, as the code never accesses it in known vanilla cases +// these unknown values get passed to a unknown z_message function +u8 D_809C1000[] = { 0x28, 0x29, 0x2A, 0x2B, 0x2D, 0x2C, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_CONTINUE), ICHAIN_VEC3S(shape.rot, 0, ICHAIN_STOP), }; -#endif +void EnWarptag_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; -extern InitChainEntry D_809C1008[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetFocus(&this->dyna.actor, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Init.s") + if (GET_WARPTAG_3C0_MAX(thisx) == WARPTAG_3C0_MAX) { + this->dyna.actor.flags &= ~ACTOR_FLAG_1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Destroy.s") + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + this->actionFunc = EnWarpTag_WaitForPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C085C.s") + } else { + if ((this->dangeonKeepObject = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_DANGEON_KEEP)) < 0) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C08E0.s") + this->actionFunc = EnWarpTag_CheckDungeonKeepObject; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C09A0.s") + } else { // not used by known variants + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0A20.s") +void EnWarptag_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + if (this->dyna.actor.draw != NULL) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0AB4.s") +/** + * Loads DynaPoly from GAMEPLAY_DANGEON_KEEP. + */ +void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, GlobalContext* globalCtx) { + if (Object_IsLoaded(&globalCtx->objectCtx, this->dangeonKeepObject)) { + this->actionFunc = EnWarpTag_WaitForPlayer; + DynaPolyActor_Init(&this->dyna, 0x1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gWarpTagGoronTrialBaseCollider); + this->dyna.actor.objBankIndex = this->dangeonKeepObject; + this->dyna.actor.draw = EnWarpTag_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0E30.s") +void EnWarpTag_WaitForPlayer(EnWarptag* this, GlobalContext* globalCtx) { + if (!Player_InCsMode(&globalCtx->state) && (this->dyna.actor.xzDistToPlayer <= 30.0f) && + (this->dyna.actor.playerHeightRel <= 10.0f)) { + if (GET_WARPTAG_INVISIBLE(&this->dyna.actor)) { + func_800B7298(globalCtx, NULL, 0x51); + this->actionFunc = EnWarpTag_GrottoReturn; + } else { + func_800B7298(globalCtx, NULL, 0xF); + this->actionFunc = EnWarpTag_RespawnPlayer; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/EnWarptag_Update.s") +/** + * Unused ActionFunc: assigned in EnWarpTag_Init, no known variants use. + */ +void EnWarpTag_Unused809C09A0(EnWarptag* this, GlobalContext* globalCtx) { + if (func_800B8718(&this->dyna.actor, &globalCtx->state)) { + // func above: checks for ACTOR_FLAG_20000000, returns true and resets if set, else return false + // this actor doesnt have that flag set default, or in init, and this is called shortly after init + // and I doubt its set externally by another actor, so I believe this is unused + // might be a bug, they might have meant to set actor flag (0x2000 0000) up above but mistyped (0x200 0000) + // also GET_WARPTAG_3C0 should always return 2C0 -> 0xF for all known in-game uses, which is OOB + func_80152434(globalCtx, D_809C1000[GET_WARPTAG_3C0(&this->dyna.actor)]); // unk message function + this->actionFunc = EnWarpTag_Unused809C0A20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Warp_tag/func_809C0F3C.s") + } else { + func_800B8804(&this->dyna.actor, globalCtx, 50.0f); // updates player->unk_A90 + } +} + +/** + * Unused ActionFunc: assigned by EnWarpTag_Unused809C09A0, no known variants use. + */ +void EnWarpTag_Unused809C0A20(EnWarptag* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode == 9) { + func_800B7298(globalCtx, NULL, 7); + this->actionFunc = EnWarpTag_RespawnPlayer; + ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); + + } else if (globalCtx->msgCtx.ocarinaMode >= 2) { + globalCtx->msgCtx.ocarinaMode = 4; + this->actionFunc = EnWarpTag_Unused809C09A0; + } +} + +/** + * ActionFunc: Goron Trial (Moon), respawn at the beginning of goron rolling track, try again. + */ +void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { + ActorEntry* playerActorEntry; + Player* player; + s32 playerSpawnIndex; + s32 new15E; + s32 entranceIndex; + u32 playerSpawnIndexPerForm[PLAYER_FORM_MAX]; + u8 playerForm; + s16 playerParams; + + player = GET_PLAYER(globalCtx); + if (globalCtx->playerActorCsIds[4] >= 0 && ActorCutscene_GetCurrentIndex() != globalCtx->playerActorCsIds[4]) { + if (ActorCutscene_GetCanPlayNext(globalCtx->playerActorCsIds[4]) == 0) { + ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[4]); + + } else { + ActorCutscene_StartAndSetUnkLinkFields(globalCtx->playerActorCsIds[4], &this->dyna.actor); + func_800B8E58(player, NA_SE_PL_WARP_PLATE); + func_8016566C(0); + } + + } else { + f32 diffX = player->actor.world.pos.x - this->dyna.actor.world.pos.x; + Vec3f newRespawnPos; + f32 diffZ = player->actor.world.pos.z - this->dyna.actor.world.pos.z; + f32 distance = sqrtf(SQ(diffX) + SQ(diffZ)); + + // some weird float behavior prevention? + if (distance != 0.0f) { + distance = (distance - 1.0f) / distance; + distance = CLAMP_MIN(distance, 0.0f); + } + + player->actor.world.pos.x = this->dyna.actor.world.pos.x + (diffX * distance); + player->actor.world.pos.z = this->dyna.actor.world.pos.z + (diffZ * distance); + + if (Math_StepToS(&this->unkValue15E, 0x2710, 0xC8)) { + player->stateFlags3 |= 0x1; + player->actor.gravity = -0.5f; + + if (this->dyna.actor.playerHeightRel < -80.0f) { + playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY] = GET_WARPTAG_EXIT_INDEX(&this->dyna.actor); + playerSpawnIndexPerForm[PLAYER_FORM_HUMAN] = playerSpawnIndexPerForm[PLAYER_FORM_FIERCE_DEITY]; + playerSpawnIndexPerForm[PLAYER_FORM_GORON] = this->dyna.actor.world.rot.x; + playerSpawnIndexPerForm[PLAYER_FORM_ZORA] = this->dyna.actor.world.rot.y; + playerSpawnIndexPerForm[PLAYER_FORM_DEKU] = this->dyna.actor.world.rot.z; + + if (this->dyna.actor.draw != NULL) { + playerForm = PLAYER_BOOTS_FIERCE_DEITY; + } else { + playerForm = player->transformation; + } + + entranceIndex = gSaveContext.save.entranceIndex; + + playerSpawnIndex = playerSpawnIndexPerForm[playerForm]; + playerActorEntry = &globalCtx->linkActorEntry[playerSpawnIndex]; + newRespawnPos.x = playerActorEntry->pos.x; + newRespawnPos.y = playerActorEntry->pos.y; + newRespawnPos.z = playerActorEntry->pos.z; + + if (GET_WARPTAG_3C0_MAX(&this->dyna.actor) == WARPTAG_3C0_MAX) { + playerParams = 0x9FF; + } else { // not used by any known variant + playerParams = 0x8FF; + } + + // 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( + &globalCtx->state, 0, entranceIndex, // parameter 3 is called "sceneSetup" + globalCtx->setupEntranceList[playerSpawnIndex].room, playerParams, &newRespawnPos, + ((((playerActorEntry->rot.y >> 7) & 0x1FF) / 180.0f) * 32768.0f)); // DEG_TO_BINANG ? + + func_80169EFC(&globalCtx->state); + gSaveContext.respawnFlag = ~0x4; + func_80165690(); + } + } + + player->actor.shape.rot.y += this->unkValue15E; + new15E = this->unkValue15E - 0xFA0; + if (new15E < 0) { + new15E = 0; + } + func_80165658(new15E * 0.04f); // unknown Play_ function + } +} + +/** + * ActionFunc: Deku Playground, return to North Clock Town. + */ +void EnWarpTag_GrottoReturn(EnWarptag* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } + } + + if (this->grottoExitDelay++ == 10) { + globalCtx->nextEntranceIndex = globalCtx->setupExitList[GET_WARPTAG_EXIT_INDEX(&this->dyna.actor)]; + Scene_SetExitFade(globalCtx); + globalCtx->sceneLoadFlag = 0x14; + func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); + func_801A4058(5); + if (1) {} + gSaveContext.seqIndex = 0xFF; + gSaveContext.nightSeqIndex = 0xFF; + } +} + +void EnWarptag_Update(Actor* thisx, GlobalContext* globalCtx) { + EnWarptag* this = THIS; + this->actionFunc(this, globalCtx); +} + +/** + * Only draws for Goron Trial (a rainblow animated target). + */ +void EnWarpTag_Draw(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWarpTagRainbowAnimMat)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_OPA_DISP++, gWarpTagGoronTrialBaseDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h index 1be6eb5ec..925fda930 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.h @@ -8,11 +8,27 @@ struct EnWarptag; typedef void (*EnWarptagActionFunc)(struct EnWarptag*, GlobalContext*); typedef struct EnWarptag { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ EnWarptagActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s8 dangeonKeepObject; + /* 0x15E */ union { + s16 reusedValue; // default name + s16 unkValue15E; // passed to unk play func, mods player rotation, stepped to 0x2710 + s16 grottoExitDelay; // 10 frame delay before player can leave the grotto + }; + /* 0x160 */ EnWarptagActionFunc actionFunc; } EnWarptag; // size = 0x164 extern const ActorInit En_Warp_tag_InitVars; +// Only two known Variants: +// Goron Trial (MOON): 0x03C1 +// Deku Playground: 0x83C0 + +#define GET_WARPTAG_3C0_MAX(thisx) ((thisx)->params & 0x3C0) +#define GET_WARPTAG_3C0(thisx) (((thisx)->params >> 6) & 0xF) +#define GET_WARPTAG_EXIT_INDEX(thisx) ((thisx)->params & 0x3F) +#define GET_WARPTAG_INVISIBLE(thisx) ((thisx)->params < 0) // 0x8000 flag + +#define WARPTAG_3C0_MAX 0x3C0 + #endif // Z_EN_WARP_TAG_H 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 3d2f837a0..127bcc1c2 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 @@ -8,7 +8,7 @@ #include "objects/object_water_effect/object_water_effect.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000035 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnWaterEffect*)thisx) @@ -82,7 +82,7 @@ void EnWaterEffect_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnWaterEffect* this = THIS; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_DC4 = Rand_ZeroFloat(100.0f); if (this->actor.params == ENWATEREFFECT_1) { @@ -296,7 +296,7 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_InsertTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } else { Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); } @@ -405,7 +405,7 @@ void func_80A59C04(Actor* thisx, GlobalContext* globalCtx2) { if ((rotaryRoom != NULL) && Flags_GetSwitch(globalCtx, (rotaryRoom->params >> 1) & 0x7F)) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; - } else if (!func_801690CC(globalCtx)) { + } else if (!Play_InCsMode(globalCtx)) { this->unk_DC4++; if (this->unk_DC6 == 0) { this->unk_DC6 = Rand_ZeroFloat(150.0f) + 100.0f; @@ -535,7 +535,7 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { if (ptr->unk_2A >= 2) { Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); } else { - Matrix_RotateY(func_800DFC68(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateY(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c index b04de536b..b21e2f0b8 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c @@ -6,7 +6,7 @@ #include "z_en_wdhand.h" -#define FLAGS 0x00000005 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #define THIS ((EnWdhand*)thisx) 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 c276b222a..f4d999fae 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 @@ -6,7 +6,7 @@ #include "z_en_weather_tag.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnWeatherTag*)thisx) @@ -67,7 +67,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { s32 pathID; // flag: is targetable. Should do nothing as not set by default above - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; switch (WEATHER_TAG_TYPE(this)) { case WEATHERTAG_TYPE_UNK0: @@ -77,7 +77,7 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag_SetupAction(this, func_80966A08); break; case WEATHERTAG_TYPE_UNK1: - if (gSaveContext.save.weekEventReg[0x34] & 0x20) { // if cleared STT + if (gSaveContext.save.weekEventReg[52] & 0x20) { // if cleared STT Actor_MarkForDeath(&this->actor); } EnWeatherTag_SetupAction(this, func_80966B08); @@ -191,11 +191,11 @@ void func_8096689C(EnWeatherTag* this, GlobalContext* globalCtx) { globalCtx->envCtx.windSpeed = (this->actor.world.rot.z * partialResult) + 30.0f; if (partialResult > 0.01f) { - globalCtx->envCtx.unk_EA = 8; + globalCtx->envCtx.sandstormState = 8; D_801F4E30 = 0x9B; - } else if (globalCtx->envCtx.unk_EA == 8) { + } else if (globalCtx->envCtx.sandstormState == 8) { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 9; + globalCtx->envCtx.sandstormState = 9; } } @@ -249,9 +249,9 @@ void func_80966BF4(EnWeatherTag* this, GlobalContext* globalCtx) { u8 newUnk20; CsCmdActorAction* tmpAction; - if (func_800EE29C(globalCtx, 0x237) != 0) { - tmpAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x237)]; - if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->unk0 >= 2)) { + if (Cutscene_CheckActorAction(globalCtx, 567)) { + tmpAction = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 567)]; + if ((globalCtx->csCtx.frames >= tmpAction->startFrame) && (tmpAction->action >= 2)) { switch (gSaveContext.save.day) { case 0: case 1: @@ -422,27 +422,27 @@ void func_809672DC(EnWeatherTag* this, GlobalContext* globalCtx) { f32 range; f32 strength = 0.0f; - func_800BCCDC(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, &this->actor.world.pos, - 0); + Actor_GetClosestPosOnPath(this->pathPoints, this->pathCount, &GET_PLAYER(globalCtx)->actor.world.pos, + &this->actor.world.pos, false); distance = Actor_XZDistanceBetweenActors(&player->actor, &this->actor); range = WEATHER_TAG_RANGE100(this); if (distance < range) { - globalCtx->envCtx.unk_EA = 6; + globalCtx->envCtx.sandstormState = 6; strength = 1.0f - (distance / range); if (0.8f < strength) { strength = 1.0f; } D_801F4E30 = (200.0f * strength); } else { - if (globalCtx->envCtx.unk_EA == 6) { + if (globalCtx->envCtx.sandstormState == 6) { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 7; + globalCtx->envCtx.sandstormState = 7; } } - Math_SmoothStepToS(&globalCtx->envCtx.unk_8C.fogNear, (s16)(-40.0f * strength), 1, 1, 1); + Math_SmoothStepToS(&globalCtx->envCtx.lightSettings.fogNear, (s16)(-40.0f * strength), 1, 1, 1); } // WEATHERTAG_TYPE_LOCALDAY2RAIN: rain proximity as approaching rainy scene @@ -452,7 +452,7 @@ void func_809674C8(EnWeatherTag* this, GlobalContext* globalCtx) { if (Actor_XZDistanceBetweenActors(&player->actor, &this->actor) < WEATHER_TAG_RANGE100(this)) { if (CURRENT_DAY == 2) { - if ((gSaveContext.save.time >= 0x4AAA) && (gSaveContext.save.time < 0xBAAA) && + if ((gSaveContext.save.time >= CLOCK_TIME(7, 0)) && (gSaveContext.save.time < CLOCK_TIME(17, 30)) && (globalCtx->envCtx.unk_F2[2] == 0)) { D_801BDBB0 = 1; @@ -485,9 +485,9 @@ void EnWeatherTag_Update(Actor* thisx, GlobalContext* globalCtx) { u16 oldTime; this->actionFunc(this, globalCtx); - if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && (globalCtx->msgCtx.unk11F04 == 0x5E6) && - (!FrameAdvance_IsEnabled(globalCtx)) && (globalCtx->sceneLoadFlag == 0) && - (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { + if ((globalCtx->actorCtx.unk5 & 2) && (globalCtx->msgCtx.msgMode != 0) && + (globalCtx->msgCtx.currentTextId == 0x5E6) && (!FrameAdvance_IsEnabled(&globalCtx->state)) && + (globalCtx->sceneLoadFlag == 0) && (ActorCutscene_GetCurrentIndex() == -1) && (globalCtx->csCtx.state == 0)) { oldTime = gSaveContext.save.time; gSaveContext.save.time = (u16)REG(0xF) + oldTime; // cast req 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 12bed5ca1..3b92a8eab 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" #include "objects/object_wf/object_wf.h" -#define FLAGS 0x00000415 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((EnWf*)thisx) @@ -360,25 +360,25 @@ void EnWf_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void func_809907D4(EnWf* this) { - this->unk_2B0 = 0.75f; - this->unk_2B4 = 1.125f; - this->unk_2AC = 1.0f; - this->unk_296 = 10; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffFrozenSteamScale = 1.125f; + this->drawDmgEffAlpha = 1.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; this->collider2.base.colType = COLTYPE_HIT3; this->collider3.base.colType = COLTYPE_HIT3; this->unk_2A0 = 80; - this->actor.flags &= ~0x400; + this->actor.flags &= ~ACTOR_FLAG_400; Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 80); } void func_80990854(EnWf* this, GlobalContext* globalCtx) { - if (this->unk_296 == 10) { - this->unk_296 = 0; + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->collider2.base.colType = COLTYPE_HIT5; this->collider3.base.colType = COLTYPE_HIT5; - this->unk_2AC = 0.0f; - Actor_SpawnIceEffects(globalCtx, &this->actor, this->unk_2B8, 10, 2, 0.3f, 0.2f); - this->actor.flags |= 0x400; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 10, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; } } @@ -526,7 +526,7 @@ void func_80990F0C(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; this->actor.shape.shadowScale = 0.0f; this->actor.scale.y = 0.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2A0 = 60; this->actionFunc = func_80990F50; } @@ -552,7 +552,7 @@ void func_80990F50(EnWf* this, GlobalContext* globalCtx) { void func_80990FC8(EnWf* this) { Animation_Change(&this->skelAnime, &object_wf_Anim_0053D0, 0.5f, 0.0f, 7.0f, 3, 0.0f); this->unk_2A0 = 5; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; } @@ -1158,7 +1158,7 @@ void func_80992D6C(EnWf* this) { if (this->actor.bgCheckFlags & 1) { this->actor.speedXZ = -6.0f; } - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; this->unk_2A0 = 25; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_DEAD); this->actionFunc = func_80992E0C; @@ -1410,7 +1410,7 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { this->collider3.base.acFlags &= ~AC_HIT; this->collider1.base.atFlags &= ~AT_ON; - if (((this->unk_296 != 10) || + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || !(collider->info.acHitInfo->toucher.dmgFlags & (0x80000 | 0x40000 | 0x10000 | 0x8000 | 0x2000 | 0x1000 | 0x80 | 0x20 | 0x10 | 0x2 | 0x1))) && (this->actor.colChkInfo.damageEffect != 0xF)) { @@ -1428,9 +1428,9 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { } else if (this->actor.colChkInfo.damageEffect == 5) { this->unk_2A0 = 40; Actor_SetColorFilter(&this->actor, 0, 0xFF, 0, 40); - this->unk_296 = 30; - this->unk_2B0 = 0.75f; - this->unk_2AC = 2.0f; + 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); func_809923B0(this); } else if (this->actor.colChkInfo.damageEffect == 3) { @@ -1442,13 +1442,13 @@ void func_8099386C(EnWf* this, GlobalContext* globalCtx) { func_809923B0(this); } else { if (this->actor.colChkInfo.damageEffect == 2) { - this->unk_296 = 0; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; } else if (this->actor.colChkInfo.damageEffect == 4) { - this->unk_296 = 20; - this->unk_2B0 = 0.75f; - this->unk_2AC = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + this->drawDmgEffScale = 0.75f; + this->drawDmgEffAlpha = 4.0f; Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, collider->info.bumper.hitPos.x, collider->info.bumper.hitPos.y, collider->info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); @@ -1517,16 +1517,16 @@ void EnWf_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_SetFocus(&this->actor, 25.0f); - if (this->unk_2AC > 0.0f) { - if (this->unk_296 != 10) { - Math_StepToF(&this->unk_2AC, 0.0f, 0.05f); - this->unk_2B0 = (this->unk_2AC + 1.0f) * 0.375f; - if (this->unk_2B0 > 0.75f) { - this->unk_2B0 = 0.75f; + 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; + if (this->drawDmgEffScale > 0.75f) { + this->drawDmgEffScale = 0.75f; } else { - this->unk_2B0 = this->unk_2B0; + this->drawDmgEffScale = this->drawDmgEffScale; } - } else if (!Math_StepToF(&this->unk_2B4, 0.75f, 0.01875f)) { + } else if (!Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.75f, 0.01875f)) { func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } } @@ -1551,7 +1551,7 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec Collider_UpdateSpheres(limbIndex, &this->collider1); if (D_809942FC[limbIndex] != -1) { - Matrix_GetStateTranslation(&this->unk_2B8[D_809942FC[limbIndex]]); + Matrix_GetStateTranslation(&this->limbPos[D_809942FC[limbIndex]]); } if (limbIndex == 6) { @@ -1580,8 +1580,9 @@ void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnWf_OverrideLimbDraw, EnWf_PostLimbDraw, &this->actor); - func_800BE680(globalCtx, &this->actor, this->unk_2B8, 10, this->unk_2B0, this->unk_2B4, this->unk_2AC, - this->unk_296); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); } } diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.h b/src/overlays/actors/ovl_En_Wf/z_en_wf.h index defd8fc79..e697ef072 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -17,7 +17,7 @@ typedef struct EnWf { /* 0x0290 */ EnWfActionFunc actionFunc; /* 0x0294 */ u8 unk_294; /* 0x0295 */ u8 unk_295; - /* 0x0296 */ u8 unk_296; + /* 0x0296 */ u8 drawDmgEffType; /* 0x0298 */ s16 unk_298; /* 0x029A */ s16 unk_29A; /* 0x029C */ s16 unk_29C; @@ -26,10 +26,10 @@ typedef struct EnWf { /* 0x02A2 */ u16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 unk_2AC; - /* 0x02B0 */ f32 unk_2B0; - /* 0x02B4 */ f32 unk_2B4; - /* 0x02B8 */ Vec3f unk_2B8[10]; + /* 0x02AC */ f32 drawDmgEffAlpha; + /* 0x02B0 */ f32 drawDmgEffScale; + /* 0x02B4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x02B8 */ Vec3f limbPos[10]; /* 0x0330 */ ColliderJntSph collider1; /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; /* 0x0450 */ ColliderCylinder collider2; 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 9264f42fb..7279650e7 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -6,7 +6,9 @@ #include "z_en_wiz.h" -#define FLAGS 0x88101035 +#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 THIS ((EnWiz*)thisx) 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 1fa6bd35b..d6ae08331 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 @@ -6,7 +6,7 @@ #include "z_en_wiz_brock.h" -#define FLAGS 0x08000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #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 0bdbf8679..80dd47feb 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 0x08000015 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_8000000) #define THIS ((EnWizFire*)thisx) @@ -70,7 +70,7 @@ void EnWizFire_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 3; this->unk_172 = 10; this->unk_1FC = 255.0f; - this->actor.flags &= ~1; + this->actor.flags &= ~ACTOR_FLAG_1; if (!func_8012405C(globalCtx)) { this->collider.info.toucher.dmgFlags = 0x20000000; @@ -108,19 +108,19 @@ void EnWizFire_Destroy(Actor* thisx, GlobalContext* globalCtx) { EnWizFire* this = THIS; if (this->unk_162 == 0) { - globalCtx->envCtx.unk_8C.fogColor[2] = 0; - globalCtx->envCtx.unk_8C.fogColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.fogColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor2[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.diffuseColor1[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[2] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[1] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.ambientColor[0] = globalCtx->envCtx.unk_8C.fogColor[2]; - globalCtx->envCtx.unk_8C.fogNear = globalCtx->envCtx.unk_8C.fogColor[2]; + globalCtx->envCtx.lightSettings.fogColor[2] = 0; + globalCtx->envCtx.lightSettings.fogColor[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.fogColor[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor2[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.diffuseColor1[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[2] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[1] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.ambientColor[0] = globalCtx->envCtx.lightSettings.fogColor[2]; + globalCtx->envCtx.lightSettings.fogNear = globalCtx->envCtx.lightSettings.fogColor[2]; } Collider_DestroyCylinder(globalCtx, &this->collider); } @@ -483,37 +483,37 @@ void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { phi_f0 = 968.0f; } - globalCtx->envCtx.unk_8C.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; + globalCtx->envCtx.lightSettings.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[0] = + globalCtx->envCtx.lightSettings.ambientColor[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.ambientColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[1] = + globalCtx->envCtx.lightSettings.ambientColor[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.ambientColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.ambientColor[2] = + globalCtx->envCtx.lightSettings.ambientColor[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.ambientColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.diffuseColor1[0] = + globalCtx->envCtx.lightSettings.diffuseColor1[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor1[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor1[1] = + globalCtx->envCtx.lightSettings.diffuseColor1[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor1[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor1[2] = + globalCtx->envCtx.lightSettings.diffuseColor1[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor1[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.diffuseColor2[0] = + globalCtx->envCtx.lightSettings.diffuseColor2[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.diffuseColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor2[1] = + globalCtx->envCtx.lightSettings.diffuseColor2[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.diffuseColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.diffuseColor2[2] = + globalCtx->envCtx.lightSettings.diffuseColor2[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.diffuseColor[2]) * this->unk_204; idx++; - globalCtx->envCtx.unk_8C.fogColor[0] = + globalCtx->envCtx.lightSettings.fogColor[0] = ((f32)D_80A4C234[idx].r - globalCtx->envCtx.unk_C4.fogColor[0]) * this->unk_204; - globalCtx->envCtx.unk_8C.fogColor[1] = + globalCtx->envCtx.lightSettings.fogColor[1] = ((f32)D_80A4C234[idx].g - globalCtx->envCtx.unk_C4.fogColor[1]) * this->unk_204; - globalCtx->envCtx.unk_8C.fogColor[2] = + globalCtx->envCtx.lightSettings.fogColor[2] = ((f32)D_80A4C234[idx].b - globalCtx->envCtx.unk_C4.fogColor[2]) * this->unk_204; } } @@ -699,7 +699,8 @@ void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); Matrix_StatePop(); - Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, 0); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + MTXMODE_NEW); Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); gSPSegment(POLY_XLU_DISP++, 0x08, 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 e24a5af95..446d92cbd 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.c @@ -5,6 +5,7 @@ */ #include "z_en_wood02.h" +#include "objects/object_wood02/object_wood02.h" #define FLAGS 0x00000000 @@ -15,7 +16,28 @@ void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx); void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +/** + * WOOD_SPAWN_SPAWNER is also used by some individual trees: EnWood02_Update also checks for parent before running any + * despawning code. + * */ +typedef enum { + /* 0 */ WOOD_SPAWN_NORMAL, + /* 1 */ WOOD_SPAWN_SPAWNED, + /* 2 */ WOOD_SPAWN_SPAWNER +} WoodSpawnType; + +typedef enum { + /* 0 */ WOOD_DRAW_TREE_CONICAL, + /* 1 */ WOOD_DRAW_TREE_OVAL, + /* 2 */ WOOD_DRAW_TREE_KAKARIKO_ADULT, + /* 3 */ WOOD_DRAW_BUSH_GREEN, + /* 4 */ WOOD_DRAW_4, // Used for black bushes and green leaves + /* 5 */ WOOD_DRAW_LEAF_YELLOW +} WoodDrawType; + +static f32 sSpawnCos; +static f32 sSpawnSin; + const ActorInit En_Wood02_InitVars = { ACTOR_EN_WOOD02, ACTORCAT_PROP, @@ -28,29 +50,464 @@ const ActorInit En_Wood02_InitVars = { (ActorFunc)EnWood02_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808C4D00 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x0100020A, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x0100020A, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 60, 0, { 0, 0, 0 } }, }; -#endif +static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f }; -extern ColliderCylinderInit D_808C4D00; +static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 }; -extern UNK_TYPE D_06000700; +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3C00.s") +Gfx* D_808C4D54[] = { + object_wood02_DL_0078D0, object_wood02_DL_007CA0, object_wood02_DL_008160, object_wood02_DL_000090, + object_wood02_DL_000340, object_wood02_DL_000340, object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C3D28.s") +Gfx* D_808C4D70[] = { + object_wood02_DL_007968, + object_wood02_DL_007D38, + object_wood02_DL_0080D0, + NULL, + NULL, + NULL, + object_wood02_DL_007AD0, + object_wood02_DL_007E20, + object_wood02_DL_009340, + object_wood02_DL_000160, + object_wood02_DL_000440, + object_wood02_DL_000700, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Init.s") +s32 EnWood02_SpawnZoneCheck(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2) { + f32 phi_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Destroy.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg2, &this->actor.projectedPos, + &this->actor.projectedW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/func_808C4458.s") + if (this->actor.projectedW == 0.0f) { + phi_f12 = 1000.0f; + } else { + phi_f12 = fabsf(1.0f / this->actor.projectedW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Update.s") + if (((-this->actor.uncullZoneScale < this->actor.projectedPos.z) && + (this->actor.projectedPos.z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale)) && + (((fabsf(this->actor.projectedPos.x) - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) && + (((this->actor.projectedPos.y + this->actor.uncullZoneDownward) * phi_f12) > -1.0f) && + (((this->actor.projectedPos.y - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wood02/EnWood02_Draw.s") +/** Spawns similar-looking trees or bushes only when the player is sufficiently close. Presumably done this way to keep + * memory usage down in Hyrule Field. */ +void EnWood02_SpawnOffspring(EnWood02* this, GlobalContext* globalCtx) { + EnWood02* child; + s32 extraRot; + Vec3f childPos; + s32 unk; + s32 i; + s16 childParams; + + for (i = 4; i >= 0; i--) { + extraRot = 0; + if (!(this->unk_14A[i] & 0x7F)) { + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + sSpawnCos = Math_CosS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + sSpawnSin = Math_SinS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot); + + childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x; + childPos.y = this->actor.home.pos.y; + childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z; + + if (EnWood02_SpawnZoneCheck(this, globalCtx, &childPos)) { + if (this->unk_14A[i] & 0x80) { + unk = 0; + } else { + unk = this->actor.home.rot.z; + } + + childParams = ((this->unk_144 << 8) & 0xFF00) | (this->actor.params + 1); + child = (EnWood02*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_WOOD02, + childPos.x, childPos.y, childPos.z, this->actor.world.rot.x, + sSpawnAngle[i], unk, childParams); + if (child != NULL) { + child->unk_14A[0] = i; + this->unk_14A[i] |= 1; + child->actor.projectedPos = this->actor.projectedPos; + } else { + this->unk_14A[i] &= 0x80; + } + } + } + } +} + +void EnWood02_Init(Actor* thisx, GlobalContext* globalCtx) { + s16 spawnType = 0; + f32 actorScale = 1.0f; + EnWood02* this = THIS; + s32 pad; + CollisionPoly* outPoly; + s32 bgId; + f32 floorY; + s16 extraRot; + + this->actor.world.rot.z = 0; + this->unk_144 = ENWOOD02_GET_FF00(&this->actor); + this->unk_146 = -1; + this->actor.shape.rot.z = this->actor.world.rot.z; + + if (this->unk_144 & 0x80) { + this->unk_144 = -1; + } + + this->actor.params &= 0xFF; + this->unk_148 = this->actor.home.rot.z; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + } + + if ((this->actor.params == WOOD_TREE_SPECIAL) && !gSaveContext.save.isNight && (this->unk_144 != -1) && + !Flags_GetCollectible(globalCtx, this->unk_144)) { + this->actor.child = + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, 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->unk_151 = 1; + } else { + this->actor.child = NULL; + this->unk_151 = 0; + } + + switch (this->actor.params) { + case WOOD_BUSH_GREEN_LARGE_SPAWNER: + case WOOD_BUSH_BLACK_LARGE_SPAWNER: + spawnType = 1; + + case WOOD_BUSH_GREEN_LARGE_SPAWNED: + case WOOD_BUSH_BLACK_LARGE_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_LARGE: + case WOOD_BUSH_GREEN_LARGE: + case WOOD_BUSH_BLACK_LARGE: + case WOOD_TREE_SPECIAL: + actorScale = 1.5f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 2000.0f; + this->actor.uncullZoneDownward = 2400.0f; + break; + + case WOOD_TREE_CONICAL_SPAWNER: + case WOOD_TREE_OVAL_YELLOW_SPAWNER: + case WOOD_TREE_OVAL_GREEN_SPAWNER: + case WOOD_BUSH_GREEN_SMALL_SPAWNER: + case WOOD_BUSH_BLACK_SMALL_SPAWNER: + spawnType = 1; + + case WOOD_TREE_CONICAL_SPAWNED: + case WOOD_TREE_OVAL_YELLOW_SPAWNED: + case WOOD_TREE_OVAL_GREEN_SPAWNED: + case WOOD_BUSH_GREEN_SMALL_SPAWNED: + case WOOD_BUSH_BLACK_SMALL_SPAWNED: + spawnType++; + + case WOOD_TREE_CONICAL_MEDIUM: + case WOOD_TREE_OVAL_GREEN: + case WOOD_TREE_KAKARIKO_ADULT: + case WOOD_BUSH_GREEN_SMALL: + case WOOD_BUSH_BLACK_SMALL: + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 800.0f; + this->actor.uncullZoneDownward = 1800.0f; + break; + + case WOOD_TREE_CONICAL_SMALL: + actorScale = 0.6f; + this->actor.uncullZoneForward = 4000.0f; + this->actor.uncullZoneScale = 400.0f; + this->actor.uncullZoneDownward = 1000.0f; + break; + + case WOOD_LEAF_GREEN: + case WOOD_LEAF_YELLOW: + this->unk_14A[0] = 75; + actorScale = 0.02f; + this->actor.velocity.x = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.z = randPlusMinusPoint5Scaled(6.0f); + this->actor.velocity.y = (Rand_ZeroOne() * 1.25f) + -3.1f; + break; + } + + if (this->actor.params < WOOD_TREE_OVAL_GREEN) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else if (this->actor.params < WOOD_TREE_KAKARIKO_ADULT) { + this->drawType = WOOD_DRAW_TREE_OVAL; + } else if (this->actor.params < WOOD_BUSH_GREEN_SMALL) { + this->drawType = WOOD_DRAW_TREE_KAKARIKO_ADULT; + } else if (this->actor.params < WOOD_BUSH_BLACK_SMALL) { + this->drawType = WOOD_DRAW_BUSH_GREEN; + } else if (this->actor.params < WOOD_LEAF_YELLOW) { + this->drawType = WOOD_DRAW_4; + } else if (this->actor.params == WOOD_TREE_SPECIAL) { + this->drawType = WOOD_DRAW_TREE_CONICAL; + } else { + this->drawType = WOOD_DRAW_LEAF_YELLOW; + } + + Actor_SetScale(&this->actor, actorScale); + this->spawnType = spawnType; + + if (spawnType != WOOD_SPAWN_NORMAL) { + extraRot = 0; + if (this->actor.params == WOOD_BUSH_GREEN_LARGE_SPAWNER) { + extraRot = 0x4000; + } + + if (spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + 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]; + } else { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_151 = 2; + } + + // Snap to floor, or remove if over void + this->actor.world.pos.y += 200.0f; + floorY = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &outPoly, &bgId, &this->actor, &this->actor.world.pos); + + if (floorY > BGCHECK_Y_MIN) { + this->actor.world.pos.y = floorY; + } else { + Actor_MarkForDeath(&this->actor); + return; + } + } + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + this->actor.home.rot.y = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; +} + +void EnWood02_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWood02* this = THIS; + + if ((this->actor.params < WOOD_BUSH_GREEN_SMALL) || (this->actor.params == WOOD_TREE_SPECIAL)) { + Collider_DestroyCylinder(globalCtx, &this->collider); + } +} + +void func_808C4458(EnWood02* this, GlobalContext* globalCtx, Vec3f* arg2, u16 arg3) { + s32 pad[2]; + s32 sp24; + + if (this->unk_148 != 0) { + if ((this->unk_144 == -1) || !Flags_GetCollectible(globalCtx, this->unk_144)) { + if ((this->unk_148 < 0) && (this->unk_148 >= -0x10)) { + if (arg3 & 1) { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, ((-1 - this->unk_148) * 0x10) | 0x8000); + } else { + Item_DropCollectibleRandom(globalCtx, &this->actor, arg2, (-1 - this->unk_148) * 0x10); + } + } else if (this->unk_148 > 0) { + sp24 = func_800A8150(this->unk_148 - 1); + if (sp24 >= 0) { + if (this->unk_144 == -1) { + Item_DropCollectible(globalCtx, arg2, sp24); + } else { + Item_DropCollectible(globalCtx, arg2, ((this->unk_144 & 0x7F) << 8) | sp24); + } + } + } + } + this->unk_148 = 0; + } +} + +void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + EnWood02* this = THIS; + f32 wobbleAmplitude; + + // Despawn extra trees in a group if out of range + if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (thisx->parent != NULL)) { + if (!(thisx->flags & 0x40) && (this->unk_151 != 2)) { + s32 index = this->unk_14A[0]; + s32 phi_v0 = 0; + + if (this->unk_148 == 0) { + phi_v0 = 0x80; + } + + ((EnWood02*)thisx->parent)->unk_14A[index] = phi_v0; + + Actor_MarkForDeath(thisx); + return; + } + this->unk_151 = 0; + } else if (this->spawnType == WOOD_SPAWN_SPAWNER) { + EnWood02_SpawnOffspring(this, globalCtx); + } + + 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); + } + + if (thisx->home.rot.y != 0) { + Vec3f dropsSpawnPt = thisx->world.pos; + + dropsSpawnPt.y += 200.0f; + + func_808C4458(this, globalCtx, &dropsSpawnPt, 0); + + // Spawn falling leaves + if (this->unk_146 >= -1) { + s32 i; + s32 leavesParams = WOOD_LEAF_GREEN; + + if ((thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNER) || + (thisx->params == WOOD_TREE_OVAL_YELLOW_SPAWNED)) { + leavesParams = WOOD_LEAF_YELLOW; + } + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + + for (i = 3; i >= 0; i--) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WOOD02, dropsSpawnPt.x, dropsSpawnPt.y, + dropsSpawnPt.z, 0, randPlusMinusPoint5Scaled(0xFFFF), 0, leavesParams); + } + } + + if ((thisx->child != NULL) && (this->unk_151 == 1)) { + thisx->child->home.rot.x = 1; + this->unk_151 = 0; + } + + if ((thisx->params == WOOD_TREE_SPECIAL) && (this->unk_144 != -1)) { + Flags_SetCollectible(globalCtx, this->unk_144); + this->unk_144 = -1; + } + this->unk_146 = -0x15; + thisx->home.rot.y = 0; + } + + if (thisx->xzDistToPlayer < 600.0f) { + Collider_UpdateCylinder(thisx, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } else if ((thisx->params < WOOD_LEAF_GREEN) || (thisx->params == WOOD_TREE_SPECIAL)) { // not leaves + Player* player = GET_PLAYER(globalCtx); + + 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)))) { + func_808C4458(this, globalCtx, &thisx->world.pos, 1); + this->unk_146 = -0x15; + Actor_PlaySfxAtPos(thisx, NA_SE_EV_TREE_SWING); + } + } else { // Leaves + this->unk_146++; + Math_ApproachF(&thisx->velocity.x, 0.0f, 1.0f, 5.0f * 0.01f); + Math_ApproachF(&thisx->velocity.z, 0.0f, 1.0f, 5.0f * 0.01f); + Actor_UpdatePos(thisx); + thisx->shape.rot.z = Math_SinS(this->unk_146 * 0xBB8) * 16384.0f; + this->unk_14A[0]--; + if (this->unk_14A[0] == 0) { + Actor_MarkForDeath(thisx); + } + } + + // Wobble from impact + if (this->unk_146 < -1) { + this->unk_146++; + wobbleAmplitude = Math_SinS((this->unk_146 ^ 0xFFFF) * 0x3332) * 250.0f; + thisx->shape.rot.x = Math_CosS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + thisx->shape.rot.z = Math_SinS(thisx->yawTowardsPlayer - thisx->shape.rot.y) * wobbleAmplitude; + } +} + +void EnWood02_Draw(Actor* thisx, GlobalContext* globalCtx) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + s16 type; + s16 pad; + u8 red; + u8 green; + u8 blue; + + OPEN_DISPS(gfxCtx); + type = thisx->params; + + if ((type == WOOD_TREE_OVAL_GREEN_SPAWNER) || (type == WOOD_TREE_OVAL_GREEN_SPAWNED) || + (type == WOOD_TREE_OVAL_GREEN) || (type == WOOD_LEAF_GREEN)) { + red = 50; + green = 170; + blue = 70; + } else if ((type == WOOD_TREE_OVAL_YELLOW_SPAWNER) || (type == WOOD_TREE_OVAL_YELLOW_SPAWNED) || + (type == WOOD_LEAF_YELLOW)) { + red = 180; + green = 155; + blue = 0; + } else { + red = green = blue = 255; + } + + func_8012C2DC(gfxCtx); + + if ((thisx->params == WOOD_LEAF_GREEN) || (thisx->params == WOOD_LEAF_YELLOW)) { + func_8012C28C(gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, 127); + + Gfx_DrawDListOpa(globalCtx, object_wood02_DL_000700); + } else if (D_808C4D70[THIS->drawType & 0xF] != NULL) { + Gfx_DrawDListOpa(globalCtx, D_808C4D54[THIS->drawType & 0xF]); + + gDPSetEnvColor(POLY_XLU_DISP++, red, green, blue, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D70[THIS->drawType & 0xF]); + } else { + func_8012C2DC(gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_808C4D54[THIS->drawType & 0xF]); + } + + CLOSE_DISPS(gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h index ef638cfcd..310d1e5de 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h @@ -5,11 +5,51 @@ struct EnWood02; +#define ENWOOD02_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct EnWood02 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x5C]; + /* 0x144 */ s16 unk_144; + /* 0x146 */ s16 unk_146; + /* 0x148 */ s16 unk_148; + /* 0x14A */ u8 unk_14A[5]; + /* 0x14F */ u8 spawnType; + /* 0x150 */ u8 drawType; + /* 0x151 */ u8 unk_151; + /* 0x154 */ ColliderCylinder collider; } EnWood02; // size = 0x1A0 +// Types with SPAWNED in the name are those that can be managed by a spawner, however the actor allows you to spawn them +// on their own without a spawner as well. +typedef enum { + /* 0x00 */ WOOD_TREE_CONICAL_LARGE, + /* 0x01 */ WOOD_TREE_CONICAL_MEDIUM, + /* 0x02 */ WOOD_TREE_CONICAL_SMALL, + /* 0x03 */ WOOD_TREE_CONICAL_SPAWNER, + /* 0x04 */ WOOD_TREE_CONICAL_SPAWNED, + /* 0x05 */ WOOD_TREE_OVAL_GREEN, + /* 0x06 */ WOOD_TREE_OVAL_YELLOW_SPAWNER, + /* 0x07 */ WOOD_TREE_OVAL_YELLOW_SPAWNED, + /* 0x08 */ WOOD_TREE_OVAL_GREEN_SPAWNER, + /* 0x09 */ WOOD_TREE_OVAL_GREEN_SPAWNED, + /* 0x0A */ WOOD_TREE_KAKARIKO_ADULT, + /* 0x0B */ WOOD_BUSH_GREEN_SMALL, + /* 0x0C */ WOOD_BUSH_GREEN_LARGE, + /* 0x0D */ WOOD_BUSH_GREEN_SMALL_SPAWNER, + /* 0x0E */ WOOD_BUSH_GREEN_SMALL_SPAWNED, + /* 0x0F */ WOOD_BUSH_GREEN_LARGE_SPAWNER, + /* 0x10 */ WOOD_BUSH_GREEN_LARGE_SPAWNED, + /* 0x11 */ WOOD_BUSH_BLACK_SMALL, + /* 0x12 */ WOOD_BUSH_BLACK_LARGE, + /* 0x13 */ WOOD_BUSH_BLACK_SMALL_SPAWNER, + /* 0x14 */ WOOD_BUSH_BLACK_SMALL_SPAWNED, + /* 0x15 */ WOOD_BUSH_BLACK_LARGE_SPAWNER, + /* 0x16 */ WOOD_BUSH_BLACK_LARGE_SPAWNED, + /* 0x17 */ WOOD_LEAF_GREEN, + /* 0x18 */ WOOD_LEAF_YELLOW, + /* 0x1A */ WOOD_TREE_SPECIAL = 0x1A +} WoodType; + extern const ActorInit En_Wood02_InitVars; #endif // Z_EN_WOOD02_H 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 bb3f81576..25cf4c473 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -5,8 +5,9 @@ */ #include "z_en_yb.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((EnYb*)thisx) @@ -15,16 +16,22 @@ void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnYb_Update(Actor* thisx, GlobalContext* globalCtx); void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BFA730(EnYb* this, GlobalContext* globalCtx); -void func_80BFA868(EnYb* this, GlobalContext* globalCtx); -void func_80BFA91C(EnYb* this, GlobalContext* globalCtx); -void func_80BFA9D4(EnYb* this, GlobalContext* globalCtx); -void func_80BFAB4C(EnYb* this, GlobalContext* globalCtx); -void func_80BFABF0(EnYb* this, GlobalContext* globalCtx); -void func_80BFAC88(EnYb* this, GlobalContext* globalCtx); -void func_80BFAE80(EnYb* this, GlobalContext* globalCtx); +void EnYb_Idle(EnYb* this, GlobalContext* globalCtx); +void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx); +void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx); + +void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx); +void EnYb_FinishTeachingCutscene(EnYb* this); +void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx); +void EnYb_ReceiveMask(EnYb* this, GlobalContext* globalCtx); +void EnYb_Talk(EnYb* this, GlobalContext* globalCtx); +void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx); +void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx); + +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx); +void EnYb_SetAnimation(GlobalContext*, EnYb*, s16, u8, f32); +s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Yb_InitVars = { ACTOR_EN_YB, ACTORCAT_NPC, @@ -37,59 +44,439 @@ const ActorInit En_Yb_InitVars = { (ActorFunc)EnYb_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BFB2B0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +// crashes if I try to mod it in to look at it +// assumption: draw uses two different skeleton functions, might be incompatible +static AnimationHeader* gYbUnusedAnimations[] = { &object_yb_Anim_000200 }; -extern ColliderCylinderInit D_80BFB2B0; +static LinkAnimationHeader* gLinkAnimations[] = { &gameplay_keep_Linkanim_00DF28, &gameplay_keep_Linkanim_00CF98 }; -extern UNK_TYPE D_06000200; +static Vec3f D_80BFB2E8 = { 0.0f, 0.5f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Init.s") +static Vec3f D_80BFB2F4 = { 500.0f, -500.0, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Destroy.s") +static Vec3f D_80BFB300 = { 500.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA2FC.s") +void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; + s16 tempCutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA350.s") + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, EnYb_ActorShadowFunc, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA444.s") + // @Bug this alignment is because of player animations, but should be using ALIGN16 + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gYbSkeleton, &object_yb_Anim_000200, + (uintptr_t)this->jointTable & ~0xF, (uintptr_t)this->morphTable & ~0xF, YB_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA5CC.s") + Animation_PlayLoop(&this->skelAnime, &object_yb_Anim_000200); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA634.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actionFunc = EnYb_Idle; + this->currentAnimIndex = 3; // gets overwritten to 2 in EnYb_SetAnimation later + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA67C.s") + EnYb_SetAnimation(globalCtx, this, 2, ANIMMODE_LOOP, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA6E0.s") + 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); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA710.s") + this->cutsceneIndex = -1; + this->actor.cutscene = this->cutscenes[0]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA730.s") + // between midnight and morning start spawned + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { + this->alpha = 255; + } else { // else (night 6pm to midnight): wait to appear + this->alpha = 0; + this->actionFunc = EnYb_WaitForMidnight; + this->actor.flags &= ~ACTOR_FLAG_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA868.s") + // check if already healed + if (gSaveContext.save.weekEventReg[82] & 4) { + Actor_MarkForDeath(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA91C.s") +void EnYb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFA9D4.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAB4C.s") +void func_80BFA2FC(GlobalContext* globalCtx) { + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + func_80151BB4(globalCtx, 0x34); + } + func_80151BB4(globalCtx, 0xF); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFABF0.s") +/** + * Custom shadow draw function of type ActorShadowFunc. + */ +void EnYb_ActorShadowFunc(Actor* thisx, Lights* mapper, GlobalContext* globalCtx) { + Vec3f oldPos; + EnYb* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAC88.s") + if (this->alpha > 0) { + if (this->currentAnimIndex == 2) { + f32 tempScale = (((27.0f - this->shadowPos.y) + this->actor.world.pos.y) * ((1 / 2.25f) * 0.001f)) + 0.01f; + this->actor.scale.x = tempScale; + } + Math_Vec3f_Copy(&oldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&this->actor.world.pos, &this->shadowPos); + func_800B4AEC(globalCtx, &this->actor, 50.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFAE80.s") + if (oldPos.y < this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + } else { + this->actor.world.pos.y = oldPos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Update.s") + ActorShadow_DrawCircle(&this->actor, mapper, globalCtx); + Math_Vec3f_Copy(&this->actor.world.pos, &oldPos); + this->actor.scale.x = 0.01f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFB074.s") +void EnYb_SetAnimation(GlobalContext* globalCtx, EnYb* this, s16 animIndex, u8 animMode, f32 transitionRate) { + if (animIndex >= 0 && animIndex < 3) { + if (animIndex != this->currentAnimIndex || animMode != ANIMMODE_LOOP) { + if (animIndex > 0) { + if (animMode == ANIMMODE_LOOP) { + LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, + transitionRate); + } else { + // unused case, (only called once with animMode = ANIMMODE_LOOP) + LinkAnimation_Change(globalCtx, &this->skelAnime, gLinkAnimations[animIndex - 1], 1.0f, 0.0f, + Animation_GetLastFrame(gLinkAnimations[animIndex - 1]), ANIMMODE_LOOP, + transitionRate); + } + } else { + // unused case, (only called once with animIndex = 2) + AnimationHeader* animationPtr = gYbUnusedAnimations[animIndex]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/func_80BFB0E0.s") + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Yb/EnYb_Draw.s") + Animation_Change(&this->skelAnime, gYbUnusedAnimations[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(animationPtr), animMode, transitionRate); + } + this->currentAnimIndex = animIndex; + } + } +} + +s32 EnYb_CanTalk(EnYb* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 100.0f && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } else { + return false; + } +} + +void EnYb_UpdateAnimation(EnYb* this, GlobalContext* globalCtx) { + if (this->currentAnimIndex <= 0) { + SkelAnime_Update(&this->skelAnime); + } else { + LinkAnimation_Update(globalCtx, &this->skelAnime); + } +} + +void EnYb_FinishTeachingCutscene(EnYb* this) { + if (this->cutsceneIndex != -1) { + if (ActorCutscene_GetCurrentIndex() == this->cutscenes[this->cutsceneIndex]) { + ActorCutscene_Stop(this->cutscenes[this->cutsceneIndex]); + } + this->cutsceneIndex = -1; + } +} + +void EnYb_ChangeCutscene(EnYb* this, s16 cutsceneId) { + EnYb_FinishTeachingCutscene(this); + this->cutsceneIndex = cutsceneId; +} + +/** + * Sets a flag that enables the Kamaro dancing proximity music at night. + */ +void EnYb_EnableProximityMusic(EnYb* this) { + func_800B9084(&this->actor); +} + +void EnYb_Disappear(EnYb* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp60; + s32 i; + + EnYb_UpdateAnimation(this, globalCtx); + for (i = 3; i >= 0; i--) { + sp60.x = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.x; + sp60.z = randPlusMinusPoint5Scaled(60.0f) + this->actor.world.pos.z; + sp60.y = randPlusMinusPoint5Scaled(50.0f) + (this->actor.world.pos.y + 20.0f); + func_800B3030(globalCtx, &sp60, &D_80BFB2E8, &D_80BFB2E8, 100, 0, 2); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EN_EXTINCT); + if (this->alpha > 10) { + this->alpha -= 10; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void EnYb_SetupLeaving(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = EnYb_Talk; + // I am counting on you + Message_StartTextbox(globalCtx, 0x147D, &this->actor); + func_80BFA2FC(globalCtx); + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_ReceiveMask(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + // Player is parent: receiving the Kamaro mask + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.parent = NULL; + this->actionFunc = EnYb_SetupLeaving; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MASK_KAMARO, 10000.0f, 100.0f); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_Talk(EnYb* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + EnYb_UpdateAnimation(this, globalCtx); + + if (Message_GetState(&globalCtx->msgCtx) == 5 && Message_ShouldAdvance(globalCtx) != 0) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x147D: // I am counting on you + func_801477B4(globalCtx); + this->actionFunc = EnYb_Disappear; + gSaveContext.save.weekEventReg[82] |= 0x4; + break; + case 0x147C: // Spread my dance across the world + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + func_801477B4(globalCtx); + this->actionFunc = EnYb_Idle; + + } else if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + func_80151938(globalCtx, 0x147D); // I am counting on you + func_80BFA2FC(globalCtx); + + } else { + func_801477B4(globalCtx); + this->actionFunc = EnYb_ReceiveMask; + EnYb_ReceiveMask(this, globalCtx); + } + break; + default: + func_801477B4(globalCtx); + this->actionFunc = EnYb_Idle; + break; + } + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_TeachingDanceFinish(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = EnYb_Talk; + // Spread my dance across the world + Message_StartTextbox(globalCtx, 0x147C, &this->actor); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else { + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +// dancing countdown +void EnYb_TeachingDance(EnYb* this, GlobalContext* globalCtx) { + EnYb_UpdateAnimation(this, globalCtx); + + if (this->teachingCutsceneTimer > 0) { + this->teachingCutsceneTimer--; + } else { + EnYb_FinishTeachingCutscene(this); + this->actionFunc = EnYb_TeachingDanceFinish; + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + } + EnYb_EnableProximityMusic(this); +} + +void EnYb_Idle(EnYb* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + EnYb_UpdateAnimation(this, globalCtx); + if (this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f && + globalCtx->msgCtx.ocarinaMode == 3 && globalCtx->msgCtx.unk1202E == 7 && + gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { + this->actionFunc = EnYb_TeachingDance; + this->teachingCutsceneTimer = 200; + EnYb_ChangeCutscene(this, 0); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + func_80BFA2FC(globalCtx); + this->actionFunc = EnYb_Talk; + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + // I have taught you, go use it + Message_StartTextbox(globalCtx, 0x147C, &this->actor); + } else { + // regular talk to him first dialogue + Message_StartTextbox(globalCtx, 0x147B, &this->actor); + } + } else if (EnYb_CanTalk(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if (this->playerOcarinaOut & 1) { + if (!(player->stateFlags2 & 0x8000000)) { + this->playerOcarinaOut &= ~1; + } + } else if ((player->stateFlags2 & 0x8000000) && this->actor.xzDistToPlayer < 180.0f && + fabsf(this->actor.playerHeightRel) < 50.0f) { + this->playerOcarinaOut |= 1; + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); + } + + EnYb_EnableProximityMusic(this); +} + +void EnYb_WaitForMidnight(EnYb* this, GlobalContext* globalCtx) { + if (gSaveContext.save.time < CLOCK_TIME(6, 0)) { + EnYb_UpdateAnimation(this, globalCtx); + this->alpha += 5; + if (this->alpha > 250) { + this->alpha = 255; + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnYb_Idle; + } + EnYb_EnableProximityMusic(this); + } +} + +void EnYb_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnYb* this = THIS; + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_1)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_1)) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 40.0f, 25.0f, 40.0f, 5); + } + + this->actionFunc(this, globalCtx); + + 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); + } + } else { + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } + } +} + +void EnYb_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnYb* this = THIS; + + if (limbIndex == YB_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_80BFB2F4, &this->actor.focus.pos); + } + if (limbIndex == YB_LIMB_LEGS_ROOT) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + } +} + +void EnYb_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnYb* this = THIS; + + if (limbIndex == YB_LIMB_HEAD) { + Matrix_MultiplyVector3fByState(&D_80BFB300, &this->actor.focus.pos); + } + if (limbIndex == YB_LIMB_LEGS_ROOT) { + Matrix_MultiplyVector3fByState(&gZeroVec3f, &this->shadowPos); + } +} + +void EnYb_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnYb* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->alpha != 0) { + if (this->alpha < 255) { + if (this->alpha > 128) { + func_8012C2B4(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 2, 2); + } else { + func_8012C304(POLY_XLU_DISP++); + Scene_SetRenderModeXlu(globalCtx, 1, 2); + } + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + + if (1) {} + + POLY_XLU_DISP = + SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnYb_PostLimbDrawXlu, &this->actor, POLY_XLU_DISP); + + } else { + func_8012C28C(globalCtx->state.gfxCtx); + Scene_SetRenderModeXlu(globalCtx, 0, 1); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, EnYb_PostLimbDrawOpa, &this->actor); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 ca8a59d93..1b4c898a2 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.h +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.h @@ -2,17 +2,28 @@ #define Z_EN_YB_H #include "global.h" +#include "objects/object_yb/object_yb.h" struct EnYb; typedef void (*EnYbActionFunc)(struct EnYb*, GlobalContext*); typedef struct EnYb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x2DC]; - /* 0x0420 */ EnYbActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[YB_LIMB_MAX]; + /* 0x20C */ UNK_TYPE1 unkPadding20C[0x94]; + /* 0x2A0 */ Vec3s morphTable[YB_LIMB_MAX]; + /* 0x324 */ UNK_TYPE1 unkPadding324[0x94]; + /* 0x3B8 */ ColliderCylinder collider; + /* 0x404 */ Vec3f shadowPos; + /* 0x410 */ u16 playerOcarinaOut; + /* 0x412 */ s16 currentAnimIndex; + /* 0x414 */ s16 alpha; + /* 0x416 */ s16 cutscenes[2]; + /* 0x41A */ s16 cutsceneIndex; + /* 0x41C */ s16 teachingCutsceneTimer; + /* 0x420 */ EnYbActionFunc actionFunc; } EnYb; // size = 0x424 -extern const ActorInit En_Yb_InitVars; - #endif // Z_EN_YB_H diff --git a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c index 0ef9f83af..004907003 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -6,7 +6,7 @@ #include "z_en_zl1.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZl1*)thisx) diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index d2b5e0378..731af3772 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -6,7 +6,7 @@ #include "z_en_zl4.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((EnZl4*)thisx) 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 432fbec9d..0f91171fb 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -7,7 +7,7 @@ #include "z_en_zo.h" #include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZo*)thisx) @@ -20,8 +20,6 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx); void EnZo_TreadWater(EnZo* this, GlobalContext* globalCtx); void EnZo_DoNothing(EnZo* this, GlobalContext* globalCtx); -typedef enum { ZO_DMG_EFF_NONE } EnZoDamageEffect; - const ActorInit En_Zo_InitVars = { ACTOR_EN_ZO, ACTORCAT_NPC, @@ -57,45 +55,48 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; static DamageTable sDamageTable = { - /* Deku Nut */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku Stick */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Horse trample */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Explosives */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora boomerang */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Hookshot */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron punch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Sword */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron pound */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Fire arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Ice arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Light arrow */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Goron spikes */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku spin */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku bubble */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Deku launch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora barrier */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal shield */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Light ray */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Thrown object */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Zora punch */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Spin attack */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Sword beam */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Normal Roll */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Unblockable */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), - /* Powder Keg */ DMG_ENTRY(0, ZO_DMG_EFF_NONE), + /* Deku Nut */ DMG_ENTRY(0, 0), + /* Deku Stick */ DMG_ENTRY(0, 0), + /* Horse trample */ DMG_ENTRY(0, 0), + /* Explosives */ DMG_ENTRY(0, 0), + /* Zora boomerang */ DMG_ENTRY(0, 0), + /* Normal arrow */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0), + /* Hookshot */ DMG_ENTRY(0, 0), + /* Goron punch */ DMG_ENTRY(0, 0), + /* Sword */ DMG_ENTRY(0, 0), + /* Goron pound */ DMG_ENTRY(0, 0), + /* Fire arrow */ DMG_ENTRY(0, 0), + /* Ice arrow */ DMG_ENTRY(0, 0), + /* Light arrow */ DMG_ENTRY(0, 0), + /* Goron spikes */ DMG_ENTRY(0, 0), + /* Deku spin */ DMG_ENTRY(0, 0), + /* Deku bubble */ DMG_ENTRY(0, 0), + /* Deku launch */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0), + /* Zora barrier */ DMG_ENTRY(0, 0), + /* Normal shield */ DMG_ENTRY(0, 0), + /* Light ray */ DMG_ENTRY(0, 0), + /* Thrown object */ DMG_ENTRY(0, 0), + /* Zora punch */ DMG_ENTRY(0, 0), + /* Spin attack */ DMG_ENTRY(0, 0), + /* Sword beam */ DMG_ENTRY(0, 0), + /* Normal Roll */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0), + /* Unblockable */ DMG_ENTRY(0, 0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0), + /* Powder Keg */ DMG_ENTRY(0, 0), }; -static ActorAnimationEntryS sAnimations[] = { - { &gZoraIdleAnim, 1.0f, 0, -1, 0, 0 }, { &gZoraIdleAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraSurfacingAnim, 1.0f, 0, -1, 0, -4 }, { &gZoraHandsOnHipsTappingFootAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraArmsOpenAnim, 1.0f, 0, -1, 0, -4 }, { &gZoraThrowRupeeAnim, 1.0f, 0, -1, 0, -4 }, - { &gZoraWalkAnim, 1.0f, 0, -1, 0, -4 }, +static AnimationInfoS sAnimations[] = { + { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gZoraIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraSurfacingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraHandsOnHipsTappingFootAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraArmsOpenAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraThrowRupeeAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gZoraWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; s8 D_8099F578[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -1, -1, -1, -1 }; @@ -110,11 +111,11 @@ s32 EnZo_SetAnimation(SkelAnime* skelAnime, s16 index) { didChange = true; frameCount = sAnimations[index].frameCount; if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimations[index].animationSeg); + frameCount = Animation_GetLastFrame(sAnimations[index].animation); } - Animation_Change(skelAnime, sAnimations[index].animationSeg, sAnimations[index].playbackSpeed, - sAnimations[index].frame, frameCount, sAnimations[index].mode, - sAnimations[index].transitionRate); + Animation_Change(skelAnime, sAnimations[index].animation, sAnimations[index].playSpeed, + sAnimations[index].startFrame, frameCount, sAnimations[index].mode, + sAnimations[index].morphFrames); } return didChange; } @@ -140,12 +141,12 @@ s32 EnZo_PlayWalkingSound(EnZo* this, GlobalContext* globalCtx) { sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; } - this->isLeftFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->leftFootPos, -6.0f); + this->isLeftFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->leftFootPos, -6.0f); if ((this->isLeftFootGrounded) && (!leftWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } - this->isRightFootGrounded = isFootGrounded = func_8013DB90(globalCtx, &this->rightFootPos, -6.0f); + this->isRightFootGrounded = isFootGrounded = SubS_IsFloorAbove(globalCtx, &this->rightFootPos, -6.0f); if ((this->isRightFootGrounded) && (!rightWasGrounded) && (isFootGrounded)) { Actor_PlaySfxAtPos(&this->actor, sfxId); } @@ -178,7 +179,7 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { Vec3f focus; SkelAnime_Update(&this->skelAnime); - if (func_8013D5E8(this->actor.shape.rot.y, 10000, this->actor.yawTowardsPlayer)) { + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { focus.x = player->actor.world.pos.x; focus.y = player->bodyPartsPos[7].y + 3.0f; focus.z = player->actor.world.pos.z; @@ -196,7 +197,7 @@ void EnZo_LookAtPlayer(EnZo* this, GlobalContext* globalCtx) { } EnZo_Blink(this, 3); - func_8013D9C8(globalCtx, this->limbRotY, this->limbRotZ, 20); + SubS_FillLimbRotTables(globalCtx, this->limbRotY, this->limbRotZ, 20); } void EnZo_Walk(EnZo* this, GlobalContext* globalCtx) { @@ -217,7 +218,7 @@ void EnZo_FollowPath(EnZo* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); speed = this->actor.speedXZ * 400.0f; - if (func_8013D68C(this->path, this->waypoint, &pos) && func_8013D768(&this->actor, &pos, speed)) { + if (SubS_CopyPointFromPath(this->path, this->waypoint, &pos) && SubS_MoveActorToPoint(&this->actor, &pos, speed)) { this->waypoint++; if (this->waypoint >= this->path->count) { this->waypoint = 0; @@ -258,7 +259,7 @@ void EnZo_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->path = func_8013D648(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); + this->path = SubS_GetPathByIndex(globalCtx, ENZO_GET_PATH(&this->actor), ENZO_NO_PATH); Actor_SetScale(&this->actor, 0.01f); this->actionFunc = EnZo_Walk; 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 51fcf53bc..6e9ddb5c0 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -5,8 +5,9 @@ */ #include "z_en_zob.h" +#include "objects/object_zob/object_zob.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZob*)thisx) @@ -15,10 +16,13 @@ void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZob_Update(Actor* thisx, GlobalContext* globalCtx); void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B9F7E4(EnZob* this, s16 arg1, u8 arg2); void func_80B9FD24(EnZob* this, GlobalContext* globalCtx); void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx); void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx); +void func_80B9FE5C(EnZob* this, GlobalContext* globalCtx); void func_80B9FF20(EnZob* this, GlobalContext* globalCtx); +void func_80B9FF80(EnZob* this, GlobalContext* globalCtx); void func_80BA005C(EnZob* this, GlobalContext* globalCtx); void func_80BA00BC(EnZob* this, GlobalContext* globalCtx); void func_80BA0318(EnZob* this, GlobalContext* globalCtx); @@ -33,7 +37,6 @@ void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx); void func_80BA0C14(EnZob* this, GlobalContext* globalCtx); void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Zob_InitVars = { ACTOR_EN_ZOB, ACTORCAT_NPC, @@ -46,79 +49,727 @@ const ActorInit En_Zob_InitVars = { (ActorFunc)EnZob_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BA10D0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &object_zob_Anim_0027D0, &object_zob_Anim_002B38, &object_zob_Anim_0037A0, + &object_zob_Anim_0043C4, &object_zob_Anim_005224, &object_zob_Anim_005E90, + &object_zob_Anim_006998, &object_zob_Anim_011144, &object_zob_Anim_001FD4, +}; -extern ColliderCylinderInit D_80BA10D0; +Vec3f D_80BA1120 = { 300.0f, 900.0f, 0.0f }; -extern UNK_TYPE D_06006998; +void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; + s32 i; + s16 cs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.0115f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zob_Skel_010810, &object_zob_Anim_006998, this->jointTable, + this->morphTable, 24); + Animation_PlayLoop(&this->skelAnime, &object_zob_Anim_006998); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->unk_2F4 = 0; + this->unk_30E = -1; + this->unk_310 = 0; + this->unk_302 = 9; + this->unk_304 = 0; + this->actor.terminalVelocity = -4.0f; + this->actor.gravity = -4.0f; + func_80B9F7E4(this, 6, 2); + this->actionFunc = func_80BA0728; + this->actor.textId = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Destroy.s") + 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); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9F7E4.s") + this->actor.cutscene = this->unk_306[0]; + this->actor.flags |= ACTOR_FLAG_2000000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9F86C.s") + switch (ENZOB_GET_F(&this->actor)) { + case ENZOB_F_1: + if (gSaveContext.save.weekEventReg[78] & 1) { + this->actionFunc = func_80BA0BB4; + } else { + this->actionFunc = func_80BA0AD8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FA3C.s") + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FC0C.s") + case ENZOB_F_2: + this->actionFunc = func_80BA0CF4; + this->unk_2F4 |= 0x20; + this->unk_312 = -1; + func_80B9F7E4(this, 0, 2); + this->unk_304 = 5; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FC70.s") + default: + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_MarkForDeath(&this->actor); + } + this->actor.flags |= ACTOR_FLAG_10; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FCA0.s") +void EnZob_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FD24.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FDDC.s") +void func_80B9F7E4(EnZob* this, s16 arg1, u8 arg2) { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), arg2, + -5.0f); + this->unk_302 = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FE1C.s") +void func_80B9F86C(EnZob* this) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_304) { + case 0: + if (Rand_ZeroFloat(1.0f) > 0.7f) { + if (this->unk_302 == 6) { + func_80B9F7E4(this, 7, 2); + } else { + func_80B9F7E4(this, 6, 2); + } + } else { + func_80B9F7E4(this, this->unk_302, 2); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FE5C.s") + case 1: + func_80B9F7E4(this, 3, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FF20.s") + case 2: + func_80B9F7E4(this, 4, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80B9FF80.s") + case 3: + func_80B9F7E4(this, 5, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA005C.s") + case 4: + if (this->unk_302 == 3) { + func_80B9F7E4(this, 0, 0); + } else { + func_80B9F7E4(this, 3, 2); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA00BC.s") + case 5: + if (Rand_ZeroFloat(1.0f) < 0.8f) { + func_80B9F7E4(this, this->unk_302, 2); + } else if (this->unk_302 == 0) { + func_80B9F7E4(this, 1, 2); + } else { + func_80B9F7E4(this, 0, 2); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0318.s") + SkelAnime_Update(&this->skelAnime); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0374.s") +void func_80B9FA3C(EnZob* this, GlobalContext* globalCtx) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0610.s") + this->unk_2F4 |= 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA06BC.s") + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[30] & 2) { + textId = 0x11F9; + } else { + textId = 0x11F8; + } + this->unk_304 = 3; + func_80B9F7E4(this, 5, 0); + } else if (this->unk_2F4 & 0x10) { + textId = 0x1210; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } else if (gSaveContext.save.weekEventReg[31] & 8) { + textId = 0x1205; + this->unk_304 = 1; + func_80B9F7E4(this, 3, 0); + } else if (this->unk_2F4 & 8) { + textId = 0x1215; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } else if (this->unk_2F4 & 2) { + textId = 0x1203; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else if (gSaveContext.save.weekEventReg[30] & 8) { + textId = 0x11FA; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else if (!(gSaveContext.save.weekEventReg[30] & 4)) { + gSaveContext.save.weekEventReg[30] |= 4; + textId = 0x11FB; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else { + textId = 0x1201; + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0728.s") + Message_StartTextbox(globalCtx, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA08E8.s") +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]); + } + this->unk_30E = -1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA09E0.s") +void func_80B9FC70(EnZob* this, s16 arg1) { + func_80B9FC0C(this); + this->unk_30E = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0A04.s") +void func_80B9FCA0(EnZob* this, GlobalContext* globalCtx) { + func_801477B4(globalCtx); + globalCtx->msgCtx.ocarinaMode = 4; + func_80B9FC0C(this); + this->unk_2F4 &= ~1; + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + func_800B8718(&this->actor, &globalCtx->state); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0AD8.s") +void func_80B9FD24(EnZob* this, GlobalContext* globalCtx) { + s32 actionIndex; + s16 action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0BB4.s") + func_80B9F86C(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0C14.s") + if (Cutscene_CheckActorAction(globalCtx, 500)) { + this->unk_30E = -1; + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 500); + action = globalCtx->csCtx.actorActions[actionIndex]->action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0CF4.s") + if (action != this->unk_310) { + this->unk_310 = action; + switch (action) { + case 1: + func_80B9F7E4(this, 8, 0); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Update.s") + case 2: + func_80B9F7E4(this, 7, 0); + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0F64.s") +void func_80B9FDDC(EnZob* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0x120C, &this->actor); + this->actionFunc = func_80BA00BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/func_80BA0FAC.s") +void func_80B9FE1C(EnZob* this, GlobalContext* globalCtx) { + Message_StartTextbox(globalCtx, 0x1211, &this->actor); + this->actionFunc = func_80BA00BC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zob/EnZob_Draw.s") +void func_80B9FE5C(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (globalCtx->msgCtx.ocarinaMode == 3) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FDDC; + func_80B9FC70(this, 0); + } else if (Message_GetState(&globalCtx->msgCtx) == 11) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FE1C; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + } +} + +void func_80B9FF20(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Message_GetState(&globalCtx->msgCtx) == 7) { + func_80152434(globalCtx, 0x42); + this->actionFunc = func_80B9FE5C; + func_80B9FC70(this, 2); + } +} + +void func_80B9FF80(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (globalCtx->msgCtx.ocarinaMode == 3) { + this->actionFunc = func_80B9FF20; + this->unk_304 = 6; + func_80B9F7E4(this, 1, 0); + func_80152434(globalCtx, 0x3E); + func_80B9FC70(this, 1); + } else if (Message_GetState(&globalCtx->msgCtx) == 11) { + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FE1C; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + } +} + +void func_80BA005C(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Message_GetState(&globalCtx->msgCtx) == 7) { + func_80152434(globalCtx, 0x41); + this->actionFunc = func_80B9FF80; + func_80B9FC70(this, 2); + } +} + +void func_80BA00BC(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1212)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 1: + func_8019F208(); + func_80151938(globalCtx, 0x1209); + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + break; + + case 0: + func_8019F230(); + func_80151938(globalCtx, 0x1213); + break; + } + } + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1208: + case 0x120E: + case 0x1216: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x120C: + globalCtx->msgCtx.unk11F10 = 0; + this->actionFunc = func_80B9FD24; + func_80B9F7E4(this, 8, 0); + func_80B9FC70(this, 3); + break; + + case 0x120D: + case 0x1211: + case 0x1213: + case 0x1217: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + break; + + case 0x1218: + func_80B9FCA0(this, globalCtx); + break; + + case 0x1214: + this->unk_2F4 |= 8; + func_80B9FCA0(this, globalCtx); + break; + + case 0x120F: + gSaveContext.save.weekEventReg[31] |= 8; + this->unk_2F4 |= 0x10; + func_80B9FCA0(this, globalCtx); + break; + + case 0x1209: + func_80152434(globalCtx, 0x3D); + this->unk_304 = 4; + func_80B9F7E4(this, 0, 0); + this->actionFunc = func_80BA005C; + func_80B9FC70(this, 1); + break; + } + } + break; + } +} + +void func_80BA0318(EnZob* this, GlobalContext* globalCtx) { + func_80152434(globalCtx, 0x3D); + this->unk_304 = 4; + func_80B9F7E4(this, 0, 0); + this->actionFunc = func_80BA005C; + func_80B9FC70(this, 1); +} + +void func_80BA0374(EnZob* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + func_80B9F86C(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 4: + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1205)) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(globalCtx, 0x1207); + func_80B9F7E4(this, 2, 2); + break; + + case 1: + func_8019F230(); + func_80151938(globalCtx, 0x1206); + break; + } + } + break; + + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x11F8: + gSaveContext.save.weekEventReg[30] |= 2; + func_80151938(globalCtx, 0x11F9); + break; + + case 0x11F9: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + this->unk_2F4 &= ~1; + break; + + case 0x11FB: + case 0x11FC: + case 0x11FF: + case 0x1201: + case 0x1203: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x11FD: + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x11FE: + this->unk_304 = 1; + func_80B9F7E4(this, 3, 0); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x11FA: + case 0x1200: + case 0x1202: + case 0x1204: + case 0x1206: + case 0x120F: + case 0x1210: + case 0x1215: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0728; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + this->unk_2F4 &= ~1; + this->unk_2F4 |= 2; + break; + + case 0x1207: + func_801477B4(globalCtx); + this->actionFunc = func_80BA0318; + player->unk_A90 = &this->actor; + player->stateFlags3 |= 0x20; + break; + } + } + break; + } +} + +void func_80BA0610(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + Message_StartTextbox(globalCtx, 0x120D, &this->actor); + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + func_80B9FC70(this, 0); + this->actionFunc = func_80BA00BC; + } else { + func_800B8614(&this->actor, globalCtx, 500.0f); + } +} + +void func_80BA06BC(EnZob* this, GlobalContext* globalCtx) { + func_80B9FD24(this, globalCtx); + if (!Cutscene_CheckActorAction(globalCtx, 500)) { + this->actionFunc = func_80BA0610; + this->actor.flags |= ACTOR_FLAG_10000; + func_80BA0610(this, globalCtx); + } +} + +void func_80BA0728(EnZob* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + + func_80B9F86C(this); + + if (func_800B8718(&this->actor, &globalCtx->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + Message_StartTextbox(globalCtx, 0x1208, NULL); + gSaveContext.save.weekEventReg[30] |= 8; + } else { + Message_StartTextbox(globalCtx, 0x1216, NULL); + } + this->actionFunc = func_80BA00BC; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + this->unk_30E = 0; + this->unk_2F4 |= 1; + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BA0374; + func_80B9FA3C(this, globalCtx); + } else if (Cutscene_CheckActorAction(globalCtx, 500)) { + this->actionFunc = func_80BA06BC; + } else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.xzDistToPlayer > 60.0f) && + Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 150.0f); + func_800B874C(&this->actor, globalCtx, 200.0f, 150.0f); + } + + 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); +} + +void func_80BA08E8(EnZob* this, GlobalContext* globalCtx) { + s32 textId; + + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { + textId = 0x1257; + this->unk_304 = 3; + func_80B9F7E4(this, 4, 2); + } else if (gSaveContext.save.weekEventReg[78] & 0x40) { + textId = 0x1256; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } else { + textId = 0x1255; + gSaveContext.save.weekEventReg[78] |= 0x40; + this->unk_304 = 1; + func_80B9F7E4(this, 2, 2); + } + } else { + textId = 0x1254; + this->unk_304 = 3; + func_80B9F7E4(this, 5, 2); + } + + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80BA09E0(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); +} + +void func_80BA0A04(EnZob* this, GlobalContext* globalCtx) { + u8 temp_v0; + + func_80B9F86C(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + + temp_v0 = Message_GetState(&globalCtx->msgCtx); + if (temp_v0 != 2) { + if ((temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { + func_801477B4(globalCtx); + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + } + } else { + this->actionFunc = func_80BA0AD8; + this->unk_304 = 0; + func_80B9F7E4(this, 6, 2); + } +} + +void func_80BA0AD8(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BA0A04; + func_80BA08E8(this, globalCtx); + } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +void func_80BA0BB4(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (gSaveContext.save.weekEventReg[79] & 1) { + this->actionFunc = func_80BA09E0; + func_80B9F7E4(this, 0, 2); + this->unk_304 = 5; + } +} + +void func_80BA0C14(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + + if (this->unk_312 < 799) { + this->unk_312 += 200; + } else { + this->unk_312 += 30; + } + + if (this->unk_312 > 999) { + this->unk_312 = 999; + } + + if (Cutscene_CheckActorAction(globalCtx, 515)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { + this->actionFunc = func_80BA0CF4; + this->unk_312 = -1; + } + } else { + this->actionFunc = func_80BA0CF4; + this->unk_312 = -1; + } +} + +void func_80BA0CF4(EnZob* this, GlobalContext* globalCtx) { + func_80B9F86C(this); + if (Cutscene_CheckActorAction(globalCtx, 515) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 2)) { + this->actionFunc = func_80BA0C14; + } +} + +void EnZob_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZob* this = THIS; + + Actor_MoveWithGravity(&this->actor); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + + this->actionFunc(this, globalCtx); + + 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); + } else { + ActorCutscene_SetIntentToPlay(this->unk_306[this->unk_30E]); + } + } + + if (this->unk_2F4 & 1) { + func_800E9250(globalCtx, &this->actor, &this->unk_2F6, &this->unk_2FC, this->actor.focus.pos); + } else { + Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2FC.x, 0, 6, 6200, 100); + Math_SmoothStepToS(&this->unk_2FC.y, 0, 6, 6200, 100); + } +} + +s32 func_80BA0F64(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZob* this = THIS; + + if (limbIndex == 9) { + rot->x += this->unk_2F6.y; + rot->y += this->unk_2F6.x; + } + return false; +} + +void func_80BA0FAC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZob* this = THIS; + + if (limbIndex == 9) { + Matrix_MultiplyVector3fByState(&D_80BA1120, &this->actor.focus.pos); + } +} + +void EnZob_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZob* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_2F4 & 0x20) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 0, 0, 0, 0, this->unk_312, 1000); + } + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80BA0F64, func_80BA0FAC, &this->actor); + + if (this->unk_2F4 & 0x20) { + POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + } + + CLOSE_DISPS(globalCtx->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 233842303..18834f17e 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.h +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.h @@ -7,9 +7,28 @@ struct EnZob; typedef void (*EnZobActionFunc)(struct EnZob*, GlobalContext*); +#define ENZOB_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + /* 1 */ ENZOB_F_1 = 1, + /* 2 */ ENZOB_F_2, +}; + typedef struct EnZob { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1D0]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[24]; + /* 0x0218 */ Vec3s morphTable[24]; + /* 0x02A8 */ ColliderCylinder collider; + /* 0x02F4 */ u16 unk_2F4; + /* 0x02F6 */ Vec3s unk_2F6; + /* 0x02FC */ Vec3s unk_2FC; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ u16 unk_304; + /* 0x0306 */ s16 unk_306[4]; + /* 0x030E */ s16 unk_30E; + /* 0x0310 */ s16 unk_310; + /* 0x0312 */ s16 unk_312; /* 0x0314 */ 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 f8a38bd52..f908ceafa 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -6,7 +6,7 @@ #include "z_en_zod.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZod*)thisx) 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 fa59fd48a..f4514a9aa 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -7,7 +7,7 @@ #include "z_en_zog.h" #include "objects/object_zog/object_zog.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZog*)thisx) @@ -206,7 +206,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA) && - ((globalCtx->csCtx.unk_12 != 2) || (gSaveContext.sceneSetupIndex != 0) || + ((globalCtx->csCtx.currentCsIndex != 2) || (gSaveContext.sceneSetupIndex != 0) || (globalCtx->sceneNum != SCENE_30GYOSON))) { Actor_MarkForDeath(&this->actor); return; @@ -256,7 +256,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { } } - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; this->actor.home.rot.z = 0; if (ENZOG_GET_F(&this->actor) != ENZOG_F_2) { for (i = 0; i < 5; i++) { @@ -268,8 +268,8 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.save.weekEventReg[88] & 0x10)) { this->unk_302 = this->unk_300 = 0; this->unk_2FC = this->unk_2FE = 3; - this->actor.flags |= 0x2000000; - this->actor.flags &= ~0x10000; + this->actor.flags |= ACTOR_FLAG_2000000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->unk_31C = 2; this->unk_31E = 0; @@ -459,9 +459,9 @@ s32 func_80B93EA0(EnZog* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); } - if (func_800EE29C(globalCtx, 0x1D7)) { - sp3E = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1D7)]->unk0; - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, 0x1D7)); + if (Cutscene_CheckActorAction(globalCtx, 471)) { + sp3E = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 471)]->action; + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 471)); switch (this->unk_306) { case 2: @@ -613,7 +613,7 @@ void func_80B943EC(EnZog* this, GlobalContext* globalCtx) { void func_80B94470(EnZog* this, GlobalContext* globalCtx) { if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x103C)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x103C)) { func_801477B4(globalCtx); this->actionFunc = func_80B9451C; this->unk_300 = this->unk_302 = 0; @@ -644,7 +644,7 @@ void func_80B9461C(EnZog* this, GlobalContext* globalCtx) { if (!func_80B93EA0(this, globalCtx)) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; gSaveContext.save.weekEventReg[91] |= 2; } @@ -664,7 +664,7 @@ void func_80B946B4(EnZog* this, GlobalContext* globalCtx) { void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -682,19 +682,19 @@ void func_80B946FC(EnZog* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1008: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1009: this->unk_300 = 4; - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1014: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1015: @@ -746,7 +746,7 @@ void func_80B94A00(EnZog* this, GlobalContext* globalCtx) { if (func_80B93BE0(this, globalCtx)) { this->actionFunc = func_80B948A8; - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; if (gSaveContext.save.weekEventReg[29] & 0x20) { this->actor.textId = 0x1009; } else { @@ -827,13 +827,13 @@ void func_80B94D0C(EnZog* this, GlobalContext* globalCtx) { this->unk_31E = 0; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { this->unk_320 = 5; - switch (globalCtx->msgCtx.unk11F04) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1004: case 0x1005: case 0x1006: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1007: @@ -882,7 +882,7 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { } if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { - Actor_PickUp(&this->actor, globalCtx, 0, 60.0f, 40.0f); + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 60.0f, 40.0f); } if (this->unk_324 > 0) { @@ -937,7 +937,7 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { break; } - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; gSaveContext.save.weekEventReg[91] |= 1; } else { func_800B8614(&this->actor, globalCtx, 150.0f); @@ -956,7 +956,7 @@ void EnZog_Update(Actor* thisx, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); - if (func_800EE29C(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { + if (Cutscene_CheckActorAction(globalCtx, 0x1D7) && (ENZOG_GET_F(&this->actor) != ENZOG_F_2)) { this->actionFunc = func_80B9461C; this->actor.shape.yOffset = 0.0f; } 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 d5dc7fda0..61be7c8e7 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -5,8 +5,10 @@ */ #include "z_en_zoraegg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_zoraegg/object_zoraegg.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((EnZoraegg*)thisx) @@ -15,7 +17,27 @@ void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx); void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 func_80B319A8(GlobalContext* globalCtx); +void func_80B32084(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32094(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B321D0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B10(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx); +void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx); + const ActorInit En_Zoraegg_InitVars = { ACTOR_EN_ZORAEGG, ACTORCAT_ITEMACTION, @@ -28,86 +50,843 @@ const ActorInit En_Zoraegg_InitVars = { (ActorFunc)EnZoraegg_Draw, }; -#endif +void func_80B31590(EnZoraegg* this) { + this->actor.shape.yOffset = 0.0f; -extern UNK_TYPE D_060005D4; -extern UNK_TYPE D_06004D20; -extern UNK_TYPE D_06004FE4; -extern UNK_TYPE D_06005098; -extern UNK_TYPE D_06005250; + if (this->actor.home.rot.x == 0) { + this->actor.scale.x = 0.4f; + } else { + this->actor.scale.x = this->actor.home.rot.x * 0.04f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31590.s") + if (this->actor.home.rot.z == 0) { + this->actor.scale.z = 0.4f; + } else { + this->actor.scale.z = this->actor.home.rot.z * 0.04f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Init.s") + this->actor.shape.rot.z = 0; + this->actor.scale.y = 0.4f; + this->actor.draw = NULL; + this->actor.shape.rot.y = this->actor.shape.rot.z; + this->actor.shape.rot.x = this->actor.shape.rot.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Destroy.s") +void EnZoraegg_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZoraegg* this = THIS; + u16 sp40[] = { 457, 458, 459, 460, 461, 462, 464 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B319A8.s") + Actor_SetScale(&this->actor, 0.006f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zoraegg_Skel_004C90, &object_zoraegg_Anim_005098, + this->jointTable, this->morphTable, 7); + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_005098); + ActorShape_Init(&this->actor.shape, 1100.0f, NULL, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B319D0.s") + this->actionFunc = func_80B32084; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31A34.s") + this->unk_1ED = 255; + this->unk_1EC = 0; + this->unk_1EA = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31C40.s") + this->unk_1E0 = 1.0f; + this->unk_1E4 = 0.0f; + this->actor.velocity.y = -10.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -5.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31CB4.s") + switch (ENZORAEGG_GET_1F(&this->actor)) { + case ENZORAEGG_1F_0: + if (Flags_GetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31D14.s") + case ENZORAEGG_1F_17: + if (func_80B319A8(globalCtx) >= 7) { + Actor_MarkForDeath(&this->actor); + this->actor.home.rot.z = 1; + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31D64.s") + case ENZORAEGG_1F_3: + case ENZORAEGG_1F_4: + case ENZORAEGG_1F_5: + case ENZORAEGG_1F_6: + case ENZORAEGG_1F_7: + case ENZORAEGG_1F_8: + case ENZORAEGG_1F_9: + if (gSaveContext.save.weekEventReg[19] & 0x40) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B31E00.s") + case ENZORAEGG_1F_10: + case ENZORAEGG_1F_11: + case ENZORAEGG_1F_12: + case ENZORAEGG_1F_13: + case ENZORAEGG_1F_14: + case ENZORAEGG_1F_15: + case ENZORAEGG_1F_16: + if (!(gSaveContext.save.weekEventReg[19] & 0x40)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32084.s") + switch (ENZORAEGG_GET_1F(&this->actor)) { + case ENZORAEGG_1F_0: + this->actionFunc = func_80B320E0; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.targetMode = 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32094.s") + case ENZORAEGG_1F_1: + this->actionFunc = func_80B322BC; + func_80B31590(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B320E0.s") + case ENZORAEGG_1F_2: + this->actionFunc = func_80B32390; + func_80B31590(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B321D0.s") + case ENZORAEGG_1F_3: + case ENZORAEGG_1F_4: + case ENZORAEGG_1F_5: + case ENZORAEGG_1F_6: + case ENZORAEGG_1F_7: + case ENZORAEGG_1F_8: + case ENZORAEGG_1F_9: + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3]; + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_001E08); + this->unk_1EC = 1; + this->unk_1EE = 0; + this->unk_1EF = 0; + this->actionFunc = func_80B32B10; + if (((ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_3) >= func_80B319A8(globalCtx)) { + this->actionFunc = func_80B32B3C; + this->actor.draw = NULL; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32228.s") + case ENZORAEGG_1F_10: + case ENZORAEGG_1F_11: + case ENZORAEGG_1F_12: + case ENZORAEGG_1F_13: + case ENZORAEGG_1F_14: + case ENZORAEGG_1F_15: + case ENZORAEGG_1F_16: + this->actorActionCmd = sp40[(ENZORAEGG_GET_1F(&this->actor)) - ENZORAEGG_1F_10]; + this->unk_1EC = 2; + this->actionFunc = func_80B324B0; + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EE = 0; + this->unk_1ED = 0; + this->unk_1EA |= 3; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B322BC.s") + case ENZORAEGG_1F_17: + Actor_SetScale(&this->actor, 0.0006f); + this->actionFunc = func_80B32D08; + this->actor.world.pos.y -= this->actor.shape.yOffset * this->actor.scale.y; + this->actor.shape.rot.x = 0; + this->actor.velocity.y = 0.0f; + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -1.0f; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32390.s") +void EnZoraegg_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B324B0.s") +s32 func_80B319A8(GlobalContext* globalCtx) { + return gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 & 7; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32644.s") +void func_80B319D0(GlobalContext* globalCtx, s32 arg1) { + if ((arg1 < 8) && (arg1 >= 0)) { + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= arg1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B326F4.s") +void func_80B31A34(EnZoraegg* this) { + s32 curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32820.s") + if (this->unk_1EA & 1) { + this->unk_1EE = this->unk_1EF = 100; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32928.s") + curFrame = this->skelAnime.curFrame; + if (curFrame < 6) { + this->unk_1EE = 0; + this->unk_1EF = 0; + } else if (curFrame < 93) { + this->unk_1EE = Math_SinS((curFrame * 0xBC) - 0x468) * 100.0f; + if (curFrame >= 89) { + this->unk_1EF = Math_SinS((curFrame * 0x1000) - (0x59 * 0x1000)) * 100.0f; + } else { + this->unk_1EF = 0; + } + } else { + this->unk_1EE = this->unk_1EF = 100; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32A88.s") +void func_80B31C40(EnZoraegg* this, GlobalContext* globalCtx) { + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B10.s") +Actor* func_80B31CB4(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B3C.s") + while (actor != NULL) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_17) && + (actor->home.rot.z == 0)) { + actor->home.rot.z = 1; + return actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32B70.s") +Actor* func_80B31D14(GlobalContext* globalCtx) { + Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32BB8.s") + while (actor != NULL) { + if ((actor->id == ACTOR_EN_ZORAEGG) && (ENZORAEGG_GET_1F(actor) == ENZORAEGG_1F_3)) { + return actor; + } + actor = actor->next; + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32C34.s") +void func_80B31D64(EnZoraegg* this, GlobalContext* globalCtx, s32 arg2, f32 arg3) { + Vec3f sp24 = this->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32D08.s") + sp24.y += arg3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Update.s") + if ((globalCtx->gameplayFrames & arg2) == 0) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 0.0f, 10.0f, 0.13f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B32F04.s") +void func_80B31E00(EnZoraegg* this) { + f32 sp20[] = { + 1.0f, + 1.075f, + 1.15f, + 1.075f, + }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B331C8.s") + if (this->unk_1E8 < 112) { + if (this->unk_1E8 > 10) { + this->unk_1ED = (s32)((112.0f - this->unk_1E8) * 2.5f) & 0xFF; + } + } else { + this->unk_1ED = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B3336C.s") + if (this->unk_1E8 < 10) { + this->unk_1E0 = sp20[this->unk_1E8 & 3]; + } else if (this->unk_1E8 < 22) { + this->unk_1E0 = (Math_SinS((this->unk_1E8 - 10.0f) * (4096.0f / 3)) * 0.8f) + 1.0f; + } else if (this->unk_1E8 < 26) { + this->unk_1E0 = (Math_CosS((this->unk_1E8 - 22.0f) * 4096.0f) * 0.8f) + 1.0f; + } else if (this->unk_1E8 < 32) { + this->unk_1E0 = sp20[(this->unk_1E8 - 1) & 3]; + } else if (this->unk_1E8 < 47) { + this->unk_1E0 = 1.0f; + } else if (this->unk_1E8 < 53) { + this->unk_1E0 = sp20[(this->unk_1E8 - 2) & 3]; + } else if (this->unk_1E8 < 74) { + this->unk_1E0 = 1.0f - ((this->unk_1E8 - 53.0f) * (1.0f / 105)); + } else if (this->unk_1E8 < 112) { + this->unk_1E0 = (this->unk_1E0 * 0.9f) + 0.15f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B333DC.s") + if ((this->unk_1E8 == 111) || (this->unk_1E8 == 32)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_BORN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B33480.s") +void func_80B32084(EnZoraegg* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/func_80B33818.s") +void func_80B32094(EnZoraegg* this, GlobalContext* globalCtx) { + if (Message_GetState(&globalCtx->msgCtx) == 2) { + this->actionFunc = func_80B320E0; + } + func_80B31C40(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zoraegg/EnZoraegg_Draw.s") +void func_80B320E0(EnZoraegg* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + Flags_SetSwitch(globalCtx, ENZORAEGG_GET_FE00(&this->actor)); + Actor_MarkForDeath(&this->actor); + } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80B32094; + Message_StartTextbox(globalCtx, 0x24B, &this->actor); + } else { + Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 60.0f); + if (this->actor.isTargeted) { + func_800B8614(&this->actor, globalCtx, 110.0f); + } + } + + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.targetMode = 3; + func_80B31C40(this, globalCtx); +} + +void func_80B321D0(EnZoraegg* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { + this->actionFunc = func_80B322BC; + func_80B319D0(globalCtx, func_80B319A8(globalCtx) + 1); + } +} + +void func_80B32228(EnZoraegg* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, 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; + this->unk_1E8 = -1; + } + + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80B322BC(EnZoraegg* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (this->actor.cutscene != -1) { + this->unk_1DC = func_80B31CB4(globalCtx); + if (this->unk_1DC != NULL) { + this->unk_1E8 = 3; + this->actionFunc = func_80B32228; + return; + } + } + + if ((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))) { + func_8012300C(globalCtx, 25); + } +} + +void func_80B32390(EnZoraegg* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + Actor* temp_v0 = func_80B31D14(globalCtx); + + if (temp_v0 != NULL) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, temp_v0); + gSaveContext.eventInf[3] |= 8; + Actor_MarkForDeath(&this->actor); + } + } else if ((func_80B319A8(globalCtx) >= 7) && + (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); + } +} + +void func_80B324B0(EnZoraegg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd)) { + if (this->unk_1EA & 4) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == + 3)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EA &= ~4; + } + } else { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == + 4)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004E04); + this->unk_1EA |= 4; + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if ((this->unk_1EA & 4) && Animation_OnFrame(&this->skelAnime, this->unk_1E4)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + this->unk_1E4 = Rand_ZeroFloat(5.0f); + } + } else if (this->unk_1EA & 4) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EA &= ~4; + } +} + +void func_80B32644(EnZoraegg* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_PlayLoop(&this->skelAnime, &object_zoraegg_Anim_004FE4); + this->unk_1EE = 0; + this->unk_1EA |= 2; + } + + if (!Cutscene_CheckActorAction(globalCtx, this->actorActionCmd)) { + this->actionFunc = func_80B324B0; + } else { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if (this->unk_1EE > 25) { + this->unk_1EE -= 25; + } else { + this->unk_1EE = 0; + } + } +} + +void func_80B326F4(EnZoraegg* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 3)) { + Animation_Change(&this->skelAnime, &object_zoraegg_Anim_004D20, 1.0f, 0.0f, + Animation_GetLastFrame(&object_zoraegg_Anim_004D20), 2, 5.0f); + this->unk_1E8 = 0; + this->actionFunc = func_80B32644; + gSaveContext.save.weekEventReg[19] |= 0x40; + this->unk_1EC = 2; + this->unk_1EE = 100; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if (Animation_OnFrame(&this->skelAnime, 4.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_1); + } +} + +void func_80B32820(EnZoraegg* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->unk_1E8 >= 2) { + this->actionFunc = func_80B326F4; + Animation_Change(&this->skelAnime, &object_zoraegg_Anim_005098, 1.0f, 0.0f, + Animation_GetLastFrame(&object_zoraegg_Anim_005098), 0, 10.0f); + this->unk_1E8 = 0; + SkelAnime_Update(&this->skelAnime); + return; + } + + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_0005D4); + this->unk_1E8 += 1; + SkelAnime_Update(&this->skelAnime); + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + if (Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_0); + } +} + +void func_80B32928(EnZoraegg* this, GlobalContext* globalCtx) { + if (this->unk_1E8 < 112) { + this->unk_1E8++; + } + + if (SkelAnime_Update(&this->skelAnime)) { + Animation_PlayOnce(&this->skelAnime, &object_zoraegg_Anim_0005D4); + this->unk_1EA |= 1; + this->actionFunc = func_80B32820; + this->unk_1E8 = 0; + this->actor.velocity.y = 0.0f; + return; + } + + func_80B31A34(this); + func_80B31E00(this); + + if (this->unk_1E8 < 112) { + if ((this->unk_1E8 >= 69) && (this->unk_1E8 < 72)) { + func_80B31D64(this, globalCtx, 0, 0.0f); + func_80B31D64(this, globalCtx, 0, 0.0f); + func_80B31D64(this, globalCtx, 0, 0.0f); + } else { + func_80B31D64(this, globalCtx, 0xD, 0.0f); + } + } + + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, + Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + + 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); + } +} + +void func_80B32A88(EnZoraegg* this, GlobalContext* globalCtx) { + if (Cutscene_CheckActorAction(globalCtx, this->actorActionCmd) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)]->action == 2)) { + this->unk_1E8 = 0; + this->actionFunc = func_80B32928; + } + func_80B31D64(this, globalCtx, 13, 0.0f); +} + +void func_80B32B10(EnZoraegg* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 8) { + this->actionFunc = func_80B32A88; + } +} + +void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx) { + if (gSaveContext.eventInf[3] & 8) { + this->actionFunc = func_80B32A88; + this->actor.draw = EnZoraegg_Draw; + } +} + +void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx) { + func_80B31C40(this, globalCtx); + if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B32BB8(EnZoraegg* this, GlobalContext* globalCtx) { + func_80B31C40(this, globalCtx); + func_80B31D64(this, globalCtx, 13, 0.0f); + + if (this->actor.bgCheckFlags & 0x1) { + this->actionFunc = func_80B32B70; + } + + if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { + Actor_MarkForDeath(&this->actor); + } +} + +void func_80B32C34(EnZoraegg* this, GlobalContext* globalCtx) { + WaterBox* sp34; + f32 sp30; + s32 pad; + + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + sp30 = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp30, + &sp34)) { + if ((this->actor.world.pos.y + 50.0f) < sp30) { + this->actionFunc = func_80B32BB8; + } + + func_80B31D64(this, globalCtx, 0, -20.0f); + func_80B31D64(this, globalCtx, 0, -20.0f); + } +} + +void func_80B32D08(EnZoraegg* this, GlobalContext* globalCtx) { + WaterBox* sp44; + f32 sp40; + Vec3f sp34; + s32 pad; + + Actor_MoveWithGravity(&this->actor); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + this->actor.focus.pos.y += 10.0f; + sp40 = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp40, + &sp44)) { + if (this->actor.world.pos.y < sp40) { + sp34.x = this->actor.world.pos.x; + sp34.y = sp40; + sp34.z = this->actor.world.pos.z; + + EffectSsGRipple_Spawn(globalCtx, &sp34, 150, 500, 0); + EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 200); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); + + this->actionFunc = func_80B32C34; + this->actor.velocity.y = -1.0f; + this->actor.terminalVelocity = -1.0f; + this->actor.gravity = -1.0f; + } + } + + if (this->actor.scale.x < 0.006f) { + Actor_SetScale(&this->actor, this->actor.scale.x + 0.0012f); + } + + if (this->actor.scale.x > 0.006f) { + Actor_SetScale(&this->actor, 0.006f); + } +} + +void EnZoraegg_Update(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + this->actionFunc(this, globalCtx); + + if (DECR(this->unk_1F4) == 0) { + this->unk_1F4 = Rand_S16Offset(60, 60); + } + + this->unk_1F2 = this->unk_1F4; + if (this->unk_1F2 >= 3) { + this->unk_1F2 = 0; + } +} + +void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { + f32 sp7C; + f32 sp78; + f32 sp74; + EnZoraegg* this = THIS; + s32 pad[3]; + s16 sp62; + s16 sp60; + f32 temp_f2; + Gfx* gfx; + Vec3f sp4C; + s32 pad2; + + Matrix_StatePush(); + + sp4C = GET_ACTIVE_CAM(globalCtx)->eye; + + sp62 = Math_Vec3f_Yaw(&sp4C, &this->actor.focus.pos); + sp60 = -Math_Vec3f_Pitch(&sp4C, &this->actor.focus.pos); + + sp74 = -((15.0f * Math_SinS(sp62)) * Math_CosS(sp60)); + sp78 = -(15.0f * Math_SinS(sp60)); + sp7C = -((15.0f * Math_CosS(sp62)) * Math_CosS(sp60)); + + Matrix_InsertTranslation(this->actor.world.pos.x + sp74, this->actor.world.pos.y + sp78 + 6.0f, + temp_f2 = this->actor.world.pos.z + sp7C, 0); + + sp7C = Math_SinS(globalCtx->gameplayFrames * 0x4000); + + Matrix_Scale(this->actor.scale.x * (((sp7C + 1.0f) * 0.1f) + 9.0f), + this->actor.scale.y * (((sp7C + 1.0f) * 0.1f) + 9.0f), + this->actor.scale.z * (((sp7C + 1.0f) * 0.1f) + 9.0f), 1); + + OPEN_DISPS(globalCtx->state.gfxCtx); + gfx = POLY_XLU_DISP; + gfx = func_8012C868(gfx); + + gSPSetOtherMode(gfx++, G_SETOTHERMODE_H, 4, 4, 0x00000080); + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); + gSPDisplayList(gfx++, gameplay_keep_DL_029CB0); + + gDPSetPrimColor(gfx++, 0, 0, 120, 180, 200, (s32)(this->unk_1ED * (20.0f / 51))); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); + + POLY_XLU_DISP = gfx; + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + + Matrix_Scale(this->unk_1E0, this->unk_1E0, this->unk_1E0, MTXMODE_APPLY); + + if (this->unk_1ED >= 254) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPDisplayList(POLY_OPA_DISP++, object_zoraegg_DL_005250); + } else { + func_8012C304(POLY_XLU_DISP++); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->unk_1ED); + gSPDisplayList(POLY_XLU_DISP++, object_zoraegg_DL_005250); + } + + Matrix_StatePop(); + + func_80B32F04(thisx, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +s32 EnZoraegg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnZoraegg* this = THIS; + + switch (this->unk_1EC) { + case 1: + if ((limbIndex != 1) && (limbIndex != 3) && (limbIndex != 4)) { + *dList = NULL; + } + break; + + case 2: + if ((limbIndex != 1) && (limbIndex != 3)) { + *dList = NULL; + } + break; + } + return false; +} + +void func_80B333DC(GlobalContext* globalCtx, Gfx** dList, f32 arg2) { + Matrix_StatePush(); + Matrix_Scale(arg2, arg2, arg2, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZoraegg* this = THIS; + f32 temp_f20; + f32 temp_f2; + + switch (this->unk_1EC) { + case 1: + switch (limbIndex) { + case 2: + temp_f20 = this->unk_1EE * 0.01f; + Matrix_StatePush(); + Matrix_Scale(temp_f20, temp_f20, temp_f20, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 4: + Matrix_StatePop(); + break; + + case 5: + case 6: + temp_f20 = this->unk_1EF * 0.01f; + func_80B333DC(globalCtx, dList, temp_f20); + break; + } + break; + + case 2: + switch (limbIndex) { + case 2: + temp_f20 = (this->unk_1EE * 0.005f) + 0.5f; + Matrix_StatePush(); + Matrix_Scale(1.0f, temp_f20, temp_f20, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + break; + + case 4: + temp_f2 = 1.0f / ((this->unk_1EE * 0.005f) + 0.5f); + temp_f20 = (this->unk_1EE * 0.0035f) + 0.65f; + Matrix_Scale(1.0f, temp_f20 * temp_f2, temp_f2, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *dList); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePop(); + break; + + case 5: + case 6: + temp_f20 = this->unk_1EE * 0.01f; + func_80B333DC(globalCtx, dList, temp_f20); + break; + } + break; + } +} + +TexturePtr D_80B33950[] = { object_zoraegg_Tex_003430, object_zoraegg_Tex_004430, object_zoraegg_Tex_004830 }; + +void func_80B33818(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80B33950[this->unk_1F2])); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZoraegg_OverrideLimbDraw, EnZoraegg_PostLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void EnZoraegg_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZoraegg* this = THIS; + + if (this->unk_1ED > 0) { + func_80B331C8(thisx, globalCtx); + } + + if (this->unk_1ED != 255) { + func_80B33818(thisx, globalCtx); + } +} 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 8c458c46e..fb65579fa 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -7,9 +7,55 @@ struct EnZoraegg; typedef void (*EnZoraeggActionFunc)(struct EnZoraegg*, GlobalContext*); +#define ENZORAEGG_GET_1F(thisx) ((thisx)->params & 0x1F) +#define ENZORAEGG_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +enum { + /* 0 */ ENZORAEGG_1F_0, + /* 1 */ ENZORAEGG_1F_1, + /* 2 */ ENZORAEGG_1F_2, + /* 3 */ ENZORAEGG_1F_3, + /* 4 */ ENZORAEGG_1F_4, + /* 5 */ ENZORAEGG_1F_5, + /* 6 */ ENZORAEGG_1F_6, + /* 7 */ ENZORAEGG_1F_7, + /* 8 */ ENZORAEGG_1F_8, + /* 9 */ ENZORAEGG_1F_9, + /* 10 */ ENZORAEGG_1F_10, + /* 11 */ ENZORAEGG_1F_11, + /* 12 */ ENZORAEGG_1F_12, + /* 13 */ ENZORAEGG_1F_13, + /* 14 */ ENZORAEGG_1F_14, + /* 15 */ ENZORAEGG_1F_15, + /* 16 */ ENZORAEGG_1F_16, + /* 17 */ ENZORAEGG_1F_17, + /* 18 */ ENZORAEGG_1F_18, + /* 19 */ ENZORAEGG_1F_19, + /* 20 */ ENZORAEGG_1F_20, + /* 21 */ ENZORAEGG_1F_21, + /* 22 */ ENZORAEGG_1F_22, + /* 23 */ ENZORAEGG_1F_23, + /* 24 */ ENZORAEGG_1F_24, + /* 25 */ ENZORAEGG_1F_25, +}; + typedef struct EnZoraegg { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xB4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[7]; + /* 0x01B2 */ Vec3s morphTable[7]; + /* 0x01DC */ Actor* unk_1DC; + /* 0x01E0 */ f32 unk_1E0; + /* 0x01E4 */ f32 unk_1E4; + /* 0x01E8 */ s16 unk_1E8; + /* 0x01EA */ u16 unk_1EA; + /* 0x01EC */ u8 unk_1EC; + /* 0x01ED */ u8 unk_1ED; + /* 0x01EE */ u8 unk_1EE; + /* 0x01EF */ u8 unk_1EF; + /* 0x01F0 */ u16 actorActionCmd; + /* 0x01F2 */ s16 unk_1F2; + /* 0x01F4 */ s16 unk_1F4; /* 0x01F8 */ EnZoraeggActionFunc actionFunc; } EnZoraegg; // size = 0x1FC 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 d18469e23..419d3325e 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -218,12 +218,12 @@ void func_80BBB15C(EnZos* this, GlobalContext* globalCtx) { this->unk_2B6 |= 0x10; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BBB2C4(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - func_801518B0(globalCtx, 0x124F, &this->actor); + Message_StartTextbox(globalCtx, 0x124F, &this->actor); this->actionFunc = func_80BBB8AC; this->actor.flags &= ~ACTOR_FLAG_10000; } else { @@ -253,13 +253,13 @@ void func_80BBB354(EnZos* this, GlobalContext* globalCtx) { void func_80BBB414(EnZos* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); - if (func_800EE29C(globalCtx, 0x1F5)) { - s16 temp = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x1F5)]->unk0; + if (Cutscene_CheckActorAction(globalCtx, 501)) { + s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 501)]->action; - if (temp != this->unk_2BA) { - this->unk_2BA = temp; + if (action != this->unk_2BA) { + this->unk_2BA = action; - switch (temp) { + switch (action) { case 1: func_80BBAE84(this, 1, 0); break; @@ -301,8 +301,8 @@ void func_80BBB574(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x124B: if (this->unk_2B8 == 9) { globalCtx->msgCtx.unk11F10 = 0; @@ -386,8 +386,8 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { } } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1237: player->exchangeItemId = 0; @@ -397,13 +397,13 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x123C: case 0x123E: case 0x123F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1244: this->unk_2B6 &= ~0x10; func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1232: @@ -413,18 +413,18 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x1239: case 0x1246: func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1233: func_80BBAE84(this, 5, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1245: case 0x1248: func_80BBAE84(this, 3, 0); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1231: @@ -471,17 +471,17 @@ void func_80BBBB84(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - func_801518B0(globalCtx, 0x1248, &this->actor); + Message_StartTextbox(globalCtx, 0x1248, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); this->unk_2B6 |= 2; } else if (gSaveContext.save.weekEventReg[41] & 0x10) { - func_801518B0(globalCtx, 0x124A, &this->actor); + Message_StartTextbox(globalCtx, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; func_80BBAE84(this, 6, 0); } else { gSaveContext.save.weekEventReg[41] |= 0x10; - func_801518B0(globalCtx, 0x124B, &this->actor); + Message_StartTextbox(globalCtx, 0x124B, &this->actor); this->actionFunc = func_80BBB574; func_80BBAE84(this, 9, 2); this->unk_2B6 |= 0x10; @@ -495,7 +495,7 @@ void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; func_80BBAE84(this, 5, 0); - func_801518B0(globalCtx, 0x124D, &this->actor); + Message_StartTextbox(globalCtx, 0x124D, &this->actor); this->actionFunc = func_80BBB574; } else { func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -504,7 +504,7 @@ void func_80BBBCBC(EnZos* this, GlobalContext* globalCtx) { void func_80BBBD5C(EnZos* this, GlobalContext* globalCtx) { func_80BBB414(this, globalCtx); - if (!func_800EE29C(globalCtx, 0x1F5)) { + if (!Cutscene_CheckActorAction(globalCtx, 0x1F5)) { this->actionFunc = func_80BBBCBC; this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); @@ -537,7 +537,7 @@ void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80BBB8AC; func_80BBB15C(this, globalCtx); - } else if (func_800EE29C(globalCtx, 0x1F5)) { + } else if (Cutscene_CheckActorAction(globalCtx, 0x1F5)) { this->actionFunc = func_80BBBD5C; } else if (func_80BBAF5C(this, globalCtx)) { func_800B8614(&this->actor, globalCtx, 120.0f); @@ -572,7 +572,7 @@ void func_80BBBFBC(EnZos* this, GlobalContext* globalCtx) { textId = 0x1258; func_80BBAE84(this, 6, 0); } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { @@ -582,7 +582,7 @@ void func_80BBC070(EnZos* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 5: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80BBAE84(this, 2, 0); func_801477B4(globalCtx); this->actionFunc = func_80BBC14C; @@ -645,8 +645,8 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { this->unk_2BC = 999; } - if (func_800EE29C(globalCtx, 0x203)) { - if (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 515)) { + if (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 1) { this->actionFunc = func_80BBC37C; this->unk_2BC = -1; } @@ -658,7 +658,8 @@ void func_80BBC298(EnZos* this, GlobalContext* globalCtx) { void func_80BBC37C(EnZos* this, GlobalContext* globalCtx) { func_80BBAFFC(this, globalCtx); - if (func_800EE29C(globalCtx, 0x203) && (globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x203)]->unk0 == 3)) { + if (Cutscene_CheckActorAction(globalCtx, 515) && + (globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 515)]->action == 3)) { this->actionFunc = func_80BBC298; } } 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 62a6f8f42..676077216 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -7,7 +7,7 @@ #include "z_en_zot.h" #include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZot*)thisx) @@ -67,7 +67,7 @@ void func_80B965D0(EnZot* this, GlobalContext* globalCtx) { s32 i; if ((this->path != NULL) && (this->path->count >= 5)) { - Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(this->path->points); + Vec3s* points = Lib_SegmentedToVirtual(this->path->points); for (i = 0; i < ARRAY_COUNT(this->unk_2D8); i++, points++) { if (this->unk_2D8[i] == NULL) { @@ -154,7 +154,7 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; case 8: - this->actor.flags |= 0x2000000; + this->actor.flags |= ACTOR_FLAG_2000000; this->actionFunc = func_80B98CA8; func_80B96BEC(this, 5, 0); break; @@ -374,15 +374,15 @@ void func_80B97110(EnZot* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[28] |= 0x40; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B97194(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x125C: case 0x125F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x125D: @@ -440,20 +440,20 @@ void func_80B972E8(EnZot* this, GlobalContext* globalCtx) { gSaveContext.save.weekEventReg[29] |= 8; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { func_80B96D4C(this); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x126E: case 0x1270: case 0x1273: case 0x1274: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1272: @@ -484,7 +484,7 @@ void func_80B973BC(EnZot* this, GlobalContext* globalCtx) { case 0x1279: func_801477B4(globalCtx); func_80B965D0(this, globalCtx); - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; this->actor.textId = 0; this->actionFunc = func_80B97708; if ((this->actor.cutscene != -1) && !(this->unk_2F2 & 1)) { @@ -520,20 +520,21 @@ void func_80B975F8(EnZot* this, GlobalContext* globalCtx) { } void func_80B9765C(EnZot* this, GlobalContext* globalCtx) { - if (1) { - do { } while (0); } - func_80B96D4C(this); - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - u16 temp = globalCtx->msgCtx.unk11F04; - u32 temp2; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + s32 requiredScopeTemp; - if ((temp == 0x1262) || (temp == 0x1267) || (temp == 0x126A) || (temp == 0x126B)) { - temp2 = temp; - func_80151938(globalCtx, temp2 + 1); - } else { - func_801477B4(globalCtx); - this->actionFunc = func_80B97708; + switch (globalCtx->msgCtx.currentTextId) { + case 0x1262: + case 0x1267: + case 0x126A: + case 0x126B: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + default: + func_801477B4(globalCtx); + this->actionFunc = func_80B97708; + break; } } } @@ -559,7 +560,7 @@ void func_80B97708(EnZot* this, GlobalContext* globalCtx) { if (phi_v1 != 0) { gSaveContext.save.weekEventReg[29] |= 0x10; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; if (phi_v1 == 5) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { this->actor.textId = 0x126E; @@ -642,7 +643,7 @@ void func_80B9787C(EnZot* this, GlobalContext* globalCtx) { break; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } } @@ -657,15 +658,15 @@ void func_80B979DC(EnZot* this, GlobalContext* globalCtx) { } void func_80B97A44(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1279: case 0x127C: case 0x127F: case 0x1282: case 0x1285: case 0x1288: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x127D: @@ -711,13 +712,13 @@ void func_80B97BF8(EnZot* this, GlobalContext* globalCtx) { } else { textId = 0x128B; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { func_801477B4(globalCtx); this->actionFunc = func_80B97CC8; } @@ -726,7 +727,7 @@ void func_80B97C40(EnZot* this, GlobalContext* globalCtx) { void func_80B97CC8(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B97C40; - func_801518B0(globalCtx, 0x128B, &this->actor); + Message_StartTextbox(globalCtx, 0x128B, &this->actor); } else if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && (this->actor.xzDistToPlayer < 100.0f)) { func_800B8614(&this->actor, globalCtx, 120.0f); } @@ -766,18 +767,18 @@ void func_80B97E4C(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x128C: this->unk_2F2 &= ~4; func_80B96BEC(this, 6, 2); - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x128D: case 0x128E: case 0x128F: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x1290: @@ -894,7 +895,7 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { } break; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98348(EnZot* this, GlobalContext* globalCtx) { @@ -924,9 +925,9 @@ void func_80B9849C(EnZot* this, GlobalContext* globalCtx) { func_80B98348(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if (this->unk_2D4 == 2) { - func_801518B0(globalCtx, 0x12AD, &this->actor); + Message_StartTextbox(globalCtx, 0x12AD, &this->actor); } else { - func_801518B0(globalCtx, 0x12B0, &this->actor); + Message_StartTextbox(globalCtx, 0x12B0, &this->actor); } this->actionFunc = func_80B98728; } else { @@ -939,7 +940,7 @@ void func_80B9854C(EnZot* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { this->actor.parent = NULL; this->actionFunc = func_80B9849C; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, EXCH_ITEM_MINUS1); } else { Actor_PickUp(&this->actor, globalCtx, this->unk_2D4, 10000.0f, 50.0f); @@ -978,7 +979,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 4: - if (func_80147624(globalCtx) && (globalCtx->msgCtx.unk11F04 == 0x1293)) { + if (Message_ShouldAdvance(globalCtx) && (globalCtx->msgCtx.currentTextId == 0x1293)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); @@ -994,8 +995,8 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { break; case 5: - if (func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x1291: case 0x1292: case 0x1296: @@ -1012,7 +1013,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { case 0x12A7: case 0x12A8: case 0x12AE: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12A9: @@ -1051,7 +1052,7 @@ void func_80B98728(EnZot* this, GlobalContext* globalCtx) { default: func_801477B4(globalCtx); this->actionFunc = func_80B98998; - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; break; } } @@ -1086,31 +1087,31 @@ void func_80B98A4C(EnZot* this, GlobalContext* globalCtx) { textId = 0x12B1; gSaveContext.save.weekEventReg[39] |= 0x40; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12B1: case 0x12B4: case 0x12B7: case 0x12B9: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12B8: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; gSaveContext.save.weekEventReg[41] &= (u8)~0x20; - func_8019C300(0); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; case 0x12BA: func_801477B4(globalCtx); this->actionFunc = func_80B98CA8; gSaveContext.save.weekEventReg[41] |= 0x20; - func_8019C300(0); + AudioOcarina_SetInstrumentId(OCARINA_INSTRUMENT_OFF); break; default: @@ -1123,12 +1124,12 @@ void func_80B98AD0(EnZot* this, GlobalContext* globalCtx) { void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags &= ~0x10000; + this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.save.weekEventReg[41] & 0x20) { - func_801518B0(globalCtx, 0x12B7, &this->actor); + Message_StartTextbox(globalCtx, 0x12B7, &this->actor); this->actionFunc = func_80B98AD0; } else { - func_801518B0(globalCtx, 0x12B9, &this->actor); + Message_StartTextbox(globalCtx, 0x12B9, &this->actor); this->actionFunc = func_80B98AD0; } } else { @@ -1139,9 +1140,9 @@ void func_80B98BF4(EnZot* this, GlobalContext* globalCtx) { void func_80B98CA8(EnZot* this, GlobalContext* globalCtx) { if (func_800B8718(&this->actor, &globalCtx->state)) { globalCtx->msgCtx.ocarinaMode = 4; - func_8019B544(0xFFFF); + AudioOcarina_StartDefault(0xFFFF); this->actionFunc = func_80B98BF4; - this->actor.flags |= 0x10000; + this->actor.flags |= ACTOR_FLAG_10000; func_800B8614(&this->actor, globalCtx, 120.0f); } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actionFunc = func_80B98AD0; @@ -1194,7 +1195,7 @@ void func_80B98E10(EnZot* this, GlobalContext* globalCtx) { textId = 0x12BB; } } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B98F30(EnZot* this, GlobalContext* globalCtx) { @@ -1212,15 +1213,15 @@ void func_80B98F94(EnZot* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; } - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - switch (globalCtx->msgCtx.unk11F04) { + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { case 0x12BB: this->unk_2F2 &= ~4; case 0x12BC: case 0x12C0: case 0x12C3: - func_80151938(globalCtx, globalCtx->msgCtx.unk11F04 + 1); + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); break; case 0x12BE: @@ -1264,7 +1265,7 @@ void func_80B99160(EnZot* this, GlobalContext* globalCtx) { textId = 0x12C6; gSaveContext.save.weekEventReg[40] |= 8; } - func_801518B0(globalCtx, textId, &this->actor); + Message_StartTextbox(globalCtx, textId, &this->actor); } void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { @@ -1273,8 +1274,8 @@ void func_80B991E4(EnZot* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if ((Message_GetState(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) { - u16 temp = globalCtx->msgCtx.unk11F04; + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + u16 temp = globalCtx->msgCtx.currentTextId; u32 temp2; if ((temp == 0x12C6) || (temp == 0x12C7) || (temp == 0x12CA) || (temp == 0x12CB)) { 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 278ffa7fe..f593709cf 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -5,8 +5,10 @@ */ #include "z_en_zov.h" +#include "objects/object_zov/object_zov.h" +#include "overlays/actors/ovl_En_Elf/z_en_elf.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnZov*)thisx) @@ -15,6 +17,7 @@ void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnZov_Update(Actor* thisx, GlobalContext* globalCtx); void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80BD1570(EnZov* this, s16 index, u8 mode); void func_80BD187C(EnZov* this, GlobalContext* globalCtx); void func_80BD19FC(EnZov* this, GlobalContext* globalCtx); void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx); @@ -23,8 +26,8 @@ void func_80BD1C84(EnZov* this, GlobalContext* globalCtx); void func_80BD1D94(EnZov* this, GlobalContext* globalCtx); void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx); void func_80BD1F1C(EnZov* this, GlobalContext* globalCtx); +s32 func_80BD1FC8(GlobalContext* globalCtx, EnZov* this); -#if 0 const ActorInit En_Zov_InitVars = { ACTOR_EN_ZOV, ACTORCAT_NPC, @@ -37,63 +40,594 @@ const ActorInit En_Zov_InitVars = { (ActorFunc)EnZov_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BD26E0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* D_80BD270C[] = { + &object_zov_Anim_00D3EC, &object_zov_Anim_008120, &object_zov_Anim_00B4CC, &object_zov_Anim_00A888, + &object_zov_Anim_00C510, &object_zov_Anim_00CAA8, &object_zov_Anim_008120, &object_zov_Anim_00A888, + &object_zov_Anim_002B5C, &object_zov_Anim_00418C, &object_zov_Anim_005A6C, &object_zov_Anim_0066A4, + &object_zov_Anim_0017D4, &object_zov_Anim_0023F4, +}; -extern ColliderCylinderInit D_80BD26E0; +static Vec3f D_80BD2744 = { 400.0f, 600.0f, 0.0f }; -extern UNK_TYPE D_0600D3EC; +static Vec3f D_80BD2750 = { 400.0f, 600.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Init.s") +static TexturePtr D_80BD275C[] = { object_zov_Tex_013C38, object_zov_Tex_015138, object_zov_Tex_014138 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Destroy.s") +static TexturePtr D_80BD2768[] = { object_zov_Tex_0135F8, object_zov_Tex_014538 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD13DC.s") +static s8 D_80BD2770[] = { + 1, 2, 1, 0, 0, 1, 2, 1, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1440.s") +void EnZov_Init(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1470.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_zov_Skel_016258, &object_zov_Anim_00D3EC, this->jontTable, + this->morphTable, 23); + Animation_PlayLoop(&this->skelAnime, &object_zov_Anim_00D3EC); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1570.s") + this->unk_320 = 0; + this->unk_32C = -1; + this->unk_326 = -1; + this->unk_328[0] = this->actor.cutscene; + this->unk_328[1] = 0x7C; + this->unk_322 = 0; + this->actionFunc = func_80BD1C84; + this->unk_144 = func_80BD1FC8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD15A4.s") + Math_Vec3f_Copy(&this->unk_2FC, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_308, &this->actor.world.pos); + Math_Vec3f_Copy(&this->unk_314, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD160C.s") + switch (ENZOV_GET_F(&this->actor)) { + case ENZOV_F_1: + this->actionFunc = func_80BD1F1C; + func_80BD1570(this, 9, 0); + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { + Actor_MarkForDeath(&this->actor); + return; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1764.s") + case ENZOV_F_2: + this->actionFunc = func_80BD1C38; + this->actor.shape.shadowDraw = NULL; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD187C.s") + default: + this->unk_320 |= 2; + if ((gSaveContext.save.weekEventReg[55] & 0x80) || (gSaveContext.save.weekEventReg[53] & 0x20)) { + Actor_MarkForDeath(&this->actor); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD19FC.s") +void EnZov_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1AE0.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1BF0.s") +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]); + } + this->unk_32C = -1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1C38.s") +void func_80BD1440(EnZov* this, s16 arg1) { + func_80BD13DC(this); + this->unk_32C = arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1C84.s") +void func_80BD1470(EnZov* this, s16 index, u8 mode, f32 transitionRate) { + f32 frame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1D30.s") + if (((index != this->unk_322) || mode) && (index >= 0) && (index < ARRAY_COUNT(D_80BD270C))) { + switch (index) { + case 6: + frame = 30.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1D94.s") + case 7: + frame = 57.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1DB8.s") + default: + frame = 0.0f; + break; + } + Animation_Change(&this->skelAnime, D_80BD270C[index], 1.0f, frame, Animation_GetLastFrame(D_80BD270C[index]), + mode, transitionRate); + this->unk_322 = index; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1F1C.s") +void func_80BD1570(EnZov* this, s16 index, u8 mode) { + func_80BD1470(this, index, mode, 5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD1FC8.s") +s32 func_80BD15A4(EnZov* this, GlobalContext* globalCtx) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Update.s") +void func_80BD160C(EnZov* this, GlobalContext* globalCtx) { + s32 textId = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD2380.s") + if (gSaveContext.save.weekEventReg[53] & 0x20) { + this->unk_320 &= ~2; + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { + textId = 0x1024; + if ((this->unk_322 == 0) || (this->unk_322 == 4)) { + func_80BD1570(this, 4, 2); + } else { + func_80BD1570(this, 6, 2); + } + } else if (this->unk_320 & 4) { + textId = 0x1023; + } else { + textId = 0x1022; + this->unk_320 |= 4; + func_80BD1570(this, 3, 2); + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + func_80BD1570(this, 2, 2); + this->actionFunc = func_80BD19FC; + this->unk_324 = 10; + func_80BD1440(this, 0); + } else { + textId = 0x1020; + func_80BD1570(this, 5, 2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/func_80BD2404.s") + this->unk_320 |= 1; + if (textId != 0) { + Message_StartTextbox(globalCtx, textId, &this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zov/EnZov_Draw.s") +void func_80BD1764(EnZov* this) { + if (SkelAnime_Update(&this->skelAnime)) { + switch (this->unk_322) { + case 1: + case 6: + func_80BD1570(this, 6, 2); + break; + + case 3: + case 7: + func_80BD1570(this, 7, 2); + break; + + case 4: + func_80BD1570(this, 0, 0); + break; + + case 8: + func_80BD1570(this, 9, 0); + break; + + case 10: + func_80BD1570(this, 11, 0); + break; + + case 12: + func_80BD1570(this, 13, 0); + break; + + default: + func_80BD1570(this, 0, 0); + this->unk_320 &= ~1; + break; + } + + SkelAnime_Update(&this->skelAnime); + } +} + +void func_80BD187C(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1022: + func_80151938(globalCtx, 0x1023); + break; + + case 0x1023: + if ((this->unk_322 != 6) && (this->unk_322 != 1)) { + func_80BD1570(this, 1, 2); + } + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + + case 0x1024: + if (this->unk_322 != 6) { + func_80BD1570(this, 0, 0); + } + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + + default: + this->unk_320 &= ~1; + func_80BD1570(this, 0, 0); + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + break; + } + } + break; + + case 2: + func_801477B4(globalCtx); + this->actionFunc = func_80BD1C84; + this->unk_320 &= ~1; + func_80BD1570(this, 0, 0); + break; + } +} + +void func_80BD19FC(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + if (this->unk_322 == 0) { + if (!(this->unk_320 & 2)) { + this->unk_320 |= 2; + this->unk_2EE = 3; + } + + if (this->unk_324 > 0) { + this->unk_324--; + } else { + func_80BD13DC(this); + Message_StartTextbox(globalCtx, 0x1021, &this->actor); + ((EnElf*)(GET_PLAYER(globalCtx)->tatlActor))->unk_264 |= 4; + Actor_ChangeFocus(&this->actor, globalCtx, GET_PLAYER(globalCtx)->tatlActor); + this->actionFunc = func_80BD187C; + } + } else if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + this->unk_320 &= ~2; + this->unk_2EE = 3; + } +} + +s32 func_80BD1AE0(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (Cutscene_CheckActorAction(globalCtx, 504)) { + s16 action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 504)]->action; + + if (action != this->unk_326) { + this->unk_326 = action; + switch (this->unk_326) { + case 1: + func_80BD1570(this, 0, 0); + break; + + case 2: + func_80BD1570(this, 8, 2); + this->unk_320 |= 0x10; + break; + + case 3: + func_80BD1470(this, 10, 2, 0.0f); + break; + + case 4: + func_80BD1570(this, 12, 2); + break; + } + } + return true; + } + + return false; +} + +void func_80BD1BF0(EnZov* this, GlobalContext* globalCtx) { + if (!func_80BD1AE0(this, globalCtx)) { + func_80BD1570(this, 0, 0); + this->actionFunc = func_80BD1C84; + } +} + +void func_80BD1C38(EnZov* this, GlobalContext* globalCtx) { + if (func_80BD1AE0(this, globalCtx)) { + Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, Cutscene_GetActorActionIndex(globalCtx, 504)); + } +} + +void func_80BD1C84(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BD187C; + func_80BD160C(this, globalCtx); + } else if (func_80BD15A4(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } + + if (Cutscene_CheckActorAction(globalCtx, 0x1F8)) { + this->actionFunc = func_80BD1BF0; + func_80BD1BF0(this, globalCtx); + } +} + +void func_80BD1D30(EnZov* this, GlobalContext* globalCtx) { + u16 textId; + + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { + textId = 0x1032; + } else { + textId = 0x1033; + } + } else { + textId = 0x1031; + } + Message_StartTextbox(globalCtx, textId, &this->actor); +} + +void func_80BD1D94(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); +} + +void func_80BD1DB8(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if ((Message_GetState(&globalCtx->msgCtx) == 5) && Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x1033: + case 0x1034: + case 0x1035: + case 0x1036: + case 0x1037: + case 0x1038: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + case 0x1039: + globalCtx->nextEntranceIndex = globalCtx->setupExitList[ENZOV_GET_FE00(&this->actor)]; + globalCtx->unk_1887F = 5; + globalCtx->sceneLoadFlag = 0x14; + gSaveContext.save.weekEventReg[78] |= 1; + this->actionFunc = func_80BD1D94; + globalCtx->msgCtx.unk11F10 = 0; + Audio_QueueSeqCmd(0x101400FF); + break; + + default: + func_801477B4(globalCtx); + this->actionFunc = func_80BD1F1C; + break; + } + } +} + +void func_80BD1F1C(EnZov* this, GlobalContext* globalCtx) { + func_80BD1764(this); + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x1000, 0x200); + this->actor.world.rot.y = this->actor.shape.rot.y; + } + + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BD1DB8; + func_80BD1D30(this, globalCtx); + } else if (func_80BD15A4(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 120.0f); + } +} + +s32 func_80BD1FC8(GlobalContext* globalCtx, EnZov* this) { + s32 ret; + s32 pad; + + ret = func_8013A530(globalCtx, &this->actor, 4, &this->actor.focus.pos, &this->actor.shape.rot, 10.0f, 300.0f, -1); + ret |= func_8013A530(globalCtx, &this->actor, 5, &this->unk_308, &this->actor.shape.rot, 50.0f, 160.0f, 0x3000); + ret |= func_8013A530(globalCtx, &this->actor, 6, &this->unk_314, &this->actor.shape.rot, 50.0f, 160.0f, 0x3000); + return ret; +} + +void EnZov_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZov* this = THIS; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 4); + + this->actionFunc(this, globalCtx); + + if (!Cutscene_CheckActorAction(globalCtx, 0x1F8)) { + this->unk_320 &= ~0x10; + } + + if ((this->unk_320 & 1) && func_80BD15A4(this, globalCtx)) { + func_800E9250(globalCtx, &this->actor, &this->unk_2F0, &this->unk_2F6, this->actor.focus.pos); + } else { + if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { + Math_SmoothStepToS(&this->unk_2F0.x, -0x1B58, 6, 0x1838, 0x64); + } else { + Math_SmoothStepToS(&this->unk_2F0.x, 0, 6, 0x1838, 0x64); + } + Math_SmoothStepToS(&this->unk_2F0.y, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_2F6.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->unk_2F6.y, 0, 6, 0x1838, 0x64); + } + + if (DECR(this->unk_2EE) == 0) { + this->unk_2EE = Rand_S16Offset(60, 60); + } + + this->unk_2EC = this->unk_2EE; + if (this->unk_2EC >= 3) { + 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->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_328[this->unk_32C]); + } + } +} + +s32 EnZov_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZov* this = THIS; + + if (limbIndex == 12) { + rot->x += this->unk_2F0.y; + if ((this->unk_320 & 0x10) && (this->unk_322 == 0)) { + rot->z += this->unk_2F0.x; + } + } + + if (limbIndex == 11) { + rot->x += this->unk_2F6.y; + } + return false; +} + +void EnZov_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnZov* this = THIS; + + if (limbIndex == 12) { + Matrix_MultiplyVector3fByState(&D_80BD2744, &this->actor.focus.pos); + Math_Vec3f_Copy(&this->unk_2FC, &this->actor.focus.pos); + this->unk_2FC.y += 10.0f; + } + + if (limbIndex == 18) { + Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_308); + } + + if (limbIndex == 13) { + Matrix_MultiplyVector3fByState(&D_80BD2750, &this->unk_314); + } +} + +void EnZov_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnZov* this = THIS; + Gfx* gfx; + s32 curFrame; + s32 phi_a1; + u8 phi_v1; + + if (1) {} + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + phi_a1 = 0; + curFrame = this->skelAnime.curFrame; + phi_v1 = this->unk_2EC; + + switch (this->unk_322) { + case 0: + if ((this->unk_2EC == 0) && !(this->unk_320 & 0x10)) { + phi_v1 = 1; + } + break; + + case 5: + if (this->unk_2EC == 0) { + phi_v1 = 1; + } + break; + + case 2: + if (curFrame < 23) { + phi_v1 = 0; + } else if (curFrame >= 26) { + phi_v1 = 1; + } else if (curFrame == 24) { + phi_v1 = 0; + } else { + phi_v1 = 1; + } + break; + + case 3: + case 7: + if (curFrame <= 50) { + if (curFrame < 43) { + phi_v1 = 0; + } else { + phi_v1 = D_80BD2770[(curFrame - 43) & 3]; + } + } + phi_a1 = 1; + break; + + case 4: + if ((curFrame < 14) || (curFrame >= 24)) { + phi_v1 = 1; + } else { + phi_v1 = D_80BD2770[4 + ((curFrame - 14) & 3)]; + } + phi_a1 = 1; + break; + + case 8: + phi_v1 = 0; + break; + + case 9: + phi_v1 = 0; + phi_a1 = 1; + break; + } + + gfx = POLY_OPA_DISP; + gSPSegment(&gfx[0], 0x09, Lib_SegmentedToVirtual(D_80BD275C[phi_v1])); + gSPSegment(&gfx[1], 0x08, Lib_SegmentedToVirtual(D_80BD2768[phi_a1])); + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZov_OverrideLimbDraw, EnZov_PostLimbDraw, &this->actor); +} 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 2a4650544..ce1cc9d0f 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.h +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.h @@ -6,10 +6,34 @@ struct EnZov; typedef void (*EnZovActionFunc)(struct EnZov*, GlobalContext*); +typedef s32 (*EnZovUnkFunc)(GlobalContext*, struct EnZov*); + +#define ENZOV_GET_F(thisx) ((thisx)->params & 0xF) +#define ENZOV_GET_FE00(thisx) (((thisx)->params & 0xFE00) >> 9) + +#define ENZOV_F_1 1 +#define ENZOV_F_2 2 typedef struct EnZov { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1EC]; + /* 0x0144 */ EnZovUnkFunc unk_144; + /* 0x0148 */ Vec3s jontTable[23]; + /* 0x01D2 */ Vec3s morphTable[23]; + /* 0x025C */ SkelAnime skelAnime; + /* 0x02A0 */ ColliderCylinder collider; + /* 0x02EC */ s16 unk_2EC; + /* 0x02EE */ s16 unk_2EE; + /* 0x02F0 */ Vec3s unk_2F0; + /* 0x02F6 */ Vec3s unk_2F6; + /* 0x02FC */ Vec3f unk_2FC; + /* 0x0308 */ Vec3f unk_308; + /* 0x0314 */ Vec3f unk_314; + /* 0x0320 */ u16 unk_320; + /* 0x0322 */ s16 unk_322; + /* 0x0324 */ s16 unk_324; + /* 0x0326 */ s16 unk_326; + /* 0x0328 */ s16 unk_328[2]; + /* 0x032C */ s16 unk_32C; /* 0x0330 */ 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 2147bc5f4..ff258fc20 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -5,8 +5,9 @@ */ #include "z_en_zow.h" +#include "objects/object_zo/object_zo.h" -#define FLAGS 0x00000019 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #define THIS ((EnZow*)thisx) @@ -21,7 +22,6 @@ void func_80BDD634(EnZow* this, GlobalContext* globalCtx); void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx); void func_80BDD79C(EnZow* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Zow_InitVars = { ACTOR_EN_ZOW, ACTORCAT_NPC, @@ -34,72 +34,617 @@ const ActorInit En_Zow_InitVars = { (ActorFunc)EnZow_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BDDCF0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_80BDDD1C = { 0.0f, 1.0f, 0.0f }; -extern ColliderCylinderInit D_80BDDCF0; +Vec3f D_80BDDD28 = { 0.0f, -1.0f, 0.0f }; -extern UNK_TYPE D_06002A50; -extern UNK_TYPE D_06002C10; -extern UNK_TYPE D_06004248; -extern UNK_TYPE D_0600D288; +void func_80BDC270(EnZowStruct* ptr, Vec3f* arg1, f32 arg2, f32 arg3, u8 arg4) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC270.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 0) { + ptr->unk_00 = 1; + ptr->unk_14 = *arg1; + ptr->unk_04 = arg2; + ptr->unk_08 = arg3; + ptr->unk_0F = arg4; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC2D8.s") +void func_80BDC2D8(EnZow* this, EnZowStruct* ptr, Vec3f* arg2) { + s16 i; + f32 temp; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC3C0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 0) { + temp = this->actor.world.pos.y + this->actor.depthInWater; + if (temp <= arg2->y) { + continue; + } + ptr->unk_00 = 3; + ptr->unk_14 = *arg2; + ptr->unk_20 = *arg2; + ptr->unk_2C = D_80BDDD1C; + ptr->unk_04 = ((Rand_ZeroOne() - 0.5f) * 0.02f) + 0.12f; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC50C.s") +void func_80BDC3C0(EnZowStruct* ptr, Vec3f* arg1, Vec3f* arg2, f32 arg3) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC5C8.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 != 2) { + ptr->unk_00 = 2; + ptr->unk_14 = *arg1; + ptr->unk_20 = D_80BDDD28; + ptr->unk_2C = *arg2; + ptr->unk_0F = (Rand_ZeroOne() * 100.0f) + 100.0f; + ptr->unk_04 = arg3; + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC6F8.s") +void func_80BDC50C(EnZowStruct* ptr) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC830.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + Math_ApproachF(&ptr->unk_04, ptr->unk_08, 0.2f, 0.8f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDC9DC.s") + if (ptr->unk_0F > 20) { + ptr->unk_0F -= 20; + } else { + ptr->unk_0F = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCB84.s") + if (ptr->unk_0F == 0) { + ptr->unk_00 = 0; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCD38.s") +void func_80BDC5C8(EnZow* this, EnZowStruct* ptr) { + f32 temp_f2; + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDCDA8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 3) { + ptr->unk_14.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.x; + ptr->unk_14.z = ((Rand_ZeroOne() * 0.5f) - 0.25f) + ptr->unk_20.z; + ptr->unk_14.y += ptr->unk_2C.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Init.s") + temp_f2 = this->actor.world.pos.y + this->actor.depthInWater; + if (temp_f2 <= ptr->unk_14.y) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Destroy.s") +void func_80BDC6F8(EnZow* this, EnZowStruct* ptr) { + s16 i; + f32 temp_f0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD04C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_2D0); i++, ptr++) { + if (ptr->unk_00 == 2) { + ptr->unk_14.x += ptr->unk_2C.x; + ptr->unk_14.y += ptr->unk_2C.y; + ptr->unk_14.z += ptr->unk_2C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD154.s") + if (ptr->unk_2C.y >= -20.0f) { + ptr->unk_2C.y += ptr->unk_20.y; + } else { + ptr->unk_2C.y = -20.0f; + ptr->unk_20.y = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD1E0.s") + temp_f0_2 = this->actor.world.pos.y + this->actor.depthInWater; + if (ptr->unk_14.y < temp_f0_2) { + ptr->unk_00 = 0; + ptr->unk_14.y = temp_f0_2; + func_80BDC270(ptr, &ptr->unk_14, 0.06f, 0.12f, 200); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD350.s") +void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD490.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD570.s") + func_8012C2DC(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD634.s") + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 1) { + if (!flag) { + gDPPipeSync(POLY_XLU_DISP++); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D220); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); + if (1) {} + flag = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD6BC.s") + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr->unk_0F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDD79C.s") + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_Scale(ptr->unk_04, 1.0f, ptr->unk_04, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Update.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_00D288); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDA7C.s") + CLOSE_DISPS(globalCtx->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAA0.s") +void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/func_80BDDAE0.s") + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zow/EnZow_Draw.s") + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 3) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_0029F0); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + if (1) {} + flag = true; + } + + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002A50); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { + s16 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + u8 flag = false; + + func_8012C2DC(globalCtx->state.gfxCtx); + + for (i = 0; i < 15; i++, ptr++) { + if (ptr->unk_00 == 2) { + if (!flag) { + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002BA0); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); + if (1) {} + flag = true; + } + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); + + Matrix_InsertTranslation(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_Scale(ptr->unk_04, ptr->unk_04, 1.0f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_zo_DL_002C10); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80BDCD38(EnZow* this, EnZowStruct* ptr, f32 arg2, f32 arg3, u8 arg4) { + static Vec3f D_80BDDD34 = { 0.0f, 0.0f, 0.0f }; + + D_80BDDD34.x = this->actor.world.pos.x; + D_80BDDD34.y = this->actor.world.pos.y + this->actor.depthInWater; + D_80BDDD34.z = this->actor.world.pos.z; + func_80BDC270(ptr, &D_80BDDD34, arg2, arg3, arg4); +} + +void func_80BDCDA8(EnZow* this, EnZowStruct* ptr) { + Vec3f sp84; + Vec3f sp78; + f32 temp_f20; + f32 temp_f22; + s32 i; + + for (i = 0; i < 10; i++) { + temp_f20 = (Rand_ZeroOne() * 1.5f) + 0.5f; + temp_f22 = Rand_ZeroOne() * 6.28f; + + sp78.y = (Rand_ZeroOne() * 3.0f) + 3.0f; + sp78.x = __sinf(temp_f22) * temp_f20; + sp78.z = __cosf(temp_f22) * temp_f20; + + sp84 = this->actor.world.pos; + sp84.x += sp78.x * 6.0f; + sp84.z += sp78.z * 6.0f; + sp84.y += this->actor.depthInWater; + + func_80BDC3C0(ptr, &sp84, &sp78, 0.08f); + } +} + +void EnZow_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80BDD79C; + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gZoraSkel, &gZoraIdleAnim, this->jointTable, this->morphTable, 20); + Animation_PlayOnce(&this->skelAnime, &gZoraSurfacingAnim); + this->unk_2C8 = 1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.shape.rot.z = 0; + this->unk_2CA = 0; + this->unk_2CC = 0; + this->unk_2CE = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.textId = 0; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.flags &= ~ACTOR_FLAG_1; +} + +void EnZow_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnZow* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +AnimationHeader* sAnimations[] = { &object_zo_Anim_004168, &gZoraSurfacingAnim, &gZoraSurfacingAnim }; + +void func_80BDD04C(EnZow* this, s16 arg1, u8 arg2) { + if ((arg1 >= 0) && (arg1 < 3)) { + if (arg1 < 2) { + Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), + arg2, -5.0f); + } else { + Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, Animation_GetLastFrame(sAnimations[arg1]), + 0.0f, arg2, 0.0f); + } + this->unk_2C8 = arg1; + } +} + +s32 func_80BDD154(EnZow* this, GlobalContext* globalCtx) { + if (Player_IsFacingActor(&this->actor, 0x3000, globalCtx) && Actor_IsFacingPlayer(&this->actor, 0x3000) && + (this->actor.xzDistToPlayer < 170.0f) && (fabsf(this->actor.playerHeightRel) < 100.0f)) { + return true; + } + return false; +} + +void func_80BDD1E0(EnZow* this, GlobalContext* globalCtx) { + u16 phi_a1; + + if (ENZOW_GET_F(&this->actor) == ENZOW_F_1) { + if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 4) { + phi_a1 = 0x12FD; + } else { + phi_a1 = 0x12FA; + gSaveContext.save.weekEventReg[78] |= 4; + } + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.save.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 8) { + phi_a1 = 0x12F8; + } else { + phi_a1 = 0x12F3; + gSaveContext.save.weekEventReg[78] |= 8; + } + } else if (gSaveContext.save.weekEventReg[78] & 0x10) { + phi_a1 = 0x1301; + } else { + gSaveContext.save.weekEventReg[78] |= 0x10; + phi_a1 = 0x12FF; + } + } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + phi_a1 = 0x12EC; + } else { + phi_a1 = 0x12F1; + } + } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[78] & 2) { + phi_a1 = 0x12EB; + } else { + phi_a1 = 0x12E8; + gSaveContext.save.weekEventReg[78] |= 2; + } + } else { + phi_a1 = 0x12EF; + } + Message_StartTextbox(globalCtx, phi_a1, &this->actor); +} + +void func_80BDD350(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CA & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_WATER); + func_80BDCDA8(this, this->unk_2D0); + this->actor.flags &= ~ACTOR_FLAG_1; + this->skelAnime.playSpeed = 0.0f; + this->actor.velocity.y = -4.0f; + } + + if (this->actor.depthInWater > 120.0f) { + Math_ApproachF(&this->actor.velocity.y, 0.0f, 0.4f, 0.6f); + if (this->actor.velocity.y > -0.1f) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + } + + if ((this->actor.bgCheckFlags & 1) || (this->actor.depthInWater > 180.0f)) { + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD79C; + } + + if (this->skelAnime.playSpeed <= 0.0f) { + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + return; + } else { + this->unk_2CE = 0; + } + } +} + +void func_80BDD490(EnZow* this, GlobalContext* globalCtx) { + this->actor.velocity.y = 0.0f; + if (this->actor.xzDistToPlayer > 440.0f) { + this->actionFunc = func_80BDD350; + func_80BDD04C(this, 2, 2); + } else if (this->unk_2CA & 2) { + func_80BDD04C(this, 0, 0); + } + + if ((globalCtx->gameplayFrames & 7) == 0) { + func_80BDCD38(this, this->unk_2D0, 0.2f, 1.0f, 200); + } + + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } +} + +void func_80BDD570(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + + switch (Message_GetState(&globalCtx->msgCtx)) { + case 5: + if (Message_ShouldAdvance(globalCtx)) { + switch (globalCtx->msgCtx.currentTextId) { + case 0x12E8: + case 0x12E9: + case 0x12EC: + case 0x12ED: + case 0x12EF: + case 0x12F1: + case 0x12F3: + case 0x12F4: + case 0x12F5: + case 0x12F6: + case 0x12F8: + case 0x12FA: + case 0x12FB: + case 0x12FD: + case 0x12FF: + func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + break; + + default: + func_801477B4(globalCtx); + break; + } + } + break; + + case 2: + this->actionFunc = func_80BDD634; + break; + } +} + +void func_80BDD634(EnZow* this, GlobalContext* globalCtx) { + func_80BDD490(this, globalCtx); + if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + this->actionFunc = func_80BDD570; + func_80BDD1E0(this, globalCtx); + } else if (func_80BDD154(this, globalCtx)) { + func_800B8614(&this->actor, globalCtx, 180.0f); + } +} + +void func_80BDD6BC(EnZow* this, GlobalContext* globalCtx) { + if (this->unk_2CE < 245) { + this->unk_2CE += 10; + } else { + this->unk_2CE = 255; + } + + if (this->actor.depthInWater < 54.0f) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OUT_OF_WATER); + func_80BDCDA8(this, this->unk_2D0); + func_80BDD04C(this, 1, 2); + this->actor.flags |= ACTOR_FLAG_1; + this->actor.velocity.y = 0.0f; + this->actionFunc = func_80BDD634; + } else if (this->actor.depthInWater < 80.0f) { + Math_ApproachF(&this->actor.velocity.y, 2.0f, 0.4f, 0.6f); + } +} + +void func_80BDD79C(EnZow* this, GlobalContext* globalCtx) { + if (this->actor.xzDistToPlayer < 400.0f) { + this->actor.velocity.y = 4.0f; + this->actionFunc = func_80BDD6BC; + } + + if (this->unk_2CE >= 6) { + this->unk_2CE -= 5; + } else { + this->unk_2CE = 0; + } + + if (this->actor.depthInWater > 180.0f) { + this->actor.world.pos.y = this->actor.world.pos.y + -180.0f + this->actor.depthInWater; + } +} + +void EnZow_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnZow* this = THIS; + Vec3f sp34; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 15.0f, 30.0f, 5); + + if (this->unk_2CE != 0) { + this->unk_2CA &= ~2; + if (SkelAnime_Update(&this->skelAnime)) { + this->unk_2CA |= 2; + } + } else { + this->unk_2CA |= 2; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0x800, 0x100); + this->actor.world.rot.y = this->actor.shape.rot.y; + + this->actionFunc(this, globalCtx); + + if (this->unk_2CE != 0) { + if ((globalCtx->state.frames & 8) != 0) { + sp34 = this->actor.world.pos; + sp34.y += ((Rand_ZeroOne() - 0.5f) * 10.0f) + 18.0f; + sp34.x += (Rand_ZeroOne() - 0.5f) * 28.0f; + sp34.z += (Rand_ZeroOne() - 0.5f) * 28.0f; + func_80BDC2D8(this, this->unk_2D0, &sp34); + } + + if (DECR(this->unk_2C6) == 0) { + this->unk_2C6 = Rand_S16Offset(60, 60); + } + + this->unk_2C4 = this->unk_2C6; + if (this->unk_2C4 >= 3) { + this->unk_2C4 = 0; + } + } + + this->actor.shape.shadowAlpha = this->unk_2CE; + func_80BDC50C(this->unk_2D0); + func_80BDC5C8(this, this->unk_2D0); + func_80BDC6F8(this, this->unk_2D0); +} + +Gfx* func_80BDDA7C(GraphicsContext* gfxCtx) { + Gfx* gfx = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + + gSPEndDisplayList(gfx); + + return gfx; +} + +Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f }; + +void func_80BDDAA0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == 15) { + Matrix_MultiplyVector3fByState(&D_80BDDD4C, &thisx->focus.pos); + } +} + +void func_80BDDAE0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + func_80BDDAA0(globalCtx, limbIndex, dList, rot, thisx); +} + +void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { + TexturePtr sp54[] = { + gZoraEyeOpenTex, + gZoraEyeHalfTex, + gZoraEyeClosedTex, + }; + EnZow* this = THIS; + + Matrix_StatePush(); + + func_80BDC830(this->unk_2D0, globalCtx); + func_80BDC9DC(this->unk_2D0, globalCtx); + func_80BDCB84(this->unk_2D0, globalCtx); + + Matrix_StatePop(); + + if (this->unk_2CE != 0) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->unk_2CE >= 255) { + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80BDDA7C(globalCtx->state.gfxCtx)); + + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, NULL, func_80BDDAA0, &this->actor); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sp54[this->unk_2C4])); + + func_800BDAA0(globalCtx, &this->skelAnime, NULL, func_80BDDAE0, &this->actor, this->unk_2CE); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.h b/src/overlays/actors/ovl_En_Zow/z_en_zow.h index 976e4e29b..e169e2816 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.h +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.h @@ -7,9 +7,35 @@ struct EnZow; typedef void (*EnZowActionFunc)(struct EnZow*, GlobalContext*); +#define ENZOW_GET_F(thisx) ((thisx)->params & 0xF) + +#define ENZOW_F_1 1 + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ UNK_TYPE1 unk_0C[0x3]; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ UNK_TYPE1 unk_10[0x4]; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; +} EnZowStruct; // size = 0x38 + typedef struct EnZow { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4D4]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ ColliderCylinder collider; + /* 0x01D4 */ Vec3s jointTable[20]; + /* 0x024C */ Vec3s morphTable[20]; + /* 0x02C4 */ s16 unk_2C4; + /* 0x02C6 */ s16 unk_2C6; + /* 0x02C8 */ s16 unk_2C8; + /* 0x02CA */ u16 unk_2CA; + /* 0x02CC */ s16 unk_2CC; + /* 0x02CE */ s16 unk_2CE; + /* 0x02D0 */ EnZowStruct unk_2D0[15]; /* 0x0618 */ EnZowActionFunc actionFunc; } EnZow; // size = 0x61C 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 c5c0c16ea..82b29e716 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -6,7 +6,7 @@ #include "z_item_etcetera.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ItemEtcetera*)thisx) diff --git a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c index a006270f3..7017dfcec 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -6,7 +6,7 @@ #include "z_item_inbox.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ItemInbox*)thisx) diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index 7d0068a52..c6de60ce2 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -2,11 +2,13 @@ * File: z_mir_ray.c * Overlay: ovl_Mir_Ray * Description: Reflectible light ray (unused, somewhat broken) + * Note: This actor is unchanged from OoT, and will not work correctly */ #include "z_mir_ray.h" +#include "objects/object_mir_ray/object_mir_ray.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay*)thisx) @@ -15,7 +17,30 @@ void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx); void MirRay_Update(Actor* thisx, GlobalContext* globalCtx); void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB); + +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ MtxF mtx; + /* 0x4C */ CollisionPoly* reflectionPoly; + /* 0x50 */ u8 opacity; +} MirRayShieldReflection; // size = 0x54 + +typedef struct { + /* 0x00 */ Vec3s sourcePoint; + /* 0x06 */ Vec3s poolPoint; // point at center of light pool on floor for windows and BigMirror, same as source + // point for Cobra Mirror + /* 0x0C */ s16 sourceEndRadius; // Radius of beam frustum at the source end + /* 0x0E */ s16 poolEndRadius; // Radius of beam frustum at the pool end + /* 0x10 */ f32 unk_10; // placement of collider center along beam + /* 0x14 */ s16 unk_14; // collider radius before scaled + /* 0x16 */ s16 lgtPtMaxRad; // light point max radius + /* 0x18 */ f32 unk_18; // placement of light point between source and reflection point (pool point for windows, + // player for mirrors) + /* 0x1C */ Color_RGB8 color; + /* 0x1F */ u8 params; +} MirRayDataEntry; // size = 0x20 + const ActorInit Mir_Ray_InitVars = { ACTOR_MIR_RAY, ACTORCAT_ITEMACTION, @@ -28,64 +53,670 @@ const ActorInit Mir_Ray_InitVars = { (ActorFunc)MirRay_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_808E3BF4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +u8 D_808E3BF0 = false; + +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_808E3C44[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808E3C68 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 1, D_808E3C44, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808E3DB8[] = { +// Note: this data is unchanged from OoT and hardcoded for Spirit Temple, so the actor will not work at all without +// modification. + +MirRayDataEntry sMirRayData[] = { + { + { -0x488, 0x2AE, -0x370 }, + { -0x398, 0x1E0, -0x379 }, + 30, + 50, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + 2, + }, + { + { -0x740, 0x444, -0xBE }, + { -0x6A7, 0x349, -0xBA }, + 30, + 70, + 0.88f, + 0x36, + 150, + 0.8f, + { 255, 255, 255 }, + 2, + }, + { + { 0x557, 0x2E2, -0x35C }, + { 0x443, 0x1DC, -0x35C }, + 30, + 0x55, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 0x898, 0x44F, -0xDC }, + { 0x7F8, 0x34B, -0xDC }, + 30, + 60, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 1, + }, + { + { -0x230, 0x879, -0x136 }, + { -0x230, 0x6CF, -0x136 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.8f, + { 255, 255, 255 }, + 0, + }, + { + { 0x3C, 0x70A, -0x442 }, + { 0x3C, 0x3CD, -0x442 }, + 30, + 70, + 0.0f, + 0, + 150, + 0.9f, + { 255, 255, 255 }, + 13, + }, + { + { 0x474, 0x1E0, -0x35C }, + { 0x474, 0x1E0, -0x35C }, + 30, + 30, + 1.0f, + 10, + 100, + 0.9f, + { 255, 255, 255 }, + 14, + }, + { + { -0x230, 0x6CF, -0x136 }, + { + -0x230, + 0x6CF, + -0x136, + }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + 12, + }, + { + { 0x3C, 0x6CF, -0x136 }, + { 0x3C, 0x6CF, -0x136 }, + 30, + 30, + 0.0f, + 0, + 100, + 0.94f, + { 255, 255, 255 }, + 12, + }, + { + { -0x496, 0x1C0, 0x4AA }, + { -0x496, 0x94, 0x4AA }, + 50, + 100, + 1.0f, + 50, + 150, + 0.8f, + { 255, 255, 255 }, + 3, + }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP), }; +const char D_808E3DD0[] = "反射光 発生失敗"; + +void MirRay_SetupCollider(MirRay* this) { + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + f32 x = (this->poolPt.x - this->sourcePt.x) * dataEntry->unk_10; + f32 y = (this->poolPt.y - this->sourcePt.y) * dataEntry->unk_10; + f32 z = (this->poolPt.z - this->sourcePt.z) * dataEntry->unk_10; + + this->collider1.elements[0].dim.worldSphere.center.x = this->sourcePt.x + x; + this->collider1.elements[0].dim.worldSphere.center.y = this->sourcePt.y + y; + this->collider1.elements[0].dim.worldSphere.center.z = this->sourcePt.z + z; + + this->collider1.elements[0].dim.worldSphere.radius = dataEntry->unk_14 * this->collider1.elements->dim.scale; +} + +// Set up a light point between source point and reflection point. Reflection point is the pool point (for windows) or +// at the player position (for mirrors) +void MirRay_MakeShieldLight(MirRay* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + Vec3f reflectionPt; + Vec3s lightPt; + + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, player->actor.world.pos.x, + player->actor.world.pos.y + 30.0f, player->actor.world.pos.z, this->sourceEndRad, + this->poolEndRad)) { + if (dataEntry->params & 8) { + Math_Vec3f_Diff(&player->actor.world.pos, &this->sourcePt, &reflectionPt); + } else { + Math_Vec3f_Diff(&this->poolPt, &this->sourcePt, &reflectionPt); + } + + lightPt.x = (dataEntry->unk_18 * reflectionPt.x) + this->sourcePt.x; + lightPt.y = (dataEntry->unk_18 * reflectionPt.y) + this->sourcePt.y; + lightPt.z = (dataEntry->unk_18 * reflectionPt.z) + this->sourcePt.z; + + // Fade up + Math_StepToS(&this->lightPointRad, dataEntry->lgtPtMaxRad, 6); + Lights_PointNoGlowSetInfo(&this->lightInfo, lightPt.x, lightPt.y, lightPt.z, dataEntry->color.r, + dataEntry->color.g, dataEntry->color.b, this->lightPointRad); + } else { + // Fade down + Math_StepToS(&this->lightPointRad, 0, 6); + Lights_PointSetColorAndRadius(&this->lightInfo, dataEntry->color.r, dataEntry->color.g, dataEntry->color.b, + this->lightPointRad); + } +} + +void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + MirRayDataEntry* dataEntry = &sMirRayData[MIRRAY_LOCATION(&this->actor)]; + + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + + if (MIRRAY_LOCATION(&this->actor) >= MIRRAY_MAX) { + Actor_MarkForDeath(&this->actor); + } + + this->sourcePt.x = dataEntry->sourcePoint.x; + this->sourcePt.y = dataEntry->sourcePoint.y; + this->sourcePt.z = dataEntry->sourcePoint.z; + this->sourceEndRad = dataEntry->sourceEndRadius; + + this->poolPt.x = dataEntry->poolPoint.x; + this->poolPt.y = dataEntry->poolPoint.y; + this->poolPt.z = dataEntry->poolPoint.z; + this->poolEndRad = dataEntry->poolEndRadius; + + Lights_PointNoGlowSetInfo(&this->lightInfo, this->sourcePt.x, this->sourcePt.y, this->sourcePt.z, 255, 255, 255, + 100); + this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + + this->shieldCorners[0].x = -536.0f; + this->shieldCorners[0].y = -939.0f; + + this->shieldCorners[1].x = -1690.0f; + this->shieldCorners[1].y = 0.0f; + + this->shieldCorners[2].x = -536.0f; + this->shieldCorners[2].y = 938.0f; + + this->shieldCorners[3].x = 921.0f; + this->shieldCorners[3].y = 0.0f; + + this->shieldCorners[4].x = 758.0f; + this->shieldCorners[4].y = 800.0f; + + this->shieldCorners[5].x = 758.0f; + this->shieldCorners[5].y = -800.0f; + + if (dataEntry->params & 2) { + Collider_InitJntSph(globalCtx, &this->collider1); + Collider_SetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit, this->collider1Elements); + if (!(dataEntry->params & 4)) { // Beams not from mirrors + MirRay_SetupCollider(this); + } + } + + Collider_InitQuad(globalCtx, &this->collider2); + Collider_SetQuad(globalCtx, &this->collider2, &this->actor, &sQuadInit); + + if ((MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR) || + (MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_COBRA1) || + (MIRRAY_LOCATION(&this->actor) == MIRRAY_SPIRIT_TOPROOM_COBRA2)) { + this->actor.room = -1; + } +} + +void MirRay_Destroy(Actor* thisx, GlobalContext* globalCtx) { + MirRay* this = THIS; + + LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, this->lightNode); + + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 2) { + Collider_DestroyJntSph(globalCtx, &this->collider1); + } + + Collider_DestroyQuad(globalCtx, &this->collider2); +} + +void MirRay_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + D_808E3BF0 = false; + + if (!this->unLit) { + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 2) { + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 4) { + MirRay_SetupCollider(this); + } + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + } + + if (this->reflectIntensity > 0.0f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + } + + MirRay_MakeShieldLight(this, globalCtx); + + if (this->reflectIntensity > 0.0f) { + func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); + } + } +} + +void MirRay_SetIntensity(MirRay* this, GlobalContext* globalCtx) { + f32 sp4C[3]; + s32 pad[4]; + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f2; + + this->reflectIntensity = 0.0f; + + if (MirRay_CheckInFrustum(&this->sourcePt, &this->poolPt, shieldMtx->wx, shieldMtx->wy, shieldMtx->wz, + this->sourceEndRad, this->poolEndRad)) { + temp_f0 = sqrtf(SQ(shieldMtx->zz) + (SQ(shieldMtx->zx) + SQ(shieldMtx->zy))); + if (temp_f0 == 0.0f) { + this->reflectRange = 1.0f; + } else { + this->reflectRange = 1.0f / temp_f0; + } + + if (sMirRayData[MIRRAY_LOCATION(&this->actor)].params & 1) { + this->reflectIntensity = 1.0f; + } else { + sp4C[0] = this->poolPt.x - this->sourcePt.x; + sp4C[1] = this->poolPt.y - this->sourcePt.y; + sp4C[2] = this->poolPt.z - this->sourcePt.z; + + temp_f2 = (-shieldMtx->zx * sp4C[0]) - (shieldMtx->zy * sp4C[1]) - (shieldMtx->zz * sp4C[2]); + + if (temp_f2 < 0.0f) { + temp_f0_2 = sqrtf(SQ(sp4C[0]) + SQ(sp4C[1]) + SQ(sp4C[2])); + if ((temp_f0 != 0.0f) && (temp_f0_2 != 0.0f)) { + this->reflectIntensity = -temp_f2 / (temp_f0 * temp_f0_2); + } + } + } + } +} + +// Draws six images, one for each corner of the shield, by finding the intersection of a line segment from the corner +// perpendicular to the shield with the nearest collision (if any). +void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { + s32 i; + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + Vec3f posA; + Vec3f posB; + Vec3f sp70; + CollisionPoly* outPoly; + f32 sp60[3]; + + sp60[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + sp60[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->shieldCorners); i++) { + posA.x = + (shieldMtx->wx + (this->shieldCorners[i].x * shieldMtx->xx)) + (this->shieldCorners[i].y * (*shieldMtx).yx); + posA.y = + (shieldMtx->wy + (this->shieldCorners[i].x * shieldMtx->xy)) + (this->shieldCorners[i].y * (*shieldMtx).yy); + posA.z = + (shieldMtx->wz + (this->shieldCorners[i].x * shieldMtx->xz)) + (this->shieldCorners[i].y * (*shieldMtx).yz); + + posB.x = sp60[0] + posA.x; + posB.y = sp60[1] + posA.y; + posB.z = sp60[2] + posA.z; + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &posA, &posB, &sp70, &outPoly, 1)) { + reflection[i].reflectionPoly = outPoly; + } else { + reflection[i].reflectionPoly = NULL; + } + } +} + +// Remove reflections that are in the same position and are sufficiently near to the same plane +void MirRay_RemoveSimilarReflections(MirRayShieldReflection* reflection) { + s32 i; + s32 j; + + for (i = 0; i < 6; i++) { + for (j = i + 1; j < 6; j++) { + if ((reflection[i].reflectionPoly != NULL) && (reflection[j].reflectionPoly != NULL)) { + if ((ABS(reflection[i].reflectionPoly->normal.x - reflection[j].reflectionPoly->normal.x) < 100) && + (ABS(reflection[i].reflectionPoly->normal.y - reflection[j].reflectionPoly->normal.y) < 100) && + (ABS(reflection[i].reflectionPoly->normal.z - reflection[j].reflectionPoly->normal.z) < 100) && + (reflection[i].reflectionPoly->dist == reflection[j].reflectionPoly->dist)) { + reflection[j].reflectionPoly = NULL; + } + } + } + } +} + +// Creates the reflected beam's collider (to interact with objects) and places and orients the shield images +#ifdef NON_MATCHING +// Beginning block re-ordered +void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 temp_f0; + Vec3f vecB; + Vec3f vecD; + Vec3f sp118; + Vec3f sp10C; + Vec3f sp100; + Vec3f intersection; + f32 spE8[3]; + f32 normalVec[3]; + MtxF* shieldMtx = &player->shieldMf; + Vec3f vecA; + Vec3f vecC; + + spE8[0] = -(shieldMtx->zx * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[1] = -(shieldMtx->zy * this->reflectRange) * this->reflectIntensity * 400.0f; + spE8[2] = -(shieldMtx->zz * this->reflectRange) * this->reflectIntensity * 400.0f; + + vecB.x = shieldMtx->wx; + vecB.y = shieldMtx->wy; + vecB.z = shieldMtx->wz; + + vecD.x = spE8[0] + vecB.x; + vecD.y = spE8[1] + vecB.y; + vecD.z = spE8[2] + vecB.z; + + vecA.x = vecB.x + (shieldMtx->xx * 300.0f); + vecA.y = vecB.y + (shieldMtx->xy * 300.0f); + vecA.z = vecB.z + (shieldMtx->xz * 300.0f); + + vecC.x = vecD.x + (shieldMtx->xx * 300.0f); + vecC.y = vecD.y + (shieldMtx->xy * 300.0f); + vecC.z = vecD.z + (shieldMtx->xz * 300.0f); + + Collider_SetQuadVertices(&this->collider2, &vecA, &vecB, &vecC, &vecD); + + for (i = 0; i < 6; i++) { + if (reflection[i].reflectionPoly != NULL) { + normalVec[0] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.x); + normalVec[1] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.y); + normalVec[2] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.z); + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &vecB, &vecD, &sp118, 1)) { + + reflection[i].pos.x = sp118.x; + reflection[i].pos.y = sp118.y; + reflection[i].pos.z = sp118.z; + + temp_f0 = sqrtf(SQ(sp118.x - vecB.x) + SQ(sp118.y - vecB.y) + SQ(sp118.z - vecB.z)); + + if (temp_f0 < (this->reflectIntensity * 600.0f)) { + reflection[i].opacity = 200; + } else { + reflection[i].opacity = (s32)(800.0f - temp_f0); + } + + reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); + + sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->xy * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->xz * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; + + reflection[i].mtx.xy = reflection[i].mtx.xz = reflection[i].mtx.xw = reflection[i].mtx.yx = + reflection[i].mtx.yz = reflection[i].mtx.yw = reflection[i].mtx.zx = reflection[i].mtx.zy = + reflection[i].mtx.zw = reflection[i].mtx.wx = reflection[i].mtx.wy = reflection[i].mtx.wz = + 0.0f; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.xx = intersection.x - sp118.x; + reflection[i].mtx.xy = intersection.y - sp118.y; + reflection[i].mtx.xz = intersection.z - sp118.z; + } + + sp10C.x = (shieldMtx->yx * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->yz * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.yx = intersection.x - sp118.x; + reflection[i].mtx.yy = intersection.y - sp118.y; + reflection[i].mtx.yz = intersection.z - sp118.z; + } + } else { + reflection[i].reflectionPoly = NULL; + } + } + } +} +#else +void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_ReflectedBeam.s") #endif -extern ColliderQuadInit D_808E3BF4; -extern ColliderJntSphElementInit D_808E3C44[1]; -extern ColliderJntSphInit D_808E3C68; -extern InitChainEntry D_808E3DB8[]; +void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay* this = THIS; + Player* player = GET_PLAYER(globalCtx); + MirRayShieldReflection reflection[6]; + s32 i; -extern UNK_TYPE D_060003F8; + this->reflectIntensity = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/D_808E3DD0.s") + if (!D_808E3BF0 && !this->unLit && func_80124088(globalCtx)) { + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + MirRay_SetIntensity(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2600.s") + if (this->reflectIntensity <= 0.0f) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E26C8.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Init.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Scale(1.0f, 1.0f, this->reflectIntensity, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Destroy.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (u8)(s8)(this->reflectIntensity * 100.0f)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Update.s") + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2C68.s") + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2E1C.s") + MirRay_SetupReflectionPolys(this, globalCtx, reflection); + MirRay_RemoveSimilarReflections(reflection); + MirRay_ReflectedBeam(this, globalCtx, reflection); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E2FF8.s") + if (reflection[0].reflectionPoly == NULL) { + reflection[0].opacity = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E30FC.s") + for (i = 1; i < ARRAY_COUNT(reflection); i++) { + if (reflection[i].reflectionPoly != NULL) { + if (reflection[0].opacity < reflection[i].opacity) { + reflection[0].opacity = reflection[i].opacity; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_Draw.s") + for (i = 0; i < ARRAY_COUNT(reflection); i++) { + if (reflection[i].reflectionPoly != NULL) { + Matrix_InsertTranslation(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + Matrix_InsertMatrix(&reflection[i].mtx, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/func_808E3984.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, reflection[0].opacity); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_0004B0); + } + } + + D_808E3BF0 = true; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +// Computes if the Point (pointx, pointy, pointz) lies within the right conical frustum with one end centred at vecA +// with radius radiusA, the other at vecB with radius radiusB +s32 MirRay_CheckInFrustum(Vec3f* vecA, Vec3f* vecB, f32 pointx, f32 pointy, f32 pointz, s16 radiusA, s16 radiusB) { + f32 coneRadius; + f32 closestPtx; + f32 closestPty; + f32 closestPtz; + Vec3f vecdiff; + f32 dist; + Vec3f sp5C; + Vec3f sp50; + Vec3f sp44; + + vecdiff.x = vecB->x - vecA->x; + vecdiff.y = vecB->y - vecA->y; + vecdiff.z = vecB->z - vecA->z; + if (1) {} + + dist = SQ(vecdiff.x) + SQ(vecdiff.y) + SQ(vecdiff.z); + + if (dist == 0.0f) { + return false; + } + + dist = + (((pointx - vecA->x) * vecdiff.x) + ((pointy - vecA->y) * vecdiff.y) + ((pointz - vecA->z) * vecdiff.z)) / dist; + + // Closest point on line A-B to Point + closestPtx = (vecdiff.x * dist) + vecA->x; + closestPty = (vecdiff.y * dist) + vecA->y; + closestPtz = (vecdiff.z * dist) + vecA->z; + + // Diameter of the double cone on the perpendicular plane through the closest point + coneRadius = ((radiusB - radiusA) * dist) + radiusA; + + // If the Point is within the bounding double cone, check if it is in the frustum by checking whether it is between + // the bounding planes + if ((SQ(closestPtx - pointx) + SQ(closestPty - pointy) + SQ(closestPtz - pointz)) <= SQ(coneRadius)) { + if (1) {} + + // Stores the vector difference again + Math_Vec3f_Diff(vecB, vecA, &sp5C); + + sp50.x = pointx - vecA->x; + sp50.y = pointy - vecA->y; + sp50.z = pointz - vecA->z; + + if (Math3D_Parallel(&sp5C, &sp50) < 0.0f) { + return false; + } + + sp44.x = pointx - vecB->x; + sp44.y = pointy - vecB->y; + sp44.z = pointz - vecB->z; + + if (Math3D_Parallel(&sp5C, &sp44) > 0.0f) { + return false; + } + return true; + } + return false; +} diff --git a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h index c03b48c6b..4d748e3b5 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h @@ -5,9 +5,39 @@ struct MirRay; +#define MIRRAY_LOCATION(thisx) ((thisx)->params) + +// Locations of light beams in sMirRayData +typedef enum { + /* 0 */ MIRRAY_SPIRIT_BOMBCHUIWAROOM_DOWNLIGHT, + /* 1 */ MIRRAY_SPIRIT_SUNBLOCKROOM_DOWNLIGHT, + /* 2 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_DOWNLIGHT, + /* 3 */ MIRRAY_SPIRIT_ARMOSROOM_DOWNLIGHT, + /* 4 */ MIRRAY_SPIRIT_TOPROOM_DOWNLIGHT, + /* 5 */ MIRRAY_SPIRIT_TOPROOM_CEILINGMIRROR, + /* 6 */ MIRRAY_SPIRIT_SINGLECOBRAROOM_COBRA, + /* 7 */ MIRRAY_SPIRIT_TOPROOM_COBRA1, + /* 8 */ MIRRAY_SPIRIT_TOPROOM_COBRA2, + /* 9 */ MIRRAY_GANONSCASTLE_SPIRITTRIAL_DOWNLIGHT, + /* 10 */ MIRRAY_MAX, +} MirRayBeamLocations; + typedef struct MirRay { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x164]; + /* 0x0000 */ Actor actor; + /* 0x0144 */ ColliderJntSph collider1; + /* 0x0164 */ ColliderJntSphElement collider1Elements[1]; + /* 0x01A4 */ ColliderQuad collider2; + /* 0x0224 */ f32 reflectIntensity; // Reflection occurs if it is positive, brightness depends on it + /* 0x0228 */ Vec3f shieldCorners[6]; + /* 0x0270 */ f32 reflectRange; + /* 0x0274 */ Vec3f sourcePt; + /* 0x0280 */ Vec3f poolPt; + /* 0x028C */ s16 sourceEndRad; + /* 0x028E */ s16 poolEndRad; + /* 0x0290 */ s16 lightPointRad; + /* 0x0294 */ LightNode* lightNode; + /* 0x0298 */ LightInfo lightInfo; + /* 0x02A6 */ u8 unLit; // Conditioned on. set in Cobra? } MirRay; // size = 0x2A8 extern const ActorInit Mir_Ray_InitVars; 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 d9eb30b4f..f6e8750cb 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -6,7 +6,7 @@ #include "z_mir_ray2.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay2*)thisx) diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c index d68880f2d..15bef2ca5 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -5,8 +5,9 @@ */ #include "z_mir_ray3.h" +#include "objects/object_mir_ray/object_mir_ray.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((MirRay3*)thisx) @@ -15,7 +16,6 @@ void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx); void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Mir_Ray3_InitVars = { ACTOR_MIR_RAY3, ACTORCAT_ITEMACTION, @@ -28,39 +28,398 @@ const ActorInit Mir_Ray3_InitVars = { (ActorFunc)MirRay3_Draw, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B9F420 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0x00200000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0x00200000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B9F470 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00200000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_OTHER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00200000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 10, 10, 0, { 0, 0, 0 } }, }; +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ MtxF unk_0C; + /* 0x4C */ CollisionPoly* unk_4C; + /* 0x50 */ u8 unk_50; +} MirRay3Struct; // size = 0x54 + +void MirRay3_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + MirRay3* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + Actor_SetScale(&this->actor, 1.0f); + + this->unk_218[0].x = -536.0f; + this->unk_218[0].y = -939.0f; + + this->unk_218[1].x = -1690.0f; + this->unk_218[1].y = 0.0f; + + this->unk_218[2].x = -536.0f; + this->unk_218[2].y = 938.0f; + + this->unk_218[3].x = 921.0f; + this->unk_218[3].y = 0.0f; + + this->unk_218[4].x = 758.0f; + this->unk_218[4].y = 800.0f; + + this->unk_218[5].x = 758.0f; + this->unk_218[5].y = -800.0f; + + Collider_InitQuad(globalCtx, &this->colliderQuad); + Collider_SetQuad(globalCtx, &this->colliderQuad, &this->actor, &sQuadInit); + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + this->actor.world.rot.x = this->actor.shape.rot.x = 0; +} + +void MirRay3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + MirRay3* this = THIS; + + Collider_DestroyQuad(globalCtx, &this->colliderQuad); + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); +} + +void MirRay3_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + Player* player = GET_PLAYER(globalCtx); + + this->unk_210 &= ~1; + + if (this->unk_214 > 0.5f) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->colliderQuad.base); + } + + this->unk_210 &= ~2; + + if (func_8012405C(globalCtx)) { + if (this->colliderCylinder.base.acFlags & AC_HIT) { + this->unk_210 |= 2; + } + this->actor.world.pos.x = player->shieldMf.mf[3][0]; + this->actor.world.pos.y = player->shieldMf.mf[3][1]; + this->actor.world.pos.z = player->shieldMf.mf[3][2]; + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } + + if (this->unk_214 > 0.1f) { + func_800B8F98(&player->actor, NA_SE_IT_SHIELD_BEAM - SFX_FLAG); + } + + Math_ApproachZeroF(&this->unk_214, 1.0f, 0.1f); +} + +void func_80B9E544(MirRay3* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + f32 temp_f0; + + if (this->unk_210 & 2) { + temp_f0 = sqrtf(SQ(shieldMtx->mf[2][0]) + SQ(shieldMtx->mf[2][1]) + SQ(shieldMtx->mf[2][2])); + if (temp_f0 == 0.0f) { + this->unk_260 = 1.0f; + } else { + this->unk_260 = 1.0f / temp_f0; + } + Math_ApproachF(&this->unk_214, 1.0f, 0.5f, 0.25f); + } +} + +void func_80B9E5F4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + MtxF* shieldMtx = &player->shieldMf; + s32 i; + Vec3f sp88; + Vec3f sp7C; + Vec3f sp70; + CollisionPoly* sp6C; + f32 sp60[3]; + + sp60[0] = -(shieldMtx->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + sp60[1] = -(shieldMtx->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + sp60[2] = -(shieldMtx->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + sp88.x = (shieldMtx->mf[3][0] + (this->unk_218[i].x * shieldMtx->mf[0][0])) + + (this->unk_218[i].y * shieldMtx->mf[1][0]); + sp88.y = (shieldMtx->mf[3][1] + (this->unk_218[i].x * shieldMtx->mf[0][1])) + + (this->unk_218[i].y * shieldMtx->mf[1][1]); + sp88.z = (shieldMtx->mf[3][2] + (this->unk_218[i].x * shieldMtx->mf[0][2])) + + (this->unk_218[i].y * shieldMtx->mf[1][2]); + + sp7C.x = sp60[0] + sp88.x; + sp7C.y = sp60[1] + sp88.y; + sp7C.z = sp60[2] + sp88.z; + + if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp88, &sp7C, &sp70, &sp6C, true)) { + ptr[i].unk_4C = sp6C; + } else { + ptr[i].unk_4C = NULL; + } + } +} + +void func_80B9E7D0(MirRay3Struct* ptr) { + s32 i; + s32 j; + + for (i = 0; i < 6; i++) { + for (j = i + 1; j < 6; j++) { + if ((ptr[i].unk_4C != NULL) && (ptr[j].unk_4C != NULL)) { + if ((ABS(ptr[i].unk_4C->normal.x - ptr[j].unk_4C->normal.x) < 100) && + (ABS(ptr[i].unk_4C->normal.y - ptr[j].unk_4C->normal.y) < 100) && + (ABS(ptr[i].unk_4C->normal.z - ptr[j].unk_4C->normal.z) < 100) && + (ptr[i].unk_4C->dist == ptr[j].unk_4C->dist)) { + ptr[j].unk_4C = NULL; + } + } + } + } +} + +#ifdef NON_MATCHING +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + MtxF* shieldMf = &player->shieldMf; + Vec3f sp140; + Vec3f sp134; + Vec3f sp128; + Vec3f sp11C; + Vec3f sp110; + Vec3f sp104; + f32 spF8[3]; + f32 spEC[3]; + f32 temp_f0; + f32 temp_f26; + f32 temp_f2; + Vec3f spD4; + Vec3f spC8; + CollisionPoly* spC4; + + spF8[0] = -(shieldMf->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; + spF8[1] = -(shieldMf->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; + spF8[2] = -(shieldMf->mf[2][2] * this->unk_260) * this->unk_214 * 400.0f; + + sp140.x = shieldMf->mf[3][0]; + sp140.y = shieldMf->mf[3][1]; + sp140.z = shieldMf->mf[3][2]; + + sp134.x = spF8[0] + sp140.x; + sp134.y = spF8[1] + sp140.y; + sp134.z = spF8[2] + sp140.z; + + temp_f26 = this->unk_214 * 400.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_218); i++) { + if (ptr[i].unk_4C != NULL) { + spEC[0] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.x); + spEC[1] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.y); + spEC[2] = COLPOLY_GET_NORMAL(ptr[i].unk_4C->normal.z); + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp140, &sp134, &sp128, true)) { + ptr[i].unk_00.x = sp128.x; + ptr[i].unk_00.y = sp128.y; + ptr[i].unk_00.z = sp128.z; + + temp_f0 = sqrtf(SQ(sp128.x - sp140.x) + SQ(sp128.y - sp140.y) + SQ(sp128.z - sp140.z)); + + if (temp_f0 < (temp_f26 * 0.9f)) { + ptr[i].unk_50 = 0xFF; + } else if (temp_f26 < temp_f0) { + ptr[i].unk_50 = 0; + } else { + ptr[i].unk_50 = (s32)((10.0f - ((10.0f / temp_f26) * temp_f0)) * 255.0f); + } + + sp11C.x = (shieldMf->mf[0][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[0][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[0][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + ptr[i].unk_0C.mf[0][0] = ptr[i].unk_0C.mf[1][1] = ptr[i].unk_0C.mf[2][2] = ptr[i].unk_0C.mf[3][3] = + 1.0f; + + ptr[i].unk_0C.mf[0][1] = ptr[i].unk_0C.mf[0][2] = ptr[i].unk_0C.mf[0][3] = ptr[i].unk_0C.mf[1][0] = + ptr[i].unk_0C.mf[1][2] = ptr[i].unk_0C.mf[1][3] = ptr[i].unk_0C.mf[2][0] = ptr[i].unk_0C.mf[2][1] = + ptr[i].unk_0C.mf[2][3] = ptr[i].unk_0C.mf[3][0] = ptr[i].unk_0C.mf[3][1] = + ptr[i].unk_0C.mf[3][2] = 0.0f; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[0][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[0][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[0][2] = sp104.z - sp128.z; + } + + sp11C.x = (shieldMf->mf[1][0] * 100.0f) + sp140.x; + sp11C.y = (shieldMf->mf[1][1] * 100.0f) + sp140.y; + sp11C.z = (shieldMf->mf[1][2] * 100.0f) + sp140.z; + + sp110.x = (spF8[0] * 4.0f) + sp11C.x; + sp110.y = (spF8[1] * 4.0f) + sp11C.y; + sp110.z = (spF8[2] * 4.0f) + sp11C.z; + + if (Math3D_LineSegVsPlane(spEC[0], spEC[1], spEC[2], ptr[i].unk_4C->dist, &sp11C, &sp110, &sp104, + true)) { + ptr[i].unk_0C.mf[1][0] = sp104.x - sp128.x; + ptr[i].unk_0C.mf[1][1] = sp104.y - sp128.y; + ptr[i].unk_0C.mf[1][2] = sp104.z - sp128.z; + } + } else { + ptr[i].unk_4C = NULL; + } + } + } + + temp_f2 = this->unk_214 * 400.0f; + + spF8[0] = -(this->unk_260 * shieldMf->mf[2][0]); + spF8[1] = -(this->unk_260 * shieldMf->mf[2][1]); + spF8[2] = -(this->unk_260 * shieldMf->mf[2][2]); + + sp134.x = (spF8[0] * temp_f2) + sp140.x; + sp134.y = (spF8[1] * temp_f2) + sp140.y; + sp134.z = (spF8[2] * temp_f2) + sp140.z; + + if (!BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp140, &sp134, &sp128, &spC4, 1)) { + Math_Vec3f_Copy(&sp128, &sp134); + } + + sp128.x += spF8[0] * 5.0f; + sp128.y += spF8[1] * 5.0f; + sp128.z += spF8[2] * 5.0f; + + spD4.x = (shieldMf->mf[0][0] * 300.0f) + sp140.x; + spD4.y = (shieldMf->mf[0][1] * 300.0f) + sp140.y; + spD4.z = (shieldMf->mf[0][2] * 300.0f) + sp140.z; + + spC8.x = (shieldMf->mf[0][0] * 300.0f) + sp128.x; + spC8.y = (shieldMf->mf[0][1] * 300.0f) + sp128.y; + spC8.z = (shieldMf->mf[0][2] * 300.0f) + sp128.z; + + Collider_SetQuadVertices(&this->colliderQuad, &spD4, &sp140, &spC8, &sp128); +} +#else +void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") #endif -extern ColliderQuadInit D_80B9F420; -extern ColliderCylinderInit D_80B9F470; +void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + MirRay3* this = THIS; + MirRay3Struct sp8C[6]; + Player* player = GET_PLAYER(globalCtx); + s32 i; + f32 temp; + u16 phi_a0; -extern UNK_TYPE D_060003F8; + if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { + Matrix_InsertMatrix(&player->shieldMf, MTXMODE_NEW); + func_80B9E544(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Init.s") + if (this->unk_214 <= 0.1f) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Destroy.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Update.s") + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_Scale(1.0f, 1.0f, this->unk_214, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E544.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E5F4.s") + if (MIRRAY3_GET_F(&this->actor) == MIRRAY3_F_1) { + phi_a0 = gSaveContext.save.time; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E7D0.s") + if (phi_a0 > CLOCK_TIME(12, 0)) { + phi_a0 = 0xFFFF - phi_a0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") + temp = (phi_a0 * (1.0f / 0x8000)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/MirRay3_Draw.s") + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, (u8)((100.0f * temp) + 105.0f), 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x78, 255, 255, 255, (u8)(s8)(100 * this->unk_214)); + gDPSetEnvColor(POLY_XLU_DISP++, 218, 225, 205, 255); + } + + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_mir_ray_Matanimheader_0003F8)); + + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_000168); + + func_80B9E5F4(this, globalCtx, sp8C); + func_80B9E7D0(sp8C); + func_80B9E8D4(this, globalCtx, sp8C); + + if (sp8C[0].unk_4C == NULL) { + sp8C[0].unk_50 = 0; + } + + for (i = 1; i < ARRAY_COUNT(sp8C); i++) { + if ((sp8C[i].unk_4C != NULL) && (sp8C[0].unk_50 < sp8C[i].unk_50)) { + sp8C[0].unk_50 = sp8C[i].unk_50; + } + } + + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); + + for (i = 0; i < ARRAY_COUNT(sp8C); i++) { + if (sp8C[i].unk_4C != NULL) { + Matrix_InsertTranslation(sp8C[i].unk_00.x, sp8C[i].unk_00.y, sp8C[i].unk_00.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + Matrix_InsertMatrix(&sp8C[i].unk_0C, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, sp8C[0].unk_50); + gSPDisplayList(POLY_XLU_DISP++, object_mir_ray_DL_0004B0); + } + } + + this->unk_210 |= 1; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} diff --git a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h index 18510673d..7aecd111f 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h @@ -5,9 +5,18 @@ struct MirRay3; +#define MIRRAY3_GET_F(thisx) ((thisx)->params & 0xF) + +#define MIRRAY3_F_1 1 + typedef struct MirRay3 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x120]; + /* 0x144 */ ColliderQuad colliderQuad; + /* 0x1C4 */ ColliderCylinder colliderCylinder; + /* 0x210 */ u16 unk_210; + /* 0x214 */ f32 unk_214; + /* 0x218 */ Vec3f unk_218[6]; + /* 0x260 */ f32 unk_260; } MirRay3; // size = 0x264 extern const ActorInit Mir_Ray3_InitVars; 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 8e168cba8..5237d9021 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -7,7 +7,7 @@ #include "z_obj_aqua.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjAqua*)thisx) @@ -268,7 +268,7 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjAqua* this = THIS; s32 framesTemp; s32 pad; - s16 yaw = func_800DFCDC(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + s16 yaw = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; s32 actionFuncTemp = this->actionFunc == func_80ACBDFC; OPEN_DISPS(globalCtx->state.gfxCtx); 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 d4ae2b79f..998e85d68 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -5,8 +5,9 @@ */ #include "z_obj_armos.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjArmos*)thisx) @@ -15,11 +16,13 @@ void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx); void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_809A54B4(ObjArmos* this); void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx); +void func_809A5610(ObjArmos* this); void func_809A562C(ObjArmos* this, GlobalContext* globalCtx); +void func_809A57D8(ObjArmos* this); void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Armos_InitVars = { ACTOR_OBJ_ARMOS, ACTORCAT_PROP, @@ -32,51 +35,358 @@ const ActorInit Obj_Armos_InitVars = { (ActorFunc)ObjArmos_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A5BC0[] = { - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), +s16 D_809A5BB0[] = { 1, -1, 0, 0 }; +s16 D_809A5BB8[] = { 0, 0, 1, -1 }; + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 120, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 250, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -#endif +s32 func_809A4E00(ObjArmos* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -extern InitChainEntry D_809A5BC0[]; +s32 func_809A4E68(ObjArmos* this) { + s16 temp_v0; -extern UNK_TYPE D_0600033C; + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E00.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4E68.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A4F00.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A500C.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A518C.s") +s32 func_809A4F00(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Init.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Destroy.s") + if (temp_v0 == OBJARMOS_ROT_7_1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54B4.s") + if (temp_v0 == OBJARMOS_ROT_7_2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A54E0.s") + if (temp_v0 == OBJARMOS_ROT_7_3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5610.s") + if (temp_v0 == OBJARMOS_ROT_7_4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A562C.s") + if (temp_v0 == OBJARMOS_ROT_7_5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57D8.s") + if (temp_v0 == OBJARMOS_ROT_7_6) { + if (this->unk_26E != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A57F4.s") + if (this->unk_270 != 0) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Update.s") + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5960.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/func_809A5A3C.s") +s32 func_809A500C(ObjArmos* this, s32 arg1) { + s32 temp_v0 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 temp_v1 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + s32 temp; + s32 temp2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Armos/ObjArmos_Draw.s") + if (temp_v0 == OBJARMOS_ROT_7_0) { + return this->unk_26E < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_1) { + return -temp_v1 < this->unk_26E; + } + + if (temp_v0 == OBJARMOS_ROT_7_2) { + return this->unk_270 < temp_v1; + } + + if (temp_v0 == OBJARMOS_ROT_7_3) { + return -temp_v1 < this->unk_270; + } + + if (temp_v0 == OBJARMOS_ROT_7_4) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + if (temp_v0 == OBJARMOS_ROT_7_5) { + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + if (temp_v0 == OBJARMOS_ROT_7_6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A5BB0[arg1] + this->unk_26E; + return temp <= temp_v1 && -temp_v1 <= temp; + } + + temp2 = D_809A5BB8[arg1] + this->unk_270; + return temp2 <= temp_v1 && -temp_v1 <= temp2; + } + + return false; +} + +void func_809A518C(ObjArmos* this, s32 arg1) { + this->unk_26E += D_809A5BB0[arg1]; + this->unk_270 += D_809A5BB8[arg1]; + + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_25C = &this->dyna.actor.world.pos.x; + this->unk_260 = this->dyna.actor.home.pos.x + (this->unk_26E * 60); + } else { + this->unk_25C = &this->dyna.actor.world.pos.z; + this->unk_260 = this->dyna.actor.home.pos.z + (this->unk_270 * 60); + } + this->unk_264 = arg1; +} + +void ObjArmos_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjArmos* this = THIS; + s32 sp44 = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + s32 sp40 = OBJARMOS_GET_ROTX_F(&this->dyna.actor); + f32 sp3C = Animation_GetLastFrame(&gArmosPushedBackAnim); + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + + this->dyna.actor.home.rot.y = this->dyna.actor.world.rot.x = this->dyna.actor.world.rot.y = + this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.x = this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_am_Colheader_005CF8); + + SkelAnime_Init(globalCtx, &this->skelAnime, &object_am_Skel_005948, &gArmosPushedBackAnim, this->jointTable, + this->morphTable, OBJECT_AM_LIMB_MAX); + + Animation_Change(&this->skelAnime, &gArmosPushedBackAnim, 0.0f, sp3C, sp3C, ANIMMODE_ONCE, 0.0f); + + if (sp40 == 0) { + func_809A57D8(this); + } else if (Flags_GetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor))) { + if (sp44 == OBJARMOS_ROT_7_0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp40 * 60); + func_809A57D8(this); + } else if (sp44 == OBJARMOS_ROT_7_3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp40 * 60); + func_809A57D8(this); + } else { + func_809A54B4(this); + } + } else { + func_809A54B4(this); + } +} + +void ObjArmos_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A54B4(ObjArmos* this) { + this->actionFunc = func_809A54E0; + this->unk_24C = 4; + this->unk_266[1] = 0; + this->unk_266[2] = 0; + this->unk_266[3] = 0; + this->unk_266[0] = 0; +} + +void func_809A54E0(ObjArmos* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A4E68(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_266); i++) { + if (sp20 == i) { + this->unk_266[i]++; + } else if (this->unk_266[i] > 0) { + this->unk_266[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_266[sp20] >= 9) && func_809A4F00(this, sp20) && func_809A500C(this, sp20) && + !func_809A4E00(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A518C(this, sp20); + func_809A5610(this); + } else { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } + } +} + +void func_809A5610(ObjArmos* this) { + this->actionFunc = func_809A562C; + this->unk_24C = 5; +} + +void func_809A562C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + Player* player; + f32 temp2 = this->unk_260 - *this->unk_25C; + s32 temp; + s32 sp20; + + if (Math_StepToF(this->unk_25C, this->unk_260, (Math_SinS(fabsf(temp2) * 546.13336f) * 1.6f) + 1.0f)) { + player = GET_PLAYER(globalCtx); + temp = OBJARMOS_GET_ROTZ_7(&this->dyna.actor); + sp20 = false; + + 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, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A500C(this, this->unk_264)) { + if (func_809A4E00(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJARMOS_GET_7F(&this->dyna.actor)); + sp20 = true; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + + if (!sp20) { + func_809A54B4(this); + } else { + func_809A57D8(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A57D8(ObjArmos* this) { + this->actionFunc = func_809A57F4; + this->unk_24C = 4; +} + +void func_809A57F4(ObjArmos* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjArmos_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjArmos* this = THIS; + s32 sp2C; + + this->actionFunc(this, globalCtx); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_24C != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 20.0f, 30.0f, 0.0f, this->unk_24C); + + if ((this->actionFunc == func_809A54E0) && (this->dyna.actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId) == NULL)) { + this->unk_24C = 0; + } + + this->unk_250.x = (Math_SinS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.x; + this->unk_250.y = this->dyna.actor.world.pos.y + 20.0f; + this->unk_250.z = (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z; + + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->dyna.actor.floorPoly, + &sp2C, &this->dyna.actor, &this->unk_250); + } +} + +void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Vec3f sp28; + + sp28.x = Math_SinS(this->dyna.actor.shape.rot.y); + Matrix_SetStateRotationAndTranslation( + (sp28.x * -9.0f) + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + (Math_CosS(this->dyna.actor.shape.rot.y) * -9.0f) + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(0.014f, 0.014f, 0.014f, MTXMODE_APPLY); + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->dyna.actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { + s32 pad[2]; + MtxF sp48; + + if (this->dyna.actor.floorPoly != NULL) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C448(globalCtx->state.gfxCtx); + + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, COMBINED, 0, 0, 0, + COMBINED); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, 255); + + func_800C0094(this->dyna.actor.floorPoly, this->unk_250.x, this->dyna.actor.floorHeight, this->unk_250.z, + &sp48); + Matrix_SetCurrentState(&sp48); + Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCircleShadowDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjArmos_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjArmos* this = THIS; + + func_809A5960(this, globalCtx); + func_809A5A3C(this, globalCtx); +} 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 cfc360daa..0a03d4915 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.h @@ -2,16 +2,40 @@ #define Z_OBJ_ARMOS_H #include "global.h" +#include "objects/object_am/object_am.h" struct ObjArmos; typedef void (*ObjArmosActionFunc)(struct ObjArmos*, GlobalContext*); +#define OBJARMOS_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJARMOS_GET_ROTZ_7(thisx) ((thisx)->home.rot.z & 7) +#define OBJARMOS_GET_ROTX_F(thisx) ((thisx)->home.rot.x & 0xF) + +enum { + /* 0 */ OBJARMOS_ROT_7_0, + /* 1 */ OBJARMOS_ROT_7_1, + /* 2 */ OBJARMOS_ROT_7_2, + /* 3 */ OBJARMOS_ROT_7_3, + /* 4 */ OBJARMOS_ROT_7_4, + /* 5 */ OBJARMOS_ROT_7_5, + /* 6 */ OBJARMOS_ROT_7_6, +}; + typedef struct ObjArmos { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x104]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ SkelAnime skelAnime; + /* 0x01A0 */ Vec3s jointTable[OBJECT_AM_LIMB_MAX]; + /* 0x01F4 */ Vec3s morphTable[OBJECT_AM_LIMB_MAX]; /* 0x0248 */ ObjArmosActionFunc actionFunc; - /* 0x024C */ char unk_24C[0x28]; + /* 0x024C */ u32 unk_24C; + /* 0x0250 */ Vec3f unk_250; + /* 0x025C */ f32* unk_25C; + /* 0x0260 */ f32 unk_260; + /* 0x0264 */ s16 unk_264; + /* 0x0266 */ s16 unk_266[4]; + /* 0x026E */ s16 unk_26E; + /* 0x0270 */ s16 unk_270; } ObjArmos; // size = 0x274 extern const ActorInit Obj_Armos_InitVars; 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 d61b3f771..a02f7f604 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -147,8 +147,8 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spA0); Math_Vec3f_Diff(&this->dyna.actor.world.pos, &spAC, &sp94); - if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &spA0, &sp94, &sp88, &this->dyna.actor.floorPoly, 1, 1, 1, 1, &spB8, - &this->dyna.actor)) { + if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &spA0, &sp94, &sp88, &this->dyna.actor.floorPoly, true, true, true, + true, &spB8, &this->dyna.actor)) { this->dyna.actor.world.pos.x = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.x) * 1.9f) + sp88.x; this->dyna.actor.world.pos.y = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.y) * 1.9f) + sp88.y; this->dyna.actor.world.pos.z = (COLPOLY_GET_NORMAL(this->dyna.actor.floorPoly->normal.z) * 1.9f) + sp88.z; @@ -234,7 +234,7 @@ 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].y; + temp_f12 = D_80938FF8[this->unk_1DE].z; if (sp34 < (actor->speedXZ * 8.0f)) { temp_f2 = ((temp_f2 - 2.0f) * 0.1f) + 2.0f; temp_f12 *= 0.4f; @@ -303,8 +303,8 @@ void func_809375C8(ObjBean* this, GlobalContext* globalCtx) { void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { static Gfx* D_80939024[] = { - gameplay_keep_DL_0527F0, - gameplay_keep_DL_0528B0, + gKakeraLeafMiddle, + gKakeraLeafTip, }; Vec3f spC4; Vec3f spB8; @@ -346,7 +346,7 @@ void func_809375F4(ObjBean* this, GlobalContext* globalCtx) { phi_v0 = 0x40; } EffectSsKakera_Spawn(globalCtx, &spC4, &spB8, &spC4, phi_s3, phi_v0, 40, 3, 0, temp_s2, 0, 0, - (temp_s2 >> 3) + 40, -1, 1, D_80939024[i & 1]); + (temp_s2 >> 3) + 40, -1, GAMEPLAY_KEEP, D_80939024[i & 1]); } } 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 3b00578a2..dd57b99e4 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -7,7 +7,7 @@ #include "z_obj_bell.h" #include "objects/object_f52_obj/object_f52_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjBell*)thisx) 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 1995aacf9..b4a85a3a0 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -5,6 +5,8 @@ */ #include "z_obj_bigicicle.h" +#include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" +#include "objects/object_bigicicle/object_bigicicle.h" #define FLAGS 0x00000000 @@ -21,7 +23,6 @@ void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx); void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Bigicicle_InitVars = { ACTOR_OBJ_BIGICICLE, ACTORCAT_PROP, @@ -34,51 +35,287 @@ const ActorInit Obj_Bigicicle_InitVars = { (ActorFunc)ObjBigicicle_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE9820 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 23, 68, -40, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AE984C = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 31, 90, -150, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AE9888[] = { +AnimatedMaterial* D_80AE9878 = object_bigicicle_Matanimheader_001678; + +Vec3f D_80AE987C = { 0.0f, -1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(gravity, -2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5600, ICHAIN_STOP), }; -#endif +s32 D_80AE9890 = false; -extern ColliderCylinderInit D_80AE9820; -extern ColliderCylinderInit D_80AE984C; -extern InitChainEntry D_80AE9888[]; +Color_RGBA8 D_80AE9894 = { 250, 250, 250, 255 }; +Color_RGBA8 D_80AE9898 = { 180, 180, 180, 255 }; -extern UNK_TYPE D_060009B0; -extern UNK_TYPE D_060014F0; +Gfx* D_80AE989C[] = { object_bigicicle_DL_001D10, object_bigicicle_DL_002530, object_bigicicle_DL_002C20 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Init.s") +Gfx* D_80AE98A8[] = { + object_bigicicle_DL_000B20, + object_bigicicle_DL_000D60, + object_bigicicle_DL_000F40, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Destroy.s") +void ObjBigicicle_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + f32 sp30; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8DE4.s") + Actor_ProcessInitChain(&this->actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE8FD4.s") + sp28 = OBJBIGICLE_GET_FF00(&this->actor); + if ((sp28 == 0) || (sp28 == 0xFF)) { + sp28 = 0x3C; + } + Actor_SetScale(&this->actor, sp28 * 0.001f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9090.s") + this->actor.params &= 0xFF; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + sp30 = sp28 * (1.0f / 60.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9180.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); + this->collider1.dim.radius = this->collider1.dim.radius * sp30; + this->collider1.dim.height = this->collider1.dim.height * sp30; + this->collider1.dim.yShift = this->collider1.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE9258.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); + this->collider2.dim.radius = this->collider2.dim.radius * sp30; + this->collider2.dim.height = this->collider2.dim.height * sp30; + this->collider2.dim.yShift = this->collider2.dim.yShift * sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/func_80AE939C.s") + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Update.s") + this->unk_148 = this->actor.shape.rot.x; + this->actor.shape.rot.x = 0x4000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bigicicle/ObjBigicicle_Draw.s") + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + + if (!D_80AE9890) { + D_80AE9878 = Lib_SegmentedToVirtual(D_80AE9878); + D_80AE9890 = true; + } + + this->unk_149 = 0; + this->actionFunc = func_80AE8FD4; +} + +void ObjBigicicle_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider1); + Collider_DestroyCylinder(globalCtx, &this->collider2); +} + +void func_80AE8DE4(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 10; i++) { + sp98.x = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.x; + sp98.y = ((Rand_ZeroFloat(20.0f) - 35.0f) * temp_f20) + this->actor.world.pos.y; + sp98.z = (randPlusMinusPoint5Scaled(4.0f) * temp_f20) + this->actor.world.pos.z; + + sp8C.x = randPlusMinusPoint5Scaled(13.0f); + sp8C.y = Rand_ZeroFloat(2.0f); + sp8C.z = randPlusMinusPoint5Scaled(13.0f); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(20.0f) + 30.0f) * temp_f20, + OBJECT_BIGICICLE, 0x28, object_bigicicle_DL_0009B0); + } + + sp98.x = this->actor.world.pos.x; + sp98.y = this->actor.world.pos.y - (25.0f * temp_f20); + sp98.z = this->actor.world.pos.z; + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &sp98, 40, NA_SE_EV_ICE_PIECE); +} + +void func_80AE8FD4(ObjBigicicle* this, GlobalContext* globalCtx) { + 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); + this->actionFunc = func_80AE9090; + return; + } + + func_80AE8DE4(this, globalCtx); + this->unk_149++; + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } +} + +void func_80AE9090(ObjBigicicle* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->unk_149++; + func_80AE8DE4(this, globalCtx); + if (this->unk_149 == 2) { + f32 temp_f0 = this->actor.scale.y * 2100.0f; + + this->actor.flags |= ACTOR_FLAG_10; + this->actor.shape.yOffset = 2100.0f; + this->actor.world.pos.y -= temp_f0; + this->collider1.dim.yShift += (s16)temp_f0; + this->collider2.dim.yShift += (s16)temp_f0; + this->actionFunc = func_80AE9258; + } else { + this->unk_14A = 50; + this->actionFunc = func_80AE9180; + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80AE9180(ObjBigicicle* this, GlobalContext* globalCtx) { + this->unk_14A--; + + if (this->unk_14A > 0) { + this->unk_14A--; + this->actor.shape.rot.x = BINANG_ADD((s32)(randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A), 0x4000); + this->actor.shape.rot.z = randPlusMinusPoint5Scaled(1408.0f) * 0.02f * this->unk_14A; + } else { + this->actor.shape.rot.x = 0x4000; + this->actor.shape.rot.z = 0; + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80AE8FD4; + } +} + +void func_80AE9258(ObjBigicicle* this, GlobalContext* globalCtx) { + Actor* itemAction; + f32 temp_f0; + ObjIcePoly* icePoly; + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (itemAction->id == ACTOR_OBJ_ICE_POLY) { + 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)) { + Flags_SetSwitch(globalCtx, this->actor.params); + this->actionFunc = func_80AE939C; + return; + } + } + itemAction = itemAction->next; + } + + if (this->actor.bgCheckFlags & 1) { + this->actionFunc = func_80AE939C; + } else { + Collider_UpdateCylinder(&this->actor, &this->collider1); + Collider_UpdateCylinder(&this->actor, &this->collider2); + } +} + +void func_80AE939C(ObjBigicicle* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + f32 temp_f20 = this->actor.scale.x * (50.0f / 3.0f); + + for (i = 0; i < 20; i++) { + sp8C.x = randPlusMinusPoint5Scaled(15.0f); + sp8C.y = Rand_ZeroFloat(7.0f) + 3.0f; + sp8C.z = randPlusMinusPoint5Scaled(15.0f); + + sp98.x = this->actor.world.pos.x + (sp8C.x * 5.0f * temp_f20); + sp98.y = this->actor.world.pos.y + (sp8C.y * 7.0f * temp_f20); + sp98.z = this->actor.world.pos.z + (sp8C.z * 5.0f * temp_f20); + + EffectSsHahen_Spawn(globalCtx, &sp98, &sp8C, &D_80AE987C, 2, (Rand_ZeroFloat(30.0f) + 40.0f) * temp_f20, + OBJECT_BIGICICLE, 30, object_bigicicle_DL_0009B0); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_GLASSBROKEN_IMPACT); + ActorCutscene_Stop(this->actor.cutscene); + Actor_MarkForDeath(&this->actor); +} + +void ObjBigicicle_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBigicicle* this = THIS; + Vec3f sp44; + + this->actionFunc(this, globalCtx); + + if (Rand_ZeroOne() < 0.05f) { + sp44.x = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.x) + + this->actor.world.pos.x; + sp44.y = ((((Rand_ZeroFloat(1400.0f) + -150.0f) - 2100.0f) + this->actor.shape.yOffset) * this->actor.scale.y) + + this->actor.world.pos.y; + sp44.z = (((215.0f + Rand_ZeroFloat(65.0f)) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)) * this->actor.scale.z) + + this->actor.world.pos.z; + + EffectSsKiraKira_SpawnDispersed(globalCtx, &sp44, &gZeroVec3f, &gZeroVec3f, &D_80AE9894, &D_80AE9898, 2000, 5); + } + + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); +} + +void ObjBigicicle_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjBigicicle* this = THIS; + + Gfx_DrawDListXlu(globalCtx, D_80AE989C[this->unk_149]); + Gfx_DrawDListXlu(globalCtx, D_80AE98A8[this->unk_149]); + AnimatedMat_Draw(globalCtx, D_80AE9878); + Gfx_DrawDListXlu(globalCtx, object_bigicicle_DL_0014F0); +} diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h index 5c3235ef2..1744a81b4 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h @@ -7,10 +7,16 @@ struct ObjBigicicle; typedef void (*ObjBigicicleActionFunc)(struct ObjBigicicle*, GlobalContext*); +#define OBJBIGICLE_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF) + typedef struct ObjBigicicle { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjBigicicleActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ u8 unk_148; + /* 0x0149 */ u8 unk_149; + /* 0x014A */ s16 unk_14A; + /* 0x014C */ ColliderCylinder collider1; + /* 0x0198 */ ColliderCylinder collider2; } ObjBigicicle; // size = 0x1E4 extern const ActorInit Obj_Bigicicle_InitVars; 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 176f961be..0d937d1c0 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -6,7 +6,7 @@ #include "z_obj_blockstop.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBlockstop*)thisx) 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 341dc5c56..880d72b3f 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -6,7 +6,7 @@ #include "z_obj_boat.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBoat*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c index 0b91f6f5f..8a09c6f01 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -5,6 +5,7 @@ */ #include "z_obj_bombiwa.h" +#include "objects/object_bombiwa/object_bombiwa.h" #define FLAGS 0x00000000 @@ -14,10 +15,15 @@ void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx); +s32 func_809393B0(Actor* thisx); +s32 func_80939470(Actor* thisx); +void func_80939EE0(ObjBombiwa* this); void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx); +void func_8093A080(ObjBombiwa* this); void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx); +void func_8093A418(Actor* thisx, GlobalContext* globalCtx); +void func_8093A608(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Bombiwa_InitVars = { ACTOR_OBJ_BOMBIWA, ACTORCAT_PROP, @@ -30,70 +36,495 @@ const ActorInit Obj_Bombiwa_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8093A940 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37FBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit1 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37FBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 55, 70, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8093A96C = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37BBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit2 = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37BBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 75, 130, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_8093A9B8 = { 0, 12, 60, MASS_IMMOVABLE }; +typedef struct { + /* 0x00 */ ColliderCylinderInit* collider; + /* 0x04 */ ActorShadowFunc unk_04; + /* 0x08 */ ActorFunc unk_08; + /* 0x0C */ s32 (*unk_0C)(Actor*); +} ObjBombiwaStruct2; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093A9C0[] = { +static ObjBombiwaStruct2 D_8093A998[] = { + { &sCylinderInit1, ActorShadow_DrawCircle, func_8093A418, func_809393B0 }, + { &sCylinderInit2, NULL, func_8093A608, func_80939470 }, +}; + +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +static s16 D_8093A9D0[] = { + 17, 14, 10, 8, 7, 5, 3, 2, +}; -extern ColliderCylinderInit D_8093A940; -extern ColliderCylinderInit D_8093A96C; -extern CollisionCheckInfoInit D_8093A9B8; -extern InitChainEntry D_8093A9C0[]; +static s16 D_8093A9E0[] = { + 16, 12, 8, 6, 5, 4, 3, 2, +}; -extern UNK_TYPE D_060009E0; -extern UNK_TYPE D_06004560; -extern UNK_TYPE D_06005990; +s32 func_809393B0(Actor* thisx) { + ObjBombiwa* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_809393B0.s") + if (this->collider.base.acFlags & AC_HIT) { + Actor* ac = this->collider.base.ac; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939470.s") + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + if ((ac != NULL) && (Math3D_Vec3fDistSq(&this->actor.world.pos, &ac->world.pos) < SQ(150.0f))) { + return true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 8) { + if ((ac != NULL) && (Math3D_Vec3fDistSq(&this->actor.world.pos, &ac->world.pos) < SQ(95.0f))) { + return true; + } + } else if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x500) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093951C.s") +s32 func_80939470(Actor* thisx) { + ObjBombiwa* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939594.s") + if (this->collider.base.acFlags & AC_HIT) { + Actor* temp_v0 = this->collider.base.ac; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Init.s") + if (temp_v0 != NULL) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + if (Math3D_Vec3fDistSq(&this->actor.world.pos, &temp_v0->world.pos) < SQ(175.0f)) { + return true; + } + } else if ((this->collider.info.acHitInfo->toucher.dmgFlags & 8) && + (Math3D_Vec3fDistSq(&this->actor.world.pos, &temp_v0->world.pos) < SQ(115.0f))) { + return true; + } + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Destroy.s") +s32 func_8093951C(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939794.s") + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939994.s") +void func_80939594(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939C50.s") + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 30.0f; + sp28.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939EE0.s") + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_80939EF4.s") +void ObjBombiwa_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjBombiwa* this = THIS; + s32 sp34 = OBJBOMBIWA_GET_100(&this->actor); + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A080.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A1F0.s") + if (Flags_GetSwitch(globalCtx, OBJBOMBIWA_GET_7F(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/ObjBombiwa_Update.s") + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, D_8093A998[sp34].collider); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A418.s") + if (sp34 == OBJBOMBIWA_100_0) { + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = this->actor.world.rot.y = (u32)Rand_Next() >> 0x10; + } + func_80939594(this, globalCtx); + } + ActorShape_Init(&this->actor.shape, -200.0f, D_8093A998[sp34].unk_04, 9.8f); + this->actor.world.pos.y = this->actor.home.pos.y + 20.0f; + this->actor.draw = D_8093A998[sp34].unk_08; + if (func_8093951C(this, globalCtx)) { + this->unk_203 |= 1; + } + func_80939EE0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Bombiwa/func_8093A608.s") +void ObjBombiwa_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void func_80939794(ObjBombiwa* this, GlobalContext* globalCtx) { + Vec3f spB4; + Vec3f spA8; + s32 phi_v1; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_8093A9D0); i++) { + spB4.x = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.x; + spB4.y = (Rand_ZeroOne() * 5.0f) + this->actor.home.pos.y + 8.0f; + spB4.z = ((Rand_ZeroOne() - 0.5f) * 10.0f) + this->actor.home.pos.z; + + spA8.x = (Rand_ZeroOne() - 0.5f) * 15.0f; + spA8.y = (Rand_ZeroOne() * 16.0f) + 5.0f; + spA8.z = (Rand_ZeroOne() - 0.5f) * 15.0f; + + if (D_8093A9D0[i] > 10) { + phi_v1 = 0x25; + } else { + phi_v1 = 0x21; + } + EffectSsKakera_Spawn(globalCtx, &spB4, &spA8, &spB4, -400, phi_v1, 10, 2, 0, D_8093A9D0[i], 1, 0, 60, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_0009E0); + } + + func_800BBFB0(globalCtx, &this->actor.world.pos, 60.0f, 8, 80, 140, 1); +} + +void func_80939994(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spAC; + Vec3f spA0; + s16 phi_v0; + s16 life; + s32 i; + + for (i = 0; i < 16; i++) { + spAC.x = (Rand_ZeroOne() - 0.5f) * 80.0f; + spAC.y = Rand_ZeroOne() * 120.0f; + spAC.z = (Rand_ZeroOne() - 0.5f) * 80.0f; + + spA0.x = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spAC.x * 0.2f); + spA0.y = (Rand_ZeroOne() * 16.0f) + 5.0f; + spA0.z = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spAC.z * 0.2f); + + spAC.x += arg1->x; + spAC.y += arg1->y; + spAC.z += arg1->z; + + if (i >= 14) { + phi_v0 = 33; + life = 60; + } else if (i >= 12) { + phi_v0 = 65; + life = 60; + } else { + life = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + EffectSsKakera_Spawn(globalCtx, &spAC, &spA0, &spAC, -450, phi_v0, 15, 0, 0, i, 1, 0, life, -1, OBJECT_BOMBIWA, + object_bombiwa_DL_005990); + } + + func_800BBFB0(globalCtx, arg1, 120.0f, 3, 80, 140, 1); + + spAC.x = arg1->x; + spAC.y = arg1->y + 70.0f; + spAC.z = arg1->z; + + func_800BBFB0(globalCtx, &spAC, 120.0f, 3, 80, 140, 1); +} + +void func_80939C50(GlobalContext* globalCtx, Vec3f* arg1) { + Vec3f spBC; + Vec3f spB0; + s32 phi_v0; + s32 phi_s0; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_8093A9E0); i++) { + spBC.x = (Rand_ZeroOne() - 0.5f) * 15.0f; + spBC.y = (Rand_ZeroOne() - 0.2f) * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 15.0f; + + spB0.x = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spBC.x * 0.85f); + spB0.y = (Rand_ZeroOne() * 15.0f) + 8.0f; + spB0.z = ((Rand_ZeroOne() - 0.5f) * 3.0f) + (spBC.z * 0.85f); + + spBC.x += arg1->x; + spBC.y += arg1->y; + spBC.z += arg1->z; + + if (i == 0) { + phi_v0 = 33; + phi_s0 = 60; + } else if (i == 1) { + phi_v0 = 65; + phi_s0 = 60; + } else { + phi_s0 = 40; + if (Rand_ZeroOne() < 0.7f) { + phi_v0 = 64; + } else { + phi_v0 = 32; + } + } + EffectSsKakera_Spawn(globalCtx, &spBC, &spB0, &spBC, -450, phi_v0, 15, 0, 0, D_8093A9E0[i], 1, 0, phi_s0, -1, + OBJECT_BOMBIWA, object_bombiwa_DL_005990); + } + + func_800BBFB0(globalCtx, arg1, 60.0f, 4, 80, 140, 1); +} + +void func_80939EE0(ObjBombiwa* this) { + this->actionFunc = func_80939EF4; +} + +void func_80939EF4(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 params = OBJBOMBIWA_GET_100(&this->actor); + ObjBombiwaStruct2* sp28 = &D_8093A998[params]; + + if (this->collider.base.acFlags & AC_HIT) { + this->unk_202 = 5; + } + + if (sp28->unk_0C(&this->actor)) { + Flags_SetSwitch(globalCtx, OBJBOMBIWA_GET_7F(&this->actor)); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 80, NA_SE_EV_WALL_BROKEN); + if (OBJBOMBIWA_GET_8000(&this->actor)) { + play_sound(NA_SE_SY_CORRECT_CHIME); + } + + if (params == OBJBOMBIWA_100_0) { + func_80939794(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + func_80939994(globalCtx, &this->actor.world.pos); + this->actor.flags |= ACTOR_FLAG_10; + func_8093A080(this); + } + } else { + this->collider.base.acFlags &= ~AC_HIT; + + if (this->actor.xzDistToPlayer < 1400.0f) { + if (this->unk_202 > 0) { + this->unk_202--; + if (this->unk_202 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void func_8093A080(ObjBombiwa* this) { + ObjBombiwaStruct* ptr; + s16 phi_s2; + s32 i; + + for (i = 0, phi_s2 = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { + ptr = &this->unk_190[i]; + + ptr->unk_00 = (Rand_ZeroOne() * 0.1f) + 0.05f; + + ptr->unk_04.x = (Math_SinS(phi_s2) * 50.0f) + this->actor.world.pos.x; + ptr->unk_04.y = ((i + 1) * 31.0f) + this->actor.world.pos.y; + ptr->unk_04.z = (Math_CosS(phi_s2) * 50.0f) + this->actor.world.pos.z; + + ptr->unk_10 = i + 3.0f; + ptr->unk_14.x = phi_s2; + ptr->unk_14.y = (u32)Rand_Next() >> 0x10; + ptr->unk_14.z = 0; + ptr->unk_1A = 0; + } + + this->unk_200 = 0; + this->unk_201 = 80; + this->actionFunc = func_8093A1F0; +} + +void func_8093A1F0(ObjBombiwa* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f sp9C; + ObjBombiwaStruct* ptr; + CollisionPoly* sp94; + s32 sp90; + f32 temp_f0; + s16 phi_s1; + + for (i = 0, phi_s1 = 0; i < ARRAY_COUNT(this->unk_190); i++, phi_s1 += 0x4000) { + ptr = &this->unk_190[i]; + + if (ptr->unk_1A != 0) { + continue; + } + + ptr->unk_10 -= 3.0f; + + ptr->unk_04.x += Math_SinS(phi_s1) * 1.5f; + ptr->unk_04.y += ptr->unk_10; + ptr->unk_04.z += Math_CosS(phi_s1) * 1.5f; + + ptr->unk_14.x += 0x5DC; + + sp9C.x = ptr->unk_04.x; + sp9C.y = ptr->unk_04.y + 30.0f; + sp9C.z = ptr->unk_04.z; + + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp94, &sp90, &this->actor, &sp9C); + if ((temp_f0 <= (BGCHECK_Y_MIN + 10.0f)) || ((ptr->unk_04.y - (200.0f * ptr->unk_00)) < temp_f0)) { + this->unk_200++; + ptr->unk_1A = 1; + func_80939C50(globalCtx, &ptr->unk_04); + } + } + + this->unk_201--; + if ((this->unk_200 >= 4) || (this->unk_201 <= 0)) { + Actor_MarkForDeath(&this->actor); + } +} + +void ObjBombiwa_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjBombiwa* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void func_8093A418(Actor* thisx, GlobalContext* globalCtx) { + ObjBombiwa* this = THIS; + f32 sp28; + + if ((this->actor.projectedPos.z <= 2200.0f) || ((this->unk_203 & 1) && (this->actor.projectedPos.z < 2300.0f))) { + this->actor.shape.shadowAlpha = 160; + Gfx_DrawDListOpa(globalCtx, object_bombiwa_DL_0009E0); + return; + } + + if (this->actor.projectedPos.z < 2300.0f) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp28 = (2300.0f - this->actor.projectedPos.z) * 2.55f; + + this->actor.shape.shadowAlpha = sp28 * (32.0f / 51); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s32)sp28); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_000AF0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + this->actor.shape.shadowAlpha = 0; + } +} + +void func_8093A608(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[8]; + ObjBombiwa* this = THIS; + f32 sp38; + s32 i; + ObjBombiwaStruct* ptr; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if (this->actionFunc == func_80939EF4) { + if ((this->actor.projectedPos.z <= 2200.0f) || + ((this->unk_203 & 1) && (this->actor.projectedPos.z < 2300.0f))) { + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x9B, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_004560); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_004688); + } else if (this->actor.projectedPos.z < 2300.0f) { + sp38 = (2300.0f - this->actor.projectedPos.z) * 2.55f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, (s32)sp38); + gSPDisplayList(POLY_XLU_DISP++, object_bombiwa_DL_004560); + } + } else { + func_8012C28C(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_190); i++) { + ptr = &this->unk_190[i]; + + if (ptr->unk_1A == 0) { + Matrix_SetStateRotationAndTranslation(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, &ptr->unk_14); + Matrix_Scale(ptr->unk_00, ptr->unk_00, ptr->unk_00, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bombiwa_DL_005990); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h index 36fafc7e6..54d4024e9 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.h @@ -7,9 +7,28 @@ struct ObjBombiwa; typedef void (*ObjBombiwaActionFunc)(struct ObjBombiwa*, GlobalContext*); +#define OBJBOMBIWA_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJBOMBIWA_GET_100(thisx) (((thisx)->params >> 8) & 1) +#define OBJBOMBIWA_GET_8000(thisx) (((thisx)->params >> 0xF) & 1) + +#define OBJBOMBIWA_100_0 0 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ f32 unk_10; + /* 0x14 */ Vec3s unk_14; + /* 0x1A */ s16 unk_1A; +} ObjBombiwaStruct; // size = 0x1C + typedef struct ObjBombiwa { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xC0]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ ObjBombiwaStruct unk_190[4]; + /* 0x0200 */ s8 unk_200; + /* 0x0201 */ s8 unk_201; + /* 0x0202 */ s8 unk_202; + /* 0x0203 */ u8 unk_203; /* 0x0204 */ ObjBombiwaActionFunc actionFunc; } ObjBombiwa; // size = 0x208 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 c4af83d59..b8da1a9f6 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_boyo/object_boyo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjBoyo*)thisx) 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 4dd0a78b1..8a822bea4 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -2,23 +2,32 @@ * File: z_obj_chan.c * Overlay: ovl_Obj_Chan * Description: Goron Shrine chandelier + * + * This actor class is used for both the chandelier and its sub-components. + * The distinction is made using the subtype actor parameter: + * - 0 for the chandelier itself + * - 1 for one of the 5 breakable pots that are attached to the chandelier */ #include "z_obj_chan.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_obj_chan/object_obj_chan.h" +#include "objects/object_tsubo/object_tsubo.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjChan*)thisx) +#define OBJCHAN_ROTATION_SPEED 364 // == (65536 * 2/360) i.e. 2 degrees per second + void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx); void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB9F24(ObjChan* this, GlobalContext* globalCtx); -void func_80BBA314(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_ChandelierAction(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Chan_InitVars = { ACTOR_OBJ_CHAN, ACTORCAT_BG, @@ -31,49 +40,399 @@ const ActorInit Obj_Chan_InitVars = { (ActorFunc)ObjChan_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BBAB30 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sObjChanCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 48, 76, -60, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BBAB5C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx); +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx); +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx); +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx); -extern ColliderCylinderInit D_80BBAB30; -extern InitChainEntry D_80BBAB5C[]; +static Vec3f sObjChanFlameSize[2] = { + { 0.16f, 0.11f, 1.0f }, + { 0.13f, 0.09f, 1.0f }, +}; +static f32 sObjChanFlameYOffset[2] = { 1800, 1800 }; +static s32 sObjChanLoaded; -extern UNK_TYPE D_06000AF0; -extern UNK_TYPE D_06001960; -extern UNK_TYPE D_06002358; +void ObjChan_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Init.s") + if (OBJCHAN_SUBTYPE(&this->actor) == OBJCHAN_SUBTYPE_CHANDELIER) { + if (sObjChanLoaded) { + Actor_MarkForDeath(&this->actor); + return; + } + this->actor.room = -1; + sObjChanLoaded = true; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sObjChanCylinderInit); + SubS_FillCutscenesList(&this->actor, this->cutscenes, ARRAY_COUNT(this->cutscenes)); + switch (OBJCHAN_SUBTYPE(&this->actor)) { + case OBJCHAN_SUBTYPE_CHANDELIER: + this->rotation = this->actor.shape.rot.y; + this->actor.shape.rot.y = 0; + ObjChan_InitChandelier(this, globalCtx); + break; + case OBJCHAN_SUBTYPE_POT: + this->actor.draw = ObjChan_DrawPot; + ObjChan_InitPot(this, globalCtx); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Destroy.s") +void ObjChan_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9A1C.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9B40.s") +u32 func_80BB9A1C(ObjChan* this, f32 arg1) { + f32 temp_f6; + f32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9C08.s") + sp20 = Math_SinS(this->unk1D4) * this->unk1D0; + temp_f6 = (Math_CosS(this->unk1D4) * 0.03834952f * this->unk1D0) + arg1; + if (temp_f6 != 0.0f) { + this->unk1D4 = RADF_TO_BINANG(func_80086B30(sp20 * 0.03834952f, 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)); + } else { + this->unk1D0 = sp20; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BB9F24.s") +void ObjChan_CalculatePotPosition(Vec3f* childPosOut, Vec3s* childRotOut, Vec3f* parentPos, Vec3s* parentRot, + s16 childAngle) { + Vec3f offset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA2FC.s") + Matrix_RotateY(parentRot->y, MTXMODE_NEW); + Matrix_InsertXRotation_s(parentRot->x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(parentRot->z, MTXMODE_APPLY); + Matrix_RotateY(childAngle, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledX(-280.0f, &offset); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA314.s") + childPosOut->x = parentPos->x + offset.x; + childPosOut->y = parentPos->y + offset.y; + childPosOut->z = parentPos->z + offset.z; + Math_Vec3s_Copy(childRotOut, parentRot); + childRotOut->y += childAngle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA488.s") +//! @TODO: Possibly takes actor and recasts +void ObjChan_InitChandelier(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; + s32 i; + ObjChan* temp_v0; + Vec3f childPos; + Vec3s childRot; + CollisionPoly* sp94; + s32 sp90; + Vec3f sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Update.s") + Math_Vec3f_Copy(&this->unk1C0, &this->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/ObjChan_Draw.s") + Math_Vec3f_Copy(&sp84, &this->actor.world.pos); + sp84.y += 1600.0f; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.world.pos, &sp84, &this->unk1C0, &sp94, false, false, + true, true, &sp90)) { + this->unk1CC = this->actor.world.pos.y - this->unk1C0.y; + } else { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA894.s") + 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( + &globalCtx->actorCtx, globalCtx, 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); + if (temp_v0 != NULL) { + this->pots[i] = temp_v0; + temp_v0->myPotIndex = i; + temp_v0->actor.cutscene = this->actor.cutscene; + } else { + Actor_MarkForDeath(&this->actor); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Chan/func_80BBA930.s") + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + + this->rotationSpeed = OBJCHAN_ROTATION_SPEED; + this->flameSize = 1.0f; + + for (i = 0; i < 5; i++) { + if (this->pots[i] != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->pots[i]->flameSize = 1.0f; + } + } + } + this->collider.dim.radius = 45; + this->collider.dim.height = 60; + this->collider.dim.yShift = -20; + this->actionFunc = ObjChan_ChandelierAction; +} + +//! @TODO: More descriptive name than Action? +void ObjChan_ChandelierAction(ObjChan* this2, GlobalContext* globalCtx) { + ObjChan* this = this2; + ObjChan* temp; + s32 i; + Vec3f sp60; + Vec3s sp58; + + if (this->unk1D0 > 0.0f) { + this->unk1D4 += 0x190; + if (this->unk1D0 <= 400.0f) { + this->unk1D0 = this->unk1D0 * 0.99f; + } else { + this->unk1D0 = this->unk1D0 - 1.0f; + } + if (this->unk1D0 < 0.0f) { + this->unk1D4 = 0; + this->unk1D0 = 0.0f; + } + } + 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, 0)) { + 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]); + } + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_RotateY(this->rotation, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledY(this->unk1CC, &this->actor.world.pos); + Math_Vec3f_Sum(&this->actor.world.pos, &this->unk1C0, &this->actor.world.pos); + Collider_UpdateCylinder(&this->actor, &this->collider); + for (i = 0; i < 5; i++) { + 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); + 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; + Math_Vec3f_ToVec3s(&temp->collider.dim.pos, &temp->actor.world.pos); + } + } + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) { + Flags_SetSwitch(globalCtx, this->actor.params & 0x7F); + } + if (Flags_GetSwitch(globalCtx, this->actor.params & 0x7F)) { + if (!(this->stateFlags & OBJCHAN_STATE_FIRE_DELAY)) { + this->rotationSpeed = 0; + this->flameSize = 0.0f; + for (i = 0; i < 5; i++) { + temp = this->pots[i]; + if (temp != NULL) { + this->pots[i]->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->pots[i]->fireDelayFrames = 20 + i * 5; + this->pots[i]->flameSize = 0.0f; + } + } + this->stateFlags |= OBJCHAN_STATE_FIRE_DELAY; + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + this->stateFlags |= OBJCHAN_STATE_START_CUTSCENE; + } else { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + this->rotation += this->rotationSpeed; + Math_StepToS(&this->rotationSpeed, OBJCHAN_ROTATION_SPEED, 5); + func_800B9010(&this->actor, NA_SE_EV_CHANDELIER_ROLL - SFX_FLAG); + } + } +} + +void ObjChan_InitPot(ObjChan* this, GlobalContext* globalCtx) { + this->actionFunc = ObjChan_PotAction; +} + +void ObjChan_PotAction(ObjChan* this, GlobalContext* globalCtx) { + s32 potBreaks; + s16 temp_v0_2; + s32 phi_v1; + + potBreaks = false; + if ((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x4004000)) { + potBreaks = true; + } + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + Math_StepToF(&this->flameSize, 1.0f, 0.05f); + } else if (this->stateFlags & OBJCHAN_STATE_FIRE_DELAY) { + this->fireDelayFrames--; + if (this->fireDelayFrames <= 0) { + this->stateFlags |= OBJCHAN_STATE_ON_FIRE; + } + } + if (potBreaks) { + ObjChan_CreateSmashParticles(this, globalCtx); + ((ObjChan*)this->actor.parent)->pots[this->myPotIndex] = NULL; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_CHANDELIER_BROKEN); + func_80BB9A1C((ObjChan*)this->actor.parent, 40.0f); + if (this->myPotIndex == 4) { + temp_v0_2 = gSaveContext.save.weekEventReg[0x25]; + if (!(temp_v0_2 & 0x10)) { + gSaveContext.save.weekEventReg[0x25] = temp_v0_2 | 0x10; + Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, 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); + } + } + Actor_MarkForDeath(&this->actor); + } +} + +void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { + s16 new_var = 0; + s32 phi_s0; + Vec3f spDC; + Vec3f spD0; + f32 temp_f0; + f32 new_var2; + s16 temp_s1 = 0; + s32 temp_s2; + f32 spAC; + f32 spA8 = new_var + 15.0f; + f32 spA4 = new_var + (spAC = 110.0f); + + for (temp_s2 = 0, temp_s1 = 0; temp_s2 != 18; temp_s2++, temp_s1 += 0x4E20) { + f32 sin = Math_SinS(temp_s1); + f32 cos = Math_CosS(temp_s1); + spDC.x = sin * 8.0f; + spDC.y = Rand_ZeroOne() * 12.0f + 2.0f; + spDC.z = cos * 8.0f; + spD0.x = spDC.x * 0.23f; + spD0.y = Rand_ZeroOne() * 5.0f + 2.5f; + spD0.z = spDC.z * 0.23f; + temp_f0 = Rand_ZeroOne(); + if (temp_f0 < 0.2f) { + phi_s0 = 0x60; + } else if (temp_f0 < 0.6f) { + phi_s0 = 0x40; + } else { + phi_s0 = 0x20; + } + new_var2 = spA4 * Rand_ZeroOne(); + EffectSsKakera_Spawn(globalCtx, &spDC, &spD0, &this->actor.world.pos, -260, phi_s0, 20, 0, 0, spA8 + new_var2, + 0, 0, 50, -1, OBJECT_TSUBO, object_tsubo_DL_001960); + } + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 20, 50, true); + func_800BBFB0(globalCtx, &this->actor.world.pos, 30.0f, 2, 10, 80, true); +} + +void ObjChan_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + + this->actionFunc(this, globalCtx); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjChan_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjChan* this = THIS; + Gfx* opa; + Gfx* xlu; + + OPEN_DISPS(globalCtx->state.gfxCtx); + Matrix_RotateY(this->rotation, MTXMODE_APPLY); + + opa = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&opa[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&opa[1], object_obj_chan_DL_000AF0); + POLY_OPA_DISP = &opa[2]; + + xlu = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&xlu[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&xlu[1], object_obj_chan_DL_000A10); + POLY_XLU_DISP = &xlu[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } + Matrix_StatePop(); +} + +void ObjChan_DrawPot(Actor* thisx, GlobalContext* globalCtx) { + ObjChan* this = THIS; + s32 pad; + Gfx* dl; + + OPEN_DISPS(globalCtx->state.gfxCtx); + dl = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPDisplayList(&dl[1], object_obj_chan_DL_002358); + POLY_OPA_DISP = &dl[2]; + CLOSE_DISPS(globalCtx->state.gfxCtx); + + if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { + ObjChan_DrawFire(this, globalCtx); + } +} + +void ObjChan_DrawFire(ObjChan* this, GlobalContext* globalCtx) { + u32 sp4C; + Gfx* dl; + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp4C = globalCtx->gameplayFrames; + + Matrix_RotateY(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, + MTXMODE_APPLY); + Matrix_Scale(sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].x * this->flameSize, + sObjChanFlameSize[OBJCHAN_SUBTYPE(&this->actor)].y * this->flameSize, 1.0f, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, sObjChanFlameYOffset[OBJCHAN_SUBTYPE(&this->actor)], 0.0f, MTXMODE_APPLY); + + dl = func_8012C2B4(POLY_XLU_DISP); + gSPMatrix(&dl[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD); + gMoveWd(&dl[1], 6, 32, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0U, -sp4C * 20, 32, 128)); + gDPSetPrimColor(&dl[2], 128, 128, 255, 255, 0, 255); + gDPSetEnvColor(&dl[3], 255, 0, 0, 0); + gSPDisplayList(&dl[4], &gGameplayKeepDrawFlameDL); + POLY_XLU_DISP = &dl[5]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 8b498f39e..2b11335b3 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -5,12 +5,56 @@ struct ObjChan; +#define OBJCHAN_SUBTYPE(thisx) (((thisx)->params >> 12) & 0xF) +#define OBJCHAN_SUBTYPE_CHANDELIER 0 +#define OBJCHAN_SUBTYPE_POT 1 + +/*** stateFlags ***/ +/* + * After the chandelier is hit by a fire attack, each pot gets OBJCHAN_STATE_FIRE_DELAY state and counts down a number of frames until it catches fire. + * The delay is different for each pot. Remaining frame count is stored in fireDelayFrames. + * The main actor also gets this flag but it's always equivalent to OBJCHAN_STATE_ON_FIRE. + */ +#define OBJCHAN_STATE_FIRE_DELAY (1 << 0) +/** + * Pot is now on fire. After this state is set the flame grows to full size over 20 frames. Flame size is stored in flameSize. + * OBJCHAN_STATE_FIRE_DELAY is not cleared when this flag is set. + * The main actor also gets this flag. + */ +#define OBJCHAN_STATE_ON_FIRE (1 << 1) // Pot has fire. Flame grows to full size over about 1 second. Flame size is stored in fireSize. +/** + * Only for the main actor. + * Once set, the actor tries to start a cutscene. + * Once cutscene is started, this flag is unset and OBJCHAN_STATE_MAIN_STOP_CUTSCENE_AT_FULL_SPEED is set. + */ +#define OBJCHAN_STATE_START_CUTSCENE (1 << 2) +/** + * Only for the main actor. + * Cutscene is running. Once set, the actor waits for full rotation speed and then cancels the cutscene. + */ +#define OBJCHAN_STATE_CUTSCENE (1 << 3) + + + typedef void (*ObjChanActionFunc)(struct ObjChan*, GlobalContext*); typedef struct ObjChan { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjChanActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x9C]; + /* 0x0148 */ ColliderCylinder collider; + /* 0x0194 */ u8 myPotIndex; // For OBJCHAN_SUBTYPE_POT: which pot is this? + /* 0x0196 */ s16 fireDelayFrames; + /* 0x0198 */ UNK_TYPE1 unk198[0x12]; + /* 0x01AA */ u8 stateFlags; + /* 0x01AC */ struct ObjChan* pots[5]; // For OBJCHAN_SUBTYPE_BODY: pointers to pot actors + /* 0x01C0 */ Vec3f unk1C0; + /* 0x01CC */ f32 unk1CC; + /* 0x01D0 */ f32 unk1D0; + /* 0x01D4 */ s16 unk1D4; + /* 0x01D8 */ f32 flameSize; + /* 0x01DC */ s16 rotationSpeed; // Main object only. Slowly ramps up under some circumstances. In other circumstances it's immediately set to maximum speed. + /* 0x01DE */ s16 rotation; // Increases as the chandelier spins. Don't know why they didn't use the actor's rotation variable. + /* 0x01E0 */ s16 cutscenes[2]; } ObjChan; // size = 0x1E4 extern const ActorInit Obj_Chan_InitVars; 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 c1e74ce53..7de79a2be 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -6,7 +6,7 @@ #include "z_obj_chikuwa.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjChikuwa*)thisx) 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 4a82c7609..573b34fdc 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -5,6 +5,7 @@ */ #include "z_obj_comb.h" +#include "objects/object_comb/object_comb.h" #define FLAGS 0x00000000 @@ -15,11 +16,12 @@ void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx); void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_8098DC44(ObjComb* this); void func_8098DC60(ObjComb* this, GlobalContext* globalCtx); void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx); +void func_8098E098(ObjComb* this); void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Comb_InitVars = { ACTOR_OBJ_COMB, ACTORCAT_PROP, @@ -32,71 +34,538 @@ const ActorInit Obj_Comb_InitVars = { (ActorFunc)ObjComb_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8098E440[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x05CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x05CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 15 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8098E464 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_8098E440, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8098E474[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP), }; -#endif +s32 func_8098CE40(ObjComb* this, GlobalContext* globalCtx) { + s32 phi_a2 = -1; + s32 temp_v0 = (OBJCOMB_GET_1F(&this->actor) << 2) | 0xFF01; -extern ColliderJntSphElementInit D_8098E440[1]; -extern ColliderJntSphInit D_8098E464; -extern InitChainEntry D_8098E474[]; + if ((u8)temp_v0 & 3) { + phi_a2 = ((temp_v0 & 0x3FC) >> 2) & 0xFF; + } -extern UNK_TYPE D_06000CB0; -extern UNK_TYPE D_06001040; + return ((phi_a2 < 0) == 1) || !Flags_GetTreasure(globalCtx, phi_a2); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098CE40.s") +void func_8098CEAC(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + s32 i; + f32 temp_f20; + s16 temp_s2 = 0; + s16 temp_f10; + s32 phi_s0; + s32 phi_v0; + s32 phi_s1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098CEAC.s") + for (i = 0; i < 31; i++) { + temp_s2 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D19C.s") + spDC.x = Math_SinS(temp_s2) * temp_f20; + spDC.y = (i - 15) * 0.7f; + spDC.z = Math_CosS(temp_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D47C.s") + Math_Vec3f_Sum(&spDC, &this->actor.world.pos, &spD0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D6E0.s") + spC4.x = (Rand_ZeroOne() - 0.5f) + (spDC.x * 0.5f); + spC4.y = (Rand_ZeroOne() - 0.5f) + (spDC.y * 0.6f); + spC4.z = (Rand_ZeroOne() - 0.5f) + (spDC.z * 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D870.s") + temp_f10 = (Rand_ZeroOne() * 72.0f) + 25.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D8C8.s") + if (temp_f10 < 40) { + phi_s0 = -200; + phi_s1 = 40; + } else if (temp_f10 < 70) { + phi_s0 = -280; + phi_s1 = 30; + } else { + phi_s0 = -340; + phi_s1 = 20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098D99C.s") + temp_f20 = Rand_ZeroOne(); + if (temp_f20 < 0.1f) { + phi_v0 = 0x60; + } else if (temp_f20 < 0.8f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } + EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f10, 0, 0, 60, -1, + OBJECT_COMB, object_comb_DL_001040); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DA74.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y - 10.0f; + spD0.z = this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Init.s") + func_800BBFB0(globalCtx, &spD0, 40.0f, 6, 70, 60, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Destroy.s") +void func_8098D19C(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spDC; + Vec3f spD0; + Vec3f spC4; + f32 temp_f20; + s16 temp_s2 = 0; + s16 temp_f8; + s32 phi_s0; + s32 phi_v0; + s32 phi_s1; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DC44.s") + for (i = 0; i < 31; i++) { + temp_s2 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DC60.s") + spDC.x = Math_SinS(temp_s2) * temp_f20; + spDC.y = i * 0.7f; + spDC.z = Math_CosS(temp_s2) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DE58.s") + Math_Vec3f_Sum(&spDC, &this->actor.world.pos, &spD0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098DEA0.s") + spC4.x = (Rand_ZeroOne() - 0.5f) + (spDC.x * 0.5f); + spC4.y = (Rand_ZeroOne() * 0.5f) + (spDC.y * 0.5f); + spC4.z = (Rand_ZeroOne() - 0.5f) + (spDC.z * 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098E098.s") + temp_f8 = (Rand_ZeroOne() * 72.0f) + 25.0f; + if (temp_f8 < 40) { + phi_s0 = -200; + phi_s1 = 40; + } else if (temp_f8 < 70) { + phi_s0 = -280; + phi_s1 = 30; + } else { + phi_s0 = -340; + phi_s1 = 20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/func_8098E0B8.s") + temp_f20 = Rand_ZeroOne(); + if (temp_f20 < 0.1f) { + phi_v0 = 0x60; + } else if (temp_f20 < 0.8f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Update.s") + EffectSsKakera_Spawn(globalCtx, &spD0, &spC4, &spD0, phi_s0, phi_v0, phi_s1, 4, 0, temp_f8, 0, 0, 60, -1, + OBJECT_COMB, object_comb_DL_001040); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Comb/ObjComb_Draw.s") + spD0.x = this->actor.world.pos.x; + spD0.y = this->actor.world.pos.y + 20.0f; + spD0.z = this->actor.world.pos.z; + + func_800BBFB0(globalCtx, &spD0, 40.0f, 6, 70, 60, 1); +} + +void func_8098D47C(ObjComb* this, GlobalContext* globalCtx) { + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + s16 temp_s1 = 0; + s16 temp_f10; + s32 phi_s0; + s32 phi_v0; + s32 i; + + for (i = 0; i < 21; i++) { + temp_s1 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; + + spD4.x = Math_SinS(temp_s1) * temp_f20; + spD4.y = i * 0.25f; + spD4.z = Math_CosS(temp_s1) * temp_f20; + + Math_Vec3f_Sum(&spD4, &this->actor.world.pos, &spC8); + + spBC.x = (Rand_ZeroOne() - 0.5f) + (spD4.x * 0.5f); + spBC.y = Rand_ZeroOne() + (spD4.y * 0.6f) + 6.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) + (spD4.z * 0.5f); + + temp_f10 = (Rand_ZeroOne() * 72.0f) + 25.0f; + if (temp_f10 < 40) { + phi_s0 = -100; + } else if (temp_f10 < 70) { + phi_s0 = -180; + } else { + phi_s0 = -240; + } + + if (Rand_ZeroOne() < 0.2f) { + phi_v0 = 0x40; + } else { + phi_v0 = 0x20; + } + + EffectSsKakera_Spawn(globalCtx, &spC8, &spBC, &spC8, phi_s0, phi_v0, 40, 0, 0, temp_f10, 0, 0, 80, -1, + OBJECT_COMB, object_comb_DL_001040); + } +} + +void func_8098D6E0(ObjComb* this, GlobalContext* globalCtx) { + s32 i; + Vec3f sp70; + f32 temp_f0; + f32 temp_f20; + s32 temp; + + sp70.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (temp = 0, i = 0; i < 8; i++, temp += 0x2000) { + temp_f0 = Rand_ZeroOne(); + temp_f20 = ((1.0f - SQ(temp_f0)) * 14.0f) + 4.0f; + sp70.x = (Math_SinS((s32)(Rand_ZeroOne() * 8000.0f) + temp) * temp_f20) + this->actor.world.pos.x; + sp70.z = (Math_CosS((s32)(Rand_ZeroOne() * 8000.0f) + temp) * temp_f20) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp70, NULL, NULL, 0, 200); + } + + sp70.x = this->actor.world.pos.x; + sp70.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp70, NULL, NULL, 0, 300); +} + +void func_8098D870(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_v0 = func_800A8150(OBJCOMB_GET_3F(&this->actor)); + + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ((OBJCOMB_GET_7F00(&this->actor)) << 8) | temp_v0); + } +} + +void func_8098D8C8(ObjComb* this, GlobalContext* globalCtx) { + s32 params = OBJCOMB_GET_F(&this->actor); + s32 i; + s32 phi_s5; + + if (this->actionFunc == func_8098DC60) { + phi_s5 = 2; + } else { + phi_s5 = 1; + } + this->unk_1B6 = 0; + + for (i = 0; i < params; i++) { + if (Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BEE, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, phi_s5)) { + this->unk_1B6 = 1; + } + } +} + +void func_8098D99C(ObjComb* this, GlobalContext* globalCtx) { + s32 params; + Actor* temp_v0; + + if (func_8098CE40(this, globalCtx)) { + params = (OBJCOMB_GET_1F(&this->actor) << 2) | 0xFF01; + temp_v0 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SW, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.home.rot.y, 0, params); + + if (temp_v0 != NULL) { + temp_v0->parent = &this->actor; + if (this->actionFunc == func_8098DC60) { + temp_v0->velocity.y = 8.0f; + temp_v0->speedXZ = 2.0f; + } else { + temp_v0->velocity.y = 10.0f; + temp_v0->speedXZ = 2.0f; + } + this->unk_1B6 = 1; + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } +} + +void func_8098DA74(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_v0 = OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor); + + if (temp_v0 == 0) { + func_8098D870(this, globalCtx); + } else if (temp_v0 == 1) { + func_8098D8C8(this, globalCtx); + } else { + func_8098D99C(this, globalCtx); + } +} + +void ObjComb_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjComb* this = THIS; + s32 sp2C = OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitJntSph(globalCtx, &this->collider); + + if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && (gSaveContext.save.weekEventReg[83] & 2)) { + Actor_MarkForDeath(&this->actor); + return; + } + + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, &this->colliderElement); + + if ((sp2C == 0) && func_800A81A4(globalCtx, OBJCOMB_GET_3F(&this->actor), OBJCOMB_GET_7F00(&this->actor))) { + this->unk_1B7 = 1; + this->actor.flags |= ACTOR_FLAG_10; + } + + if ((sp2C != 2) || !func_8098CE40(this, globalCtx)) { + this->unk_1B8 = -1; + } + func_8098DC44(this); +} + +void ObjComb_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyJntSph(globalCtx, &THIS->collider); +} + +void func_8098DC44(ObjComb* this) { + this->unk_1AC = 0x2EE0; + this->actionFunc = func_8098DC60; +} + +void func_8098DC60(ObjComb* this, GlobalContext* globalCtx) { + s32 temp_a0; + s8 temp_v0; + u32 temp_v1; + + this->unk_1AA += this->unk_1AC; + if (this->unk_1B3) { + this->collider.base.acFlags &= ~AC_HIT; + } + + this->unk_1A8 -= 0x32; + if (this->unk_1A8 < 0) { + this->unk_1A8 = 0; + } + + if (this->unk_1B3) { + if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x0182C29C) { + func_8098CEAC(this, globalCtx); + func_8098DA74(this, globalCtx); + Actor_MarkForDeath(&this->actor); + } else { + s32 dmgFlags = this->collider.elements->info.acHitInfo->toucher.dmgFlags; + + if (dmgFlags & 0x13820) { + this->unk_1A8 = 0xDAC; + this->unk_1AC = 0x36B0; + } else { + this->unk_1A8 = 0x5DC; + this->unk_1AC = 0x2EE0; + } + + if ((this->unk_1B2 <= 0) && (dmgFlags & 0x13820)) { + if (this->unk_1B5 == 0) { + this->unk_1B5 = 1; + this->actor.flags |= ACTOR_FLAG_10; + } + this->unk_1B2 = 20; + } + } + } else { + if (this->unk_1B8 >= 0) { + if (this->unk_1B8 == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALGOLD_ROLL); + if (Rand_ZeroOne() < 0.1f) { + this->unk_1B8 = Rand_S16Offset(40, 80); + } else { + this->unk_1B8 = 8; + } + } else { + this->unk_1B8--; + } + } + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actor.update != NULL) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_1AA) * this->unk_1A8) + this->actor.home.rot.x; +} + +void func_8098DE58(ObjComb* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_1B4 = 100; + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = -1.5f; + this->actor.speedXZ = 0.0f; + this->actionFunc = func_8098DEA0; +} + +void func_8098DEA0(ObjComb* this, GlobalContext* globalCtx) { + this->unk_1B4--; + if ((this->actor.bgCheckFlags & 1) || (this->unk_1B4 <= 0)) { + func_8098DA74(this, globalCtx); + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 30.0f)) { + func_8098D47C(this, globalCtx); + } else { + func_8098D19C(this, globalCtx); + } + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_HONEYCOMB_BROKEN); + func_8098E098(this); + } else { + if (this->actor.bgCheckFlags & 0x40) { + func_8098D6E0(this, globalCtx); + } + + if (this->actor.bgCheckFlags & 0x20) { + this->actor.gravity = -0.5f; + this->actor.velocity.y *= 0.8f; + this->unk_1AE >>= 1; + this->unk_1B0 >>= 1; + } else { + this->actor.gravity = -1.5f; + this->actor.velocity.y *= 0.96f; + + this->unk_1AE += 0x1F4; + if (this->unk_1AE > 0x7D0) { + this->unk_1AE = 0x7D0; + } + + this->unk_1B0 += 0xC8; + if (this->unk_1B0 > 0x258) { + this->unk_1B0 = 0x258; + } + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } + + Actor_MoveWithGravity(&this->actor); + this->actor.shape.rot.x += this->unk_1AE; + this->actor.shape.rot.y += this->unk_1B0; + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 12.0f, 0.0f, 5); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_8098E098(ObjComb* this) { + this->actor.draw = NULL; + this->unk_1B4 = 20; + this->actionFunc = func_8098E0B8; +} + +void func_8098E0B8(ObjComb* this, GlobalContext* globalCtx) { + this->unk_1B4--; + if (this->unk_1B4 <= 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((this->unk_1B4 == 10) && (this->unk_1B6 != 0) && (this->unk_1B5 == 2) && (this->actor.cutscene >= 0)) { + if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { + func_800B7298(globalCtx, &this->actor, 4); + } + } +} + +void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjComb* this = THIS; + + this->unk_1B3 = (this->collider.base.acFlags & AC_HIT) != 0; + if (this->unk_1B3) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (this->unk_1B2 > 0) { + this->unk_1B2--; + if (this->unk_1B2 == 0) { + func_8098DE58(this); + } + } + + this->actionFunc(this, globalCtx); + + if (this->actor.update == NULL) { + if ((this->unk_1B5 == 2) && (func_800F2138(this->actor.cutscene) == -1)) { + ActorCutscene_Stop(this->actor.cutscene); + 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) { + func_800B7298(globalCtx, &this->actor, 1); + } + + if (((OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor)) == 1) && + OBJCOMB_GET_10(&this->actor)) { + gSaveContext.save.weekEventReg[83] |= 2; + } + + this->unk_1B5 = 2; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } + } + + if (this->unk_1B7 != 0) { + globalCtx->actorCtx.unk5 |= 8; + this->actor.flags |= ACTOR_FLAG_10; + } + } +} + +void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjComb* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y + (118.0f * this->actor.scale.y), + this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, -(this->actor.scale.y * 118.0f), 0.0f, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_comb_DL_000CB0); + + Collider_UpdateSpheres(0, &this->collider); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h index 303a3ed5e..fc47df429 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.h @@ -7,10 +7,31 @@ struct ObjComb; typedef void (*ObjCombActionFunc)(struct ObjComb*, GlobalContext*); +#define OBJCOMB_GET_F(thisx) ((thisx)->params & 0xF) +#define OBJCOMB_GET_10(thisx) (((thisx)->params >> 4) & 0x1) +#define OBJCOMB_GET_1F(thisx) ((thisx)->params & 0x1F) +#define OBJCOMB_GET_3F(thisx) ((thisx)->params & 0x3F) +#define OBJCOMB_GET_80(thisx) (((thisx)->params >> 7) & 0x1) +#define OBJCOMB_GET_7F00(thisx) (((thisx)->params >> 0x8) & 0x7F) +#define OBJCOMB_GET_8000(thisx) (((thisx)->params >> 0xE) & 2) + typedef struct ObjComb { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjCombActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x74]; + /* 0x0148 */ ColliderJntSph collider; + /* 0x0168 */ ColliderJntSphElement colliderElement; + /* 0x01A8 */ s16 unk_1A8; + /* 0x01AA */ s16 unk_1AA; + /* 0x01AC */ s16 unk_1AC; + /* 0x01AE */ s16 unk_1AE; + /* 0x01B0 */ s16 unk_1B0; + /* 0x01B2 */ s8 unk_1B2; + /* 0x01B3 */ s8 unk_1B3; + /* 0x01B4 */ s8 unk_1B4; + /* 0x01B5 */ s8 unk_1B5; + /* 0x01B6 */ s8 unk_1B6; + /* 0x01B7 */ s8 unk_1B7; + /* 0x01B8 */ s8 unk_1B8; } ObjComb; // size = 0x1BC extern const ActorInit Obj_Comb_InitVars; 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 6e14ea096..aa72f3052 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -6,7 +6,7 @@ #include "z_obj_danpeilift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDanpeilift*)thisx) 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 a51a7e8d2..2fba4b96a 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -6,7 +6,7 @@ #include "z_obj_demo.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDemo*)thisx) 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 1177a6855..bec773c2f 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -1,12 +1,13 @@ /* * File: z_obj_dhouse.c * Overlay: ovl_Obj_Dhouse - * Description: Dinner plate Prop + * Description: Stone bridge that Keeta sleeps under */ #include "z_obj_dhouse.h" +#include "objects/object_dhouse/object_dhouse.h" -#define FLAGS 0x00400010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #define THIS ((ObjDhouse*)thisx) @@ -15,7 +16,17 @@ void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3); +void func_80B13908(ObjDhouse* this); +void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B1392C(ObjDhouse* this); +void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B139D8(ObjDhouse* this); +void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx); +void func_80B13C08(Actor* thisx, GlobalContext* globalCtx); +void func_80B13E40(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Dhouse_InitVars = { ACTOR_OBJ_DHOUSE, ACTORCAT_BG, @@ -28,58 +39,504 @@ const ActorInit Obj_Dhouse_InitVars = { (ActorFunc)ObjDhouse_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B13FB4[] = { +ObjDhouseStruct3 D_80B13E90[] = { + { + object_dhouse_DL_006E28, + object_dhouse_DL_006CE0, + { 84.2f, 30.480001f, 109.68001f }, + { 3.0f, 21.0f, 11.0f }, + 5500, + 500, + -500, + 7, + }, + { + object_dhouse_DL_0070A8, + object_dhouse_DL_006EF8, + { 40.8f, -38.72f, 62.12f }, + { -5.0f, 22.0f, 8.0f }, + 600, + -300, + 2000, + 4, + }, + { + object_dhouse_DL_007348, + object_dhouse_DL_007190, + { 125.31999f, -34.52f, 62.12f }, + { 8.0f, 13.0f, 6.0f }, + -2400, + 200, + -300, + 4, + }, + { + object_dhouse_DL_007568, + object_dhouse_DL_007438, + { 150.56f, -80.520004f, 62.12f }, + { -4.0f, 7.0f, 3.0f }, + 100, + 50, + 850, + 8, + }, + { + object_dhouse_DL_007780, + object_dhouse_DL_007638, + { 82.08f, 21.32f, -99.64f }, + { -7.0f, 34.0f, -1.0f }, + -2400, + -100, + 1000, + 5, + }, + { + object_dhouse_DL_007A00, + object_dhouse_DL_007850, + { 45.64f, -38.16f, -56.24f }, + { -1.0f, 20.0f, -16.0f }, + -2000, + 700, + 500, + 6, + }, + { + object_dhouse_DL_007C98, + object_dhouse_DL_007AE8, + { 140.4f, -60.84f, -56.24f }, + { 2.0f, 27.0f, -10.0f }, + -1000, + -500, + -500, + 9, + }, +}; + +Vec3f D_80B13FA8 = { 0.0f, 0.3f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 8000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +Vec3f D_80B13FC4 = { 160.0f, 0.0f, 240.0f }; -extern InitChainEntry D_80B13FB4[]; +void ObjDhouse_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; -extern UNK_TYPE D_06004928; -extern UNK_TYPE D_06005A78; -extern UNK_TYPE D_06008040; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Init.s") + DynaPolyActor_Init(&this->dyna, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Destroy.s") + if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + this->dyna.actor.draw = func_80B13E40; + func_80B13908(this); + } else { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_dhouse_Colheader_008040); + this->dyna.actor.flags |= ACTOR_FLAG_10; + func_80B1392C(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12A50.s") +void ObjDhouse_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12A88.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12B38.s") +void func_80B12A50(ObjDhouseStruct1* this, ObjDhouseStruct3* ptr3, Vec3f* arg2) { + arg2->x = this->unk_00.x + ptr3->unk_08.x; + arg2->y = this->unk_00.y + ptr3->unk_08.y; + arg2->z = this->unk_00.z + ptr3->unk_08.z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12D78.s") +void func_80B12A88(Actor* thisx) { + ObjDhouse* this = THIS; + s32 i; + ObjDhouseStruct1* ptr; + ObjDhouseStruct3* ptr3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B12E7C.s") + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + Math_Vec3f_Copy(&ptr->unk_00, &this->dyna.actor.world.pos); + Math_Vec3f_Copy(&ptr->unk_0C, &ptr3->unk_14); + ptr->unk_18 = this->dyna.actor.shape.rot; + ptr->unk_1E = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13170.s") +void func_80B12B38(ObjDhouse* this2, GlobalContext* globalCtx) { + ObjDhouse* this = this2; + s32 i; + f32 temp_f0; + CollisionPoly* sp90; + s32 phi_s3; + Vec3f sp80; + s32 sp7C; + ObjDhouseStruct1* ptr; + ObjDhouseStruct3* ptr3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13474.s") + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + if (ptr->unk_1E >= 0) { + if (ptr->unk_1E >= ptr3->unk_26) { + ptr->unk_0C.y -= 2.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13724.s") + Math_Vec3f_Scale(&ptr->unk_0C, 0.96f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13908.s") + ptr->unk_00.x += ptr->unk_0C.x; + ptr->unk_00.y += ptr->unk_0C.y; + ptr->unk_00.z += ptr->unk_0C.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B1391C.s") + ptr->unk_18.x += ptr3->unk_20.x; + ptr->unk_18.y += ptr3->unk_20.y; + ptr->unk_18.z += ptr3->unk_20.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B1392C.s") + if (ptr->unk_1E == ptr3->unk_26) { + func_80B12E7C(this, globalCtx, ptr, ptr3); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13940.s") + phi_s3 = false; + if (ptr->unk_0C.y < 0.0f) { + func_80B12A50(ptr, ptr3, &sp80); + temp_f0 = BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp90, &sp7C, &this->dyna.actor, &sp80); + if (((sp80.y - 35.0f) < temp_f0) && (temp_f0 > (BGCHECK_Y_MIN + 1.0f))) { + phi_s3 = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B139D8.s") + if (phi_s3) { + ptr->unk_1E = -1; + func_80B13170(this, globalCtx, ptr, ptr3); + } else if (ptr->unk_1E > 60) { + ptr->unk_1E = -1; + } else { + ptr->unk_1E++; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B139F4.s") +s32 func_80B12D78(ObjDhouse* this) { + s32 i; + ObjDhouseStruct2* ptr2 = &this->unk_240[0]; + s32 count = 0; + ObjDhouseStruct2* ptr22 = &this->unk_240[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Update.s") + for (i = 1; i < ARRAY_COUNT(this->unk_240); i++, ptr22++) { + if (ptr22->unk_28 < ptr2->unk_28) { + ptr2 = ptr22; + count = i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/ObjDhouse_Draw.s") + return count; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13C08.s") +void func_80B12E7C(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { + s32 i; + Vec3f spA0; + Vec3f sp94; + Vec3f sp88; + ObjDhouseStruct2* ptr2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Dhouse/func_80B13E40.s") + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultiplyVector3fXZByCurrentState(&D_80B13FC4, &sp94); + sp94.y = 100.0f; + func_80B12A50(ptr, ptr3, &spA0); + + for (i = 0; i < 15; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 24.0f; + ptr2->unk_0C.y = ptr2->unk_00.y * 34.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 24.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 140.0f) + spA0.x; + ptr2->unk_00.y = ((ptr2->unk_00.y - 0.2f) * 50.0f) + spA0.y; + ptr2->unk_00.z = (ptr2->unk_00.z * 140.0f) + spA0.z; + + ptr2->unk_18 = (Rand_ZeroOne() * 0.057f) + 0.003f; + + ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + + ptr2->unk_22 = ((u32)Rand_Next() >> 0x11) - 0x3FFF; + ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_29 = 0; + ptr2->unk_28 = 40; + + if ((i % 2) != 0) { + sp88.x = ((Rand_ZeroOne() - 0.5f) * sp94.x) + ptr2->unk_00.x; + sp88.y = ((Rand_ZeroOne() - 0.3f) * sp94.y) + ptr2->unk_00.y; + sp88.z = ((Rand_ZeroOne() - 0.5f) * sp94.z) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp88, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 130.0f) + 20, + (s32)(Rand_ZeroOne() * 140.0f) + 60); + } + } +} + +void func_80B13170(ObjDhouse* this, GlobalContext* globalCtx, ObjDhouseStruct1* ptr, ObjDhouseStruct3* ptr3) { + s32 i; + Vec3f sp98; + Vec3f sp8C; + ObjDhouseStruct2* ptr2; + + func_80B12A50(ptr, ptr3, &sp98); + + for (i = 0; i < 11; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 23.0f; + ptr2->unk_0C.y = (ptr2->unk_00.y * 19.0f) + 5.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 23.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 80.0f) + sp98.x; + ptr2->unk_00.y = (ptr2->unk_00.y * 23.0f) + sp98.y + 15.0f; + ptr2->unk_00.z = (ptr2->unk_00.z * 80.0f) + sp98.z; + + ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + + ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + + ptr2->unk_28 = 40; + + if (i < 3) { + ptr2->unk_18 = (Rand_ZeroOne() * 0.06f) + 0.12f; + ptr2->unk_29 = 1; + } else { + ptr2->unk_18 = (Rand_ZeroOne() * 0.05f) + 0.003f; + ptr2->unk_29 = 0; + } + + if ((i % 2) != 0) { + sp8C.x = ((Rand_ZeroOne() - 0.5f) * 160.0f) + ptr2->unk_00.x; + sp8C.y = (Rand_ZeroOne() * 120.0f) + ptr2->unk_00.y; + sp8C.z = ((Rand_ZeroOne() - 0.5f) * 160.0f) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp8C, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 140.0f) + 20, + (s32)(Rand_ZeroOne() * 140.0f) + 40); + } + } +} + +void func_80B13474(ObjDhouse* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + Vec3f sp88; + ObjDhouseStruct2* ptr2; + + for (i = 0; i < 5; i++) { + ptr2 = &this->unk_240[func_80B12D78(this)]; + + ptr2->unk_00.x = Rand_ZeroOne() - 0.5f; + ptr2->unk_00.y = Rand_ZeroOne(); + ptr2->unk_00.z = Rand_ZeroOne() - 0.5f; + + ptr2->unk_0C.x = ptr2->unk_00.x * 18.0f; + ptr2->unk_0C.y = ptr2->unk_00.y * 23.0f; + ptr2->unk_0C.z = ptr2->unk_00.z * 18.0f; + + ptr2->unk_00.x = (ptr2->unk_00.x * 40.0f) + arg2->x; + ptr2->unk_00.y = ((ptr2->unk_00.y - 0.4f) * 20.0f) + arg2->y; + ptr2->unk_00.z = (ptr2->unk_00.z * 40.0f) + arg2->z; + + ptr2->unk_1C.x = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.y = (u32)Rand_Next() >> 0x10; + ptr2->unk_1C.z = (u32)Rand_Next() >> 0x10; + + ptr2->unk_22 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + ptr2->unk_24 = ((u32)Rand_Next() >> 0x13) - 0xFFF; + ptr2->unk_26 = ((u32)Rand_Next() >> 0x12) - 0x1FFF; + + ptr2->unk_28 = 40; + ptr2->unk_18 = (Rand_ZeroOne() * 0.07f) + 0.003f; + ptr2->unk_29 = 0; + + sp88.x = ((Rand_ZeroOne() * 70.0f) - 35.0f) + ptr2->unk_00.x; + sp88.y = (Rand_ZeroOne() * 60.0f) + ptr2->unk_00.y; + sp88.z = ((Rand_ZeroOne() * 70.0f) - 35.0f) + ptr2->unk_00.z; + + func_800B1210(globalCtx, &sp88, &gZeroVec3f, &D_80B13FA8, (s32)(Rand_ZeroOne() * 80.0f) + 20, + (s32)(Rand_ZeroOne() * 90.0f) + 40); + } +} + +void func_80B13724(ObjDhouse* this, GlobalContext* globalCtx) { + f32 temp_f0; + f32 temp_f20 = this->dyna.actor.home.pos.y - 300.0f; + s32 i; + CollisionPoly* sp80; + ObjDhouseStruct2* ptr2; + Vec3f sp70; + s32 sp6C; + + for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { + if (ptr2->unk_28 > 0) { + ptr2->unk_0C.y -= 2.2f; + + Math_Vec3f_Scale(&ptr2->unk_0C, 0.95f); + + ptr2->unk_00.x += ptr2->unk_0C.x; + ptr2->unk_00.y += ptr2->unk_0C.y; + ptr2->unk_00.z += ptr2->unk_0C.z; + + if (ptr2->unk_00.y < temp_f20) { + ptr2->unk_28 = 0; + } else { + ptr2->unk_1C.x += ptr2->unk_22; + ptr2->unk_1C.y += ptr2->unk_24; + ptr2->unk_1C.z += ptr2->unk_26; + ptr2->unk_28--; + + if (ptr2->unk_29 & 1) { + temp_f0 = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &sp80, &sp6C, &this->dyna.actor, &ptr2->unk_00); + if (((ptr2->unk_00.y - 20.0f) < temp_f0) && (temp_f0 > BGCHECK_Y_MIN + 1.0f)) { + Math_Vec3f_Copy(&sp70, &ptr2->unk_00); + ptr2->unk_28 = 0; + func_80B13474(this, globalCtx, &sp70); + } + } + } + } + } +} + +void func_80B13908(ObjDhouse* this) { + this->actionFunc = func_80B1391C; +} + +void func_80B1391C(ObjDhouse* this, GlobalContext* globalCtx) { +} + +void func_80B1392C(ObjDhouse* this) { + this->actionFunc = func_80B13940; +} + +void func_80B13940(ObjDhouse* this, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + s32 sp20 = false; + + if (Flags_GetSwitch(globalCtx, OBJDHOUSE_GET_7F(&this->dyna.actor))) { + sp20 = true; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_EXPLSION_LONG); + } + + if (sp20) { + func_80B12A88(&this->dyna.actor); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = func_80B13C08; + this->dyna.actor.flags |= ACTOR_FLAG_20; + func_80B139D8(this); + } +} + +void func_80B139D8(ObjDhouse* this) { + this->unk_1370 = 120; + this->actionFunc = func_80B139F4; +} + +void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx) { + Camera* camera = GET_ACTIVE_CAM(globalCtx); + s16 quake; + + if (this->unk_1370 == 117) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 8, 0, 0, 0); + Quake_SetCountdown(quake, 17); + } else if (this->unk_1370 == 105) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 7, 0, 0, 0); + Quake_SetCountdown(quake, 20); + } else if (this->unk_1370 == 90) { + quake = Quake_Add(camera, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 5, 0, 0, 0); + Quake_SetCountdown(quake, 62); + } + + this->unk_1370--; + if (this->unk_1370 <= 0) { + this->dyna.actor.draw = func_80B13E40; + this->dyna.actor.flags &= ~ACTOR_FLAG_20; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + func_80B13908(this); + } else { + func_80B12B38(this, globalCtx); + func_80B13724(this, globalCtx); + } +} + +void ObjDhouse_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjDhouse_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_005A78); +} + +void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { + ObjDhouse* this = THIS; + ObjDhouseStruct1* ptr; + ObjDhouseStruct2* ptr2; + ObjDhouseStruct3* ptr3; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_004928); + + for (i = 0, ptr = &this->unk_160[0], ptr3 = &D_80B13E90[0]; i < ARRAY_COUNT(this->unk_160); i++, ptr3++, ptr++) { + if (ptr->unk_1E >= 0) { + Matrix_SetStateRotationAndTranslation(ptr->unk_00.x + ptr3->unk_08.x, ptr->unk_00.y + ptr3->unk_08.y, + ptr->unk_00.z + ptr3->unk_08.z, &ptr->unk_18); + Matrix_InsertTranslation(-ptr3->unk_08.x, -ptr3->unk_08.y, -ptr3->unk_08.z, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, ptr3->unk_00); + gSPDisplayList(POLY_OPA_DISP++, ptr3->unk_04); + } + } + + for (i = 0, ptr2 = &this->unk_240[0]; i < ARRAY_COUNT(this->unk_240); i++, ptr2++) { + if (ptr2->unk_28 > 0) { + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &ptr2->unk_1C); + Matrix_Scale(ptr2->unk_18, ptr2->unk_18, ptr2->unk_18, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dhouse_DL_0081D8); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B13E40(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, object_dhouse_DL_004928); +} diff --git a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h index 793aabfac..053928c1c 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.h @@ -7,11 +7,42 @@ struct ObjDhouse; typedef void (*ObjDhouseActionFunc)(struct ObjDhouse*, GlobalContext*); +#define OBJDHOUSE_GET_7F(thisx) ((thisx)->params & 0x7F) + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3s unk_18; + /* 0x1E */ s8 unk_1E; +} ObjDhouseStruct1; // size = 0x20 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3s unk_1C; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s8 unk_28; + /* 0x29 */ u8 unk_29; +} ObjDhouseStruct2; // size = 0x2C + +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ Gfx* unk_04; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3s unk_20; + /* 0x26 */ s8 unk_26; +} ObjDhouseStruct3; // size = 0x28 + typedef struct ObjDhouse { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjDhouseActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x1214]; + /* 0x0160 */ ObjDhouseStruct1 unk_160[7]; + /* 0x0240 */ ObjDhouseStruct2 unk_240[100]; + /* 0x1370 */ s16 unk_1370; } ObjDhouse; // size = 0x1374 extern const ActorInit Obj_Dhouse_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c index bca94a538..57f9d7550 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -7,7 +7,7 @@ #include "z_obj_dinner.h" #include "objects/object_obj_dinner/object_obj_dinner.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjDinner*)thisx) @@ -31,7 +31,7 @@ const ActorInit Obj_Dinner_InitVars = { void ObjDinner_Init(Actor* thisx, GlobalContext* globalCtx) { ObjDinner* this = THIS; - if (gSaveContext.save.isNight != true || (CURRENT_DAY == 3 && gSaveContext.save.weekEventReg[0x16] & 1)) { + if (gSaveContext.save.isNight != true || (CURRENT_DAY == 3 && gSaveContext.save.weekEventReg[22] & 1)) { Actor_MarkForDeath(&this->actor); } Actor_SetScale(&this->actor, 0.1f); 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 77285cdfd..1d77cc257 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -6,7 +6,7 @@ #include "z_obj_dora.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDora*)thisx) 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 a75bc0a3b..dbc945109 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -6,7 +6,7 @@ #include "z_obj_dowsing.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjDowsing*)thisx) 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 f193fbbc1..abd30b256 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -5,6 +5,7 @@ */ #include "z_obj_driftice.h" +#include "objects/object_driftice/object_driftice.h" #define FLAGS 0x00000000 @@ -15,7 +16,15 @@ void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx); void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A671A8(ObjDriftice* this); +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A671CC(ObjDriftice* this); +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A6743C(ObjDriftice* this); +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx); +void func_80A674A8(ObjDriftice* this); +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx); + const ActorInit Obj_Driftice_InitVars = { ACTOR_OBJ_DRIFTICE, ACTORCAT_BG, @@ -28,52 +37,430 @@ const ActorInit Obj_Driftice_InitVars = { (ActorFunc)ObjDriftice_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A676F4[] = { +static f32 D_80A67620[][3] = { + { 1.0f, 150.0f, 150.0f }, + { 1.5f, 250.0f, 200.0f }, + { 2.0f, 350.0f, 250.0f }, +}; + +static f32 D_80A67644[] = { 1.5f, 3.0f, 4.5f, 6.0f, 7.5f, 9.0f, 10.5f, 0.0f }; + +static f32 D_80A67664[][4] = { + { 0.6f, 0.5f, 0.2f, 0.4f }, + { 0.8f, 0.7f, 0.35f, 0.7f }, + { 1.0f, 1.0f, 0.8f, 1.0f }, +}; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x2 */ s16 unk_02; + /* 0x4 */ f32 unk_04; + /* 0x8 */ f32 unk_08; +} ObjDrifticeDataStruct; // size = 0xC + +static ObjDrifticeDataStruct D_80A67694[] = { + { 0x12C, 0x64, 1.3f, 2.0f }, + { 0x258, 0x1F4, 1.2f, 1.8f }, + { 0x4B0, 0x3E8, 1.1f, 1.5f }, +}; + +static ObjDrifticeDataStruct D_80A676B8[] = { { 0x320, 0x190, 200.0f, 400.0f }, { 0x5DC, 0x258, 100.0f, 300.0f } }; + +static ObjDrifticeDataStruct D_80A676D0[] = { + { 0x12C, 0x64, 300.0f, 700.0f }, + { 0x258, 0x258, 200.0f, 400.0f }, + { 0x4B0, 0x4B0, 100.0f, 300.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; +void func_80A66570(ObjDriftice* this, s32 arg1) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->unk_16C[arg1]); +} + +void func_80A665AC(s16* arg0, s16 arg1) { + if (arg1 < *arg0) { + *arg0 = arg1; + } else if (*arg0 < -arg1) { + *arg0 = -arg1; + } +} + +f32 func_80A665EC(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 phi_f2 = 0.0f; + f32 sp20; + + if (this->unk_248 >= 10) { + sp20 = -8.0f; + } else if (this->unk_248 < -9) { + sp20 = 0.0f; + } else if (this->unk_248 > 0) { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) - 1.0f) * 4.0f; + } else { + sp20 = (Math_CosS(fabsf(this->unk_248) * (0x8000 * 0.1f)) + 1.0f) * -4.0f; + } + + if (this->unk_248 > 0) { + if (arg0->unk_00.unk_00 > 0) { + arg0->unk_00.unk_00--; + } else { + arg0->unk_00.unk_00 = Rand_S16Offset(30, 70); + arg0->unk_00.unk_04 = Rand_S16Offset(1000, 1000); + arg0->unk_00.unk_0C = (Rand_ZeroOne() * 1.5f) + 1.0f; + arg0->unk_00.unk_10 = fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f; + } + } else { + arg0->unk_00.unk_00 = 0; + arg0->unk_00.unk_0C = phi_f2; + arg0->unk_00.unk_10 = (fabsf(arg0->unk_00.unk_0C - arg0->unk_00.unk_08) * 0.05f) + 0.02f; + } + + arg0->unk_00.unk_02 += arg0->unk_00.unk_04; + Math_StepToF(&arg0->unk_00.unk_08, arg0->unk_00.unk_0C, arg0->unk_00.unk_10); + + sp20 += (Math_SinS(arg0->unk_00.unk_02) * arg0->unk_00.unk_08); + return sp20; +} + +f32 func_80A667F0(ObjDrifticeStruct3* arg0, ObjDriftice* this) { + f32 temp_f20 = 0.0f; + ObjDrifticeStruct3* temp_s0; + s32 i; + + for (i = 0; i < 3; i++) { + temp_s0 = &arg0[i]; + + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A67694[i].unk_00, D_80A67694[i].unk_02); + temp_s0->unk_0C = D_80A67694[i].unk_04 + (D_80A67694[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.05f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } + + return temp_f20; +} + +#ifdef NON_MATCHING +void func_80A66930(ObjDrifticeStruct2* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f22 = 0.0f; + s16 phi_s0; + s32 i; + + if (this->unk_248 > 0) { + f32 temp_f20 = this->dyna.actor.xzDistToPlayer * this->unk_240 * 0.0007075472f; + if (temp_f20 > 1.0f) { + temp_f20 = 1.0f; + } else if (temp_f20 < 0.01f) { + temp_f20 = 0.01f; + } + + Math_StepToS(&arg0->unk_00[1], 1200.0f * temp_f20, 0x64); + phi_s0 = 2500.0f * temp_f20; + Math_StepToS(&arg0->unk_00[3], Math_CosS(arg0->unk_00[2] * 6.5536f) * (120.0f * temp_f20), 0x28); + Math_StepToF(&arg0->unk_08, 1.0f, 0.02f); + } else { + Math_StepToS(&arg0->unk_00[1], 0, 0x96); + phi_s0 = 0; + Math_StepToS(&arg0->unk_00[3], 20, 7); + Math_StepToF(&arg0->unk_08, 0.0f, 0.02f); + } + Math_ScaledStepToS(arg0->unk_00, this->dyna.actor.yawTowardsPlayer, arg0->unk_00[1]); + *arg3 = arg0->unk_00[0]; + Math_ScaledStepToS(&arg0->unk_00[2], phi_s0, arg0->unk_00[3]); + + for (i = 0; i < 2; i++) { + temp_s0 = &arg0->unk_0C[i]; + + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676B8[i].unk_00, D_80A676B8[i].unk_02); + temp_s0->unk_0C = D_80A676B8[i].unk_04 + (D_80A676B8[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f22 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } + + temp_f22 *= arg0->unk_08; + + *arg2 = (s32)temp_f22 + arg0->unk_00[2]; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") #endif -extern InitChainEntry D_80A676F4[]; +void func_80A66C4C(ObjDrifticeStruct4* arg0, ObjDriftice* this, s16* arg2, s16* arg3) { + ObjDrifticeStruct3* temp_s0; + f32 temp_f20 = 0.0f; + s32 i; -extern UNK_TYPE D_060016A0; -extern UNK_TYPE D_06001AA8; + if (arg0->unk_00[0] > 0) { + arg0->unk_00[0]--; + } else { + arg0->unk_00[0] = Rand_S16Offset(30, 70); + arg0->unk_00[2] = Rand_S16Offset(-200, 200); + arg0->unk_00[4] = Rand_S16Offset(-400, 400); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66570.s") + Math_StepToS(&arg0->unk_00[1], arg0->unk_00[2], 0x32); + Math_StepToS(&arg0->unk_00[3], arg0->unk_00[4], 0x32); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665AC.s") + *arg3 = arg0->unk_00[3] + arg0->unk_00[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A665EC.s") + for (i = 0; i < 3; i++) { + temp_s0 = &arg0->unk_0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A667F0.s") + if (temp_s0->unk_00 > 0) { + temp_s0->unk_00--; + } else { + temp_s0->unk_00 = Rand_S16Offset(30, 70); + temp_s0->unk_04 = Rand_S16Offset(D_80A676D0[i].unk_00, D_80A676D0[i].unk_02); + temp_s0->unk_0C = D_80A676D0[i].unk_04 + (D_80A676D0[i].unk_08 * Rand_ZeroOne()); + temp_s0->unk_10 = fabsf(temp_s0->unk_0C - temp_s0->unk_08) * 0.033333335f; + } + temp_s0->unk_02 += temp_s0->unk_04; + Math_StepToF(&temp_s0->unk_08, temp_s0->unk_0C, temp_s0->unk_10); + temp_f20 += Math_SinS(temp_s0->unk_02) * temp_s0->unk_08; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66930.s") + *arg2 = temp_f20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66C4C.s") +void func_80A66E30(ObjDrifticeStruct* arg0, ObjDriftice* this) { + f32 temp; + f32* temp_s1 = D_80A67664[OBJDRIFTICE_GET_ROT(&this->dyna.actor) - 1]; + s16 sp36; + s16 sp34; + s16 sp32; + s16 sp30; + f32 sp2C; + f32 sp28; + f32 sp24; + s16 sp22; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A66E30.s") + sp2C = func_80A665EC(arg0, this); + sp28 = func_80A667F0(arg0->unk_14, this); + func_80A66930(&arg0->unk_50, this, &sp32, &sp30); + func_80A66C4C(&arg0->unk_84, this, &sp36, &sp34); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Init.s") + this->dyna.actor.shape.yOffset = this->unk_240 * ((sp28 * temp_s1[1]) + (sp2C * temp_s1[0])); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Destroy.s") + sp24 = (sp32 * temp_s1[2]) + (sp36 * temp_s1[3]) * (temp = 1.0f); + sp22 = (sp34 + sp30) - this->dyna.actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671A8.s") + this->dyna.actor.shape.rot.x = Math_CosS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.x, 0xA28); + this->dyna.actor.shape.rot.z = -Math_SinS(sp22) * sp24; + func_80A665AC(&this->dyna.actor.shape.rot.z, 0xA28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671BC.s") +void ObjDriftice_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjDriftice* this = THIS; + f32* sp2C = D_80A67620[OBJDRIFTICE_GET_3(&this->dyna.actor)]; + Path* path; + s32 phi_a1; + s32 sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671CC.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + + Actor_SetScale(&this->dyna.actor, sp2C[0] * 0.035377357f); + this->dyna.actor.uncullZoneScale = sp2C[1]; + this->dyna.actor.uncullZoneDownward = sp2C[2]; + this->unk_240 = 1.0f / this->dyna.actor.scale.x; + this->unk_23C = D_80A67644[OBJDRIFTICE_GET_E00(&this->dyna.actor)]; + + sp20 = 0; + if (this->unk_23C < 0.01f) { + sp20 = 1; + } + + this->unk_244 = thisx->home.rot.z * 45.511112f; + + phi_a1 = 0; + if (sp20 == 0) { + phi_a1 = 1; + } + + if (thisx->home.rot.z != 0) { + phi_a1 |= 3; + } + + DynaPolyActor_Init(&this->dyna, phi_a1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_driftice_Colheader_001AA8); + + if (sp20 != 0) { + func_80A671A8(this); + } else { + this->dyna.actor.flags |= ACTOR_FLAG_10; + + path = &globalCtx->setupPathList[OBJDRIFTICE_GET_1FC(&this->dyna.actor)]; + this->unk_164 = 0; + this->unk_160 = path->count - 1; + this->unk_168 = 1; + + this->unk_16C = Lib_SegmentedToVirtual(path->points); + func_80A66570(this, this->unk_164); + func_80A671CC(this); + } +} + +void ObjDriftice_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A671A8(ObjDriftice* this) { + this->actionFunc = func_80A671BC; +} + +void func_80A671BC(ObjDriftice* this, GlobalContext* globalCtx) { +} + +void func_80A671CC(ObjDriftice* this) { + this->actionFunc = func_80A671E0; +} + +#ifdef NON_MATCHING +// stack +void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { + f32 phi_f0; + Vec3f sp40; + f32 sp3C; + f32 phi_f12; + Vec3s* points; + s32 sp30; + Vec3s* points2; + + Math_Vec3s_ToVec3f(&sp40, &(&this->unk_16C[this->unk_164])[this->unk_168]); + Math_Vec3f_Diff(&sp40, &this->dyna.actor.world.pos, &this->dyna.actor.velocity); + + sp3C = Math3D_Vec3fMagnitude(&this->dyna.actor.velocity); + if (sp3C < (this->unk_23C * 8.0f)) { + phi_f0 = this->unk_23C * 0.4f; + phi_f12 = this->unk_23C * 0.05f; + } else { + phi_f0 = this->unk_23C; + phi_f12 = this->unk_23C * 0.13f; + } + + Math_StepToF(&this->dyna.actor.speedXZ, phi_f0, phi_f12); + + if ((this->dyna.actor.speedXZ + 0.05f) < sp3C) { + Math_Vec3f_Scale(&this->dyna.actor.velocity, this->dyna.actor.speedXZ / 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; + } else { + sp30 = true; + this->unk_164 += this->unk_168; + + if (1) {} + + this->dyna.actor.speedXZ *= 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)) { + this->unk_168 = -this->unk_168; + func_80A674A8(this); + } else { + points = &this->unk_16C[this->unk_160]; + + if (this->unk_168 > 0) { + this->unk_164 = 0; + } else { + this->unk_164 = this->unk_160; + } + + points2 = &this->unk_16C[0]; + if ((points2->x != points->x) || (points2->y != points->y) || (points2->z != points->z)) { + func_80A6743C(this); + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + sp30 = false; + } + } + } + + if (sp30) { + func_80A66570(this, this->unk_164); + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A671E0.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A6743C.s") +void func_80A6743C(ObjDriftice* this) { + this->actionFunc = func_80A67450; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A67450.s") +void func_80A67450(ObjDriftice* this, GlobalContext* globalCtx) { + if (this->unk_248 < 0) { + func_80A66570(this, this->unk_164); + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_80A671CC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674A8.s") +void func_80A674A8(ObjDriftice* this) { + this->unk_24C = 10; + this->actionFunc = func_80A674C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/func_80A674C4.s") +void func_80A674C4(ObjDriftice* this, GlobalContext* globalCtx) { + this->unk_24C--; + if (this->unk_24C <= 0) { + this->dyna.actor.speedXZ = 0.0f; + func_80A671CC(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Update.s") +void ObjDriftice_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Driftice/ObjDriftice_Draw.s") + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->unk_248 < 0) { + this->unk_248 = 1; + } else { + this->unk_248++; + } + } else { + if (this->unk_248 > 0) { + this->unk_248 = -1; + } else { + this->unk_248--; + } + } + + this->dyna.actor.shape.rot.y += this->unk_244; + + this->actionFunc(this, globalCtx); + + if (OBJDRIFTICE_GET_ROT(&this->dyna.actor) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A66E30(&this->unk_170, this); + } +} + +void ObjDriftice_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjDriftice* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_driftice_DL_0016A0); +} 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 cdfc01f17..190fbdcb6 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.h @@ -7,11 +7,53 @@ struct ObjDriftice; typedef void (*ObjDrifticeActionFunc)(struct ObjDriftice*, GlobalContext*); +#define OBJDRIFTICE_GET_3(thisx) ((thisx)->params & 3) +#define OBJDRIFTICE_GET_1FC(thisx) (((thisx)->params >> 2) & 0x7F) +#define OBJDRIFTICE_GET_E00(thisx) (((thisx)->params >> 9) & 7) +#define OBJDRIFTICE_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJDRIFTICE_GET_ROT(thisx) ((thisx)->home.rot.x & 3) + +typedef struct { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; +} ObjDrifticeStruct3; // size = 0x14 + +typedef struct { + /* 0x00 */ s16 unk_00[2]; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[2]; +} ObjDrifticeStruct2; // size = 0x34 + +typedef struct { + /* 0x00 */ s16 unk_00[6]; + /* 0x0C */ ObjDrifticeStruct3 unk_0C[3]; +} ObjDrifticeStruct4; // size = 0x48 + +typedef struct { + /* 0x00 */ ObjDrifticeStruct3 unk_00; + /* 0x14 */ ObjDrifticeStruct3 unk_14[3]; + /* 0x50 */ ObjDrifticeStruct2 unk_50; + /* 0x84 */ ObjDrifticeStruct4 unk_84; +} ObjDrifticeStruct; // size = 0xCC + typedef struct ObjDriftice { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjDrifticeActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF0]; + /* 0x0160 */ s32 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; + /* 0x016C */ Vec3s* unk_16C; + /* 0x0170 */ ObjDrifticeStruct unk_170; + /* 0x023C */ f32 unk_23C; + /* 0x0240 */ f32 unk_240; + /* 0x0244 */ s16 unk_244; + /* 0x0248 */ s32 unk_248; + /* 0x024C */ s32 unk_24C; } ObjDriftice; // size = 0x250 extern const ActorInit Obj_Driftice_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c index be348ef1c..5109cf284 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -7,7 +7,7 @@ #include "z_obj_ending.h" #include "objects/object_ending_obj/object_ending_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjEnding*)thisx) @@ -44,7 +44,7 @@ void ObjEnding_Init(Actor* thisx, GlobalContext* globalCtx) { this->modelInfo = &sModelInfo[thisx->params]; animMat = this->modelInfo->animMat; if (animMat != NULL) { - this->animMat = (AnimatedMaterial*)Lib_SegmentedToVirtual(animMat); + this->animMat = Lib_SegmentedToVirtual(animMat); } } diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c index 0d4432ddd..8ed237927 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -5,8 +5,9 @@ */ #include "z_obj_entotu.h" +#include "objects/object_f53_obj/object_f53_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjEntotu*)thisx) @@ -15,7 +16,6 @@ void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx); void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Entotu_InitVars = { ACTOR_OBJ_ENTOTU, ACTORCAT_PROP, @@ -28,23 +28,147 @@ const ActorInit Obj_Entotu_InitVars = { (ActorFunc)ObjEntotu_Draw, }; -#endif +#include "overlays/ovl_Obj_Entotu/ovl_Obj_Entotu.c" -extern UNK_TYPE D_06000158; -extern UNK_TYPE D_06001C00; +s32 func_80A34700(s16 minutes) { + s32 ret = 0; + s16 time = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = time / 60; + s32 currMinutes = time % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34700.s") + if (hours >= 16) { + if ((hours == 16) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A349C0.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34A44.s") + if ((hours == 19) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/func_80A34B28.s") + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Destroy.s") + if ((hours == 13) && (minutes < currMinutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Update.s") + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (currMinutes < minutes)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Entotu/ObjEntotu_Draw.s") + if (hours >= 9) { + return 0; + } + + if ((hours == 8) && (minutes < currMinutes)) { + return 0; + } + + ret = 1; + } + return ret; +} + +void func_80A349C0(ObjEntotu* this) { + s32 temp_v0 = func_80A34700(this->unk_1C6); + u8 temp = temp_v0; + s16 temp2 = this->unk_1C4; + + if (temp_v0 != temp2) { + this->unk_1C4 = temp; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + temp2 = this->unk_1C4; + Math_ApproachF(&this->unk_1B8.x, (temp2 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A34A44(ObjEntotu* this, GlobalContext* globalCtx) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_f53_obj_DL_000158); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1B8.y += 1.8f; + this->unk_1B8.z += 0.6f; + sp57 = 0x7F - (u8)this->unk_1B8.y; + sp56 = 0x7F - (u8)this->unk_1B8.z; + + this->unk_1B8.x = CLAMP(this->unk_1B8.x, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(ovl_Obj_Entotu_Vtx_000D10); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Entotu_Vtx_000D10[i].v.cn[3] * this->unk_1B8.x; + } + + if (this->unk_1B8.x > 0.0f) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjEntotu_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Entotu_Vtx_000D10, sizeof(ovl_Obj_Entotu_Vtx_000D10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjEntotu_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjEntotu_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A349C0(this); +} + +void ObjEntotu_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjEntotu* this = THIS; + + func_80A34B28(this, globalCtx); + func_80A34A44(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h index 5d0b3cedd..a00a7fcd4 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h @@ -7,7 +7,11 @@ struct ObjEntotu; typedef struct ObjEntotu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ Vec3f unk_1B8; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjEntotu; // size = 0x1C8 extern const ActorInit Obj_Entotu_InitVars; 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 23d2dfa7f..eb91a93d4 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -7,7 +7,7 @@ #include "z_obj_etcetera.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjEtcetera*)thisx) 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 eaa085f49..705dc93bf 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.c @@ -5,8 +5,9 @@ */ #include "z_obj_fireshield.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjFireshield*)thisx) @@ -15,12 +16,12 @@ void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx); void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A4CABC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CB7C(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CCBC(ObjFireshield* this, GlobalContext* globalCtx); -void func_80A4CD28(ObjFireshield* this, GlobalContext* globalCtx); +void func_80A4CABC(ObjFireshield* this); +void func_80A4CB7C(ObjFireshield* this); +void func_80A4CC54(ObjFireshield* this); +void func_80A4CCBC(ObjFireshield* this); +void func_80A4CD28(ObjFireshield* this); -#if 0 const ActorInit Obj_Fireshield_InitVars = { ACTOR_OBJ_FIRESHIELD, ACTORCAT_PROP, @@ -33,49 +34,365 @@ const ActorInit Obj_Fireshield_InitVars = { (ActorFunc)ObjFireshield_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A4D820 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 28, 144, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A4D8A4[] = { +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; +} ObjFireshieldStruct; // size = 0x8 + +ObjFireshieldStruct D_80A4D84C[] = { + { 1.0f, 200.0f }, + { 2.0f, 400.0f }, + { 3.0f, 700.0f }, +}; + +s32 D_80A4D864[] = { 0, 0, 0, 0 }; +s32 D_80A4D874[] = { 0, 0, 0, 0 }; +s32 D_80A4D884[] = { 0, 0, 0, 0 }; +s32 D_80A4D894[] = { 0, 0, 0, 0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80A4CA90(ObjFireshield* this) { + if (this->actor.cutscene >= 0) { + this->actionFunc = func_80A4CABC; + } else { + this->actionFunc = func_80A4CC54; + } +} -extern ColliderCylinderInit D_80A4D820; -extern InitChainEntry D_80A4D8A4[]; +void func_80A4CABC(ObjFireshield* this) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CA90.s") + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0 = (sp18 & ~0x1F) >> 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CABC.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &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); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CB7C.s") +void func_80A4CB7C(ObjFireshield* this) { + s32 pad; + s32 sp18 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CC54.s") + if (this->unk_194 > 0) { + if (this->unk_194 == 20) { + D_80A4D884[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); + } + this->unk_194--; + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CCBC.s") + ActorCutscene_Stop(this->actor.cutscene); + this->actionFunc = func_80A4CD28; + D_80A4D894[(sp18 & ~0x1F) >> 5] &= ~(1 << (sp18 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD28.s") +void func_80A4CC54(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CD34.s") + this->actionFunc = func_80A4CCBC; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + D_80A4D894[(temp_v0 & ~0x1F) >> 5] |= temp_v1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4CE28.s") +void func_80A4CCBC(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D174.s") + this->actionFunc = func_80A4CD28; + D_80A4D884[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); + D_80A4D894[(temp_v0 & ~0x1F) >> 5] &= ~(1 << (temp_v0 & 0x1F)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/func_80A4D1CC.s") +void func_80A4CD28(ObjFireshield* this) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Init.s") +void func_80A4CD34(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjFireshield* this = THIS; + s32 sp24 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_7F(&this->actor)); + s32 phi_v1; + s32 phi_a0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Destroy.s") + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + phi_v1 = false; + phi_a0 = false; + } else { + phi_v1 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + phi_a0 = false; + } + } else { + phi_a0 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + phi_v1 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Update.s") + if (phi_v1 || phi_a0) { + this->unk_19C = 0; + } else if (sp24) { + this->unk_19C = 0; + } else { + this->unk_19C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Fireshield/ObjFireshield_Draw.s") + if (this->unk_19C == 0) { + this->unk_198 = 0.0f; + } else { + this->unk_198 = 1.0f; + } +} + +void func_80A4CE28(ObjFireshield* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 pad2[2]; + s32 sp24; + s32 sp20; + + if (this->unk_1A8 == 0) { + if (OBJFIRESHIELD_GET_2000(&this->actor)) { + sp24 = false; + sp20 = false; + } else { + sp24 = Flags_GetTreasure(globalCtx, OBJFIRESHIELD_GET_1F00(&this->actor)); + sp20 = false; + } + } else { + sp20 = Flags_GetSwitch(globalCtx, OBJFIRESHIELD_GET_3F80(&this->actor)); + sp24 = false; + } + + if (!sp24 || !sp20 || (this->unk_19C != 0)) { + s32 sp1C = Flags_GetSwitch(globalCtx, sp30); + s32 temp_v0 = (sp30 & ~0x1F) >> 5; + + if (this->unk_19C == 2) { + if (Math_StepToF(&this->unk_198, 1.0f, 0.03f)) { + this->unk_19C = 1; + if (((this->actor.home.rot.z * 10) > 0) && (this->unk_1A7 != 0)) { + Flags_UnsetSwitch(globalCtx, sp30); + sp1C = false; + } + } + } else if (this->unk_19C == 3) { + if (Math_StepToF(&this->unk_198, 0.0f, 0.03f)) { + this->unk_19C = 0; + } + } + + if ((this->unk_1A0 > 0) && (this->unk_19C == 1) && ((this->actor.home.rot.z * 10) > 0) && + !(D_80A4D894[temp_v0] & (1 << (sp30 & 0x1F)))) { + this->unk_1A0 = 0; + } + + if ((this->unk_19C == 0) || (this->unk_19C == 3)) { + if (!sp24 && !sp20) { + if ((this->actor.home.rot.z * 10) > 0) { + if (this->unk_1A0 > 1) { + this->unk_1A0--; + } + + if (this->unk_1A0 == 1) { + this->unk_19C = 2; + } + } + + if (!sp1C) { + this->unk_19C = 2; + } + } + } else if (sp24 || sp20) { + this->unk_19C = 3; + } else if (sp1C && ((this->unk_19C == 1) || (this->unk_19C == 2))) { + if ((D_80A4D884[temp_v0] & 1 << (sp30 & 0x1F)) && !(D_80A4D874[temp_v0] & 1 << (sp30 & 0x1F))) { + this->unk_19C = 3; + } else if (((this->actor.home.rot.z * 10) == 0) || (this->unk_1A0 == 0)) { + if ((this->actor.home.rot.z * 10) > 0) { + this->unk_1A0 = this->actor.home.rot.z * 10; + } + + if (this->unk_1A7 != 0) { + func_80A4CA90(this); + } + } + } + } +} + +void func_80A4D174(ObjFireshield* this) { + s32 temp_v0 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_v1 = 1 << (temp_v0 & 0x1F); + + if (!(D_80A4D864[(temp_v0 & ~0x1F) >> 5] & temp_v1)) { + this->unk_1A7 = 1; + D_80A4D864[(temp_v0 & ~0x1F) >> 5] |= temp_v1; + } +} + +void func_80A4D1CC(void) { + D_80A4D864[0] = 0; + D_80A4D864[1] = 0; + D_80A4D864[2] = 0; + D_80A4D864[3] = 0; +} + +void ObjFireshield_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + s32 temp = 0x8000; + ObjFireshieldStruct* sp2C = &D_80A4D84C[OBJFIRESHIELD_GET_C000(&this->actor)]; + s32 sp28 = OBJFIRESHIELD_GET_ROTX(&this->actor); + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (sp28) { + this->actor.shape.rot.z = temp; + } else { + this->actor.shape.rot.z = 0; + } + + this->actor.world.rot.z = 0; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + + this->actor.scale.x = sp2C->unk_00 * 0.0348f; + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = 0.05f; + + this->actor.uncullZoneScale = sp2C->unk_04; + this->unk_1A4 = Rand_ZeroOne() * 128.0f; + + if ((this->actor.home.rot.z * 10) < 0) { + this->unk_1A8 = 1; + this->actor.home.rot.z = -thisx->home.rot.z; + } + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); + + this->collider.dim.radius *= sp2C->unk_00; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + func_80A4D174(this); + func_80A4CD34(&this->actor, globalCtx); + this->actionFunc = func_80A4CD28; +} + +void ObjFireshield_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void ObjFireshield_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + ObjFireshield* this2 = THIS; + s32 sp44 = OBJFIRESHIELD_GET_ROTX(&this->actor); + s32 sp40 = OBJFIRESHIELD_GET_7F(&this->actor); + s32 temp_a0; + s32 temp_v1; + + func_80A4D1CC(); + + if (this->unk_1A7 != 0) { + temp_a0 = (sp40 & ~0x1F) >> 5; + temp_v1 = 1 << (sp40 & 0x1F); + if ((D_80A4D884[temp_a0] & temp_v1)) { + D_80A4D874[temp_a0] |= temp_v1; + } else { + D_80A4D874[temp_a0] &= ~temp_v1; + } + } + + this->unk_1A4++; + + this->actionFunc(this); + + if (this->actionFunc == func_80A4CABC) { + this->collider.base.atFlags &= ~AT_HIT; + } else if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_800B8D98(globalCtx, &this->actor, 5.0f, this->actor.yawTowardsPlayer, 1.0f); + } + + func_80A4CE28(this, globalCtx); + + this->actor.world.pos.y = ((sp44 ? 144.0f : -144.0f) * (1.0f - this2->unk_198)) + this->actor.home.pos.y; + + this->unk_1A6 = this->unk_198 * 255.0f; + + if (this->unk_198 >= 0.7f) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.dim.height = this->unk_198 * 80.0f; + + if (sp44) { + this->collider.dim.yShift = + (s32)(this->actor.home.pos.y - this->actor.world.pos.y) - this->collider.dim.height; + } else { + this->collider.dim.yShift = this->actor.home.pos.y - this->actor.world.pos.y; + } + + func_800B9010(&this->actor, NA_SE_EV_BURNING - SFX_FLAG); + + if (player->transformation == PLAYER_FORM_GORON) { + this->collider.info.toucher.damage = 0; + this->collider.info.toucher.effect = 0; + } else { + this->collider.info.toucher.damage = 4; + this->collider.info.toucher.effect = 1; + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjFireshield_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjFireshield* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 220, 0, this->unk_1A6); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, this->unk_1A4 & 0x7F, 0, 0x20, 0x40, 1, 0, + (this->unk_1A4 * -15) & 0xFF, 0x20, 0x40)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_02E510); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h index f39039793..4d6a971eb 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h @@ -5,13 +5,27 @@ struct ObjFireshield; -typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*, GlobalContext*); +typedef void (*ObjFireshieldActionFunc)(struct ObjFireshield*); + +#define OBJFIRESHIELD_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJFIRESHIELD_GET_1F00(thisx) (((thisx)->params >> 8) & 0x1F) +#define OBJFIRESHIELD_GET_2000(thisx) (((thisx)->params >> 0xD) & 1) +#define OBJFIRESHIELD_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) +#define OBJFIRESHIELD_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) +#define OBJFIRESHIELD_GET_ROTX(thisx) ((thisx)->home.rot.x & 1) typedef struct ObjFireshield { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4C]; + /* 0x0144 */ ColliderCylinder collider; /* 0x0190 */ ObjFireshieldActionFunc actionFunc; - /* 0x0194 */ char unk_194[0x18]; + /* 0x0194 */ s32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ s32 unk_19C; + /* 0x01A0 */ s32 unk_1A0; + /* 0x01A4 */ s16 unk_1A4; + /* 0x01A6 */ u8 unk_1A6; + /* 0x01A7 */ s8 unk_1A7; + /* 0x01A8 */ s8 unk_1A8; } ObjFireshield; // size = 0x1AC extern const ActorInit Obj_Fireshield_InitVars; 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 0365f3420..16ac7e8e9 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -447,7 +447,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1CBF8(this); this->actor.room = -1; this->actor.colChkInfo.mass = 180; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (func_800A817C(ENOBJFLOWERPOT_GET_3F(&this->actor))) { func_80A1B914(this, globalCtx); } @@ -465,7 +465,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1BD80(this, globalCtx); func_80A1B994(this, globalCtx); Actor_MarkForDeath(&this->actor); - } else if ((this->collider.elements[0].info.bumperFlags & 2) && + } else if ((this->collider.elements[0].info.bumperFlags & BUMP_HIT) && (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x058BFFBC)) { if (!(this->unk_1EA & 2)) { func_80A1B914(this, globalCtx); @@ -477,10 +477,10 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { func_80A1B994(this, globalCtx); Actor_MarkForDeath(&this->actor); } else { - if (this->collider.elements[1].info.bumperFlags & 2) { + if (this->collider.elements[1].info.bumperFlags & BUMP_HIT) { if (!(this->unk_1EA & 2)) { this->unk_1EA |= 2; - this->collider.elements[1].info.bumperFlags &= ~0x1; + this->collider.elements[1].info.bumperFlags &= ~BUMP_ON; func_80A1C0FC(this, globalCtx); func_80A1B914(this, globalCtx); func_80A1B9CC(this, globalCtx); @@ -493,7 +493,7 @@ void func_80A1C838(ObjFlowerpot* this, GlobalContext* globalCtx) { if (this->actor.bgCheckFlags & 1) { if (this->actor.colChkInfo.mass == MASS_IMMOVABLE) { if (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->unk_1EA &= ~0x1; } } else if (Math3D_Vec3fDistSq(&this->actor.world.pos, &this->actor.prevPos) < 0.01f) { diff --git a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c index 5dac29b65..2ec24e73e 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -7,7 +7,7 @@ #include "z_obj_funen.h" #include "objects/object_funen/object_funen.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjFunen*)thisx) @@ -35,7 +35,7 @@ void ObjFunen_Draw(Actor* thisx, GlobalContext* globalCtx) { OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateY((s16)(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); + Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - 0x8000), MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); 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 b7f0a8105..c41ee530b 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -7,7 +7,7 @@ #include "z_obj_ghaka.h" #include "objects/object_ghaka/object_ghaka.h" -#define FLAGS 0x00000029 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_20) #define THIS ((ObjGhaka*)thisx) @@ -97,23 +97,23 @@ void func_80B3C4E0(ObjGhaka* this, GlobalContext* globalCtx) { u8 talkState = Message_GetState(&globalCtx->msgCtx); if (talkState == 5) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { globalCtx->msgCtx.msgMode = 0x43; globalCtx->msgCtx.unk12023 = 4; func_80B3C260(this); } } else if (talkState == 4) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (globalCtx->msgCtx.choiceIndex) { case 0: func_8019F208(); this->dyna.actor.textId = 0xCF5; - func_801518B0(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); break; case 1: func_8019F208(); this->dyna.actor.textId = 0xCF7; - func_801518B0(globalCtx, this->dyna.actor.textId, &this->dyna.actor); + Message_StartTextbox(globalCtx, this->dyna.actor.textId, &this->dyna.actor); break; case 2: func_8019F230(); 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 8dc01d386..d95cc0631 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.c @@ -5,8 +5,10 @@ */ #include "z_obj_grass.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjGrass*)thisx) @@ -15,7 +17,13 @@ void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx); void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +ObjGrassStruct1* D_809AADA0[4]; +f32 D_809AADB0[4]; +ObjGrassStruct1_1* D_809AADC0[20]; +f32 D_809AAE10[20]; + +#include "overlays/ovl_Obj_Grass/ovl_Obj_Grass.c" + const ActorInit Obj_Grass_InitVars = { ACTOR_OBJ_GRASS, ACTORCAT_PROP, @@ -28,41 +36,486 @@ const ActorInit Obj_Grass_InitVars = { (ActorFunc)ObjGrass_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809AAB20 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x0580C71C, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x0580C71C, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 6, 44, 0, { 0, 0, 0 } }, }; -#endif +Vec3f D_809AAB4C[] = { + { 0.0f, 0.707099974155f, 0.707099974155f }, + { 0.707099974155f, 0.707099974155f, 0.0f }, + { 0.0f, 0.707099974155f, -0.707099974155f }, + { -0.707099974155f, 0.707099974155f, 0.0f }, +}; -extern ColliderCylinderInit D_809AAB20; +s16 D_809AAB7C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9110.s") +s32 func_809A9110(GlobalContext* globalCtx, Vec3f* arg1) { + f32 sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A91FC.s") + SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, &sp20, &sp2C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A92D0.s") + if ((globalCtx->unk_187F0.z * -130.13191f) < sp20.z) { + if (sp2C < 1.0f) { + sp2C = 1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9314.s") + if (((fabsf(sp20.x) - (130.13191f * globalCtx->unk_187F0.x)) < sp2C) && + ((fabsf(sp20.y) - (130.13191f * globalCtx->unk_187F0.y)) < sp2C)) { + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Init.s") +void func_809A91FC(MtxF* matrix) { + s32 i; + MtxF* temp = Matrix_GetCurrentState(); + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Destroy.s") + for (i = 0; i < 16; i++) { + *tmp++ += *tmp2++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9790.s") +void func_809A92D0(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + if (!(ptr->unk_0E & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, &ptr->unk_00, ptr->unk_0E * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A983C.s") +void func_809A9314(ObjGrassStruct1_1* ptr, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809A9DB8.s") + for (i = 0; i < ARRAY_COUNT(D_809AAB4C); i++) { + ptr2 = &D_809AAB4C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Update.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 8.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 8.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA278.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA54C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/func_809AA798.s") + spB0.x = ptr->unk_00.x + (ptr2->x * 16.0f); + spB0.y = (ptr->unk_00.y + (ptr2->y * 16.0f)) + 10.0f; + spB0.z = ptr->unk_00.z + (ptr2->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass/ObjGrass_Draw.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; + + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809AAB7C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); + } +} + +void ObjGrass_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + Actor_SetScale(&this->actor, 0.4f); + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_InitCylinder(globalCtx, &this->unk_2948[i].collider); + Collider_SetCylinder(globalCtx, &this->unk_2948[i].collider, &this->actor, &sCylinderInit); + } + + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_3288 = (u32)Rand_Next() >> 0x10; + this->unk_328A = (u32)Rand_Next() >> 0x10; + this->unk_328C = (u32)Rand_Next() >> 0x10; + this->unk_328E = (u32)Rand_Next() >> 0x10; + this->unk_3290 = (u32)Rand_Next() >> 0x10; +} + +void ObjGrass_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + Collider_DestroyCylinder(globalCtx, &this->unk_2948[i].collider); + } + + for (i = 0; i < ARRAY_COUNT(this->unk_3298); i++) { + ObjGrassCarry** ptr = &this->unk_3298[i]; + + if (*ptr != NULL) { + (*ptr)->unk_190 = 0; + *ptr = NULL; + } + } +} + +void func_809A9790(ObjGrass* this, GlobalContext* globalCtx) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ObjGrassStruct1_1* ptr = this->unk_2948[i].unk_4C; + + if ((ptr != NULL) && (this->unk_2948[i].collider.base.acFlags & AC_HIT)) { + func_809A9314(ptr, globalCtx); + func_809A92D0(ptr, globalCtx); + ptr->unk_0F |= 4; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &ptr->unk_00, 20, NA_SE_EV_PLANT_BROKEN); + } + } +} + +void func_809A983C(ObjGrass* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 i; + s32 j; + s32 x; + s32 y; + f32 temp_f0; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + ObjGrassStruct2* ptr3; + s16 yaw; + + for (i = 0; i < ARRAY_COUNT(D_809AADC0); i++) { + D_809AADC0[i] = NULL; + D_809AAE10[i] = 422500.0f; + } + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + D_809AADA0[i] = NULL; + D_809AADB0[i] = 422500.0f; + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr->unk_0C[j].unk_0F &= (u16)~2; + } + } + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_00, &player->actor.world.pos); + + for (j = 0; j < ARRAY_COUNT(D_809AADB0); j++) { + if (temp_f0 < D_809AADB0[j]) { + break; + } + } + + if (j < ARRAY_COUNT(D_809AADB0)) { + for (x = 2; x >= j; x--) { + D_809AADB0[x + 1] = D_809AADB0[x]; + D_809AADA0[x + 1] = D_809AADA0[x]; + } + + D_809AADB0[j] = temp_f0; + D_809AADA0[j] = ptr; + } + } + + this->unk_3294 = NULL; + + for (i = 0; i < ARRAY_COUNT(D_809AADA0); i++) { + ptr = D_809AADA0[i]; + + if (ptr != NULL) { + for (j = 0; j < ptr->unk_FC; j++) { + if (!(ptr->unk_0C[j].unk_0F & 4)) { + temp_f0 = Math3D_Vec3fDistSq(&ptr->unk_0C[j].unk_00, &player->actor.world.pos); + + for (x = 0; x < ARRAY_COUNT(D_809AAE10); x++) { + if (temp_f0 < D_809AAE10[x]) { + break; + } + } + + if (x < ARRAY_COUNT(D_809AAE10)) { + for (y = 18; y >= x; y--) { + D_809AAE10[y + 1] = D_809AAE10[y]; + D_809AADC0[y + 1] = D_809AADC0[y]; + } + + D_809AAE10[x] = temp_f0; + D_809AADC0[x] = &ptr->unk_0C[j]; + + if (temp_f0 < 2500.0f) { + yaw = player->actor.shape.rot.y - + Math_Vec3f_Yaw(&player->actor.world.pos, &ptr->unk_0C[j].unk_00); + + if (ABS_ALT(yaw) < 0x2000) { + this->unk_3294 = &ptr->unk_0C[j]; + } + } + } + } + } + } + } + + for (i = 0; i < ARRAY_COUNT(this->unk_2948); i++) { + ptr3 = &this->unk_2948[i]; + + ptr3->collider.base.acFlags &= (u16)~AC_HIT; + ptr3->collider.base.ocFlags1 &= (u16)~OC1_HIT; + + ptr2 = D_809AADC0[i]; + if (ptr2 != NULL) { + ptr3->collider.dim.pos.x = ptr2->unk_00.x; + ptr3->collider.dim.pos.y = ptr2->unk_00.y; + ptr3->collider.dim.pos.z = ptr2->unk_00.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &ptr3->collider.base); + ptr2->unk_0F |= 2; + ptr3->unk_4C = ptr2; + } else { + ptr3->unk_4C = NULL; + } + } +} + +void func_809A9DB8(ObjGrass* this) { + s32 i; + s32 pad; + f32* ptr; + f32 temp_f28; + f32 spA4; + f32 spA0; + f32 temp_f22; + f32 temp_f24; + f32 sp94; + f32 sp90; + f32 temp_f26; + f32 sp6C[8]; + f32 tempf1; + f32 tempf2; + f32 tempf3; + f32 tempf4; + f32 tempf5; + f32 temp_f16; + f32 temp_f20; + + this->unk_3288 += 70; + this->unk_328A += 300; + this->unk_328C += 700; + this->unk_328E += 1300; + this->unk_3290 += 8900; + + temp_f24 = Math_SinS(this->unk_3288); + temp_f28 = Math_SinS(this->unk_328A); + temp_f26 = Math_SinS(this->unk_328C); + spA4 = Math_SinS(this->unk_328E) * 1.2f; + spA0 = Math_SinS(this->unk_3290) * 1.5f; + temp_f22 = Math_CosS(this->unk_3288); + temp_f20 = Math_CosS(this->unk_328A); + sp94 = Math_CosS(this->unk_328C); + sp90 = Math_CosS(this->unk_328E) * 1.3f; + temp_f16 = Math_CosS(this->unk_3290) * 1.7f; + + sp6C[0] = (temp_f24 - temp_f20) * temp_f26 * temp_f22 * temp_f24 * 0.0015f; + sp6C[1] = (temp_f28 - sp94) * spA4 * temp_f20 * temp_f24 * 0.0015f; + sp6C[2] = (temp_f26 - sp90) * sp94 * temp_f24 * temp_f22 * 0.0015f; + sp6C[3] = (spA4 - temp_f20) * sp90 * temp_f28 * temp_f22 * 0.0015f; + sp6C[4] = (temp_f24 - sp94) * temp_f24 * temp_f28 * spA0 * 0.0015f; + sp6C[5] = (temp_f28 - sp90) * temp_f26 * spA4 * spA0 * 0.0015f; + sp6C[6] = (temp_f26 - temp_f22) * temp_f22 * temp_f20 * temp_f16 * 0.0015f; + sp6C[7] = (spA4 - temp_f20) * sp94 * sp90 * temp_f16 * 0.0015f; + + for (i = 0; i < ARRAY_COUNT(this->unk_2F88); i++) { + ptr = &this->unk_2F88[i].mf[0][0]; + + tempf1 = sp6C[(i + 0) & 7]; + tempf2 = sp6C[(i + 1) & 7]; + tempf3 = sp6C[(i + 2) & 7]; + tempf4 = sp6C[(i + 3) & 7]; + tempf5 = sp6C[(i + 4) & 7]; + + ptr[0] = sp6C[1] * 0.2f; + ptr[1] = tempf1; + ptr[2] = tempf2; + ptr[3] = 0.0f; + + ptr[4] = tempf3; + ptr[5] = sp6C[0]; + ptr[6] = tempf3; + ptr[7] = 0.0f; + + ptr[8] = tempf4; + ptr[9] = tempf5; + ptr[10] = sp6C[3] * 0.2f; + ptr[11] = 0.0f; + + ptr[12] = 0.0f; + ptr[13] = 0.0f; + ptr[14] = 0.0f; + ptr[15] = 0.0f; + } +} + +void ObjGrass_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809A9790(this, globalCtx); + func_809A983C(this, globalCtx); + func_809A9DB8(this); +} + +void func_809AA278(ObjGrass* this, GlobalContext* globalCtx) { + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + f32 distSq; + f32 temp_f22; + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + temp_f22 = Math3D_Vec3fDistSq(&ptr->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + + if ((temp_f22 < SQ(1280.0f)) && func_809A9110(globalCtx, &ptr->unk_00)) { + ptr->unk_FE |= 1; + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if (ptr2->unk_0F & 4) { + ptr2->unk_10 = 255; + ptr2->unk_0F &= ~1; + } else { + ptr2->unk_0F |= 1; + if (temp_f22 < SQ(980.0f)) { + ptr2->unk_10 = 255; + } else { + distSq = Math3D_Vec3fDistSq(&ptr2->unk_00, &GET_ACTIVE_CAM(globalCtx)->eye); + if ((distSq <= SQ(1080.0f)) || ((ptr2->unk_0F & 8) && (distSq < SQ(1180.0f)))) { + ptr2->unk_10 = 255; + } else if (distSq >= SQ(1180.0f)) { + ptr2->unk_10 = 0; + } else { + ptr2->unk_10 = (1180.0f - sqrtf(distSq)) * 2.55f; + } + } + } + } + } else { + ptr->unk_FE &= ~1; + } + } +} + +void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { + ObjGrass* this = THIS; + GlobalContext* globalCtx = globalCtx2; + Lights* temp_s0; + ObjGrassStruct1* ptr; + s32 i; + s32 j; + Vec3s sp70 = { 0, 0, 0 }; + ObjGrassStruct1_1* ptr2; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AA9F0); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + temp_s0 = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); + Lights_BindAll(temp_s0, globalCtx->lightCtx.listHead, &ptr->unk_00, globalCtx); + Lights_Draw(temp_s0, globalCtx->state.gfxCtx); + + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 == 255)) { + sp70.y = ptr2->unk_0C; + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp70); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if (ptr2->unk_0F & 2) { + func_809A91FC(&this->unk_2F88[j]); + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + ObjGrassStruct1* ptr; + ObjGrassStruct1_1* ptr2; + s32 i; + s32 j; + Vec3s sp6C = { 0, 0, 0 }; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAA68); + + for (i = 0; i < this->unk_2944; i++) { + ptr = &this->unk_144[i]; + + if (ptr->unk_FE & 1) { + for (j = 0; j < ptr->unk_FC; j++) { + ptr2 = &ptr->unk_0C[j]; + + if ((ptr2->unk_0F & 1) && (ptr2->unk_10 > 0) && (ptr2->unk_10 < 255)) { + sp6C.y = ptr2->unk_0C; + Matrix_SetStateRotationAndTranslation(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, &sp6C); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, ptr2->unk_10); + gSPDisplayList(POLY_XLU_DISP++, gObjGrass_D_809AAAE0); + } + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjGrass_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjGrass* this = THIS; + + func_809AA278(this, globalCtx); + func_809AA54C(thisx, globalCtx); + func_809AA798(thisx, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h index e05e1618e..1c87108df 100644 --- a/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h +++ b/src/overlays/actors/ovl_Obj_Grass/z_obj_grass.h @@ -2,12 +2,46 @@ #define Z_OBJ_GRASS_H #include "global.h" +#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h" struct ObjGrass; +struct ObjGrassCarry; + +typedef struct ObjGrassStruct1_1 { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ u8 unk_0F; + /* 0x10 */ u8 unk_10; + /* 0x11 */ UNK_TYPE1 unk_11[0x3]; +} ObjGrassStruct1_1; // size = 0x14 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ ObjGrassStruct1_1 unk_0C[12]; + /* 0xFC */ s16 unk_FC; + /* 0xFE */ u8 unk_FE; +} ObjGrassStruct1; // size = 0x100 + +typedef struct { + /* 0x00 */ ColliderCylinder collider; + /* 0x4C */ ObjGrassStruct1_1* unk_4C; +} ObjGrassStruct2; // size = 0x50 typedef struct ObjGrass { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_0144[0x315C]; + /* 0x0144 */ ObjGrassStruct1 unk_144[40]; + /* 0x2944 */ s16 unk_2944; + /* 0x2948 */ ObjGrassStruct2 unk_2948[20]; + /* 0x2F88 */ MtxF unk_2F88[12]; + /* 0x3288 */ s16 unk_3288; + /* 0x328A */ s16 unk_328A; + /* 0x328C */ s16 unk_328C; + /* 0x328E */ s16 unk_328E; + /* 0x3290 */ s16 unk_3290; + /* 0x3292 */ s16 unk_3292; + /* 0x3294 */ ObjGrassStruct1_1* unk_3294; + /* 0x3298 */ struct ObjGrassCarry* unk_3298[2]; } ObjGrass; // size = 0x32A0 extern const ActorInit Obj_Grass_InitVars; 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 4d717fabd..2e9df3323 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 @@ -5,8 +5,11 @@ */ #include "z_obj_grass_carry.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_Obj_Grass/z_obj_grass.h" -#define FLAGS 0x00800030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_800000) #define THIS ((ObjGrassCarry*)thisx) @@ -14,7 +17,18 @@ void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809AB3C4(ObjGrassCarry* this); +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB428(ObjGrassCarry* this); +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB474(ObjGrassCarry* this); +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB5FC(ObjGrassCarry* this); +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809AB6FC(ObjGrassCarry* this); +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx); +void func_809ABB7C(Actor* this, GlobalContext* globalCtx); + const ActorInit Obj_Grass_Carry_InitVars = { ACTOR_OBJ_GRASS_CARRY, ACTORCAT_PROP, @@ -27,61 +41,320 @@ const ActorInit Obj_Grass_Carry_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809ABBD0 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_2, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 10, 44, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809ABC4C[] = { +s16 D_809ABBFC = 0; +s16 D_809ABC00 = 0; +s16 D_809ABC04 = 0; +s16 D_809ABC08 = 0; + +Vec3f D_809ABC0C[] = { + { 0.0f, 0.7071f, 0.7071f }, + { 0.7071f, 0.7071f, 0.0f }, + { 0.0f, 0.7071f, -0.7071f }, + { -0.7071f, 0.7071f, 0.0f }, +}; + +s16 D_809ABC3C[] = { 0x6C, 0x66, 0x60, 0x54, 0x42, 0x37, 0x2A, 0x26 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -3200, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -17000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_STOP), }; -#endif +void func_809AAE60(ObjGrassCarry* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -extern ColliderCylinderInit D_809ABBD0; -extern InitChainEntry D_809ABC4C[]; +void func_809AAE94(Vec3f* arg0, f32 arg1) { + arg1 += ((Rand_ZeroOne() * 0.2f) - 0.1f) * arg1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE60.s") + arg0->x -= (arg0->x * arg1); + arg0->y -= (arg0->y * arg1); + arg0->z -= (arg0->z * arg1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAE94.s") +void func_809AAF18(ObjGrassCarry* this) { + func_809AAE60(this); + func_809AAE94(&this->actor.velocity, 0.05f); + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF18.s") +void func_809AAF58(ObjGrassCarry* this, GlobalContext* globalCtx) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 7.5f, 35.0f, 0.0f, 0xC5); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF58.s") +void func_809AAF9C(Vec3f* arg0, s16 arg1, GlobalContext* globalCtx) { + if (!(arg1 & 0x10)) { + Item_DropCollectibleRandom(globalCtx, NULL, arg0, arg1 * 0x10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAF9C.s") +void func_809AAFE8(Vec3f* arg0, GlobalContext* globalCtx) { + Vec3f spBC; + Vec3f spB0; + s32 i; + Vec3f* ptr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AAFE8.s") + for (i = 0; i < ARRAY_COUNT(D_809ABC0C); i++) { + ptr = &D_809ABC0C[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Init.s") + spB0.x = arg0->x + (ptr->x * 8.0f); + spB0.y = arg0->y + (ptr->y * 8.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 8.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Destroy.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 8.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 8.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3C4.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) & 7], 0, 0, 80, -1, 1, gKakeraLeafMiddle); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB3D8.s") + spB0.x = arg0->x + (ptr->x * 16.0f); + spB0.y = arg0->y + (ptr->y * 16.0f) + 10.0f; + spB0.z = arg0->z + (ptr->z * 16.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB428.s") + spBC.x = (Rand_ZeroOne() - 0.5f) * 6.0f; + spBC.y = Rand_ZeroOne() * 10.0f; + spBC.z = (Rand_ZeroOne() - 0.5f) * 6.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB43C.s") + EffectSsKakera_Spawn(globalCtx, &spB0, &spBC, &spB0, -100, 64, 40, 3, 0, + D_809ABC3C[(s32)(Rand_ZeroOne() * 111.1f) % 7], 0, 0, 80, -1, 1, gKakeraLeafTip); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB474.s") +void ObjGrassCarry_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB4A8.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = 80; + func_809AB3C4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB5FC.s") +void ObjGrassCarry_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB610.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB6FC.s") + if (this->unk_190 != NULL) { + ObjGrassCarry** carry = &this->unk_190->unk_3298[this->actor.params]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809AB77C.s") + if (this == *carry) { + *carry = NULL; + this->unk_190 = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/ObjGrassCarry_Update.s") +void func_809AB3C4(ObjGrassCarry* this) { + this->actionFunc = func_809AB3D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Grass_Carry/func_809ABB7C.s") +void func_809AB3D8(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->unk_190 != NULL) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } else { + func_809AB428(this); + } + } +} + +void func_809AB428(ObjGrassCarry* this) { + this->actionFunc = func_809AB43C; +} + +void func_809AB43C(ObjGrassCarry* this, GlobalContext* globalCtx) { + if (this->actor.params != this->unk_190->unk_3292) { + func_809AB474(this); + } +} + +void func_809AB474(ObjGrassCarry* this) { + this->actor.shape.rot.z = 0; + this->actionFunc = func_809AB4A8; + this->unk_194 = NULL; + this->actor.shape.rot.y = this->actor.shape.rot.z; + this->actor.shape.rot.x = this->actor.shape.rot.z; + this->actor.world.rot.z = this->actor.shape.rot.z; + this->actor.world.rot.y = this->actor.shape.rot.z; + this->actor.world.rot.x = this->actor.shape.rot.z; +} + +void func_809AB4A8(ObjGrassCarry* this, GlobalContext* globalCtx) { + ObjGrassCarry* this2 = this; + + if (Actor_HasParent(&this->actor, globalCtx)) { + func_809AB5FC(this); + if (this->unk_194 != NULL) { + this->unk_194->unk_0F |= 4; + } + this->actor.draw = func_809ABB7C; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.shape.shadowAlpha = 60; + this->actor.shape.shadowScale = 1.0f; + this->unk_190->unk_3292 ^= 1; + this->actor.room = -1; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_PL_PULL_UP_PLANT); + } else if (this->unk_190->unk_3294 != NULL) { + Player* player = GET_PLAYER(globalCtx); + + this->unk_194 = this->unk_190->unk_3294; + 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.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, globalCtx); + } +} + +void func_809AB5FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB610; +} + +void func_809AB610(ObjGrassCarry* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + 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.gravity = -0.1f; + this->actor.terminalVelocity = -17.0f; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + this->actor.gravity = -3.2f; + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_809AB6FC(ObjGrassCarry* this) { + this->actionFunc = func_809AB77C; + D_809ABBFC = -0xBB8; + D_809ABC04 = (Rand_ZeroOne() - 0.5f) * 1600.0f; + D_809ABC00 = 0; + D_809ABC08 = 0; + this->unk_19A = 60; +} + +void func_809AB77C(ObjGrassCarry* this, GlobalContext* globalCtx) { + s16 phi_s0; + s32 temp_v0 = (this->collider.base.atFlags & AT_HIT) != 0; + Vec3f sp5C; + s32 i; + + if (temp_v0) { + this->collider.base.atFlags &= ~AT_HIT; + } + + this->unk_19A--; + + if ((this->actor.bgCheckFlags & (1 | 2 | 8)) || temp_v0 || (this->unk_19A <= 0)) { + func_809AAFE8(&this->actor.world.pos, globalCtx); + func_809AAF9C(&this->actor.world.pos, this->unk_198, globalCtx); + + this->actor.draw = NULL; + this->actor.shape.shadowDraw = NULL; + + if (this->unk_190 != NULL) { + this->actor.room = this->unk_190->actor.room; + } + + if (!(this->actor.bgCheckFlags & 0x20)) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_PLANT_BROKEN); + } + func_809AB428(this); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { + sp5C.y = this->actor.world.pos.y + this->actor.depthInWater; + + for (phi_s0 = 0, i = 0; i < 4; i++, phi_s0 += 0x4000) { + sp5C.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp5C.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 190); + } + + sp5C.x = this->actor.world.pos.x; + sp5C.z = this->actor.world.pos.z; + + EffectSsGSplash_Spawn(globalCtx, &sp5C, NULL, NULL, 0, 280); + EffectSsGRipple_Spawn(globalCtx, &sp5C, 300, 700, 0); + + this->actor.terminalVelocity = -3.0f; + this->actor.velocity.x *= 0.1f; + this->actor.velocity.y *= 0.4f; + this->actor.velocity.z *= 0.1f; + this->actor.gravity *= 0.5f; + + D_809ABC00 = D_809ABC00 >> 1; + D_809ABBFC = D_809ABBFC >> 1; + D_809ABC08 = D_809ABC08 >> 1; + D_809ABC04 = D_809ABC04 >> 1; + this->actor.bgCheckFlags &= ~0x40; + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + } + + Math_StepToS(&D_809ABC00, D_809ABBFC, 0x1F4); + Math_StepToS(&D_809ABC08, D_809ABC04, 0xAA); + this->actor.shape.rot.x += D_809ABC00; + this->actor.shape.rot.y += D_809ABC08; + func_809AAF18(this); + func_809AAF58(this, globalCtx); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjGrassCarry_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjGrassCarry* this = THIS; + + if (this->unk_190 == NULL) { + if ((this->actionFunc != func_809AB610) && (this->actionFunc != func_809AB77C)) { + Actor_MarkForDeath(&this->actor); + return; + } + } + + this->actionFunc(this, globalCtx); +} + +void func_809ABB7C(Actor* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gKusaBushType1); +} diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h index 90ded06c5..50d2f61f7 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h +++ b/src/overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h @@ -4,12 +4,18 @@ #include "global.h" struct ObjGrassCarry; +struct ObjGrass; +struct ObjGrassStruct1_1; typedef void (*ObjGrassCarryActionFunc)(struct ObjGrassCarry*, GlobalContext*); typedef struct ObjGrassCarry { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x58]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ struct ObjGrass* unk_190; + /* 0x0194 */ struct ObjGrassStruct1_1* unk_194; + /* 0x0198 */ s16 unk_198; + /* 0x019A */ s16 unk_19A; /* 0x019C */ ObjGrassCarryActionFunc actionFunc; } ObjGrassCarry; // size = 0x1A0 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 978f2cd13..4b96d3a77 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -5,8 +5,9 @@ */ #include "z_obj_hakaisi.h" +#include "objects/object_hakaisi/object_hakaisi.h" -#define FLAGS 0x00000029 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_20) #define THIS ((ObjHakaisi*)thisx) @@ -15,7 +16,27 @@ void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHakaisi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B1444C(ObjHakaisi* this); +void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14510(ObjHakaisi* this); +void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14558(ObjHakaisi* this); +void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B145F4(ObjHakaisi* this); +void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B149A8(ObjHakaisi* this); +void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B14A24(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec); +void func_80B14B6C(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec, s16 arg3); +void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 arg4); +void func_80B14F4C(ObjHakaisi* this, GlobalContext* globalCtx, s32 arg2); +void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B15254(Actor* thisx, GlobalContext* globalCtx); +void func_80B15264(ObjHakaisi* this); +void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx); +void func_80B1544C(Actor* thisx, GlobalContext* globalCtx); +void func_80B154A0(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Hakaisi_InitVars = { ACTOR_OBJ_HAKAISI, ACTORCAT_PROP, @@ -28,57 +49,395 @@ const ActorInit Obj_Hakaisi_InitVars = { (ActorFunc)ObjHakaisi_Draw, }; -#endif +Vec3f D_80B155B0 = { 0.0f, 25.0f, 30.0f }; -extern UNK_TYPE D_06001F10; -extern UNK_TYPE D_060021B0; -extern UNK_TYPE D_06002650; -extern UNK_TYPE D_06002FC4; +Vec3f D_80B155BC[] = { { 0.0f, 65.0f, 8.0f }, { 0.0f, 35.0f, 8.0f }, { 0.0f, 15.0f, 8.0f } }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Init.s") +Vec3f D_80B155E0 = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Destroy.s") +Vec3f D_80B155EC = { 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1444C.s") +Color_RGBA8 D_80B155F8 = { 170, 130, 90, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14460.s") +Color_RGBA8 D_80B155FC = { 100, 60, 20, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14510.s") +Vec3f D_80B15600 = { 1.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14524.s") +void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHakaisi* this = THIS; + CollisionHeader* sp7C = NULL; + MtxF sp3C; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14558.s") + switch (OBJHAKAISI_GET_FF(&this->dyna.actor)) { + case 0: + this->dyna.actor.textId = 0x13F9; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1456C.s") + case 1: + this->dyna.actor.textId = 0x13FA; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B145F4.s") + case 2: + this->dyna.actor.textId = 0x13FB; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14648.s") + case 3: + this->dyna.actor.textId = 0x13FC; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B149A8.s") + case 4: + case 5: + func_80B151E0(this, globalCtx); + return; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B149C0.s") + default: + this->dyna.actor.textId = 0x1412; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14A24.s") + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.targetMode = 0; + this->dyna.actor.colChkInfo.health = 30; + if (OBJHAKAISI_GET_FF(&this->dyna.actor) == 3) { + this->dyna.actor.draw = NULL; + func_80B1444C(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14B6C.s") + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&object_hakaisi_Colheader_002FC4, &sp7C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14CF8.s") + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B14F4C.s") + if (this->switchFlag == 0xFF) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Update.s") + if ((this->switchFlag != -1) && Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/ObjHakaisi_Draw.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B151E0.s") + if (this->dyna.actor.floorPoly == NULL) { + Actor_MarkForDeath(&this->dyna.actor); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15254.s") + func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, + this->dyna.actor.world.pos.z, &sp3C); + Matrix_SetCurrentState(&sp3C); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp3C); + func_8018219C(&sp3C, &this->dyna.actor.shape.rot, 1); + this->dyna.actor.world.rot = this->dyna.actor.shape.rot; + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&D_80B155B0, &this->dyna.actor.focus.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15264.s") + for (i = 0; i < ARRAY_COUNT(D_80B155BC); i++) { + Matrix_MultiplyVector3fByState(&D_80B155BC[i], &this->unk_160[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B15330.s") + func_80B1444C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B1544C.s") +void ObjHakaisi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hakaisi/func_80B154A0.s") + if (OBJHAKAISI_GET_FF(&this->dyna.actor) != 3) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void func_80B1444C(ObjHakaisi* this) { + this->actionFunc = func_80B14460; +} + +void func_80B14460(ObjHakaisi* this, GlobalContext* globalCtx) { + s16 sp26 = BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.yawTowardsPlayer); + + if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + func_80B14510(this); + } else if (this->dyna.actor.textId != 0) { + if (ABS_ALT(sp26) < 0x2000) { + func_800B8614(&this->dyna.actor, globalCtx, 100.0f); + } + } + + if (this->unk_198 == 1) { + func_80B14558(this); + } +} + +void func_80B14510(ObjHakaisi* this) { + this->actionFunc = func_80B14524; +} + +void func_80B14524(ObjHakaisi* this, GlobalContext* globalCtx) { + if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { + func_80B1444C(this); + } +} + +void func_80B14558(ObjHakaisi* this) { + this->actionFunc = func_80B1456C; +} + +void func_80B1456C(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_196 != -1) { + if (ActorCutscene_GetCanPlayNext(this->unk_196)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_196, &this->dyna.actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_196); + } + } + if (this->dyna.actor.colChkInfo.health < 30) { + func_80B145F4(this); + func_800C62BC(globalCtx, &globalCtx->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_1; + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = func_80B14648; +} + +void func_80B14648(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_19A < 2) { + func_80B14CF8(globalCtx, this->unk_160[this->unk_194], 100, 30, 5); + } + + this->unk_19A++; + + if (this->dyna.actor.colChkInfo.health == 0) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 70); + Flags_SetSwitch(globalCtx, this->switchFlag); + this->dyna.actor.draw = NULL; + func_80B149A8(this); + } + + if (this->unk_19E != this->dyna.actor.colChkInfo.health) { + if ((this->unk_19E > 20) && (this->dyna.actor.colChkInfo.health <= 20)) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14F4C(this, globalCtx, 0); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 40); + this->unk_194 = 1; + } else if ((this->unk_19E > 10) && (this->dyna.actor.colChkInfo.health <= 10)) { + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14A24(this, globalCtx, this->unk_160[this->unk_194]); + func_80B14B6C(this, globalCtx, this->unk_160[this->unk_194], 60); + this->unk_194 = 2; + } + this->unk_19A = 0; + this->dyna.actor.shape.yOffset -= 3.0f; + } + + Math_ApproachZeroF(&this->dyna.actor.shape.yOffset, 0.8f, 100.0f); + this->unk_19E = this->dyna.actor.colChkInfo.health; +} + +void func_80B149A8(ObjHakaisi* this) { + this->unk_19A = 0; + this->actionFunc = func_80B149C0; +} + +void func_80B149C0(ObjHakaisi* this, GlobalContext* globalCtx) { + if (this->unk_19A < 60) { + this->unk_19A++; + } else if ((this->unk_196 != -1) && !ActorCutscene_GetCanPlayNext(this->unk_196)) { + ActorCutscene_Stop(this->unk_196); + } +} + +void func_80B14A24(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec) { + s32 i; + + func_80B14CF8(globalCtx, vec, 100, 30, 5); + + for (i = 0; i < 5; i++) { + vec.x += Rand_Centered() * 20.0f; + vec.y += Rand_ZeroOne() * 5.0f; + vec.z += Rand_Centered() * 20.0f; + EffectSsHahen_SpawnBurst(globalCtx, &vec, 5.0f, 0, 20, 15, 3, OBJECT_HAKAISI, 10, object_hakaisi_DL_0021B0); + } +} + +void func_80B14B6C(ObjHakaisi* this, GlobalContext* globalCtx, Vec3f vec, s16 arg3) { + s32 i; + s16 temp_s1; + Vec3f sp6C; + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WALL_BROKEN); + + for (i = 0; i < 5; i++) { + temp_s1 = Rand_Next(); + + sp6C.x = (Math_SinS(temp_s1) * 15.0f) + vec.x; + sp6C.y = (Rand_ZeroOne() * 3.0f) + vec.y; + sp6C.z = (Math_CosS(temp_s1) * 15.0f) + vec.z; + + EffectSsHahen_SpawnBurst(globalCtx, &sp6C, 10.0f, 0, arg3, 30, 2, OBJECT_HAKAISI, 15, object_hakaisi_DL_0021B0); + } + + func_80B14CF8(globalCtx, vec, 100, 50, 20); +} + +void func_80B14CF8(GlobalContext* globalCtx, Vec3f vec, s16 arg2, s16 arg3, s32 arg4) { + s32 i; + s16 temp_s0; + Vec3f spAC; + Vec3f spA0 = D_80B155E0; + Vec3f sp94 = D_80B155EC; + f32 temp_f20; + f32 temp_f22; + + for (i = 0; i < arg4; i++) { + temp_f20 = Rand_ZeroOne() * 30.0f; + temp_f22 = Rand_ZeroOne() * 1.5f; + temp_s0 = Rand_Next(); + + spAC.x = (Math_SinS(temp_s0) * temp_f20) + vec.x; + spAC.y = (Rand_Centered() * 4.0f) + vec.y; + spAC.z = (Math_CosS(temp_s0) * temp_f20) + vec.z; + + spA0.x += temp_f22 * Math_SinS(temp_s0); + spA0.y += Rand_Centered() + 0.5f; + spA0.z += temp_f22 * Math_CosS(temp_s0); + + sp94.x = -0.1f * spA0.x; + sp94.y = -0.1f * spA0.y; + sp94.z = -0.1f * spA0.z; + + func_800B0EB0(globalCtx, &spAC, &spA0, &sp94, &D_80B155F8, &D_80B155FC, arg2, arg3, 10); + } +} + +void func_80B14F4C(ObjHakaisi* this, GlobalContext* globalCtx, s32 arg2) { + if (arg2 == 0) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_HAKAISI, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + 55.0f, this->dyna.actor.world.pos.z - 10.0f, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 4); + } else { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_HAKAISI, this->dyna.actor.world.pos.x + 20.0f, + this->dyna.actor.world.pos.y + 30.0f, this->dyna.actor.world.pos.z - 10.0f, + this->dyna.actor.shape.rot.x, this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 5); + } +} + +void ObjHakaisi_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void ObjHakaisi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_194 == 0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_002650); + } else if (this->unk_194 == 1) { + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_0029C0); + } else { + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_002CC0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void func_80B151E0(ObjHakaisi* this, GlobalContext* globalCtx) { + this->dyna.actor.update = func_80B1544C; + this->dyna.actor.draw = func_80B154A0; + this->dyna.actor.destroy = func_80B15254; + Actor_SetScale(&this->dyna.actor, 0.1f); + this->dyna.actor.shape.yOffset = 100.0f; + this->dyna.actor.flags &= ~ACTOR_FLAG_1; + func_80B15264(this); +} + +void func_80B15254(Actor* thisx, GlobalContext* globalCtx) { +} + +void func_80B15264(ObjHakaisi* this) { + s32 pad; + s16 sp32 = Rand_Next(); + + Matrix_InsertRotation(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&D_80B15600, &this->unk_184); + this->dyna.actor.gravity = -1.0f; + this->unk_19C = Rand_Next() >> 0x12; + this->dyna.actor.velocity.x = Math_SinS(sp32) * 4.0f; + this->dyna.actor.velocity.z = Math_CosS(sp32) * 4.0f; + this->dyna.actor.velocity.y = 7.0f; + this->actionFunc = func_80B15330; +} + +void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx) { + s32 pad; + MtxF sp34; + + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + Actor_UpdatePos(&this->dyna.actor); + + if (this->dyna.actor.bgCheckFlags & 2) { + func_80B14B6C(this, globalCtx, this->dyna.actor.world.pos, 40); + func_80B14CF8(globalCtx, this->dyna.actor.world.pos, 100, 30, 10); + Actor_MarkForDeath(&this->dyna.actor); + } + + Matrix_InsertRotationAroundUnitVector_s(this->unk_19C, &this->unk_184, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z, MTXMODE_APPLY); + Matrix_CopyCurrentState(&sp34); + + func_8018219C(&sp34, &this->dyna.actor.shape.rot, 0); +} + +void func_80B1544C(Actor* thisx, GlobalContext* globalCtx) { + ObjHakaisi* this = THIS; + + this->actionFunc(this, globalCtx); + + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); +} + +void func_80B154A0(Actor* thisx, GlobalContext* globalCtx) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (OBJHAKAISI_GET_FF(thisx) == 4) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_001F10); + } else { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_hakaisi_DL_0021B0); + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 5c6f1a64a..4f1d1ada9 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -7,13 +7,21 @@ struct ObjHakaisi; typedef void (*ObjHakaisiActionFunc)(struct ObjHakaisi*, GlobalContext*); +#define OBJHAKAISI_GET_FF(thisx) ((thisx)->params & 0xFF) +#define OBJHAKAISI_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct ObjHakaisi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjHakaisiActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x38]; + /* 0x0160 */ Vec3f unk_160[3]; + /* 0x0184 */ Vec3f unk_184; + /* 0x0190 */ s32 switchFlag; + /* 0x0194 */ s16 unk_194; + /* 0x0196 */ s16 unk_196; /* 0x0198 */ s16 unk_198; - /* 0x019A */ char unk_19A[0x6]; + /* 0x019A */ s16 unk_19A; + /* 0x019C */ s16 unk_19C; + /* 0x019E */ u8 unk_19E; } ObjHakaisi; // size = 0x1A0 extern const ActorInit Obj_Hakaisi_InitVars; 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 9784e212c..10d8891ef 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -5,8 +5,9 @@ */ #include "z_obj_hamishi.h" +#include "objects/gameplay_field_keep/gameplay_field_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHamishi*)thisx) @@ -15,7 +16,6 @@ void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Hamishi_InitVars = { ACTOR_OBJ_HAMISHI, ACTORCAT_PROP, @@ -28,44 +28,261 @@ const ActorInit Obj_Hamishi_InitVars = { (ActorFunc)ObjHamishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809A1AA0 = { - { COLTYPE_HARD, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x81C37FB6, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x81C37FB6, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 50, 70, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809A1ACC = { 0, 12, 60, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 0, 12, 60, MASS_IMMOVABLE }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A1AE8[] = { +s16 D_809A1AD4[] = { + 145, 135, 115, 85, 75, 53, 45, 40, 35, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 250, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; -#endif +void func_809A0F20(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; -extern ColliderCylinderInit D_809A1AA0; -extern CollisionCheckInfoInit D_809A1ACC; -extern InitChainEntry D_809A1AE8[]; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_UpdateCylinder(&this->actor, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F20.s") +void func_809A0F78(ObjHamishi* this) { + if (this->unk_198 > 0) { + this->unk_198--; + this->unk_19A += 0x1388; + this->unk_19C += 0xE10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A0F78.s") + Math_StepToF(&this->unk_190, 0.0f, 0.15f); + Math_StepToF(&this->unk_194, 0.0f, 40.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A10F4.s") + this->actor.world.pos.x = (Math_SinS(this->unk_19A * 4) * this->unk_190) + this->actor.home.pos.x; + this->actor.world.pos.z = (Math_CosS(this->unk_19A * 7) * this->unk_190) + this->actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A13A0.s") + this->actor.shape.rot.x = (s32)(Math_SinS(this->unk_19C * 4) * this->unk_194) + this->actor.home.rot.x; + this->actor.shape.rot.z = (s32)(Math_CosS(this->unk_19C * 7) * this->unk_194) + this->actor.home.rot.z; + } else { + Math_StepToF(&this->actor.world.pos.x, this->actor.home.pos.x, 1.0f); + Math_StepToF(&this->actor.world.pos.z, this->actor.home.pos.z, 1.0f); + Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.home.rot.x, 0xBB8); + Math_ScaledStepToS(&this->actor.shape.rot.z, this->actor.home.rot.z, 0xBB8); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/func_809A1408.s") +void func_809A10F4(ObjHamishi* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spC8; + Vec3f spBC; + f32 temp_f20; + s16 temp_s0 = 1000; + s32 gravity; + s32 phi_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Init.s") + for (i = 0; i < ARRAY_COUNT(D_809A1AD4); i++) { + temp_s0 += 0x4E20; + temp_f20 = Rand_ZeroOne() * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Destroy.s") + spBC.x = (Math_SinS(temp_s0) * temp_f20) + this->actor.world.pos.x; + spBC.y = (Rand_ZeroOne() * 40.0f) + this->actor.world.pos.y + 5.0f; + spBC.z = (Math_CosS(temp_s0) * temp_f20) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Update.s") + temp_f20 = (Rand_ZeroOne() * 10.0f) + 2.0f; + spC8.x = Math_SinS(temp_s0) * temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hamishi/ObjHamishi_Draw.s") + spC8.y = (Rand_ZeroOne() * 15.0f) + (Rand_ZeroOne() * i * 2.5f); + spC8.z = Math_CosS(temp_s0) * temp_f20; + + if (i == 0) { + phi_v0 = 41; + gravity = -450; + } else if (i < 4) { + phi_v0 = 37; + gravity = -380; + } else { + phi_v0 = 69; + gravity = -320; + } + + EffectSsKakera_Spawn(globalCtx, &spBC, &spC8, &this->actor.world.pos, gravity, phi_v0, 30, 5, 0, D_809A1AD4[i], + 3, 0, 70, 1, GAMEPLAY_FIELD_KEEP, gameplay_field_keep_DL_006420); + } + + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 6, 180, 90, 1); + func_800BBFB0(globalCtx, &this->actor.world.pos, 140.0f, 12, 80, 90, 1); +} + +void func_809A13A0(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp28; + s32 sp24; + + sp28.x = this->actor.world.pos.x; + sp28.y = this->actor.world.pos.y + 30.0f; + sp28.z = this->actor.world.pos.z; + + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp24, &this->actor, &sp28); +} + +s32 func_809A1408(ObjHamishi* this, GlobalContext* globalCtx) { + s32 pad; + WaterBox* sp30; + f32 sp2C; + s32 sp28; + + if (WaterBox_GetSurfaceImpl(globalCtx, &globalCtx->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp2C, + &sp30, &sp28) && + (this->actor.world.pos.y < sp2C)) { + return true; + } + return false; +} + +void ObjHamishi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + + if (globalCtx->csCtx.state != 0) { + this->actor.uncullZoneForward += 1000.0f; + } + + if (this->actor.shape.rot.y == 0) { + this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.home.rot.y = this->actor.shape.rot.y; + } + + func_809A0F20(&this->actor, globalCtx); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + func_809A13A0(this, globalCtx); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 2.3f); + + if (Flags_GetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor))) { + Actor_MarkForDeath(&this->actor); + return; + } + + this->actor.shape.yOffset = 80.0f; + + if (func_809A1408(this, globalCtx)) { + this->unk_1A2 |= 1; + } +} + +void ObjHamishi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + Collider_DestroyCylinder(globalCtx, &THIS->collider); +} + +void ObjHamishi_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHamishi* this = THIS; + s32 sp24 = (this->collider.base.acFlags & AC_HIT) != 0; + + func_809A0F78(this); + + if (sp24) { + this->unk_1A1 = 5; + this->collider.base.acFlags &= ~AC_HIT; + } + + if (sp24) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000500) { + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x400) { + this->unk_1A0 = 26; + } else { + this->unk_1A0 = 11; + } + + if (this->collider.info.acHitInfo->toucher.dmgFlags & 0x80000000) { + this->unk_19E = 2; + } else { + this->unk_19E++; + } + + if (this->unk_19E < 2) { + this->unk_198 = 15; + this->unk_190 = 2.0f; + this->unk_194 = 400.0f; + } else { + func_809A10F4(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_WALL_BROKEN); + Flags_SetSwitch(globalCtx, OBJHAMISHI_GET_SWITCHFLAG(&this->actor)); + Actor_MarkForDeath(&this->actor); + } + } + } + + if (this->actor.update != NULL) { + if (this->unk_1A1 > 0) { + this->unk_1A1--; + if (this->unk_1A1 == 0) { + this->collider.base.colType = COLTYPE_HARD; + } else { + this->collider.base.colType = COLTYPE_NONE; + } + } + + if (this->unk_1A0 > 0) { + this->unk_1A0--; + } else if ((this->actor.flags & ACTOR_FLAG_40) && (this->actor.xzDistToPlayer < 1000.0f)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + + if (this->actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } +} + +void ObjHamishi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHamishi* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + if ((thisx->projectedPos.z <= 2150.0f) || ((this->unk_1A2 & 1) && (thisx->projectedPos.z < 2250.0f))) { + thisx->shape.shadowAlpha = 160; + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, D_801AEFA0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 170, 130, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_field_keep_DL_0061E8); + } else if (thisx->projectedPos.z < 2250.0f) { + f32 sp20 = (2250.0f - thisx->projectedPos.z) * 2.55f; + + thisx->shape.shadowAlpha = sp20 * 0.627451f; + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, D_801AEF88); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 170, 130, (s32)sp20); + gSPDisplayList(POLY_XLU_DISP++, gameplay_field_keep_DL_0061E8); + } else { + thisx->shape.shadowAlpha = 0; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h index 1305f49ee..da838d480 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h @@ -5,9 +5,20 @@ struct ObjHamishi; +#define OBJHAMISHI_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + typedef struct ObjHamishi { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x60]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ f32 unk_190; + /* 0x194 */ f32 unk_194; + /* 0x198 */ s16 unk_198; + /* 0x19A */ s16 unk_19A; + /* 0x19C */ s16 unk_19C; + /* 0x19E */ s16 unk_19E; + /* 0x1A0 */ s8 unk_1A0; + /* 0x1A1 */ s8 unk_1A1; + /* 0x1A2 */ u8 unk_1A2; } ObjHamishi; // size = 0x1A4 extern const ActorInit Obj_Hamishi_InitVars; 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 286080631..f07b9c6d4 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -5,8 +5,9 @@ */ #include "z_obj_hariko.h" +#include "assets/objects/object_hariko/object_hariko.h" -#define FLAGS 0x02000020 +#define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((ObjHariko*)thisx) @@ -15,10 +16,12 @@ void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B66A90(ObjHariko* this, GlobalContext* globalCtx); -void func_80B66AC4(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupWait(ObjHariko* this); +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_SetupBobHead(ObjHariko* this); +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx); +void ObjHariko_CheckForQuakes(ObjHariko* this); -#if 0 const ActorInit Obj_Hariko_InitVars = { ACTOR_OBJ_HARIKO, ACTORCAT_PROP, @@ -31,24 +34,71 @@ const ActorInit Obj_Hariko_InitVars = { (ActorFunc)ObjHariko_Draw, }; -#endif +void ObjHariko_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -extern UNK_TYPE D_06000080; + Actor_SetScale(&this->actor, 0.1f); + this->headRotation.x = 0; + this->headRotation.y = 0; + this->headRotation.z = 0; + this->headOffset = 0; + this->bobbleStep = 0.0f; + ObjHariko_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Init.s") +void ObjHariko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Destroy.s") +void ObjHariko_SetupWait(ObjHariko* this) { + this->actionFunc = ObjHariko_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A7C.s") +void ObjHariko_Wait(ObjHariko* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66A90.s") +void ObjHariko_SetupBobHead(ObjHariko* this) { + this->bobbleStep = 2730.0f; + this->unk154 = 0; + this->actionFunc = ObjHariko_BobHead; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AA0.s") +void ObjHariko_BobHead(ObjHariko* this, GlobalContext* globalCtx) { + this->headOffset += 0x1555; + this->headRotation.x = Math_SinS(this->headOffset) * this->bobbleStep; + this->headRotation.y = Math_CosS(this->headOffset) * this->bobbleStep; + Math_SmoothStepToF(&this->bobbleStep, 0, 0.5f, 18.0f, 18.0f); + if (this->bobbleStep < 182.0f) { + ObjHariko_SetupWait(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66AC4.s") +void ObjHariko_CheckForQuakes(ObjHariko* this) { + if (Quake_NumActiveQuakes() != 0) { + ObjHariko_SetupBobHead(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/func_80B66B78.s") +void ObjHariko_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Update.s") + this->actionFunc(this, globalCtx); + ObjHariko_CheckForQuakes(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hariko/ObjHariko_Draw.s") +void ObjHariko_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHariko* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + + Matrix_StatePush(); + Matrix_InsertXRotation_s(this->headRotation.x, MTXMODE_APPLY); + Matrix_RotateY(this->headRotation.y, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHarikoBodyDL); + gSPDisplayList(POLY_OPA_DISP++, gHarikoFaceDL); + + Matrix_StatePop(); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h index d9ac284bd..12d4fe505 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h @@ -10,7 +10,10 @@ typedef void (*ObjHarikoActionFunc)(struct ObjHariko*, GlobalContext*); typedef struct ObjHariko { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjHarikoActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x10]; + /* 0x0148 */ f32 bobbleStep; + /* 0x014C */ Vec3s headRotation; + /* 0x0152 */ s16 headOffset; + /* 0x0154 */ s16 unk154; // Set but not used } ObjHariko; // size = 0x158 extern const ActorInit Obj_Hariko_InitVars; 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 e759bc419..4e6b3791d 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -7,7 +7,7 @@ #include "z_obj_hgdoor.h" #include "objects/object_hgdoor/object_hgdoor.h" -#define FLAGS 0x00100000 +#define FLAGS (ACTOR_FLAG_100000) #define THIS ((ObjHgdoor*)thisx) @@ -128,13 +128,13 @@ void func_80BD433C(ObjHgdoor* this) { } void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { - u32 actionIndex; + s32 actionIndex; - if (func_800EE29C(globalCtx, 0x1E3)) { - actionIndex = func_800EE200(globalCtx, 0x1E3); - if (this->unk166 != globalCtx->csCtx.npcActions[actionIndex]->unk0) { - this->unk166 = globalCtx->csCtx.npcActions[actionIndex]->unk0; - switch (globalCtx->csCtx.npcActions[actionIndex]->unk0) { + if (Cutscene_CheckActorAction(globalCtx, 483)) { + actionIndex = Cutscene_GetActorActionIndex(globalCtx, 483); + if (this->unk166 != globalCtx->csCtx.actorActions[actionIndex]->action) { + this->unk166 = globalCtx->csCtx.actorActions[actionIndex]->action; + switch (globalCtx->csCtx.actorActions[actionIndex]->action) { case 1: Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOOD_DOOR_OPEN_SPEEDY); if ((this->dyna.actor.parent != NULL) && (this->dyna.actor.parent->id == ACTOR_EN_HG)) { 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 c1a308bae..1ce6faa7d 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -7,7 +7,7 @@ #include "z_obj_hsstump.h" #include "objects/object_hsstump/object_hsstump.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHsStump*)thisx) @@ -37,14 +37,14 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 180, ICHAIN_STOP), }; -static Vec3f iceSmokeAccel = { 0.0f, 0.0f, 0.0f }; +static Vec3f sIceSmokeAccel = { 0.0f, 0.0f, 0.0f }; void ObjHsStump_Init(Actor* thisx, GlobalContext* globalCtx) { ObjHsStump* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); this->isHidden = OBJHSSTUMP_GET_ISHIDDEN(thisx); - this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); // Must be thisx to match + this->switchFlag = OBJHSSTUMP_GET_SWITCHFLAG(thisx); DynaPolyActor_Init(&this->dyna, 1); DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hsstump_Colheader_0011B0); switch (this->isHidden) { @@ -87,43 +87,43 @@ void ObjHsStump_Appear(ObjHsStump* this, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = (Math_SinS(this->rotAngle * 2) * this->rotFactor) + this->dyna.actor.home.rot.z; this->rotAngle += 0x2000; } - if (this->framesAppeared < 11) { + if (this->framesAppeared <= 10) { if (this->framesAppeared == 0) { s32 i; - f32 angle; + f32 angleDeg; s16 numDirections = 4; Vec3f iceSmokePosOffset; Vec3f iceSmokeVelOffset; s16 offsetAngle; Vec3f iceSmokeVel; - f32 angleBinary; + f32 angleBrad; Vec3f iceSmokePos; iceSmokePosOffset.x = 1.0f; iceSmokePosOffset.y = 0.5f; iceSmokePosOffset.z = 0.0f; + iceSmokeVelOffset.x = 1.0f; iceSmokeVelOffset.y = 0.5f; iceSmokeVelOffset.z = 0.0f; - angle = 360.0f / numDirections; - i = angle * (0x10000 / 360.0f); - angleBinary = i; + angleDeg = (360.0f / numDirections); + angleBrad = (s32)(angleDeg * (0x10000 / 360.0f)); for (i = 0; i < numDirections; i++) { - offsetAngle = i * angleBinary; + offsetAngle = i * angleBrad; Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.world.pos, offsetAngle, &iceSmokePosOffset, &iceSmokePos); Lib_Vec3f_TranslateAndRotateY(&gZeroVec3f, offsetAngle, &iceSmokeVelOffset, &iceSmokeVel); - EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &iceSmokeAccel, 100); + EffectSsIceSmoke_Spawn(globalCtx, &iceSmokePos, &iceSmokeVel, &sIceSmokeAccel, 100); } } } if (this->framesAppeared >= 10) { - Math_SmoothStepToF(&this->dyna.actor.scale.x, 0.17999999f, 1.0f, 0.01f, 0.001f); + 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 == 0.17999999f) { + if (this->dyna.actor.scale.x == 18.0f * 0.01f) { this->isHidden = false; func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); ObjHsStump_SetupIdle(this, globalCtx); 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 79880eaf5..06293bf40 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -7,7 +7,7 @@ #include "z_obj_hugebombiwa.h" #include "objects/object_bombiwa/object_bombiwa.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjHugebombiwa*)thisx) @@ -440,7 +440,7 @@ void func_80A54E10(ObjHugebombiwa* this) { Vec3f sp84; Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < 20; i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; @@ -535,7 +535,7 @@ void func_80A55310(ObjHugebombiwa* this) { Vec3f sp84; Matrix_StatePush(); - Matrix_RotateY(this->actor.shape.rot.y, 0); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_NEW); for (i = 0, phi_s2 = 0x1000; i < ARRAY_COUNT(this->unk_190); i++, phi_s2 += 0x4000) { ptr = &this->unk_190[i]; 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 ff90f2e3e..4e09bb655 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -4,9 +4,11 @@ * Description: Switch-Activated Geyser */ +#include "prevent_bss_reordering.h" #include "z_obj_hunsui.h" +#include "objects/object_hunsui/object_hunsui.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjHunsui*)thisx) @@ -15,7 +17,36 @@ void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx); void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D0FC(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D2BC(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D4D0(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx); +void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx); + +AnimatedMaterial* D_80B9DED0; +AnimatedMaterial* D_80B9DED4; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; + /* 0x02 */ u8 unk_02; +} ObjHansuiBssStruct; // size = 0x3 + +ObjHansuiBssStruct D_80B9DED8; + +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 unk_01; +} ObjHansuiStruct; // size = 0x2 + +ObjHansuiStruct D_80B9DC70[] = { + { 1, 1 }, { 1, 0 }, { 2, 3 }, { 2, 1 }, { 2, 2 }, { 2, 0 }, { 3, 7 }, + { 3, 3 }, { 3, 5 }, { 3, 1 }, { 3, 6 }, { 3, 2 }, { 3, 4 }, { 3, 0 }, +}; + const ActorInit Obj_Hunsui_InitVars = { ACTOR_OBJ_HUNSUI, ACTORCAT_BG, @@ -28,42 +59,622 @@ const ActorInit Obj_Hunsui_InitVars = { (ActorFunc)ObjHunsui_Draw, }; -#endif +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_STOP), +}; -extern UNK_TYPE D_06000220; -extern UNK_TYPE D_06000C74; -extern UNK_TYPE D_06000EC0; +s32 func_80B9C450(GlobalContext* globalCtx, s32 arg1, s32 arg2) { + s32 sp2C = 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9C450.s") + if (arg2 < ARRAY_COUNT(D_80B9DC70)) { + s32 val = D_80B9DC70[arg2].unk_00; + s32 val3 = D_80B9DC70[arg2].unk_01; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9C5E8.s") + while (val--) { + if ((1 << val) & val3) { + if (!Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } else if (Flags_GetSwitch(globalCtx, arg1 + val)) { + sp2C = 0; + break; + } + } + } else { + sp2C = 0; + switch (arg2) { + case 14: + if (!Flags_GetSwitch(globalCtx, arg1)) { + sp2C = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Init.s") + if (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3)) { + sp2C += 2; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Destroy.s") + case 15: + if (!Flags_GetSwitch(globalCtx, arg1) || + (Flags_GetSwitch(globalCtx, arg1 + 1) && Flags_GetSwitch(globalCtx, arg1 + 2) && + Flags_GetSwitch(globalCtx, arg1 + 3))) { + sp2C = 1; + } + break; + } + } + return sp2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Update.s") +void func_80B9C5E8(ObjHunsui* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 temp_f10; + f32 temp_f16; + Vec3f sp40; + s16 sp3E; + f32 sp38; + f32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9CE64.s") + 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)) { + this->unk_172 &= ~8; + this->unk_19C = 0.0f; + this->unk_1A0 = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D094.s") + this->unk_18C++; + if (this->unk_18C >= 3) { + this->unk_18C = 0; + Math_Vec3f_Copy(&sp40, &player->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D0FC.s") + sp40.x += randPlusMinusPoint5Scaled(10.0f); + sp40.z += randPlusMinusPoint5Scaled(10.0f); + sp40.y += Rand_ZeroFloat(2.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D120.s") + EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 2.0f * Rand_ZeroOne(), 1); + } + } else { + this->unk_172 |= 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D288.s") + this->unk_18C++; + if (this->unk_18C >= 3) { + Math_Vec3f_Copy(&sp40, &player->actor.world.pos); + this->unk_18C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D2BC.s") + sp40.x += randPlusMinusPoint5Scaled(10.0f); + sp40.z += randPlusMinusPoint5Scaled(10.0f); + sp40.y += Rand_ZeroFloat(45.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D334.s") + EffectSsGSplash_Spawn(globalCtx, &sp40, NULL, NULL, 1, 1); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D4D0.s") + sp3E = BINANG_ROT180(player->actor.world.rot.y - this->dyna.actor.yawTowardsPlayer); + player->actor.gravity = 0.0f; + player->actor.velocity.y = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D508.s") + if ((this->unk_160 != OBJHUNSUI_F000_5) && (this->unk_160 != OBJHUNSUI_F000_6)) { + Math_SmoothStepToF(&player->actor.world.pos.y, this->dyna.actor.world.pos.y, 0.5f, 4.0f, 1.0f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9D714.s") + if ((sp3E < 0x4000) && (sp3E > -0x4000)) { + this->unk_1A4 = BINANG_ROT180(player->actor.world.rot.y); + sp34 = this->dyna.actor.xzDistToPlayer / (45.0f * this->dyna.actor.scale.x * 10.0f); + if (1) {} + sp38 = this->dyna.actor.xzDistToPlayer / (45.0f * this->dyna.actor.scale.x * 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/ObjHunsui_Draw.s") + if (sp38 > 1.0f) { + sp38 = sp34; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hunsui/func_80B9DA60.s") + player->linearVelocity *= sp38; + + if ((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) { + Math_ApproachF(&this->unk_1A0, 4.5f, 2.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 2.0f, 0.3f * sp38); + } else { + Math_ApproachF(&this->unk_1A0, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 1.0f, 0.3f * sp38); + } + } else { + this->unk_1A4 = player->actor.world.rot.y; + player->linearVelocity *= 0.5f; + Math_ApproachF(&this->unk_1A0, 3.0f, 1.0f, 1.0f); + Math_ApproachF(&this->unk_19C, this->unk_1A0, 1.0f, 0.1f); + } + player->unk_B84 = this->unk_1A4; + player->unk_B80 = this->unk_19C; + } + } else { + if (this->unk_172 & 8) { + player->linearVelocity = this->unk_19C + player->linearVelocity; + player->currentYaw = this->unk_1A4; + } + this->unk_1A0 = 0.0f; + this->unk_19C = 0.0f; + this->unk_172 &= ~8; + } +} + +void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + 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); + + if ((this->unk_160 != OBJHUNSUI_F000_5) && (this->unk_160 != OBJHUNSUI_F000_6)) { + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_hunsui_Colheader_000C74); + } + + D_80B9DED0 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_000BF0); + D_80B9DED4 = Lib_SegmentedToVirtual(object_hunsui_Matanimheader_001888); + SubS_FillCutscenesList(&this->dyna.actor, &this->unk_170, 1); + this->unk_18C = 0; + + switch (this->unk_160) { + case OBJHUNSUI_F000_1: + case OBJHUNSUI_F000_2: + case OBJHUNSUI_F000_3: + case OBJHUNSUI_F000_4: + case OBJHUNSUI_F000_5: + case OBJHUNSUI_F000_6: + this->dyna.actor.uncullZoneScale = 900.0f; + this->dyna.actor.uncullZoneDownward = 90.0f; + this->dyna.actor.uncullZoneForward = 4000.0f; + break; + } + + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + if (D_80B9DED8.unk_01 == 0) { + D_80B9DED8.unk_01 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + + case OBJHUNSUI_F000_6: + if (D_80B9DED8.unk_02 == 0) { + D_80B9DED8.unk_02 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->dyna.actor.world.rot.z; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.room = -1; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + } + + switch (this->unk_160) { + case OBJHUNSUI_F000_0: + if (D_80B9DED8.unk_00 == 0) { + D_80B9DED8.unk_00 = 1; + this->unk_16C = this->dyna.actor.room; + this->unk_16D = this->unk_164; + // clang-format off + this->dyna.actor.room = -1; this->actionFunc = func_80B9D714; + // clang-format on + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + break; + + case OBJHUNSUI_F000_2: + this->unk_172 |= 1; + + case OBJHUNSUI_F000_1: + this->dyna.actor.draw = func_80B9DA60; + if ((this->unk_172 & 1) && func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_174 = 240.0f; + this->unk_172 |= 4; + this->unk_184 = 0xFF0; + } else { + this->unk_174 = -30.0f; + this->unk_172 |= 2; + this->unk_184 = 0; + } + this->unk_178 = this->unk_174; + this->unk_180 = func_80B9C450(globalCtx, this->unk_168, this->unk_164); + this->actionFunc = func_80B9CE64; + break; + + case OBJHUNSUI_F000_4: + this->unk_172 |= 1; + + case OBJHUNSUI_F000_3: + case OBJHUNSUI_F000_5: + case OBJHUNSUI_F000_6: + this->dyna.actor.draw = func_80B9DA60; + if ((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) { + func_80B9D2BC(this, globalCtx); + this->unk_178 = this->unk_174; + } else { + if ((this->unk_172 & 1) || func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, globalCtx); + } else { + func_80B9D0FC(this, globalCtx); + } + this->unk_178 = this->unk_174; + } + break; + } +} + +void ObjHunsui_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void ObjHunsui_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + this->actionFunc(this, globalCtx); + + if ((this->unk_172 & 0x40) && SubS_StartActorCutscene(&this->dyna.actor, this->unk_17C, -1, 0)) { + this->unk_172 &= ~0x40; + } + + if (this->unk_1AC > 1024.0f) { + this->unk_1AC -= 1024.0f; + } + + if (this->unk_1AC <= 0.0f) { + this->unk_1AC += 1024.0f; + } +} + +void func_80B9CE64(ObjHunsui* this, GlobalContext* globalCtx) { + s32 sp2C; + f32 sins; + + if (!(this->unk_172 & 2)) { + func_80B9C5E8(this, globalCtx); + } + + this->unk_18A += 0x71C; + Math_SmoothStepToF(&this->unk_190, this->unk_194, 1.0f, 0.2f, 0.01f); + + sp2C = func_80B9C450(globalCtx, this->unk_168, this->unk_164); + + if (!(this->unk_172 & 1)) { + if (sp2C != this->unk_180) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + } + } + + if ((this->unk_172 & 1) || (sp2C != 0)) { + this->unk_172 &= ~2; + if (this->unk_186 == 0) { + this->unk_172 |= 0x10; + this->unk_174 = 240.0f; + if (this->unk_178 == 240.0f) { + if (this->unk_188++ > 40) { + this->unk_188 = 0; + this->unk_186 = 1; + this->unk_194 = 0.0f; + } else { + this->unk_194 = 8.0f; + } + } + } else { + this->unk_174 = 30.0f; + if (this->unk_178 == 30.0f) { + if (this->unk_188++ > 40) { + this->unk_188 = 0; + this->unk_186 = 0; + this->unk_194 = 0.0f; + } else { + this->unk_194 = 8.0f; + } + } + } + } else { + this->unk_174 = -30.0f; + if (this->unk_178 == -30.0f) { + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + } + + sins = Math_SinS(this->unk_18A); + this->unk_198 = sins * this->unk_190; + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + this->unk_180 = sp2C; +} + +void func_80B9D094(ObjHunsui* this, GlobalContext* globalCtx) { + f32 sins; + + this->unk_18A += 0x71C; + Math_SmoothStepToF(&this->unk_190, this->unk_194, 1.0f, 0.2f, 0.01f); + sins = Math_SinS(this->unk_18A); + this->unk_198 = sins * this->unk_190; +} + +void func_80B9D0FC(ObjHunsui* this, GlobalContext* globalCtx) { + this->unk_174 = -30.0f; + this->actionFunc = func_80B9D120; +} + +void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx) { + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + ((this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num))) { + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + D_80B9DED8.unk_01 = 0; + break; + + case OBJHUNSUI_F000_6: + D_80B9DED8.unk_02 = 0; + break; + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + func_80B9D094(this, globalCtx); + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + if (this->unk_178 == this->unk_174) { + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + + if (func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + func_80B9D4D0(this, globalCtx); + } +} + +s32 func_80B9D288(GlobalContext* globalCtx, Actor* thisx, Actor* iter, void* verifyData) { + s32 ret = false; + + if (BGDBLUEMOVEBG_GET_F(iter) == BGDBLUEMOVEBG_F_8) { + ret = true; + } + return ret; +} + +void func_80B9D2BC(ObjHunsui* this, GlobalContext* globalCtx) { + if ((this->unk_172 & 1) || func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + func_80B9D4D0(this, globalCtx); + } else { + this->unk_172 |= 2; + func_80B9D0FC(this, globalCtx); + } +} + +void func_80B9D334(ObjHunsui* this, GlobalContext* globalCtx) { + Vec3f sp74; + s32 i; + s32 phi_s2 = 0; + s32 phi_s3; + + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + phi_s2 = 1; + break; + + case OBJHUNSUI_F000_6: + break; + } + + if (this->unk_1B4 != NULL) { + phi_s3 = false; + for (i = 0; i < 8; i++) { + if (this->unk_1B4->unk_300[phi_s2][i] == (phi_s2 + 1)) { + phi_s3 = true; + Math_Vec3f_Copy(&sp74, &this->unk_1B4->unk_238[phi_s2][i]); + this->unk_174 = sp74.y - this->dyna.actor.home.pos.y; + if (this->unk_174 > 240.0f) { + this->unk_174 = 240.0f; + } + this->unk_190 = 0.0f; + this->unk_198 = 0.0f; + this->unk_18A = 0; + } + } + + if (!phi_s3) { + this->unk_174 = 240; + } + } else { + Actor* dblueMovebg = SubS_FindActorCustom(globalCtx, &this->dyna.actor, NULL, ACTORCAT_BG, + ACTOR_BG_DBLUE_MOVEBG, NULL, func_80B9D288); + + if (dblueMovebg != NULL) { + this->unk_1B4 = (BgDblueMovebg*)dblueMovebg; + func_80B9D2BC(this, globalCtx); + } + } +} + +void func_80B9D4D0(ObjHunsui* this, GlobalContext* globalCtx) { + this->unk_172 &= ~2; + this->unk_172 |= 0x10; + this->unk_174 = 240.0f; + this->actionFunc = func_80B9D508; +} + +void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx) { + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + (this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num)) { + switch (this->unk_160) { + case OBJHUNSUI_F000_5: + D_80B9DED8.unk_01 = 0; + break; + + case OBJHUNSUI_F000_6: + D_80B9DED8.unk_02 = 0; + break; + } + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + func_80B9C5E8(this, globalCtx); + func_80B9D094(this, globalCtx); + + if (((this->unk_160 == OBJHUNSUI_F000_5) || (this->unk_160 == OBJHUNSUI_F000_6)) && + (globalCtx->roomCtx.currRoom.num == 8)) { + func_80B9D334(this, globalCtx); + } + + if (!(this->unk_172 & 0x40)) { + Math_SmoothStepToF(&this->unk_178, this->unk_174, 0.6f, 10.5f, 0.05f); + } + + this->dyna.actor.world.pos.y = this->unk_198 + (this->dyna.actor.home.pos.y + this->unk_178); + + if ((this->unk_160 == OBJHUNSUI_F000_6) || (this->unk_160 == OBJHUNSUI_F000_5)) { + this->unk_1AC += -10.0f + (1.8f * (this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y)); + this->unk_1B0 += -8.0f + (0.9f * (this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y)); + } + + if (!(this->unk_172 & 1) && !func_80B9C450(globalCtx, this->unk_168, this->unk_164)) { + this->unk_17C = this->unk_170; + this->unk_172 |= 0x40; + func_80B9D0FC(this, globalCtx); + } +} + +void func_80B9D714(ObjHunsui* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = GET_PLAYER(globalCtx); + s16 cs; + f32 sp28; + + if ((this->unk_16C != globalCtx->roomCtx.currRoom.num) && (this->unk_16C != globalCtx->roomCtx.prevRoom.num) && + (this->unk_16D != globalCtx->roomCtx.currRoom.num) && (this->unk_16D != globalCtx->roomCtx.prevRoom.num)) { + Actor_MarkForDeath(&this->dyna.actor); + } else { + if (Flags_GetSwitch(globalCtx, this->unk_168)) { + this->unk_172 &= ~2; + this->unk_172 |= 0x10; + cs = this->dyna.actor.cutscene; + + if (this->unk_16E == 0) { + if ((cs >= 0) && !ActorCutscene_GetCanPlayNext(cs)) { + ActorCutscene_SetIntentToPlay(cs); + } else if (cs >= 0) { + ActorCutscene_StartAndSetUnkLinkFields(cs, &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)) { + this->unk_16E = 40; + } + } else { + s32 pad; + + if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 800.0f, 0.1f, 8.0f, + 1.0f) < 0.5f) { + if (DECR(this->unk_16E) == 0) { + Flags_UnsetSwitch(globalCtx, this->unk_168); + } + } + this->dyna.actor.velocity.y = this->dyna.actor.world.pos.y - this->dyna.actor.prevPos.y; + } + } else { + Math_StepToF(&this->dyna.actor.velocity.y, -10.0f, 4.0f); + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + if (this->dyna.actor.world.pos.y < this->dyna.actor.home.pos.y) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + this->unk_172 &= ~0x10; + this->unk_172 |= 2; + } + } + } + + if (!DynaPolyActor_IsInRidingMovingState(&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)) { + sp28 = (45.0f - this->dyna.actor.xzDistToPlayer) * 0.5f; + player->actor.world.pos.x += sp28 * Math_SinS(this->dyna.actor.yawTowardsPlayer); + player->actor.world.pos.z += sp28 * Math_CosS(this->dyna.actor.yawTowardsPlayer); + } + } + } +} + +void ObjHunsui_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjHunsui* this = THIS; + + if (this->unk_172 & 0x10) { + f32 temp_f8 = (this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) / 800.0f; + + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_WATER_PILLAR - SFX_FLAG, 1.0f + temp_f8); + } + + if (!(this->unk_172 & 2)) { + AnimatedMat_Draw(globalCtx, D_80B9DED0); + Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000220); + } +} + +void func_80B9DA60(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjHunsui* this = THIS; + f32 temp; + + if (this->unk_172 & 0x10) { + temp = 1.0f + ((this->unk_178 - 240.0f) / 270.0f); + func_8019FAD8(&this->dyna.actor.projectedPos, NA_SE_EV_WATER_PILLAR - SFX_FLAG, 1.0f + temp); + } + + if ((this->dyna.actor.flags & ACTOR_FLAG_40) && !(this->unk_172 & 2)) { + if ((this->unk_160 == OBJHUNSUI_F000_6) || (this->unk_160 == OBJHUNSUI_F000_5)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (globalCtx->gameplayFrames % 128) * -9, 0x20, + 0x20, 1, 0, (globalCtx->gameplayFrames % 128) * -8, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (s32)this->unk_1AC, 0x20, 0x20, 1, 0, + (s32)this->unk_1B0, 0x20, 0x20)); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + AnimatedMat_DrawXlu(globalCtx, D_80B9DED4); + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x7F, 255, 255, 255, 127); + + Gfx_DrawDListXlu(globalCtx, object_hunsui_DL_000EC0); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} 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 e4bacf821..cbf1e4f13 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.h @@ -2,16 +2,56 @@ #define Z_OBJ_HUNSUI_H #include "global.h" +#include "overlays/actors/ovl_Bg_Dblue_Movebg/z_bg_dblue_movebg.h" struct ObjHunsui; typedef void (*ObjHunsuiActionFunc)(struct ObjHunsui*, GlobalContext*); +#define OBJHUNSUI_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJHUNSUI_GET_F80(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJHUNSUI_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) + +enum { + /* 0 */ OBJHUNSUI_F000_0, + /* 1 */ OBJHUNSUI_F000_1, + /* 2 */ OBJHUNSUI_F000_2, + /* 3 */ OBJHUNSUI_F000_3, + /* 4 */ OBJHUNSUI_F000_4, + /* 5 */ OBJHUNSUI_F000_5, + /* 6 */ OBJHUNSUI_F000_6, +}; + typedef struct ObjHunsui { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjHunsuiActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x58]; + /* 0x0160 */ s16 unk_160; + /* 0x0164 */ s32 unk_164; + /* 0x0168 */ s32 unk_168; + /* 0x016C */ s8 unk_16C; + /* 0x016D */ s8 unk_16D; + /* 0x016E */ s8 unk_16E; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ u16 unk_172; + /* 0x0174 */ f32 unk_174; + /* 0x0178 */ f32 unk_178; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ s32 unk_180; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s16 unk_186; + /* 0x0188 */ s16 unk_188; + /* 0x018A */ s16 unk_18A; + /* 0x018C */ s16 unk_18C; + /* 0x0190 */ f32 unk_190; + /* 0x0194 */ f32 unk_194; + /* 0x0198 */ f32 unk_198; + /* 0x019C */ f32 unk_19C; + /* 0x01A0 */ f32 unk_1A0; + /* 0x01A4 */ s16 unk_1A4; + /* 0x0196 */ UNK_TYPE1 unk1A6[0x6]; + /* 0x01AC */ f32 unk_1AC; + /* 0x01B0 */ f32 unk_1B0; + /* 0x01B4 */ BgDblueMovebg* unk_1B4; } ObjHunsui; // size = 0x1B8 extern const ActorInit Obj_Hunsui_InitVars; 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 6a4e8ce27..d6ac6f342 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 @@ -8,7 +8,7 @@ #include "overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS ACTOR_FLAG_10 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjIcePoly*)thisx) 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 6ccc8217d..582c3a299 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -7,7 +7,7 @@ #include "z_obj_iceblock.h" #include "objects/object_ice_block/object_ice_block.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjIceblock*)thisx) @@ -16,8 +16,8 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80A257A0(ObjIceblock* this); -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx); +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this); +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25824(ObjIceblock* this); void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx); void func_80A25978(ObjIceblock* this); @@ -77,7 +77,7 @@ static ColliderCylinderInit sCylinderInit = { { 44, 62, -31, { 0, 0, 0 } }, }; -static AnimatedMaterial* D_80A26E7C = NULL; +static AnimatedMaterial* sCubeSublimatingAirTexMat = NULL; s16 func_80A23090(s16 arg0, s16 arg1, s16 arg2) { if (arg0 >= 0) { @@ -460,7 +460,7 @@ s32 func_80A24118(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* spD0.y = spDC.y; spD0.z = temp_f26 + spDC.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spDC, &spD0, &spB8, &spA8, 1, 0, 0, 1, &spAC, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spDC, &spD0, &spB8, &spA8, true, false, false, true, &spAC, &this->dyna.actor, 0.0f)) { temp_f20 = Math3D_Vec3fDistSq(&spDC, &spB8); if (temp_f20 < phi_f20) { @@ -536,7 +536,7 @@ s32 func_80A243E0(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg0) { spE0.y = spEC.y; spE0.z = temp_f30 + spEC.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, 1, 0, 0, 1, &spBC, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, &this->dyna.actor, 0.0f)) { temp_f12 = Math3D_Vec3fDistSq(&spEC, &spC8); if (temp_f12 < phi_f22) { @@ -600,7 +600,7 @@ s32 func_80A246D8(ObjIceblock* this, GlobalContext* globalCtx, Vec3f* arg2) { spB4.y = spC0.y; spB4.z = (Math_CosS(phi_s3) * temp_f20) + spC0.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC0, &spB4, &sp9C, &sp94, 1, 0, 0, 1, &sp98, + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC0, &spB4, &sp9C, &sp94, true, false, false, true, &sp98, &this->dyna.actor, 0.0f)) { ret = true; temp_v0 = (ObjIceblock*)DynaPoly_GetActor(&globalCtx->colCtx, sp98); @@ -670,7 +670,7 @@ void func_80A24B74(ObjIceblock* this, GlobalContext* globalCtx) { s32 pad; Vec3f sp20; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { if (1) {} sp20.x = this->dyna.actor.world.pos.x; sp20.y = this->unk_244; @@ -687,7 +687,7 @@ void func_80A24BDC(ObjIceblock* this, GlobalContext* globalCtx, f32 arg2, f32 ar s16 phi_s0; s32 phi_s1 = 0; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { sp88.y = this->unk_244; temp_f22 = 0x10000 / arg4; @@ -723,7 +723,7 @@ void func_80A24DD0(ObjIceblock* this, GlobalContext* globalCtx) { } this->unk_2A2++; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { if (this->unk_2A2 >= 0x2E) { phi_f22 = 1.0f; } else { @@ -764,7 +764,7 @@ void func_80A2508C(ObjIceblock* this, GlobalContext* globalCtx) { f32 temp_f0; s32 temp_v0; - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { temp_v0 = (s32)(this->dyna.actor.scale.y * 130.0f) - 3; if (temp_v0 > 0) { this->unk_2AC += temp_v0; @@ -915,28 +915,29 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.world.rot.z = 0; this->dyna.actor.home.rot.x = 0; this->dyna.actor.home.rot.z = 0; - if (!OBJICEBLOCK_GET_2(&this->dyna.actor)) { + if (!GET_ICEBLOCK_SNAP_ROT(&this->dyna.actor)) { this->dyna.actor.shape.rot.y = (this->dyna.actor.shape.rot.y + 0x2000) & 0xC000; this->dyna.actor.home.rot.y = this->dyna.actor.shape.rot.y; this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y; } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_ice_block_Colheader_000438); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gIceBlockDynaColHeader); func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); Collider_InitCylinder(globalCtx, &this->collider); Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -100; this->collider.dim.height = 126; this->collider.dim.radius = 29; } - if (D_80A26E7C == NULL) { - D_80A26E7C = Lib_SegmentedToVirtual(object_ice_block_Matanimheader_000328); + if (sCubeSublimatingAirTexMat == NULL) { + sCubeSublimatingAirTexMat = Lib_SegmentedToVirtual(gIceBlockCubeSublimatingAirTexAnim); } + // ... this is init, why would this value be set? if (!(this->unk_1B0 & 8)) { parent = this->dyna.actor.parent; if (parent != NULL) { @@ -948,14 +949,14 @@ void ObjIceblock_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = -1.0f; } this->unk_2B0 = 0; - this->unkFunc = func_80A26B64; - func_80A257A0(this); - this->unk_2AE = 450; + this->extendedDrawFunc = func_80A26B64; + ObjIceBlock_SetupAttemptSpawnCutscene(this); + this->meltTimer = 450; // (450/20) = 22 seconds } void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -965,15 +966,15 @@ void ObjIceblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { Collider_DestroyCylinder(globalCtx, &this->collider); } -void func_80A257A0(ObjIceblock* this) { - this->actionFunc = func_80A257B4; +void ObjIceBlock_SetupAttemptSpawnCutscene(ObjIceblock* this) { + this->actionFunc = ObjIceBlock_AttemptSpawnCutscene; } -void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { +void ObjIceBlock_AttemptSpawnCutscene(ObjIceblock* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); - this->unkFunc = func_80A26BF8; - this->unk_2B1 = 80; + this->extendedDrawFunc = func_80A26BF8; + this->spawnCutsceneTimer = 80; func_80A25824(this); } else { ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); @@ -982,7 +983,7 @@ void func_80A257B4(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A25824(ObjIceblock* this) { this->actionFunc = func_80A2586C; - this->unk_2A0 = 2; + this->stateTimer = 2; Actor_SetScale(&this->dyna.actor, 0.01f); func_80A2319C(this, this->dyna.actor.scale.x); } @@ -990,32 +991,32 @@ void func_80A25824(ObjIceblock* this) { void func_80A2586C(ObjIceblock* this, GlobalContext* globalCtx) { func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } if (Math_StepToF(&this->dyna.actor.scale.x, 0.1f, 0.02f)) { Actor_SetScale(&this->dyna.actor, 0.1f); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.05f; } func_80A25978(this); } else { Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); - this->unk_2A0 = 2; + this->stateTimer = 2; } func_80A2319C(this, this->dyna.actor.scale.x); - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, (this->dyna.actor.scale.x + 0.05f) * 0.6666666f, 1.0f, 3); } } void func_80A25978(ObjIceblock* this) { this->actionFunc = func_80A25994; - this->unk_2A0 = 4; + this->stateTimer = 4; } void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1023,14 +1024,14 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { Vec3f sp30; func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } - if (this->dyna.actor.flags & 0x40) { + if (this->dyna.actor.flags & ACTOR_FLAG_40) { func_80A2339C(globalCtx, &this->dyna.actor.world.pos, this->dyna.actor.scale.x, 1.2f, 15); - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { sp30.x = this->dyna.actor.world.pos.x; sp30.y = this->dyna.actor.world.pos.y - 30.0f; sp30.z = this->dyna.actor.world.pos.z; @@ -1038,17 +1039,17 @@ void func_80A25994(ObjIceblock* this, GlobalContext* globalCtx) { } } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = 0.1f; } func_80A25A8C(this); - this->unkFunc = func_80A26B74; + this->extendedDrawFunc = func_80A26B74; } void func_80A25A8C(ObjIceblock* this) { this->actionFunc = func_80A25AA8; - this->unk_2A0 = 2; + this->stateTimer = 2; } void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1056,8 +1057,8 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { f32 sp24; s32 temp = func_80A236D4(this, &this->dyna.actor.home.pos); - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; return; } @@ -1074,7 +1075,7 @@ void func_80A25AA8(ObjIceblock* this, GlobalContext* globalCtx) { this->dyna.actor.shape.yOffset = 300.0f; this->unk_248.y += sp24; - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->collider.dim.yShift = -69; } else { this->collider.dim.yShift = 0; @@ -1180,7 +1181,7 @@ void func_80A25E50(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); func_80A25CF4(this); } else { - func_800B9010(&this->dyna.actor, 0xDF); + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } } @@ -1226,7 +1227,7 @@ void func_80A260E8(ObjIceblock* this) { this->unk_260 = D_80A26FC0[this->unk_26C]; this->unk_25C = 0.0f; this->dyna.actor.velocity.y = 0.0f; - this->unk_2A0 = 15; + this->stateTimer = 15; func_80A24DC4(this); this->actionFunc = func_80A26144; } @@ -1237,8 +1238,8 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { s32 isBool; s32 sp24; - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } Math_StepToF(&this->unk_25C, this->unk_260, 0.75f); @@ -1248,7 +1249,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { sp24 = func_80A23F90(this, globalCtx); isBool = sp24 == 0; - if (isBool || sp28 || (this->unk_2A0 == 1)) { + if (isBool || sp28 || (this->stateTimer == 1)) { func_80A2541C(this, globalCtx); } @@ -1266,7 +1267,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { func_80A23B88(this); func_80A25FA0(this); } else { - func_800B9010(&this->dyna.actor, 0xDF); + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); } func_80A24DD0(this, globalCtx); @@ -1275,7 +1276,7 @@ void func_80A26144(ObjIceblock* this, GlobalContext* globalCtx) { void func_80A262BC(ObjIceblock* this) { this->actionFunc = func_80A262EC; this->dyna.actor.velocity.y *= 0.7f; - this->unk_2A0 = -1; + this->stateTimer = -1; } void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1289,20 +1290,20 @@ void func_80A262EC(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } - if (this->unk_2A0 == -1) { + if (this->stateTimer == -1) { if ((this->dyna.actor.velocity.y < 0.0f) && (this->dyna.actor.world.pos.y < this->unk_244) && ((this->unk_244 - (600.0f * this->dyna.actor.scale.y)) <= this->dyna.actor.world.pos.y)) { func_80A24BDC(this, globalCtx, 1.0f, 0.9f, 11); func_80A24B74(this, globalCtx); - this->unk_2A0 = 3; + this->stateTimer = 3; } else { - this->unk_2A0 = 0; + this->stateTimer = 0; } - } else if (this->unk_2A0 == 1) { + } else if (this->stateTimer == 1) { func_80A24BDC(this, globalCtx, 0.7f, 1.3f, 6); func_80A24B74(this, globalCtx); } @@ -1344,7 +1345,7 @@ void func_80A26574(ObjIceblock* this) { this->unk_27C.unk_18 = 500; this->unk_27C.unk_22 = 500; this->unk_27C.unk_08 = 7.0f; - this->unk_2A0 = 40; + this->stateTimer = 40; } void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { @@ -1355,11 +1356,11 @@ void func_80A265C0(ObjIceblock* this, GlobalContext* globalCtx) { func_80A2541C(this, globalCtx); } - if (this->unk_2A0 > 0) { - this->unk_2A0--; + if (this->stateTimer > 0) { + this->stateTimer--; } else { ptr = &this->unk_27C; - this->unk_2A0 = Rand_S16Offset(30, 60); + this->stateTimer = Rand_S16Offset(30, 60); ptr->unk_0C = Rand_S16Offset(300, 300); ptr->unk_0E = Rand_S16Offset(900, 600); ptr->unk_04 = (2.0f * Rand_ZeroOne()) + 1.0f; @@ -1400,7 +1401,7 @@ void func_80A266E0(ObjIceblock* this, GlobalContext* globalCtx) { actor->scale.z = actor->scale.x; } - if (OBJICEBLOCK_GET_1(&this->dyna.actor)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor)) { this->unk_2B4 = actor->scale.y; this->collider.dim.height = (s32)(actor->scale.y * 1230.0f) + 1; this->collider.dim.yShift = actor->scale.y * -1000.0f; @@ -1441,14 +1442,14 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_2B0 == 1) || (this->unk_2B0 == 2) || (this->unk_2B0 == 3)) { - if (this->unk_2AE > 0) { - this->unk_2AE--; + if (this->meltTimer > 0) { + this->meltTimer--; } } if (((this->collider.base.acFlags & AC_HIT) && (this->collider.info.acHitInfo->toucher.dmgFlags & 0x800)) || - (this->unk_2AE == 0)) { - this->unk_2AE = -1; + (this->meltTimer == 0)) { + this->meltTimer = -1; this->unk_2B0 = 4; this->unk_1B0 &= ~0x100; if (this->unk_1B0 & 1) { @@ -1458,9 +1459,10 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { func_80A266C4(this); } - if (this->unk_2B1 > 0) { - this->unk_2B1--; - if (this->unk_2B1 == 0) { + // this could have been in the actionFunc? + if (this->spawnCutsceneTimer > 0) { + this->spawnCutsceneTimer--; + if (this->spawnCutsceneTimer == 0) { ActorCutscene_Stop(this->dyna.actor.cutscene); } } @@ -1482,7 +1484,7 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); if (this->unk_1B0 & 0x10) { - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { this->collider.base.ocFlags1 &= ~OC1_NO_PUSH; this->collider.base.ocFlags1 |= (OC1_TYPE_2 | OC1_TYPE_1 | OC1_TYPE_PLAYER); this->collider.info.bumper.dmgFlags |= @@ -1507,14 +1509,16 @@ void ObjIceblock_Update(Actor* thisx, GlobalContext* globalCtx) { void func_80A26B64(ObjIceblock* this, GlobalContext* globalCtx) { } +// draw func void func_80A26B74(ObjIceblock* this, GlobalContext* globalCtx) { - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0001A0); - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); - Gfx_DrawDListXlu(globalCtx, object_ice_block_DL_0007F0); + Gfx_DrawDListXlu(globalCtx, gIceBlockCubeDL); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); + Gfx_DrawDListXlu(globalCtx, gIceBlockIceBergDL); } } +// draw func void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { s32 pad[2]; ObjIceBlockUnkStruct* ptr; @@ -1535,17 +1539,17 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { Matrix_Scale(ptr->unk_04, ptr->unk_08, ptr->unk_0C, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0001A0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockCubeDL); } - if (OBJICEBLOCK_GET_1(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_ice_block_Matanimheader_0009D0)); + if (GET_ICEBLOCK_ICEBERG(&this->dyna.actor) && (this->unk_2B4 > 0.0f)) { + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gIceBlockIceBergSublimatingAirTexAnim)); Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 20.0f, this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); Matrix_Scale(this->unk_2B4, this->unk_2B4, this->unk_2B4, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_ice_block_DL_0007F0); + gSPDisplayList(POLY_XLU_DISP++, gIceBlockIceBergDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -1554,7 +1558,7 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { void ObjIceblock_Draw(Actor* thisx, GlobalContext* globalCtx) { ObjIceblock* this = THIS; - AnimatedMat_Draw(globalCtx, D_80A26E7C); - this->unkFunc(this, globalCtx); + AnimatedMat_Draw(globalCtx, sCubeSublimatingAirTexMat); + this->extendedDrawFunc(this, globalCtx); func_80A24AA8(this, globalCtx); } diff --git a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h index 6a4875bb3..52460b87d 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.h @@ -6,10 +6,10 @@ struct ObjIceblock; typedef void (*ObjIceblockActionFunc)(struct ObjIceblock*, GlobalContext*); -typedef void (*ObjIceblockUnkFunc)(struct ObjIceblock*, GlobalContext*); +typedef void (*ObjIceblockExtendedDrawFunc)(struct ObjIceblock*, GlobalContext*); -#define OBJICEBLOCK_GET_2(thisx) (((thisx)->params >> 1) & 1) -#define OBJICEBLOCK_GET_1(thisx) ((thisx)->params & 1) +#define GET_ICEBLOCK_SNAP_ROT(thisx) (((thisx)->params >> 1) & 1) +#define GET_ICEBLOCK_ICEBERG(thisx) ((thisx)->params & 1) typedef struct { /* 0x00 */ s16 unk_00; @@ -51,7 +51,7 @@ typedef struct ObjIceblock { /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ColliderCylinder collider; /* 0x01A8 */ ObjIceblockActionFunc actionFunc; - /* 0x01AC */ ObjIceblockUnkFunc unkFunc; + /* 0x01AC */ ObjIceblockExtendedDrawFunc extendedDrawFunc; /* 0x01B0 */ s32 unk_1B0; /* 0x01B4 */ ObjIceBlockUnkStruct unk_1B4[4]; /* 0x01F4 */ ObjIceBlockUnkStruct2 unk_1F4[5]; @@ -67,14 +67,14 @@ typedef struct ObjIceblock { /* 0x0276 */ s16 unk_276; /* 0x0278 */ s16 unk_278; /* 0x027C */ ObjIceBlockUnkStruct4 unk_27C; - /* 0x02A0 */ s16 unk_2A0; + /* 0x02A0 */ s16 stateTimer; // re-used per-actionFunc /* 0x02A2 */ s16 unk_2A2; /* 0x02A4 */ f32 unk_2A4; /* 0x02A8 */ f32 unk_2A8; /* 0x02AC */ s16 unk_2AC; - /* 0x02AE */ s16 unk_2AE; + /* 0x02AE */ s16 meltTimer; // starts at 450 frames = 22 seconds /* 0x02B0 */ s8 unk_2B0; - /* 0x02B1 */ s8 unk_2B1; + /* 0x02B1 */ s8 spawnCutsceneTimer; /* 0x02B4 */ f32 unk_2B4; } ObjIceblock; // size = 0x2B8 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 a70d14600..53d1d7669 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 @@ -7,7 +7,7 @@ #include "z_obj_jg_gakki.h" #include "objects/object_jg/object_jg.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjJgGakki*)thisx) @@ -31,16 +31,16 @@ const ActorInit Obj_Jg_Gakki_InitVars = { void ObjJgGakki_Init(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; ObjJgGakki* this = THIS; - f32 frameCount = Animation_GetLastFrame(&gGoronElderDrumAnim); + f32 frameCount = Animation_GetLastFrame(&gGoronElderDrumTakeOutAnim); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); SkelAnime_Init(globalCtx, &this->skelAnime, &gGoronElderDrumSkel, NULL, NULL, NULL, 0); if (((globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 7)) && - (globalCtx->csCtx.unk_12 == 0)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumAnim, 1.0f, frameCount, frameCount, 2, 0.0f); + (globalCtx->csCtx.currentCsIndex == 0)) { + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, 2, 0.0f); } else if ((globalCtx->sceneNum == SCENE_17SETUGEN) || (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA)) { - Animation_Change(&this->skelAnime, &gGoronElderDrumAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, 2, 0.0f); } else { Actor_MarkForDeath(&this->actor); } diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c index 6c8cb3722..68e7717c1 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.c @@ -6,7 +6,7 @@ #include "z_obj_jgame_light.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjJgameLight*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h index 12d958e73..50023c252 100644 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h +++ b/src/overlays/actors/ovl_Obj_Jgame_Light/z_obj_jgame_light.h @@ -5,6 +5,8 @@ struct ObjJgameLight; +#define OBJJGAMELIGHT_GET_7F(thisx) ((thisx)->params & 0x7F) + typedef struct ObjJgameLight { /* 0x000 */ Actor actor; /* 0x144 */ char unk_144[0x78]; 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 82e4e4de2..6cf8e0751 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 @@ -5,6 +5,7 @@ */ #include "z_obj_kendo_kanban.h" +#include "objects/object_dora/object_dora.h" #define FLAGS 0x00000000 @@ -15,11 +16,14 @@ void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80B65880(ObjKendoKanban* this); void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx); void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx); +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx); +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Kendo_Kanban_InitVars = { ACTOR_OBJ_KENDO_KANBAN, ACTORCAT_NPC, @@ -32,33 +36,89 @@ const ActorInit Obj_Kendo_Kanban_InitVars = { (ActorFunc)ObjKendoKanban_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80B6673C[2] = { +Vec3f D_80B66660 = { -1.5f, 10.0f, 0.5f }; +Vec3f D_80B6666C = { 1.5f, 10.0f, 0.5f }; +Vec3f D_80B66678 = { 0.0f, 4.0f, -1.0f }; +Vec3f D_80B66684 = { 1.0f, 7.0f, 4.0f }; +Vec3f D_80B66690 = { -150.0f, 425.0f, 40.0f }; +Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; +Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; +Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; + +Gfx* D_80B666C0 = object_dora_DL_002080; +Gfx* D_80B666C4 = object_dora_DL_002180; +Gfx* D_80B666C8 = object_dora_DL_002380; +Gfx* D_80B666CC = object_dora_DL_002280; + +Vec3f D_80B666D0 = { -300.0f, 850.0f, 40.0f }; +Vec3f D_80B666DC = { 10.0f, 850.0f, 40.0f }; +Vec3f D_80B666E8 = { 300.0f, 850.0f, 40.0f }; +Vec3f D_80B666F4 = { -300.0f, 310.0f, 40.0f }; +Vec3f D_80B66700 = { 0.0f, 280.0f, 40.0f }; +Vec3f D_80B6670C = { 300.0f, 250.0f, 40.0f }; +Vec3f D_80B66718 = { -300.0f, 10.0f, 40.0f }; +Vec3f D_80B66724 = { 0.0f, 10.0f, 40.0f }; +Vec3f D_80B66730 = { 300.0f, 10.0f, 40.0f }; + +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -300.0f, 850.0f, 40.0f }, { -300.0f, 10.0f, 40.0f }, { 300.0f, 850.0f, 40.0f } } }, }, { - { ELEMTYPE_UNK5, { 0x00000000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK5, + { 0x00000000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 300.0f, 850.0f, 40.0f }, { 300.0f, 10.0f, 40.0f }, { -300.0f, 10.0f, 40.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B667B4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, D_80B6673C, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_TRIS, + }, + 2, + sTrisElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B667C4 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 33, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B667F0 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -93,41 +153,357 @@ static DamageTable D_80B667F0 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B66810 = { 8, 0, 0, 0, MASS_HEAVY }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -#endif +Vec3f D_80B6681C = { 0.0f, 0.0f, 0.0f }; +Vec3f D_80B66828 = { 1.0f, 0.0f, 0.0f }; -extern ColliderTrisElementInit D_80B6673C[2]; -extern ColliderTrisInit D_80B667B4; -extern ColliderCylinderInit D_80B667C4; -extern DamageTable D_80B667F0; -extern CollisionCheckInfoInit2 D_80B66810; +void ObjKendoKanban_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad[2]; + ObjKendoKanban* this = THIS; + Vec3f sp70[3]; + s32 i; + s32 j; -extern UNK_TYPE D_06000180; + Actor_SetScale(&this->actor, 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Init.s") + Collider_InitCylinder(globalCtx, &this->colliderCylinder); + Collider_SetCylinder(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->actor, &sTrisInit, this->colliderTrisElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Destroy.s") + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65880.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultiplyVector3fByState(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65894.s") + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B658A4.s") + this->unk_30C = OBJKENDOKANBAN_GET_F(&this->actor); + this->actor.gravity = -2.0f; + this->unk_2CC = D_80B6681C; + this->unk_2D8 = D_80B6681C; + this->unk_2E4 = D_80B6681C; + this->unk_2F0 = D_80B66828; + this->unk_302 = 0; + this->unk_304 = 0; + this->unk_2FC = -1; + this->unk_300 = 0; + this->unk_308 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65CE0.s") + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + this->unk_26C[i] = this->unk_29C[i] = D_80B6681C; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D54.s") + this->unk_30A = 0; + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + func_80B65880(this); + } else { + func_80B658A4(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65D68.s") +void ObjKendoKanban_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B65DA8.s") + Collider_DestroyCylinder(globalCtx, &this->colliderCylinder); + Collider_DestroyTris(globalCtx, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B6618C.s") +void func_80B65880(ObjKendoKanban* this) { + this->actionFunc = func_80B65894; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/func_80B66304.s") +void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Update.s") +void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + if ((player->swordAnimation == 0) || (player->swordAnimation == 1) || (player->swordAnimation == 0x14)) { + this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); + this->unk_304 = 0x71C; + this->actor.velocity = D_80B6666C; + this->unk_2CC = D_80B6669C; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x - 5.0f, this->actor.home.pos.y, this->actor.home.pos.z, 0, 0, 0, + 0xA); + + this->unk_29C[0] = D_80B666DC; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66724; + } else { + this->unk_30C = (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_4); + this->unk_304 = -0x71C; + this->actor.velocity = D_80B66678; + this->unk_2CC = D_80B666A8; + + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + this->actor.home.pos.x, this->actor.home.pos.y + 5.0f, this->actor.home.pos.z, 0, 0, 0, + 3); + + this->unk_29C[0] = D_80B666F4; + this->unk_29C[1] = D_80B6670C; + this->unk_29C[2] = D_80B66730; + this->unk_29C[3] = D_80B66718; + } + } else if (this->unk_30C == (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_2)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66660; + this->unk_2CC = D_80B66690; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666DC; + this->unk_29C[2] = D_80B66724; + this->unk_29C[3] = D_80B66718; + } else if (this->unk_30C == (OBJKENDOKANBAN_F_2 | OBJKENDOKANBAN_F_1)) { + this->unk_304 = 0x71C; + this->actor.velocity = D_80B66684; + this->unk_2CC = D_80B666B4; + + this->unk_29C[0] = D_80B666D0; + this->unk_29C[1] = D_80B666E8; + this->unk_29C[2] = D_80B6670C; + this->unk_29C[3] = D_80B666F4; + } + + this->unk_30A = 0; + this->actionFunc = func_80B65CE0; +} + +void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx) { + this->actor.velocity.y += this->actor.gravity; + Actor_UpdatePos(&this->actor); + this->unk_302 += this->unk_304; + func_80B65DA8(this, globalCtx); + if (this->actor.world.pos.y < -200.0f) { + this->actor.world.pos.y = -200.0f; + } +} + +void func_80B65D54(ObjKendoKanban* this) { + this->actionFunc = func_80B65D68; +} + +void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (func_80B6618C(this, globalCtx) == 1) { + player->unk_AC0 = 700.0f; + } +} + +void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { + Vec3f sp5C; + s32 pad[2]; + Vec3f sp48; + s32 pad2; + s32 index = 0; + s32 i; + f32 sp38; + + sp5C = this->unk_26C[0]; + sp48 = this->actor.world.pos; + + sp48.x -= this->unk_2D8.x; + sp48.y -= this->unk_2D8.y; + sp48.z -= this->unk_2D8.z; + + sp38 = (this->unk_2F0.x * sp48.z) + (this->unk_2F0.z * -sp48.x); + + if (sp38 < 0.0f) { + this->unk_304 += 0x64; + } else { + this->unk_304 -= 0x64; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (this->unk_26C[i].y < sp5C.y) { + sp5C = this->unk_26C[i]; + index = i; + } + } + + if (index != this->unk_2FC) { + this->unk_300 = 1; + this->unk_2FC = index; + this->unk_2E4 = this->unk_29C[index]; + + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_MultiplyVector3fByState(&this->unk_2E4, &this->actor.world.pos); + this->actor.world.pos = sp5C; + this->actor.prevPos = this->actor.world.pos; + Matrix_StatePop(); + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4); + + if (this->actor.bgCheckFlags & 1) { + this->actor.velocity.x *= 0.8f; + this->actor.velocity.z *= 0.8f; + } + + if (this->unk_300 == 1) { + if (this->unk_308 >= 7) { + s16 temp_v0_3 = this->unk_302 & 0x3FFF; + + if (temp_v0_3 >= 0x2000) { + temp_v0_3 -= 0x4000; + } + this->unk_302 -= temp_v0_3; + this->unk_304 = 0; + func_80B65D54(this); + return; + } + + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + this->unk_300 = 0; + this->actor.velocity.y *= 0.5f; + } else if (this->actor.bgCheckFlags & 1) { + this->unk_308++; + this->unk_300 = 0; + this->actor.velocity.x *= 0.3f; + this->actor.velocity.z *= 0.3f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); + + if (sp38 > 0.0f) { + if (this->unk_304 > 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } else if (this->unk_304 < 0) { + this->unk_304 *= 1.2f; + } else { + this->unk_304 *= -0.6f; + } + } + } +} + +s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 phi_v0; + s32 phi_v1 = 0; + s32 i; + f32 x; + f32 z; + f32 x2; + f32 z2; + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + if (i != 3) { + phi_v0 = i + 1; + } else { + phi_v0 = 0; + } + + z = this->unk_26C[i].z - player->actor.world.pos.z; + x = this->unk_26C[i].x - player->actor.world.pos.x; + + z2 = (this->unk_26C[phi_v0].z - player->actor.world.pos.z); + x2 = (this->unk_26C[phi_v0].x - player->actor.world.pos.x); + + if ((x * z2) < (z * x2)) { + if (phi_v1 == 0) { + phi_v1 = 1; + } else if (phi_v1 != 1) { + return false; + } + } else if (phi_v1 == 0) { + phi_v1 = -1; + } else if (phi_v1 != -1) { + return false; + } + } + return true; +} + +void func_80B66304(ObjKendoKanban* this, GlobalContext* globalCtx) { + if ((this->actionFunc != func_80B65CE0) && (this->actionFunc != func_80B65D68)) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AC_HIT; + func_80B658A4(this, globalCtx); + } + + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + this->colliderCylinder.dim.pos.z -= (s16)(20.0f * Math_CosS(this->actor.shape.rot.y)); + this->colliderCylinder.dim.pos.x -= (s16)(20.0f * Math_SinS(this->actor.shape.rot.y)); + + if (this->actionFunc == func_80B65894) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + } +} + +void ObjKendoKanban_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + + this->actionFunc(this, globalCtx); + + func_80B66304(this, globalCtx); +} + +#ifdef NON_MATCHING +void ObjKendoKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjKendoKanban* this = THIS; + s32 i; + Gfx* poly; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + if (this->unk_30C == OBJKENDOKANBAN_F_0) { + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_dora_DL_000180); + } else { + Matrix_InsertRotationAroundUnitVector_s(this->unk_302, &this->unk_2F0, MTXMODE_APPLY); + Matrix_InsertTranslation(-this->unk_2E4.x, -this->unk_2E4.y, -this->unk_2E4.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (this->unk_30C & OBJKENDOKANBAN_F_1) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C0); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_2) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C4); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_4) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666C8); + } + + if (this->unk_30C & OBJKENDOKANBAN_F_8) { + gSPDisplayList(POLY_OPA_DISP++, D_80B666CC); + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { + Matrix_MultiplyVector3fByState(&this->unk_29C[i], &this->unk_26C[i]); + } + + Matrix_MultiplyVector3fByState(&this->unk_2CC, &this->unk_2D8); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") +#endif diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h index 6adb95dd1..a8c4f8d7c 100644 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h +++ b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h @@ -7,11 +7,34 @@ struct ObjKendoKanban; typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, GlobalContext*); +#define OBJKENDOKANBAN_GET_F(thisx) ((thisx)->params & 0xF) + +#define OBJKENDOKANBAN_F_0 0 +#define OBJKENDOKANBAN_F_1 (1 << 0) +#define OBJKENDOKANBAN_F_2 (1 << 1) +#define OBJKENDOKANBAN_F_4 (1 << 2) +#define OBJKENDOKANBAN_F_8 (1 << 3) + typedef struct ObjKendoKanban { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x124]; + /* 0x0144 */ ColliderCylinder colliderCylinder; + /* 0x0190 */ ColliderTris colliderTris; + /* 0x01B0 */ ColliderTrisElement colliderTrisElements[2]; /* 0x0268 */ ObjKendoKanbanActionFunc actionFunc; - /* 0x026C */ char unk_26C[0xA4]; + /* 0x026C */ Vec3f unk_26C[4]; + /* 0x029C */ Vec3f unk_29C[4]; + /* 0x02CC */ Vec3f unk_2CC; + /* 0x02D8 */ Vec3f unk_2D8; + /* 0x02E4 */ Vec3f unk_2E4; + /* 0x02F0 */ Vec3f unk_2F0; + /* 0x02FC */ s32 unk_2FC; + /* 0x0300 */ s16 unk_300; + /* 0x0302 */ s16 unk_302; + /* 0x0304 */ s16 unk_304; + /* 0x0306 */ UNK_TYPE1 pad306[2]; + /* 0x0308 */ s16 unk_308; + /* 0x030A */ s16 unk_30A; + /* 0x030C */ u8 unk_30C; } ObjKendoKanban; // size = 0x310 extern const ActorInit Obj_Kendo_Kanban_InitVars; 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 9a31d39f5..979848c3b 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 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjKibako*)thisx) @@ -271,7 +271,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { ObjKibako_SetupHeld(this); this->actor.room = -1; - this->actor.colChkInfo.mass = 0x78; + this->actor.colChkInfo.mass = 120; if (func_800A817C(KIBAKO_COLLECTIBLE_ID(&this->actor))) { ObjKibako_SpawnCollectible(this, globalCtx); } @@ -347,7 +347,7 @@ void ObjKibako_Held(ObjKibako* this, GlobalContext* globalCtx) { } else { Actor_MoveWithGravity(&this->actor); ObjKibako_SetupThrown(this); - this->actor.flags &= ~0x4000000; + this->actor.flags &= ~ACTOR_FLAG_4000000; } Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 18.0f, 15.0f, 0.0f, 0x45); } else { 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 dd8029eca..c0e5d8b4b 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -161,7 +161,7 @@ void ObjKibako2_Init(Actor* thisx, GlobalContext* globalCtx) { if (func_800A81A4(globalCtx, KIBAKO2_COLLECTIBLE_ID(&this->dyna.actor), KIBAKO2_COLLECTIBLE_FLAG(&this->dyna.actor))) { this->unk_1AC = 1; - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; } } if ((contents != CONTENTS_SKULLTULA) || !ObjKibako2_ContainsSkulltula(this, globalCtx)) { @@ -210,7 +210,7 @@ void ObjKibako2_Idle(ObjKibako2* this, GlobalContext* globalCtx) { if (ObjKibako2_ShouldBreak(this)) { ObjKibako2_Break(this, globalCtx); SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); - this->dyna.actor.flags |= 0x10; + this->dyna.actor.flags |= ACTOR_FLAG_10; func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = NULL; this->actionFunc = ObjKibako2_Kill; 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 8d4b2f582..740439ead 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -5,8 +5,9 @@ */ #include "z_obj_kinoko.h" +#include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjKinoko*)thisx) @@ -15,7 +16,6 @@ void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx); void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Kinoko_InitVars = { ACTOR_OBJ_KINOKO, ACTORCAT_ITEMACTION, @@ -28,12 +28,63 @@ const ActorInit Obj_Kinoko_InitVars = { (ActorFunc)ObjKinoko_Draw, }; -#endif +void ObjKinoko_Init(Actor* thisx, GlobalContext* globalCtx) { + thisx->world.pos.y += 4.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Init.s") +void ObjKinoko_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Destroy.s") +void ObjKinoko_Update(Actor* thisx, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Update.s") + if (player->currentMask != PLAYER_MASK_SCENTS) { + thisx->draw = NULL; + thisx->hintId = 0xFF; + thisx->flags &= ~ACTOR_FLAG_1; + } else { + thisx->draw = ObjKinoko_Draw; + thisx->hintId = 0x64; + thisx->flags |= ACTOR_FLAG_1; + if (Actor_HasParent(thisx, globalCtx)) { + Flags_SetCollectible(globalCtx, OBJ_KINOKO_GET_FLAG(thisx)); + Actor_MarkForDeath(thisx); + return; + } + Actor_PickUp(thisx, globalCtx, GI_MAX, 20.0f, 10.0f); + if (Math_SmoothStepToF(&thisx->speedXZ, 0.0f, 0.04f, 2.0f, 0.5f) < 0.5f) { + thisx->scale.x = 0.0f; + thisx->speedXZ = 110.0f; + thisx->velocity.x = 0.2f; + } + if (Math_SmoothStepToF(&thisx->scale.x, thisx->velocity.x, 0.04f, 0.004f, 0.001f) < + ((thisx->velocity.x == 0.0f) ? 0.0f : 0.05f)) { + thisx->velocity.x = 0.0f; + } + thisx->scale.y = thisx->scale.x; + thisx->scale.z = thisx->scale.x; + thisx->shape.rot.y = Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kinoko/ObjKinoko_Draw.s") +void ObjKinoko_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx* gfx; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + + gfx = POLY_XLU_DISP; + gDPSetPrimColor(&gfx[0], 0, 0, 169, 63, 186, (u8)thisx->speedXZ); + gDPSetEnvColor(&gfx[1], 110, 44, 200, 100); + gDPSetRenderMode(&gfx[2], G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPMatrix(&gfx[3], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[4], &gameplay_keep_DL_029D10[2]); + Matrix_InsertXRotation_s(-0x4000, 1); + gSPMatrix(&gfx[5], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[6], &gameplay_keep_DL_029D10[2]); + POLY_XLU_DISP = &gfx[7]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h index 9ae26adf9..9073e3e14 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h @@ -11,4 +11,6 @@ typedef struct ObjKinoko { extern const ActorInit Obj_Kinoko_InitVars; +#define OBJ_KINOKO_GET_FLAG(thisx) ((thisx)->params & 0x7F) + #endif // Z_OBJ_KINOKO_H 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 1f9548839..5080c19e6 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c @@ -7,7 +7,7 @@ #include "z_obj_kzsaku.h" #include "objects/object_kzsaku/object_kzsaku.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjKzsaku*)thisx) 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 481cc22f6..300e299aa 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -6,7 +6,7 @@ #include "z_obj_lift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjLift*)thisx) 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 ae7b508bd..e9456bac1 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -7,7 +7,7 @@ #include "z_obj_lightswitch.h" #include "objects/object_lightswitch/object_lightswitch.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjLightswitch*)thisx) 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 57db84b12..d804f6b63 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -6,7 +6,7 @@ #include "z_obj_lupygamelift.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjLupygamelift*)thisx) 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 19c078792..a5aaefd4f 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -6,7 +6,7 @@ #include "z_obj_makekinsuta.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjMakekinsuta*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c index c7f49d683..1645f8469 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -6,7 +6,7 @@ #include "z_obj_makeoshihiki.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjMakeoshihiki*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c index 1e17d7902..a32f791bc 100644 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c +++ b/src/overlays/actors/ovl_Obj_Milk_Bin/z_obj_milk_bin.c @@ -16,8 +16,6 @@ void ObjMilkBin_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx); void ObjMilkBin_Draw(Actor* thisx, GlobalContext* globalCtx); -// gMilkBinMilkJarDL - const ActorInit Obj_Milk_Bin_InitVars = { ACTOR_OBJ_MILK_BIN, ACTORCAT_PROP, @@ -60,7 +58,7 @@ void ObjMilkBin_Init(Actor* thisx, GlobalContext* globalCtx) { this->disableDraw = 0; this->type = thisx->params; - if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.save.weekEventReg[0x34] & 1)) { + if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.save.weekEventReg[52] & 1)) { this->disableDraw |= 1; } } @@ -76,14 +74,14 @@ void ObjMilkBin_Update(Actor* thisx, GlobalContext* globalCtx2) { ObjMilkBin* this = THIS; if (this->type == OBJ_MILK_BIN_TYPE_1) { - if (gSaveContext.save.weekEventReg[0x16] & 1) { + if (gSaveContext.save.weekEventReg[22] & 1) { if (((gSaveContext.save.day == 2) && (gSaveContext.save.isNight == 1)) || (gSaveContext.save.day >= 3)) { Actor_MarkForDeath(&this->actor); return; } } } else if (this->type == OBJ_MILK_BIN_TYPE_2) { - if (gSaveContext.save.weekEventReg[0x34] & 1) { + if (gSaveContext.save.weekEventReg[52] & 1) { this->disableDraw &= ~1; } else { this->disableDraw |= 1; 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 247e01f06..546f0db16 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 @@ -7,7 +7,7 @@ #include "z_obj_moon_stone.h" #include "objects/object_gi_reserve00/object_gi_reserve00.h" -#define FLAGS 0x00100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000) #define THIS ((ObjMoonStone*)thisx) @@ -47,19 +47,17 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos.y += 10.0f; if (this->unk194 == 0) { this->actor.colChkInfo.health = 0; - this->actor.flags |= 9; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80C0662C(this); - } else { - if ((gSaveContext.save.weekEventReg[74] & 0x40) == 0) { - if ((gSaveContext.save.weekEventReg[74] & 0x80)) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, -1); - } - this->actor.flags &= ~1; - func_80C0673C(this); - } else { - Actor_MarkForDeath(&this->actor); + } else if (!(gSaveContext.save.weekEventReg[74] & 0x40)) { + if ((gSaveContext.save.weekEventReg[74] & 0x80)) { + Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, -1); } + this->actor.flags &= ~ACTOR_FLAG_1; + func_80C0673C(this); + } else { + Actor_MarkForDeath(&this->actor); } } @@ -77,7 +75,7 @@ void func_80C06640(ObjMoonStone* this, GlobalContext* globalCtx) { sp1A -= player->actor.shape.rot.y; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { this->actor.colChkInfo.health = 1; - func_801518B0(globalCtx, 0x5E3U, &this->actor); + Message_StartTextbox(globalCtx, 0x5E3U, &this->actor); func_80C066F8(this); } else { s32 phi_v0 = ABS_ALT(sp1A); @@ -99,7 +97,7 @@ void func_80C0670C(ObjMoonStone* this, GlobalContext* globalCtx) { } void func_80C0673C(ObjMoonStone* this) { - if ((gSaveContext.save.weekEventReg[74] & 0x80) == 0) { + if (!(gSaveContext.save.weekEventReg[74] & 0x80)) { this->actor.draw = NULL; } this->actionFunc = func_80C06768; @@ -107,7 +105,7 @@ void func_80C0673C(ObjMoonStone* this) { void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { if ((gSaveContext.save.weekEventReg[74] & 0x80)) { - if (this->actor.draw == 0) { + if (this->actor.draw == NULL) { this->actor.draw = ObjMoonStone_Draw; Actor_Spawn(&globalCtx->actorCtx, globalCtx, 1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, -1); @@ -129,7 +127,7 @@ void func_80C0685C(ObjMoonStone* this) { } void func_80C06870(ObjMoonStone* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 6 && func_80147624(globalCtx)) { + if (Message_GetState(&globalCtx->msgCtx) == 6 && Message_ShouldAdvance(globalCtx)) { gSaveContext.save.weekEventReg[74] |= 0x40; Actor_MarkForDeath(&this->actor); } @@ -139,7 +137,7 @@ void ObjMoonStone_Update(Actor* thisx, GlobalContext* globalCtx) { ObjMoonStone* this = THIS; Player* player = GET_PLAYER(globalCtx); - if ((player->stateFlags1 & 0x10000282) == 0) { + if (!(player->stateFlags1 & 0x10000282)) { this->actionFunc(this, globalCtx); } } 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 86969df2c..f81b4fe47 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 @@ -6,7 +6,7 @@ #include "z_obj_mu_pict.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ObjMuPict*)thisx) @@ -109,7 +109,7 @@ void func_80C06CD8(ObjMuPict* this, GlobalContext* globalCtx) { func_80C06E88(this, globalCtx); break; case 6: - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { func_80C06B5C(this); if (this->actor.cutscene >= 0) { ActorCutscene_Stop(this->actor.cutscene); @@ -137,51 +137,51 @@ void func_80C06DC8(ObjMuPict* this, GlobalContext* globalCtx) { if (this->unk14A == 0) { if (this->unk148 == 0) { this->unk148 = 1; - func_801518B0(globalCtx, 0x159A, &this->actor); + Message_StartTextbox(globalCtx, 0x159A, &this->actor); this->textId = 0x159A; } else { - func_801518B0(globalCtx, 0x159D, &this->actor); + Message_StartTextbox(globalCtx, 0x159D, &this->actor); this->textId = 0x159D; } } else if (this->unk148 == 0) { this->unk148 = 1; - func_801518B0(globalCtx, 0x15A0, &this->actor); + Message_StartTextbox(globalCtx, 0x15A0, &this->actor); this->textId = 0x15A0; } else { - func_801518B0(globalCtx, 0x15A3, &this->actor); + Message_StartTextbox(globalCtx, 0x15A3, &this->actor); this->textId = 0x15A3; } } void func_80C06E88(ObjMuPict* this, GlobalContext* globalCtx) { - if (func_80147624(globalCtx)) { + if (Message_ShouldAdvance(globalCtx)) { switch (this->textId) { case 0x159A: - func_801518B0(globalCtx, 0x159B, &this->actor); + Message_StartTextbox(globalCtx, 0x159B, &this->actor); this->textId = 0x159B; break; case 0x159B: - func_801518B0(globalCtx, 0x159C, &this->actor); + Message_StartTextbox(globalCtx, 0x159C, &this->actor); this->textId = 0x159C; break; case 0x159D: - func_801518B0(globalCtx, 0x159E, &this->actor); + Message_StartTextbox(globalCtx, 0x159E, &this->actor); this->textId = 0x159E; break; case 0x159E: - func_801518B0(globalCtx, 0x159F, &this->actor); + Message_StartTextbox(globalCtx, 0x159F, &this->actor); this->textId = 0x159F; break; case 0x15A0: - func_801518B0(globalCtx, 0x15A1, &this->actor); + Message_StartTextbox(globalCtx, 0x15A1, &this->actor); this->textId = 0x15A1; break; case 0x15A1: - func_801518B0(globalCtx, 0x15A2, &this->actor); + Message_StartTextbox(globalCtx, 0x15A2, &this->actor); this->textId = 0x15A2; break; case 0x15A3: - func_801518B0(globalCtx, 0x15A4, &this->actor); + Message_StartTextbox(globalCtx, 0x15A4, &this->actor); this->textId = 0x15A4; 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 f41e577b4..b24354482 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -259,7 +259,7 @@ void ObjMure_InitialAction(ObjMure* this, GlobalContext* globalCtx) { void ObjMure_CulledState(ObjMure* this, GlobalContext* globalCtx) { if (fabsf(this->actor.projectedPos.z) < sZClip[this->type]) { this->actionFunc = ObjMure_ActiveState; - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; ObjMure_SpawnActors(this, globalCtx); } } @@ -382,7 +382,7 @@ void ObjMure_ActiveState(ObjMure* this, GlobalContext* globalCtx) { ObjMure_CheckChildren(this, globalCtx); if (sZClip[this->type] + 40.0f <= fabsf(this->actor.projectedPos.z)) { this->actionFunc = ObjMure_CulledState; - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; ObjMure_KillActors(this, globalCtx); } else if (sTypeGroupBehaviorFunc[this->type] != NULL) { sTypeGroupBehaviorFunc[this->type](this, globalCtx); 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 d2cd9f7fa..ba5b62151 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -6,7 +6,7 @@ #include "z_obj_nozoki.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjNozoki*)thisx) 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 66dbd49fb..731bc4328 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -6,7 +6,7 @@ #include "z_obj_ocarinalift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjOcarinalift*)thisx) 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 2d1149715..fa3b46cf7 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -332,7 +332,7 @@ s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, Ob maxDist = maxDists[D_80918940[i]]; faceVtxOffset.x = (sFaceVtx[i].x * this->dyna.actor.scale.x * 10.0f) + sFaceDirection[i].x; - faceVtxOffset.y = (sFaceVtx[i].y * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].y; + faceVtxOffset.y = (sFaceVtx[i].z * this->dyna.actor.scale.y * 10.0f) + sFaceDirection[i].z; faceVtxOffset.z = 0.0f; ObjOshihiki_RotateXZ(&faceVtx, &faceVtxOffset, sn, cs); @@ -345,8 +345,8 @@ s32 ObjOshihiki_CheckWall(GlobalContext* globalCtx, s16 angle, f32 direction, Ob faceVtxNext.y = faceVtx.y; faceVtxNext.z = (maxDist * cs) + faceVtx.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, 1, 0, 0, 1, &bgId, - &this->dyna.actor, 0.0f)) { + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &faceVtx, &faceVtxNext, &posResult, &outPoly, true, false, + false, true, &bgId, &this->dyna.actor, 0.0f)) { return true; } } 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 1c8f0a132..0f594f1e1 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -6,7 +6,7 @@ #include "z_obj_purify.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjPurify*)thisx) 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 b89a0b1c3..95b9a3a13 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -5,8 +5,10 @@ */ #include "z_obj_pzlblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" +#include "objects/object_secom_obj/object_secom_obj.h" -#define FLAGS 0x04000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_4000000) #define THIS ((ObjPzlblock*)thisx) @@ -14,7 +16,15 @@ void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_809A3A48(ObjPzlblock* this); +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3BA4(ObjPzlblock* this); +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3D1C(ObjPzlblock* this); +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx); +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx); +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx); + const ActorInit Obj_Pzlblock_InitVars = { ACTOR_OBJ_PZLBLOCK, ACTORCAT_PROP, @@ -27,46 +37,337 @@ const ActorInit Obj_Pzlblock_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_809A4078[] = { +s16 D_809A4050[] = { 1, -1, 0, 0 }; +s16 D_809A4058[] = { 0, 0, 1, -1 }; + +typedef struct { + /* 0x0 */ s16 unk_00; + /* 0x4 */ CollisionHeader* unk_04; + /* 0x8 */ Gfx* unk_08; +} ObjPzlblockStruct; + +ObjPzlblockStruct D_809A4060[] = { + { GAMEPLAY_DANGEON_KEEP, &gameplay_dangeon_keep_Colheader_01D488, gameplay_dangeon_keep_DL_01C228 }, + { OBJECT_SECOM_OBJ, &object_secom_obj_Colheader_002CB8, object_secom_obj_DL_001A58 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3S(world.rot, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +Color_RGB8 D_809A4088[] = { + { 180, 150, 250 }, { 100, 180, 150 }, { 0, 0, 255 }, { 255, 255, 0 }, + { 0, 255, 255 }, { 255, 0, 255 }, { 0, 0, 0 }, { 255, 255, 255 }, +}; -extern InitChainEntry D_809A4078[]; +s32 func_809A33E0(ObjPzlblock* this, GlobalContext* globalCtx, s16 arg2) { + return !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 1) || + !DynaPolyActor_ValidateMove(globalCtx, &this->dyna, 30, arg2, 28); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A33E0.s") +s32 func_809A3448(ObjPzlblock* this) { + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3448.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A34E0.s") + if (this->dyna.pushForce < 0.0f) { + temp_v0 = BINANG_ROT180(temp_v0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A35EC.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A376C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Init.s") + if (temp_v0 < 0x4000) { + return 2; + } + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Destroy.s") +s32 func_809A34E0(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A48.s") + if (temp_v0 == 0) { + return arg1 == 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3A74.s") + if (temp_v0 == 1) { + return arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BA4.s") + if (temp_v0 == 2) { + return arg1 == 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3BC0.s") + if (temp_v0 == 3) { + return arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D1C.s") + if (temp_v0 == 4) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3D38.s") + if (temp_v0 == 5) { + return arg1 == 2 || arg1 == 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/ObjPzlblock_Update.s") + if (temp_v0 == 6) { + if (this->unk_176 != 0) { + return arg1 == 0 || arg1 == 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3E58.s") + if (this->unk_178 != 0) { + return arg1 == 2 || arg1 == 3; + } + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Pzlblock/func_809A3F0C.s") +s32 func_809A35EC(ObjPzlblock* this, s32 arg1) { + s32 temp_v0 = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 temp_v1 = this->dyna.actor.home.rot.x & 0xF; + s32 temp; + + if (temp_v0 == 0) { + return this->unk_176 < temp_v1; + } + + if (temp_v0 == 1) { + return -temp_v1 < this->unk_176; + } + + if (temp_v0 == 2) { + return this->unk_178 < temp_v1; + } + + if (temp_v0 == 3) { + return -temp_v1 < this->unk_178; + } + + if (temp_v0 == 4) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 5) { + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + if (temp_v0 == 6) { + if ((arg1 == 0) || (arg1 == 1)) { + temp = D_809A4050[arg1] + this->unk_176; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + temp = D_809A4058[arg1] + this->unk_178; + return (temp_v1 >= temp) && (-temp_v1 <= temp); + } + + return false; +} + +void func_809A376C(ObjPzlblock* this, s32 arg1) { + this->unk_176 += D_809A4050[arg1]; + this->unk_178 += D_809A4058[arg1]; + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_164 = &this->dyna.actor.world.pos.x; + this->unk_168 = this->dyna.actor.home.pos.x + (this->unk_176 * 60); + } else { + this->unk_164 = &this->dyna.actor.world.pos.z; + this->unk_168 = this->dyna.actor.home.pos.z + (this->unk_178 * 60); + } + this->unk_16C = arg1; +} + +void ObjPzlblock_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + s32 sp2C = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 sp28 = this->dyna.actor.home.rot.x & 0xF; + ObjPzlblockStruct* sp24 = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 0.1f); + + this->dyna.actor.home.rot.y = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + + DynaPolyActor_Init(&this->dyna, 0); + + this->unk_17A = Object_GetIndex(&globalCtx->objectCtx, sp24->unk_00); + + if (sp28 == 0) { + func_809A3D1C(this); + } else if (Flags_GetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor))) { + if (sp2C == 0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 1) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 2) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (sp28 * 60); + func_809A3D1C(this); + } else if (sp2C == 3) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z - (sp28 * 60); + func_809A3D1C(this); + } else { + func_809A3A48(this); + } + } else { + func_809A3A48(this); + } +} + +void ObjPzlblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_809A3A48(ObjPzlblock* this) { + this->actionFunc = func_809A3A74; + this->unk_16E[1] = 0; + this->unk_16E[2] = 0; + this->unk_16E[3] = 0; + this->unk_16E[0] = 0; + this->unk_160 = 4; +} + +void func_809A3A74(ObjPzlblock* this, GlobalContext* globalCtx) { + s32 i; + s32 sp20 = func_809A3448(this); + + for (i = 0; i < ARRAY_COUNT(this->unk_16E); i++) { + if (sp20 == i) { + this->unk_16E[i]++; + } else if (this->unk_16E[i] > 0) { + this->unk_16E[i]--; + } + } + + if (sp20 != -1) { + if ((this->unk_16E[sp20] >= 11) && func_809A34E0(this, sp20) && func_809A35EC(this, sp20)) { + if (!func_809A33E0(this, globalCtx, (this->dyna.pushForce > 0.0f) ? 90 : 120)) { + func_809A376C(this, sp20); + func_809A3BA4(this); + return; + } + } + + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void func_809A3BA4(ObjPzlblock* this) { + this->actionFunc = func_809A3BC0; + this->unk_160 = 5; +} + +void func_809A3BC0(ObjPzlblock* this, GlobalContext* globalCtx) { + if (Math_StepToF(this->unk_164, this->unk_168, 2.3f)) { + Player* player = GET_PLAYER(globalCtx); + s32 params = OBJPZLBLOCK_GET_ROTZ(&this->dyna.actor); + s32 pad; + s32 sp20 = 0; + + if ((params == 4) || (params == 5) || (params == 6)) { + if (!func_809A35EC(this, this->unk_16C) || func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else if (func_809A35EC(this, this->unk_16C)) { + if (func_809A33E0(this, globalCtx, 0x5A)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + } + } else { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + Flags_SetSwitch(globalCtx, OBJPZLBLOCK_GET_7F(&this->dyna.actor)); + sp20 = 1; + } + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + if (sp20 == 0) { + func_809A3A48(this); + } else { + func_809A3D1C(this); + } + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); + } +} + +void func_809A3D1C(ObjPzlblock* this) { + this->actionFunc = func_809A3D38; + this->unk_160 = 4; +} + +void func_809A3D38(ObjPzlblock* this, GlobalContext* globalCtx) { + if (fabsf(this->dyna.pushForce) > 0.1f) { + GET_PLAYER(globalCtx)->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; + } +} + +void ObjPzlblock_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjPzlblock* this = THIS; + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, 4); + + if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_17A)) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(&this->dyna.actor)]; + + this->dyna.actor.objBankIndex = this->unk_17A; + Actor_SetObjectDependency(globalCtx, &this->dyna.actor); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp2C->unk_04); + this->dyna.actor.update = func_809A3E58; + this->dyna.actor.draw = func_809A3F0C; + } +} + +void func_809A3E58(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblock* this = THIS; + + this->actionFunc(this, globalCtx); + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + + if (this->unk_160 != 0) { + Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 15.0f, 30.0f, 0.0f, this->unk_160); + if (((this->actionFunc == func_809A3A74) || (this->actionFunc == func_809A3D38)) && + (this->dyna.actor.bgCheckFlags & 1) && !DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + this->unk_160 = 0; + } + } +} + +void func_809A3F0C(Actor* thisx, GlobalContext* globalCtx) { + ObjPzlblockStruct* sp2C = &D_809A4060[OBJPZLBLOCK_GET_1000(thisx)]; + Color_RGB8* sp28 = &D_809A4088[OBJPZLBLOCK_GET_700(thisx)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sp28->r, sp28->g, sp28->b, 255); + gSPDisplayList(POLY_OPA_DISP++, sp2C->unk_08); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} 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 437583f62..fa1ca1f59 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.h @@ -5,9 +5,24 @@ struct ObjPzlblock; +typedef void (*ObjPzlblockActionFunc)(struct ObjPzlblock*, GlobalContext*); + +#define OBJPZLBLOCK_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJPZLBLOCK_GET_700(thisx) (((thisx)->params >> 8) & 7) +#define OBJPZLBLOCK_GET_1000(thisx) (((thisx)->params >> 0xC) & 1) +#define OBJPZLBLOCK_GET_ROTZ(thisx) ((thisx)->home.rot.z & 7) + typedef struct ObjPzlblock { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x38]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjPzlblockActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ f32* unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ s16 unk_16C; + /* 0x16E */ s16 unk_16E[4]; + /* 0x176 */ s16 unk_176; + /* 0x178 */ s16 unk_178; + /* 0x17A */ s8 unk_17A; } ObjPzlblock; // size = 0x17C extern const ActorInit Obj_Pzlblock_InitVars; 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 17490112f..24f3fe0d6 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -7,7 +7,7 @@ #include "z_obj_raillift.h" #include "objects/object_raillift/object_raillift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjRaillift*)thisx) @@ -89,7 +89,7 @@ void ObjRaillift_Init(Actor* thisx, GlobalContext* globalCtx) { this->curPoint = OBJRAILLIFT_GET_STARTING_POINT(thisx); this->endPoint = path->count - 1; this->direction = 1; - this->points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + this->points = Lib_SegmentedToVirtual(path->points); ObjRaillift_UpdatePosition(this, this->curPoint); if (OBJRAILLIFT_HAS_FLAG(thisx) && !Flags_GetSwitch(globalCtx, OBJRAILLIFT_GET_FLAG(thisx))) { this->actionFunc = ObjRaillift_Idle; 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 d7f15477a..ff0c8d270 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -6,7 +6,7 @@ #include "z_obj_roomtimer.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjRoomtimer*)thisx) @@ -68,7 +68,7 @@ void func_80973D3C(ObjRoomtimer* this, GlobalContext* globalCtx) { this->actionFunc = func_80973DE0; } else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) { play_sound(NA_SE_OC_ABYSS); - func_80169EFC(globalCtx); + func_80169EFC(&globalCtx->state); Actor_MarkForDeath(&this->actor); } } diff --git a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c index 61bc5570c..f6f744d15 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -6,7 +6,7 @@ #include "z_obj_shutter.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjShutter*)thisx) 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 7bd1dfc1e..1253747e4 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -5,8 +5,9 @@ */ #include "z_obj_skateblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSkateblock*)thisx) @@ -15,7 +16,17 @@ void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A22308(ObjSkateblock* this); +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A2244C(ObjSkateblock* this); +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22628(ObjSkateblock* this); +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22728(ObjSkateblock* this); +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A227A4(ObjSkateblock* this); +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx); + const ActorInit Obj_Skateblock_InitVars = { ACTOR_OBJ_SKATEBLOCK, ACTORCAT_BG, @@ -28,76 +39,658 @@ const ActorInit Obj_Skateblock_InitVars = { (ActorFunc)ObjSkateblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A22AE0[] = { - ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +s32 D_80A22A10 = 0; + +s32 D_80A22A14 = 0; + +AnimatedMaterial* D_80A22A18 = NULL; + +Vec2f D_80A22A1C[] = { + { -300.0f, 300.0f }, { 300.0f, 300.0f }, { -300.0f, -300.0f }, { 300.0f, -300.0f }, { 0.0f, 0.0f }, }; -#endif +Vec2f D_80A22A44[] = { + { 0.5f, -0.5f }, { -0.5f, -0.5f }, { 0.5f, 0.5f }, { -0.5f, 0.5f }, { 0.0f, 0.0f }, +}; -extern InitChainEntry D_80A22AE0[]; +Vec2f D_80A22A6C[] = { + { -300.0f, 0.0f }, { 300.0f, 0.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 300.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21150.s") +Vec2f D_80A22A94[] = { + { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A211F4.s") +f32 D_80A22ABC[] = { -300.0f, 300.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A212F0.s") +f32 D_80A22AC4[] = { 1.0f, -1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21370.s") +Vec3f D_80A22ACC = { 0.0f, 0.3f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21548.s") +Color_RGBA8 D_80A22AD8 = { 250, 250, 250, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A216D4.s") +Color_RGBA8 D_80A22ADC = { 180, 180, 180, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21934.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21990.s") +f32 D_80A22AF8[] = { 14.0f, -14.0f, 14.0f, -14.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C30.s") +Color_RGB8 D_80A22B08[] = { + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C88.s") +s32 func_80A21150(ObjSkateblock* this) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CB4.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + } else { + temp_v0 = BINANG_SUB(this->dyna.yRotation, 0x6000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CD8.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21D1C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21E9C.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F68.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F74.s") +void func_80A211F4(ObjSkateblock* this, s32 arg1) { + s32 i; + s32 phi_v0 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Init.s") + if (this->dyna.pushForce > 0.0f) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Destroy.s") + for (i = 0; i < ARRAY_COUNT(this->unk_172); i++) { + if ((arg1 == i) && phi_v0) { + this->unk_172[i]++; + } else if (this->unk_172[i] > 0) { + this->unk_172[i]--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22308.s") +void func_80A212F0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22334.s") + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2244C.s") +s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { + ObjSkateblockFloor* floor; + s32 i; + s32 pad; + s32 sp98; + Vec3f sp8C; + s32 sp88; + f32 phi_f20 = BGCHECK_Y_MIN; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A224A4.s") + sp88 = false; + sp8C.y = this->dyna.actor.world.pos.y + 40.0f; + sp98 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22628.s") + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2264C.s") + floor->poly = NULL; + floor->height = BGCHECK_Y_MIN; + floor->bgId = BG_ACTOR_MAX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22728.s") + sp8C.x = this->dyna.actor.world.pos.x + ((D_80A22A1C[i].x * this->dyna.actor.scale.x) + D_80A22A44[i].x); + sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].z * this->dyna.actor.scale.z) + D_80A22A44[i].z); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2273C.s") + floor->height = + BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227A4.s") + if (floor->height > BGCHECK_Y_MIN + 1.0f) { + sp88 = true; + if (phi_f20 < floor->height) { + phi_f20 = floor->height; + sp98 = i; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227C0.s") + if (sp98 >= 0) { + this->dyna.actor.floorPoly = this->unk_184[sp98].poly; + this->dyna.actor.floorHeight = this->unk_184[sp98].height; + this->dyna.actor.floorBgId = this->unk_184[sp98].bgId; + } + return sp88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Update.s") +s32 func_80A21548(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 i; + ObjSkateblockFloor* floor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Draw.s") + this->unk_1C1 &= ~4; + + if (func_80A21370(this, globalCtx)) { + f32 maxHeight = BGCHECK_Y_MIN; + s32 phi_v1 = false; + f32 temp_f12 = this->dyna.actor.world.pos.y - 10.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; + if ((temp_f12 < floor->height) && (floor->height > maxHeight)) { + maxHeight = floor->height; + phi_v1 = true; + } + } + + if (phi_v1) { + this->dyna.actor.world.pos.y = maxHeight; + this->unk_1C1 |= 4; + this->dyna.actor.velocity.y = 0.0f; + } + return phi_v1; + } + return false; +} + +s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { + s32 pad; + f32 spE8; + f32 spE4; + s32 i; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + f32 temp_f20; + f32 temp_f24; + s32 spA4; + CollisionPoly* spA0; + s32 ret; + f32 temp_f26; + s16 sp96 = this->dyna.yRotation; + f32 temp_f2; + + if (this->dyna.pushForce < 0.0f) { + sp96 -= 0x8000; + } + spE8 = Math_SinS(sp96); + spE4 = Math_CosS(sp96); + + temp_f2 = Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos) + + (300.0f * this->dyna.actor.scale.z) + arg2; + temp_f24 = temp_f2 * spE8; + temp_f26 = temp_f2 * spE4; + + ret = false; + temp_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22A6C); i++) { + spBC.x = (D_80A22A6C[i].x * this->dyna.actor.scale.x) + D_80A22A94[i].x; + spBC.y = (D_80A22A6C[i].z * this->dyna.actor.scale.y) + D_80A22A94[i].z; + spBC.z = 0.0f; + + func_80A212F0(&spD4, &spBC, sp96); + + spD4.x += this->dyna.actor.prevPos.x; + spD4.y += this->dyna.actor.prevPos.y; + spD4.z += this->dyna.actor.prevPos.z; + + spC8.x = temp_f24 + spD4.x; + spC8.y = spD4.y; + spC8.z = temp_f26 + spD4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD4, &spC8, &spB0, &spA0, true, false, false, true, &spA4, + &this->dyna.actor, 0.0f)) { + temp_f2 = Math3D_Vec3fDistSq(&spD4, &spB0); + if (temp_f2 < temp_f20) { + temp_f20 = temp_f2; + ret = true; + Math_Vec3f_Diff(&spB0, &spC8, arg3); + } + } + } + return ret; +} + +s32 func_80A21934(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A216D4(this, globalCtx, 0.0f, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} + +s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + f32 sp100; + s16 phi_s6 = this->dyna.yRotation; + f32 phi_f22; + Vec3f spEC; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + f32 temp_f0; + f32 temp_f12; + s32 spBC; + CollisionPoly* spB8; + s32 ret; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + + if (this->dyna.pushForce < 0.0f) { + phi_s6 -= 0x8000; + } + + sp100 = Math_SinS(phi_s6); + temp_f26 = Math_CosS(phi_s6); + + temp_f12 = + (300.0f * this->dyna.actor.scale.z + Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos)) + + 2.0f; + temp_f28 = -temp_f12 * sp100; + temp_f30 = -temp_f12 * temp_f26; + + ret = false; + phi_f22 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22ABC); i++) { + spD4.x = (D_80A22ABC[i] * this->dyna.actor.scale.x) + D_80A22AC4[i]; + spD4.y = -10.0f; + spD4.z = 0.0f; + + func_80A212F0(&spEC, &spD4, phi_s6); + + spEC.x += this->dyna.actor.world.pos.x; + spEC.y += this->dyna.actor.world.pos.y; + spEC.z += this->dyna.actor.world.pos.z; + + spE0.x = temp_f28 + spEC.x; + spE0.y = spEC.y; + spE0.z = temp_f30 + spEC.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, + &this->dyna.actor, 0.0f)) { + temp_f0 = Math3D_Vec3fDistSq(&spEC, &spC8); + if (temp_f0 < phi_f22) { + ret = true; + arg2->x = (spC8.x - spEC.x) + (300.0f * this->dyna.actor.scale.z * sp100); + arg2->y = 0.0f; + arg2->z = (spC8.z - spEC.z) + (300.0f * this->dyna.actor.scale.z * temp_f26); + phi_f22 = temp_f0; + } + } + } + return ret; +} + +s32 func_80A21C30(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A21990(this, globalCtx, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + + return false; +} + +void func_80A21C88(ObjSkateblock* this, s32 arg1) { + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_16C = &this->dyna.actor.world.pos.x; + } else { + this->unk_16C = &this->dyna.actor.world.pos.z; + } + this->unk_170 = arg1; +} + +void func_80A21CB4(ObjSkateblock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; +} + +void func_80A21CD8(ObjSkateblock* this) { + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + if (this->dyna.actor.velocity.y < this->dyna.actor.terminalVelocity) { + this->dyna.actor.velocity.y = this->dyna.actor.terminalVelocity; + } + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; +} + +void func_80A21D1C(ObjSkateblock* this) { + f32 sp4; + f32 temp_f14; + f32 temp_f16; + f32 temp_f6; + f32 phi_f2; + + temp_f14 = this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x; + phi_f2 = ((temp_f14 >= 0.0f) ? 0.5f : -0.5f); + sp4 = ((s32)(phi_f2 + temp_f14) / 30) * 30; + temp_f14 -= sp4; + + if (fabsf(temp_f14) < 3.0f) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + sp4; + } + + temp_f16 = this->dyna.actor.world.pos.z - this->dyna.actor.home.pos.z; + phi_f2 = ((temp_f16 >= 0.0f) ? 0.5f : -0.5f); + temp_f6 = ((s32)(phi_f2 + temp_f16) / 30) * 30; + temp_f16 -= temp_f6; + + if (fabsf(temp_f16) < 3.0f) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + temp_f6; + } +} + +void func_80A21E9C(ObjSkateblock* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0; + s32 i; + ObjSkateblockFloor* ptr; + + if (!(this->unk_1C1 & 4)) { + return; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + ptr = &this->unk_184[i]; + + temp_v0 = DynaPoly_GetActor(&globalCtx->colCtx, ptr->bgId); + if ((temp_v0 != NULL) && (temp_v0->actor.id == ACTOR_OBJ_SKATEBLOCK)) { + ObjSkateblock* skateBlock = (ObjSkateblock*)temp_v0; + f32 height = this->dyna.actor.world.pos.y - ptr->height; + + if (fabsf(height) < 0.1f) { + skateBlock->unk_1C1 |= 2; + } + } + } +} + +void func_80A21F68(ObjSkateblock* this) { + this->unk_17C = 0; +} + +void func_80A21F74(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spA8; + Vec3f sp9C; + f32 phi_f22; + s32 i; + f32 temp; + s32 pad2; + s16 sp8A = this->dyna.yRotation; + + if (this->dyna.pushForce < 0.0f) { + sp8A -= 0x8000; + } + + this->unk_17C++; + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + if (this->unk_17C >= 46) { + phi_f22 = 1.0f; + } else { + phi_f22 = (this->unk_17C * 0.017777778f) + 0.2f; + } + sp9C.y = 12.0f; + + for (i = 0; i < 2; i++) { + if (phi_f22 < (Rand_ZeroOne() * 1.2f)) { + continue; + } + this->unk_180 += Rand_ZeroOne(); + + if (this->unk_180 > 1.0f) { + this->unk_180 -= 1.0f; + } + + sp9C.x = (this->unk_180 - 0.5f) * 600.0f * this->dyna.actor.scale.x; + sp9C.z = (this->dyna.actor.scale.z * -300.0f) + 4.0f; + + func_80A212F0(&spA8, &sp9C, sp8A); + + spA8.x += this->dyna.actor.world.pos.x; + spA8.y += this->dyna.actor.world.pos.y; + spA8.z += this->dyna.actor.world.pos.z; + + temp = ((Rand_ZeroOne() * 800.0f) + (1600.0f * this->dyna.actor.scale.x)) * phi_f22; + func_800B0E48(globalCtx, &spA8, &gZeroVec3f, &D_80A22ACC, &D_80A22AD8, &D_80A22ADC, temp, + (Rand_ZeroOne() * 20.0f) + 30.0f); + } + } +} + +void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + if (D_80A22A18 == NULL) { + D_80A22A18 = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + } + func_80A22308(this); + this->unk_1C0 = D_80A22A14; + D_80A22A14++; + D_80A22A14 &= 0x1F; +} + +void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A22308(ObjSkateblock* this) { + this->actionFunc = func_80A22334; + this->unk_172[1] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 0; + this->unk_172[0] = 0; + this->dyna.actor.velocity.y = 0.0f; +} + +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30; + s32 sp2C; + Vec3f sp20; + + func_80A21CD8(this); + func_80A21548(this, globalCtx); + sp2C = func_80A21150(this); + func_80A211F4(this, sp2C); + + sp30 = true; + + if (sp2C == -1) { + sp30 = false; + } else if (!(this->unk_1C1 & 2) && (this->unk_172[sp2C] > 10) && (D_80A22A10 == 0) && + !func_80A216D4(this, globalCtx, 2.0f, &sp20) && !Player_InCsMode(&globalCtx->state)) { + func_80A21C88(this, sp2C); + func_80A2244C(this); + sp30 = false; + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->unk_1C1 |= 1; + } + + if (sp30) { + func_80A21CB4(this, globalCtx); + } +} + +void func_80A2244C(ObjSkateblock* this) { + this->actionFunc = func_80A224A4; + this->unk_168 = D_80A22AF8[this->unk_170]; + this->unk_164 = 0.0f; + this->unk_17A = 15; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; + func_80A21F68(this); +} + +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + Math_StepToF(&this->unk_164, this->unk_168, 0.75f); + + *this->unk_16C += this->unk_164; + + if (func_80A21934(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80A21D1C(this); + sp28 = true; + } else { + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); + } + + func_80A21CD8(this); + + if (!func_80A21548(this, globalCtx)) { + func_80A21C30(this, globalCtx); + func_80A21D1C(this); + func_80A22628(this); + sp24 = true; + } else if (sp28) { + func_80A22308(this); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + } + + if (sp24 || sp28 || (this->unk_17A == 1)) { + func_80A21CB4(this, globalCtx); + } + + if ((this->unk_1C1 & 1) && (sp24 || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { + this->unk_1C1 &= ~1; + func_800B7298(globalCtx, &this->dyna.actor, 6); + } + + func_80A21F74(this, globalCtx); +} + +void func_80A22628(ObjSkateblock* this) { + this->actionFunc = func_80A2264C; + this->unk_160 = this->dyna.actor.world.pos.y; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; +} + +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; + + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + func_80A21CD8(this); + + sp20 = func_80A21548(this, globalCtx); + if (sp20 || ((this->unk_160 - this->dyna.actor.world.pos.y) > 300.0f)) { + if (func_800C9B40(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 12) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80A22728(this); + return; + } + } + + if (sp20) { + func_80A22308(this); + } +} + +void func_80A22728(ObjSkateblock* this) { + this->actionFunc = func_80A2273C; +} + +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx) { + if (!DynaPolyActor_IsInRidingMovingState(&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; + + func_80A227A4(this); + } +} + +void func_80A227A4(ObjSkateblock* this) { + this->actionFunc = func_80A227C0; + this->unk_17A = 40; +} + +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + return; + } + + func_800C6314(globalCtx, &globalCtx->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)) { + D_80A22A10 |= 1 << this->unk_1C0; + } +} + +void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + D_80A22A10 &= ~(1 << this->unk_1C0); + this->actionFunc(this, globalCtx); + this->unk_1C1 &= ~2; +} + +void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSkateblock* this = THIS; + Color_RGB8* sp2C = &D_80A22B08[OBJSKAEBLOCK_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, D_80A22A18, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, sp2C->r, sp2C->g, sp2C->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + func_80A21E9C(this, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h index 00f3a0f1b..c26a93844 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -7,11 +7,29 @@ struct ObjSkateblock; typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, GlobalContext*); +#define OBJSKAEBLOCK_GET_F(thisx) ((thisx)->params & 0xF) + +typedef struct { + /* 0x00 */ CollisionPoly* poly; + /* 0x04 */ f32 height; + /* 0x08 */ s32 bgId; +} ObjSkateblockFloor; // size = 0xC + typedef struct ObjSkateblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSkateblockActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x64]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32* unk_16C; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172[4]; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ f32 unk_180; + /* 0x0184 */ ObjSkateblockFloor unk_184[5]; + /* 0x01C0 */ u8 unk_1C0; + /* 0x01C1 */ u8 unk_1C1; } ObjSkateblock; // size = 0x1C4 extern const ActorInit Obj_Skateblock_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c index f928acc0e..ded17da2d 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -5,8 +5,9 @@ */ #include "z_obj_smork.h" +#include "objects/object_f53_obj/object_f53_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjSmork*)thisx) @@ -15,7 +16,6 @@ void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Smork_InitVars = { ACTOR_OBJ_SMORK, ACTORCAT_PROP, @@ -28,20 +28,125 @@ const ActorInit Obj_Smork_InitVars = { (ActorFunc)ObjSmork_Draw, }; -#endif +#include "overlays/ovl_Obj_Smork/ovl_Obj_Smork.c" -extern UNK_TYPE D_06001C00; +u8 func_80A3D680(s16 arg0) { + u8 ret = 0; + s16 temp_f18 = TIME_TO_MINUTES_F(gSaveContext.save.time); + s32 hours = temp_f18 / 60; + s32 minutes = temp_f18 % 60; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D680.s") + if (hours >= 16) { + if ((hours == 16) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D940.s") + if (hours >= 20) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/func_80A3D9C4.s") + if ((hours == 19) && (arg0 < minutes)) { + return 0; + } + ret = 3; + } else if (hours >= 11) { + if ((hours == 11) && (minutes < arg0)) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Init.s") + if (hours >= 14) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Destroy.s") + if ((hours == 13) && (arg0 < minutes)) { + return 0; + } + ret = 2; + } else if (hours >= 6) { + if ((hours == 6) && (minutes < arg0)) { + return 0; + } + if (hours >= 9) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Update.s") + if ((hours == 8) && (arg0 < minutes)) { + return 0; + } + ret = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Smork/ObjSmork_Draw.s") + return ret; +} + +void func_80A3D940(ObjSmork* this) { + u8 temp_v0 = func_80A3D680(this->unk_1C6); + + if (temp_v0 != this->unk_1C4) { + this->unk_1C4 = temp_v0; + this->unk_1C6 = Rand_S16Offset(0, 59); + } + + Math_ApproachF(&this->unk_1B8, (this->unk_1C4 == 0) ? 0.0f : 1.0f, 0.02f, 1000.0f); +} + +void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { + u8 sp57; + u8 sp56; + s32 i; + + this->unk_1BC += 1.8f; + this->unk_1C0 += 0.6f; + + sp57 = 127 - (u8)this->unk_1BC; + sp56 = 127 - (u8)this->unk_1C0; + + this->unk_1B8 = CLAMP(this->unk_1B8, 0.0f, 1.0f); + + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + this->unk_148[i].v.cn[3] = ovl_Obj_Smork_Vtx_000C10[i].v.cn[3] * this->unk_1B8; + } + + if (this->unk_1B8 > 0.0f) { + Matrix_InsertTranslation(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + MTXMODE_NEW); + this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + Matrix_RotateY(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.0f, MTXMODE_APPLY); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, sp57, 0x20, 0x20, 1, 0, sp56, 0x20, 0x20)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(this->unk_148)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_f53_obj_DL_001C00); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void ObjSmork_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + Lib_MemCpy(this->unk_148, ovl_Obj_Smork_Vtx_000C10, sizeof(Vtx) * ARRAY_COUNT(ovl_Obj_Smork_Vtx_000C10)); + this->unk_1C6 = Rand_S16Offset(0, 59); + this->unk_1C4 = 0; +} + +void ObjSmork_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void ObjSmork_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D940(this); +} + +void ObjSmork_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSmork* this = THIS; + + func_80A3D9C4(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h index dd6ab4cf7..5ab3e405c 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h @@ -7,7 +7,13 @@ struct ObjSmork; typedef struct ObjSmork { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x84]; + /* 0x144 */ UNK_TYPE1 unk_144[4]; + /* 0x148 */ Vtx unk_148[7]; + /* 0x1B8 */ f32 unk_1B8; + /* 0x1BC */ f32 unk_1BC; + /* 0x1C0 */ f32 unk_1C0; + /* 0x1C4 */ u8 unk_1C4; + /* 0x1C6 */ s16 unk_1C6; } ObjSmork; // size = 0x1C8 extern const ActorInit Obj_Smork_InitVars; 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 9eb0ae99f..15a63746b 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -228,8 +228,8 @@ void func_80B030F8(ObjSnowball* this, GlobalContext* globalCtx) { scale = ((Rand_ZeroOne() * 15.0f) + 30.0f) * this->unk_20C; - EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, 0xEF, - temp_s2); + EffectSsKakera_Spawn(globalCtx, &spFC, &spF0, &spFC, gravity, phi_s0, 30, 0, 0, scale, phi_s4, 0, 50, -1, + OBJECT_GOROIWA, temp_s2); if ((this->unk_210 == 0) && (temp_s7 >= 3)) { spFC.x += (Rand_ZeroOne() * 120.0f) - 60.0f; spFC.y += Rand_ZeroOne() * 80.0f; @@ -333,7 +333,6 @@ void func_80B03688(ObjSnowball* this, GlobalContext* globalCtx) { } } -#ifdef NON_MATCHING void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { f32 temp_f30 = sqrtf(arg1); Vec3f spD8; @@ -341,14 +340,16 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { s32 i; Gfx* temp_s1; f32 temp_f20; - s32 phi_s5; - s32 pad; s16 phi_s2; - s32 pad2; s16 phi_s0; s16 phi_s3; + s32 phi_s5; + s32 tmp; + s32 pad; for (i = 0, phi_s5 = 0; i < 13; i++, phi_s5 += 0x1999) { + tmp = i & 3; + temp_f20 = (Rand_ZeroOne() * (40.0f * arg1)) + 20.0f; spD8.x = Math_SinS((s32)(Rand_ZeroOne() * 6553.6f) + phi_s5) * temp_f20; @@ -363,7 +364,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { spD8.y += arg2->y; spD8.z += arg2->z; - if ((i & 3) == 0) { + if (tmp == 0) { temp_s1 = D_80B04FC8[0]; phi_s2 = -400; phi_s3 = 1; @@ -372,7 +373,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { } else { phi_s0 = 0x41; } - } else if ((i & 3) == 1) { + } else if (tmp == 1) { temp_s1 = D_80B04FC8[1]; phi_s2 = -340; phi_s3 = 1; @@ -389,7 +390,7 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { } EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_s2, phi_s0, 30, 0, 0, - ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, 0xEF, temp_s1); + ((Rand_ZeroOne() * 15.0f) + 25.0f) * arg1, phi_s3, 0, 0x36, -1, OBJECT_GOROIWA, temp_s1); spD8.x += (Rand_ZeroOne() * 80.0f) - 40.0f; spD8.y += Rand_ZeroOne() * 55.0f; @@ -401,10 +402,6 @@ void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2) { (s32)(Rand_ZeroOne() * 30.0f * temp_f30) + 60); } } -#else -void func_80B03A80(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball/func_80B03A80.s") -#endif void func_80B03E2C(ObjSnowball* this, GlobalContext* globalCtx) { ObjSnowballStruct* ptr; @@ -482,7 +479,7 @@ void ObjSnowball_Init(Actor* thisx, GlobalContext* globalCtx) { if (sp34) { this->actor.textId = 0x238; - this->actor.flags |= 1; + this->actor.flags |= ACTOR_FLAG_1; this->actor.targetArrowOffset = 1400.0f / 3.0f; Actor_SetFocus(&this->actor, 24.0f); this->actor.targetMode = 3; @@ -539,9 +536,9 @@ void func_80B04350(ObjSnowball* this, GlobalContext* globalCtx) { if (flag && (this->unk_211 == 0) && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & (0x80000000 | 0x4000 | 0x800 | 0x400 | 0x100 | 0x8))) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; if (this->actor.home.rot.y == 1) { - this->actor.flags &= ~(8 | 1); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); } if (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0x4000) { @@ -761,11 +758,11 @@ void ObjSnowball_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.home.rot.y == 1) { if (this->unk_211 != 0) { if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actor.flags &= ~0x10; + this->actor.flags &= ~ACTOR_FLAG_10; this->unk_211 = 0; } } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actor.flags |= 0x10; + this->actor.flags |= ACTOR_FLAG_10; this->unk_211 = 1; } else if (this->actor.isTargeted) { sp24 = true; 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 d21acc8b5..229cdf516 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -5,8 +5,9 @@ */ #include "z_obj_snowball2.h" +#include "objects/object_goroiwa/object_goroiwa.h" -#define FLAGS 0x00800000 +#define FLAGS (ACTOR_FLAG_800000) #define THIS ((ObjSnowball2*)thisx) @@ -15,7 +16,16 @@ void ObjSnowball2_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B38E20(ObjSnowball2* this); +void func_80B39C78(ObjSnowball2* this); +void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B39F60(ObjSnowball2* this); +void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A0D8(ObjSnowball2* this); +void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx); +void func_80B3A498(ObjSnowball2* this); +void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx); + const ActorInit Obj_Snowball2_InitVars = { ACTOR_OBJ_SNOWBALL2, ACTORCAT_PROP, @@ -28,82 +38,587 @@ const ActorInit Obj_Snowball2_InitVars = { (ActorFunc)ObjSnowball2_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80B3A8E0[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00400000, 0x00, 0x02 }, { 0x0583FFBE, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00400000, 0x00, 0x02 }, + { 0x0583FFBE, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 15 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80B3A904 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_80B3A8E0, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + 1, + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B3A93C[] = { - ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), +Color_RGBA8 D_80B3A914 = { 250, 250, 250, 255 }; + +Color_RGBA8 D_80B3A918 = { 180, 180, 180, 255 }; + +Gfx* D_80B3A91C[] = { + object_goroiwa_DL_0072F0, + object_goroiwa_DL_0077D0, + object_goroiwa_DL_007C60, + object_goroiwa_DL_007C60, }; -#endif +Vec3f D_80B3A92C = { 0.0f, 0.3f, 0.0f }; -extern ColliderJntSphElementInit D_80B3A8E0[1]; -extern ColliderJntSphInit D_80B3A904; -extern InitChainEntry D_80B3A93C[]; +void func_80B38E20(ObjSnowball2* this) { + Matrix_SetStateRotationAndTranslation(this->actor.world.pos.x, + this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->collider); +} -extern UNK_TYPE D_06008B90; +void func_80B38E88(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38E20.s") + if (this->unk_1AE == 0) { + temp_v0 = func_800A8150(ENOBJSNOWBALL2_GET_3F(&this->actor)); + if (temp_v0 >= 0) { + Item_DropCollectible(globalCtx, &this->actor.world.pos, + (ENOBJSNOWBALL2_GET_7F00(&this->actor) << 8) | temp_v0); + this->unk_1AE = 1; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38E88.s") +void func_80B38EFC(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 i; + Vec3f spA4; + Vec3f sp98; + Vec3f sp8C; + f32 sp88 = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B38EFC.s") + for (i = 0; i < 2; i++) { + sp8C.x = ((Rand_ZeroOne() * 30.0f) - 15.0f) + this->actor.world.pos.x; + sp8C.y = ((Rand_ZeroOne() * 20.0f) - 10.0f) + sp88; + sp8C.z = ((Rand_ZeroOne() * 30.0f) - 15.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39108.s") + sp98.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + sp98.y = -1.5f; + sp98.z = (Rand_ZeroOne() - 0.5f) * 1.6f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39470.s") + spA4.x = sp98.x * -0.06f; + spA4.y = sp98.y * -0.06f; + spA4.z = sp98.z * -0.06f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B395C4.s") + func_800B0E48(globalCtx, &sp8C, &sp98, &spA4, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, + (s32)(Rand_ZeroOne() * 30.0f) + 10); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B395EC.s") +void func_80B39108(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 phi_s5; + s16 phi_s1; + s32 phi_v0; + s32 i; + u32 temp; + s32 temp_s3; + Vec3f spDC; + Vec3f spD0; + f32 temp_f2; + f32 spC8 = this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y); + f32 temp_f0; + f32 temp_f12; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39638.s") + for (i = 0, phi_s5 = 0; i < 11; i++, phi_s5 += (0x10000 / 11)) { + temp_s3 = (s32)(Rand_ZeroOne() * 5957.0f) + phi_s5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39834.s") + if (((u32)Rand_Next() >> 0x1E) == 0) { + phi_s1 = 0x20; + } else { + phi_s1 = 0x40; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39908.s") + if ((i & 3) == 0) { + phi_s1 |= 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39B28.s") + temp_f0 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f0)) * 12.0f; + temp_f22 = Math_SinS(temp_s3); + temp_f24 = Math_CosS(temp_s3); + temp_f12 = (Rand_ZeroOne() * 1.6f) - 0.8f; + temp_f2 = fabsf(temp_f12) * temp_f12; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39B5C.s") + spDC.x = temp_f22 * 4.0f; + spDC.y = (temp_f2 * 6.0f) + 9.0f; + spDC.z = temp_f24 * 4.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Init.s") + spD0.x = (temp_f22 * temp_f20) + this->actor.world.pos.x; + spD0.y = (temp_f2 * temp_f20) + spC8; + spD0.z = (temp_f24 * temp_f20) + this->actor.world.pos.z; + temp = Rand_Next(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Destroy.s") + if ((i & 3) == 0) { + phi_v0 = 1; + } else { + phi_v0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39C78.s") + EffectSsKakera_Spawn(globalCtx, &spD0, &spDC, &spD0, -300, phi_s1, 30, 0, 0, (temp >> 0x1D) + 8, phi_v0, 0, 50, + -1, OBJECT_GOROIWA, D_80B3A91C[i & 3]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39C9C.s") + spD0.x += (Rand_ZeroOne() - 0.5f) * 40.0f; + spD0.y += (Rand_ZeroOne() - 0.3f) * 45.0f; + spD0.z += (Rand_ZeroOne() - 0.5f) * 40.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39F60.s") + func_800B0E48(globalCtx, &spD0, &gZeroVec3f, &D_80B3A92C, &D_80B3A914, &D_80B3A918, + (s32)(Rand_ZeroOne() * 70.0f) + 10, (s32)(Rand_ZeroOne() * 100.0f) + 10); + } + spD0.y = (temp_f2 * temp_f20) + spC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B39FA8.s") +void func_80B39470(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + Vec3f sp58; + s32 phi_s0; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A0D8.s") + sp58.y = this->actor.world.pos.y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A13C.s") + for (phi_s0 = 0, i = 0; i < 5; i++, phi_s0 += (0x10000 / 5)) { + sp58.x = (Math_SinS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.x; + sp58.z = (Math_CosS((s32)(Rand_ZeroOne() * 7200.0f) + phi_s0) * 15.0f) + this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 200); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A498.s") + sp58.x = this->actor.world.pos.x; + sp58.z = this->actor.world.pos.z; + EffectSsGSplash_Spawn(globalCtx, &sp58, NULL, NULL, 0, 300); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/func_80B3A500.s") +void func_80B395C4(GlobalContext* this, Vec3f* arg1) { + EffectSsGRipple_Spawn(this, arg1, 200, 700, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Update.s") +void func_80B395EC(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + Vec3f sp18; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Snowball2/ObjSnowball2_Draw.s") + sp18.x = this->actor.world.pos.x; + sp18.y = this->actor.world.pos.y + this->actor.depthInWater; + sp18.z = this->actor.world.pos.z; + func_80B395C4(globalCtx, &sp18); +} + +void func_80B39638(GlobalContext* globalCtx, Vec3f* arg1) { + static s16 D_80B3A938 = 0; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + Vec3f sp98; + Vec3f sp8C; + Vec3f sp80; + f32 temp_f2; + s32 i; + + D_80B3A938 += (s16)((u32)Rand_Next() >> 0x11); + + for (i = 0; i < 2; i++) { + D_80B3A938 += 0x8000; + temp_f20 = Rand_ZeroOne(); + temp_f22 = Math_SinS(D_80B3A938) * temp_f20; + temp_f24 = Rand_ZeroOne(); + temp_f2 = Math_CosS(D_80B3A938) * temp_f20; + + sp98.x = arg1->x + (temp_f22 * 5.0f); + sp98.y = arg1->y + (temp_f24 * 25.0f); + sp98.z = arg1->z + (temp_f2 * 5.0f); + + sp8C.x = temp_f22 * 1.55f; + sp8C.y = temp_f24 * -0.7f; + sp8C.z = temp_f2 * 1.55f; + + sp80.x = sp8C.x * -0.02f; + sp80.y = sp8C.y * -0.025f; + sp80.z = sp8C.z * -0.02f; + + EffectSsIceSmoke_Spawn(globalCtx, &sp98, &sp8C, &sp80, (s32)(Rand_ZeroOne() * 30.0f) + 68); + } +} + +void func_80B39834(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + s32 i; + + for (i = 0; i < 3; i++) { + EffectSsBubble_Spawn(globalCtx, &this->actor.world.pos, 0.0f, 20.0f, 30.0f, (Rand_ZeroOne() * 0.11f) + 0.03f); + } +} + +void func_80B39908(ObjSnowball2* this, GlobalContext* globalCtx) { + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + s32 i; + + if (this->collider.elements[0].info.bumperFlags & BUMP_HIT) { + Vec3s* hitPos = &this->collider.elements[0].info.bumper.hitPos; + + for (i = 0; i < 4; i++) { + sp94.x = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->x; + sp94.y = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->y; + sp94.z = ((Rand_ZeroOne() * 14.0f) - 7.0f) + hitPos->z; + + spA0.x = (Rand_ZeroOne() - 0.5f) * 1.6f; + spA0.y = -0.8f; + spA0.z = (Rand_ZeroOne() - 0.5f) * 1.6f; + + spAC.x = spA0.x * -0.06f; + spAC.y = spA0.y * -0.06f; + spAC.z = spA0.z * -0.06f; + + func_800B0E48(globalCtx, &sp94, &spA0, &spAC, &D_80B3A914, &D_80B3A918, (s32)(Rand_ZeroOne() * 40.0f) + 10, + (s32)(Rand_ZeroOne() * 30.0f) + 10); + } + } +} + +void func_80B39B28(ObjSnowball2* this, GlobalContext* globalCtx) { + if ((this->unk_1AE == 0) && (globalCtx->roomCtx.currRoom.num != this->unk_1AF)) { + this->unk_1AE = 1; + } +} + +void func_80B39B5C(ObjSnowball2* this, GlobalContext* globalCtx) { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 40, NA_SE_EV_SMALL_SNOWBALL_BROKEN); +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 25, ICHAIN_STOP), +}; + +void ObjSnowball2_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Actor_ProcessInitChain(&this->actor, sInitChain); + Collider_InitJntSph(globalCtx, &this->collider); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.shape.rot.y = (u32)Rand_Next() >> 0x10; + ActorShape_Init(&this->actor.shape, 200.0f, NULL, 12.5f); + this->actor.shape.shadowAlpha = 130; + Collider_SetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + func_80B38E20(this); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->unk_1AF = this->actor.room; + func_80B39C78(this); +} + +void ObjSnowball2_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Collider_DestroyJntSph(globalCtx, &this->collider); +} + +void func_80B39C78(ObjSnowball2* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->unk_1AD = 0; + this->actionFunc = func_80B39C9C; +} + +void func_80B39C9C(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = (this->collider.base.acFlags & AC_HIT) != 0; + s32 pad2; + + if (sp38) { + this->collider.base.acFlags &= ~AC_HIT; + } + + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.room = -1; + this->actor.flags |= ACTOR_FLAG_10; + if (func_800A817C(ENOBJSNOWBALL2_GET_3F(&this->actor))) { + func_80B38E88(this, globalCtx); + } + func_80B38EFC(this, globalCtx); + func_800B8E58(GET_PLAYER(globalCtx), NA_SE_PL_PULL_UP_SNOWBALL); + func_80B39F60(this); + } else if ((this->actor.bgCheckFlags & 0x20) && + ((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)) { + func_80B38E88(this, globalCtx); + func_80B39108(this, globalCtx); + func_80B39B5C(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } else { + if (sp38 && (this->collider.elements->info.acHitInfo->toucher.dmgFlags & 2)) { + func_80B39908(this, globalCtx); + } + + if (this->unk_1AD == 0) { + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x44); + if ((this->actor.bgCheckFlags & 1) && + (DynaPoly_GetActor(&globalCtx->colCtx, this->actor.floorBgId) == NULL)) { + this->unk_1AD = 1; + this->actor.flags &= ~ACTOR_FLAG_10; + } + } + + if (this->actor.xzDistToPlayer < 800.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 150.0f) { + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->actor.xzDistToPlayer < 100.0f) { + if (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, GET_PLAYER(globalCtx)->actor.world.rot.y)) >= + 0x5556) { + Actor_PickUp(&this->actor, globalCtx, GI_NONE, 36.0f, 30.0f); + } + } + } + } + } +} + +void func_80B39F60(ObjSnowball2* this) { + this->actor.world.pos.y += (600.0f - this->actor.shape.yOffset) * this->actor.scale.y; + this->unk_1AC = 4; + this->actor.shape.yOffset = 600.0f; + this->actionFunc = func_80B39FA8; +} + +void func_80B39FA8(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp30; + s32 sp2C; + + func_80B39B28(this, globalCtx); + + if (this->unk_1AC > 0) { + this->unk_1AC--; + func_80B38EFC(this, globalCtx); + } + + if (Actor_HasNoParent(&this->actor, globalCtx)) { + this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.speedXZ *= 3.8f; + this->actor.velocity.y *= 0.4f; + this->actor.gravity = -2.8f; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + func_80B3A0D8(this); + } else { + sp30.x = this->actor.world.pos.x; + sp30.y = this->actor.world.pos.y + 20.0f; + sp30.z = this->actor.world.pos.z; + this->actor.floorHeight = + BgCheck_EntityRaycastFloor5(&globalCtx->colCtx, &this->actor.floorPoly, &sp2C, &this->actor, &sp30); + } +} + +void func_80B3A0D8(ObjSnowball2* this) { + this->unk_1AC = 60; + this->actor.colChkInfo.mass = 180; + this->unk_1A8 = Rand_S16Offset(-5000, 4000); + this->unk_1AA = Rand_S16Offset(-800, 1600); + this->actionFunc = func_80B3A13C; +} + +void func_80B3A13C(ObjSnowball2* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = (this->collider.base.atFlags & AT_HIT) != 0; + s32 sp34 = (this->collider.base.ocFlags1 & OC1_HIT) != 0; + s32 sp30; + + if (sp38) { + this->collider.base.atFlags &= ~AT_HIT; + } + + if (sp34) { + this->collider.base.ocFlags1 &= ~OC1_HIT; + } + + if (this->unk_1AC > 0) { + this->unk_1AC--; + } + + func_80B39B28(this, globalCtx); + + if ((((this->actor.bgCheckFlags & 9) || sp38) && !(this->actor.bgCheckFlags & 0x20)) || (this->unk_1AC <= 0)) { + func_80B38E88(this, globalCtx); + func_80B39108(this, globalCtx); + func_80B39B5C(this, globalCtx); + Actor_MarkForDeath(&this->actor); + return; + } + + sp30 = false; + if (this->actor.bgCheckFlags & 0x60) { + if ((this->actor.bgCheckFlags & 0x40) || (this->actor.speedXZ > 3.0f)) { + if (this->actor.depthInWater < (1200.0f * this->actor.scale.y)) { + func_80B39470(&this->actor, globalCtx); + func_80B395EC(&this->actor, globalCtx); + } + if (this->actor.bgCheckFlags & 0x40) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); + } + } else if ((((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) && + (this->actor.depthInWater < (1200.0f * this->actor.scale.y))) { + func_80B395EC(&this->actor, globalCtx); + } + + func_80B39834(&this->actor, globalCtx); + this->unk_1A8 >>= 1; + this->unk_1AA >>= 1; + + if (sp34) { + this->actor.speedXZ *= 0.8f; + } else { + this->actor.speedXZ *= 0.65f; + } + this->actor.velocity.y *= 0.27f; + this->actor.gravity *= 0.27f; + if (this->actor.speedXZ < 0.4f) { + sp30 = true; + } + } else { + if (sp34) { + this->actor.speedXZ *= 0.8f; + } else { + this->actor.speedXZ *= 0.96f; + } + this->actor.velocity.y *= 0.96f; + } + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 15.0f, 15.0f, 0.0f, 0x45); + this->actor.shape.rot.x += this->unk_1A8; + this->actor.shape.rot.y += this->unk_1AA; + func_80B38E20(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (sp30) { + func_80B3A498(this); + } else { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B3A498(ObjSnowball2* this) { + this->actor.home.pos.x = this->actor.world.pos.x; + this->unk_1AC = 46; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.home.pos.y = this->actor.world.pos.y + this->actor.depthInWater; + 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->actionFunc = func_80B3A500; +} + +void func_80B3A500(ObjSnowball2* this, GlobalContext* globalCtx) { + f32 phi_f0; + s32 pad; + f32 temp_f14 = this->actor.home.pos.y - this->actor.world.pos.y; + f32 temp_f12 = this->actor.scale.y * 600.0f; + + this->unk_1AC--; + + this->actor.speedXZ *= 0.7f; + + this->unk_1A8 >>= 1; + this->unk_1AA >>= 1; + + this->actor.shape.rot.x += this->unk_1A8; + this->actor.shape.rot.y += this->unk_1AA; + + if (temp_f14 < -temp_f12) { + this->actor.gravity = this->actor.scale.y * -40.0f; + phi_f0 = 0.94f; + } else if (temp_f12 < temp_f14) { + this->actor.gravity = this->actor.scale.y * 24.0f; + phi_f0 = 0.8f; + } else if (temp_f12 > 0.001f) { + this->actor.gravity = (((1.6f * temp_f14) / temp_f12) + -1.0f + 0.6f) * 0.5f * 40.0f * this->actor.scale.y; + phi_f0 = (((-0.13999999f * temp_f14) / temp_f12) + 0.94f + 0.8f) * 0.5f; + } else { + this->actor.gravity = 0.0f; + phi_f0 = 1.0f; + } + + this->actor.velocity.y *= phi_f0; + this->actor.velocity.y += this->actor.gravity; + this->actor.world.pos.y += this->actor.velocity.y; + + if (((globalCtx->gameplayFrames % 16) == 0) || (((u32)Rand_Next() >> 0x10) == 0)) { + func_80B395C4(globalCtx, &this->actor.home.pos); + } + + if (this->unk_1AC <= 0) { + Actor_MarkForDeath(&this->actor); + return; + } + + if (this->unk_1AC < 20) { + this->actor.scale.x -= 0.00125f; + if (this) {} + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; + + if ((this->unk_1AC >= 6) && (temp_f14 < temp_f12)) { + func_80B39638(globalCtx, &this->actor.home.pos); + } + + if (this->unk_1AC == 10) { + func_80B38E88(this, globalCtx); + } + + func_800B9010(&this->actor, NA_SE_EV_ICE_MELT_LEVEL - SFX_FLAG); + } else { + func_80B38E20(this); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void ObjSnowball2_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + this->actionFunc(this, globalCtx); + + if (this->actor.projectedPos.z < 460.0f) { + if (this->actor.projectedPos.z > 200.0f) { + this->actor.shape.shadowAlpha = (460 - (s32)this->actor.projectedPos.z) >> 1; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else if (this->actor.projectedPos.z > -10.0f) { + this->actor.shape.shadowAlpha = 130; + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + } else { + this->actor.shape.shadowDraw = NULL; + } + } else { + this->actor.shape.shadowDraw = NULL; + } +} + +void ObjSnowball2_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSnowball2* this = THIS; + + Gfx_DrawDListOpa(globalCtx, object_goroiwa_DL_008B90); +} diff --git a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h index cbffe01f2..120358a80 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h @@ -7,11 +7,21 @@ struct ObjSnowball2; typedef void (*ObjSnowball2ActionFunc)(struct ObjSnowball2*, GlobalContext*); +#define ENOBJSNOWBALL2_GET_3F(thisx) ((thisx)->params & 0x3F) +#define ENOBJSNOWBALL2_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjSnowball2 { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x60]; + /* 0x0144 */ ColliderJntSph collider; + /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ ObjSnowball2ActionFunc actionFunc; - /* 0x01A8 */ char unk_1A8[0xC]; + /* 0x01A8 */ s16 unk_1A8; + /* 0x01AA */ s16 unk_1AA; + /* 0x01AC */ s8 unk_1AC; + /* 0x01AD */ u8 unk_1AD; + /* 0x01AE */ s8 unk_1AE; + /* 0x01AF */ s8 unk_1AF; + /* 0x01B0 */ UNK_TYPE1 unk1B0[4]; } ObjSnowball2; // size = 0x1B4 extern const ActorInit Obj_Snowball2_InitVars; diff --git a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c index 6b59eeb16..231dd99f3 100644 --- a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c +++ b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c @@ -6,7 +6,7 @@ #include "z_obj_sound.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjSound*)thisx) 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 90fa1f42f..1bc0f57b2 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -5,8 +5,9 @@ */ #include "z_obj_spidertent.h" +#include "objects/object_spidertent/object_spidertent.h" -#define FLAGS 0x10000000 +#define FLAGS (ACTOR_FLAG_10000000) #define THIS ((ObjSpidertent*)thisx) @@ -15,7 +16,13 @@ void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80B307E0(ObjSpidertent* this); +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30A2C(ObjSpidertent* this); +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx); +void func_80B30AD4(ObjSpidertent* this); +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx); + const ActorInit Obj_Spidertent_InitVars = { ACTOR_OBJ_SPIDERTENT, ACTORCAT_BG, @@ -28,118 +35,789 @@ const ActorInit Obj_Spidertent_InitVars = { (ActorFunc)ObjSpidertent_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B31060[6] = { +static ColliderTrisElementInit sTrisElementsInit1[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, { 23.799999237060547f, 0.0f, -116.30000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 76.30000305175781f, 0.0f, -63.79999923706055f }, + { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, { -111.30000305175781f, 0.0f, -26.299999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, -116.30000305175781f }, + { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -111.30000305175781f, 0.0f, -26.299999237060547f }, + { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -81.30000305175781f, 0.0f, 78.80000305175781f }, + { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, { 68.80000305175781f, 0.0f, 18.799999237060547f }, { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 23.799999237060547f, 0.0f, 108.80000305175781f }, + { 68.80000305175781f, 0.0f, 18.799999237060547f }, + { 1.2999999523162842f, 40.0f, -3.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B311C8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B31060, // sTrisElementsInit, +static ColliderTrisInit sTrisInit1 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit1, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80B311D8[6] = { +static ColliderTrisElementInit sTrisElementsInit2[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 17.799999237060547f, 0.0f, 81.5999984741211f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 17.799999237060547f, 0.0f, 81.5999984741211f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, { -60.900001525878906f, 0.0f, 59.099998474121094f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { -60.900001525878906f, 0.0f, 59.099998474121094f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, { -83.4000015258789f, 0.0f, -19.700000762939453f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { -83.4000015258789f, 0.0f, -19.700000762939453f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 17.799999237060547f, 0.0f, -87.19999694824219f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 17.799999237060547f, 0.0f, -87.19999694824219f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00000800, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, { 57.20000076293945f, 0.0f, -47.79999923706055f }, { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00000800, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 51.599998474121094f, 0.0f, 14.100000381469727f }, + { 57.20000076293945f, 0.0f, -47.79999923706055f }, + { 0.8999999761581421f, 30.0f, -2.799999952316284f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80B31340 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80B311D8, // sTrisElementsInit, +static ColliderTrisInit sTrisInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit2, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B31418[] = { +typedef struct { + /* 0x00 */ Gfx* unk_00; + /* 0x04 */ CollisionHeader* unk_04; + /* 0x08 */ ColliderTrisInit* 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; +} ObjSpidertentStruct; + +ObjSpidertentStruct D_80B31350[] = { + { + object_spidertent_DL_000070, + &object_spidertent_Colheader_0011AC, + &sTrisInit1, + 0.9f, + 1.3f, + 40.0f, + -3.8f, + SQ(120.0f), + 240.0f, + 200.0f, + }, + { + object_spidertent_DL_001250, + &object_spidertent_Colheader_00238C, + &sTrisInit2, + 0.9f, + 0.9f, + 30.0f, + -2.8f, + SQ(88.0f), + 176.0f, + 168.0f, + }, +}; + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s8 unk_0E; + /* 0x0F */ s8 unk_0F; + /* 0x10 */ Color_RGBA8 unk_10; + /* 0x14 */ Color_RGBA8 unk_14; +} ObjSpidertentStruct2; + +ObjSpidertentStruct2 D_80B313A0[] = { + { + -20.0f, + 6.0f, + 0.0f, + 100, + 14, + 5, + { 255, 255, 160, 160 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.0f, + 1.2f, + 80, + 9, + 3, + { 255, 255, 160, 120 }, + { 255, 0, 0, 0 }, + }, + { + 0.0f, + 4.2f, + 0.3f, + 70, + 12, + 2, + { 255, 255, 160, 100 }, + { 55, 0, 0, 0 }, + }, + { + 0.0f, + 3.0f, + 0.0f, + 20, + 6, + 2, + { 255, 100, 20, 80 }, + { 255, 0, 0, 0 }, + }, +}; + +Vec3f D_80B31400 = { 1.0f, 0.0f, 0.0f }; +Vec3f D_80B3140C = { 0.0f, 1.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; +s32 func_80B2FB10(Vec3f* arg0, Vec3f* arg1) { + f32 temp_f0 = Math3D_LengthSquared(arg0); + f32 temp_f2; + + if (temp_f0 < 9.999999e-9f) { + return false; + } + temp_f2 = 1.0f / sqrtf(temp_f0); + arg1->x = arg0->x * temp_f2; + arg1->y = arg0->y * temp_f2; + arg1->z = arg0->z * temp_f2; + return true; +} + +s32 func_80B2FB94(Vec3f* arg0, f32 arg1, TriNorm* triNorm, Vec3f* arg3, f32* arg4) { + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f16; + Vec3f sp48; + Vec3f sp3C; + f32 temp_f2; + f32 temp_f2_2; + + temp_f0 = triNorm->plane.normal.x * arg1; + temp_f2 = triNorm->plane.normal.y * arg1; + temp_f16 = triNorm->plane.normal.z * arg1; + + sp48.x = arg0->x + temp_f0; + sp48.y = arg0->y + temp_f2; + sp48.z = arg0->z + temp_f16; + + sp3C.x = arg0->x - temp_f0; + sp3C.y = arg0->y - temp_f2; + sp3C.z = arg0->z - temp_f16; + + if (Math3D_LineSegVsPlane(triNorm->plane.normal.x, triNorm->plane.normal.y, triNorm->plane.normal.z, + triNorm->plane.originDist, &sp48, &sp3C, arg3, 0)) { + temp_f0_2 = Math3D_Vec3fDistSq(arg0, arg3); + temp_f2_2 = SQ(arg1) - temp_f0_2; + if (SQ(arg1) < temp_f0_2) { + return false; + } + *arg4 = sqrtf(temp_f2_2); + return true; + } + return false; +} + +s32 func_80B2FC98(TriNorm* triNorm, Vec3f* arg1) { + Vec3f sp84; + Vec3f sp78; + Vec3f* vtx; + Vec3f* vtx2; + Vec3f sp4C[3]; + s32 i; + + if (triNorm->plane.normal.x > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = 0.0f; + sp84.y = vtx->y - arg1->y; + sp84.z = vtx->z - arg1->z; + + sp78.x = 0.0f; + sp78.y = vtx2->y - arg1->y; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].x >= 0.0f) && (sp4C[1].x >= 0.0f) && (sp4C[2].x >= 0.0f)) || + ((sp4C[0].x < 0.0f) && (sp4C[1].x < 0.0f) && (sp4C[2].x < 0.0f)); + } else if (triNorm->plane.normal.y > 0.5f) { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = 0.0f; + sp84.z = vtx->z - arg1->z; + + sp78.x = vtx2->x - arg1->x; + sp78.y = 0.0f; + sp78.z = vtx2->z - arg1->z; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].y >= 0.0f) && (sp4C[1].y >= 0.0f) && (sp4C[2].y >= 0.0f)) || + ((sp4C[0].y < 0.0f) && (sp4C[1].y < 0.0f) && (sp4C[2].y < 0.0f)); + } else { + vtx = &triNorm->vtx[0]; + vtx2 = &triNorm->vtx[2]; + + for (i = 0; i < ARRAY_COUNT(sp4C); i++, vtx = &triNorm->vtx[i]) { + sp84.x = vtx->x - arg1->x; + sp84.y = vtx->y - arg1->y; + sp84.z = 0.0f; + + sp78.x = vtx2->x - arg1->x; + sp78.y = vtx2->y - arg1->y; + sp78.z = 0.0f; + + Math3D_CrossProduct(&sp84, &sp78, &sp4C[i]); + + vtx2 = vtx; + } + + return ((sp4C[0].z >= 0.0f) && (sp4C[1].z >= 0.0f) && (sp4C[2].z >= 0.0f)) || + ((sp4C[0].z < 0.0f) && (sp4C[1].z < 0.0f) && (sp4C[2].z < 0.0f)); + } +} + +void func_80B300F4(ObjSpidertent* thisx, GlobalContext* globalCtx, TriNorm* triNorm, Vec3f* arg3, f32 arg4, s32 arg5) { + ObjSpidertent* this = THIS; + ObjSpidertentStruct* spE0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + f32 temp_f24; + f32 phi_f22; + s32 i; + f32 temp_f0; + Vec3f spC4; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + Vec3f sp88; + f32 temp_f2; + ObjSpidertentStruct2* sp80 = &D_80B313A0[arg5]; + + spAC.x = triNorm->plane.normal.x; + spAC.y = triNorm->plane.normal.y; + spAC.z = triNorm->plane.normal.z; + + if (triNorm->plane.normal.y < 0.5f) { + Math3D_CrossProduct(&spAC, &D_80B3140C, &sp88); + } else { + Math3D_CrossProduct(&spAC, &D_80B31400, &sp88); + } + + if (func_80B2FB10(&sp88, &spA0)) { + phi_f22 = 0.0f; + temp_f24 = (2 * M_PI) / sp80->unk_0F; + + for (i = 0; i < sp80->unk_0F; i++) { + temp_f2 = (Rand_ZeroOne() * temp_f24) + phi_f22; + Matrix_InsertRotationAroundUnitVector_f(temp_f2, &spAC, MTXMODE_NEW); + Matrix_MultiplyVector3fByState(&spA0, &sp94); + + if (arg5 == 0) { + spC4.x = (sp94.x * arg4) + arg3->x; + spC4.y = (sp94.y * arg4) + arg3->y; + spC4.z = (sp94.z * arg4) + arg3->z; + } else { + temp_f0 = Rand_ZeroOne(); + temp_f0 = (1.0f - SQ(temp_f0)) * arg4; + spC4.x = (sp94.x * temp_f0) + arg3->x; + spC4.y = (sp94.y * temp_f0) + arg3->y; + spC4.z = (sp94.z * temp_f0) + arg3->z; + } + + if ((Math3D_Vec3fDistSq(&spC4, &this->dyna.actor.world.pos) < spE0->unk_1C) && + func_80B2FC98(triNorm, &spC4)) { + spB8.x = sp80->unk_08 * sp94.x; + spB8.y = sp80->unk_08 * sp94.y; + spB8.z = sp80->unk_08 * sp94.z; + + EffectSsDeadDb_Spawn(globalCtx, &spC4, &spB8, &gZeroVec3f, &sp80->unk_10, &sp80->unk_14, sp80->unk_0C, + 0, sp80->unk_0E); + } + + phi_f22 += temp_f24; + } + } +} + +void func_80B30410(ObjSpidertent* this, Vec3f* arg1) { + s32 i; + + Math_Vec3f_Copy(&this->unk_3A4, arg1); + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + for (i = 0; i < ARRAY_COUNT(D_80B313A0); i++) { + this->unk_3B0[i] = D_80B313A0[i].unk_00; + } + this->unk_3C0 = 0; +} + +s32 func_80B30480(ObjSpidertent* this, GlobalContext* globalCtx, Vec3f* arg2) { + Player* player = GET_PLAYER(globalCtx); + TriNorm* triNorm; + s32 i; + Vec3f sp58; + f32 sp54; + + if (player->itemActionParam == 7) { + if (player->unk_B28 > 0) { + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + if (func_80B2FB94(&player->swordInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && + func_80B2FC98(triNorm, &sp58)) { + break; + } + } + + if (i < ARRAY_COUNT(this->colliderElements)) { + Math_Vec3f_Copy(arg2, &player->swordInfo[0].tip); + return true; + } + } + } + return false; +} + +void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpidertent* this = THIS; + s32 temp_s1 = OBJSPIDERTENT_GET_1(&this->dyna.actor); + ObjSpidertentStruct* ptr = &D_80B31350[temp_s1]; + ColliderTrisElementInit* element; + Vec3f sp70[3]; + Vec3f sp64; + s32 i, j; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitTris(globalCtx, &this->collider); + + if (Flags_GetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor))) { + Actor_MarkForDeath(&this->dyna.actor); + return; + } + + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, ptr->unk_04); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, D_80B31350[temp_s1].unk_08, this->colliderElements); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + + sp64.x = ptr->unk_10 * 1.2f; + sp64.y = ptr->unk_10 * 1.2f; + sp64.z = ptr->unk_10 * 1.2f; + + Matrix_MultiplyVector3fByState(&sp64, &this->dyna.actor.focus.pos); + Matrix_InsertTranslation(ptr->unk_10, ptr->unk_14 + 5.0f, ptr->unk_18, MTXMODE_APPLY); + Matrix_Scale(ptr->unk_0C, ptr->unk_0C, ptr->unk_0C, MTXMODE_APPLY); + Matrix_InsertTranslation(-ptr->unk_10, -ptr->unk_14, -ptr->unk_18, MTXMODE_APPLY); + + for (i = 0; i < 6; i++) { + element = &ptr->unk_08->elements[i]; + + for (j = 0; j < ARRAY_COUNT(sp70); j++) { + Matrix_MultiplyVector3fByState(&element->dim.vtx[j], &sp70[j]); + } + + Collider_SetTrisVertices(&this->collider, i, &sp70[0], &sp70[1], &sp70[2]); + } + + func_80B307E0(this); +} + +void ObjSpidertent_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80B307E0(ObjSpidertent* this) { + this->unk_3C2 = 255; + this->unk_3C3 = 255; + this->unk_3C4 = 255; + this->unk_3C5 = 255; + this->actionFunc = func_80B30808; +} + +void func_80B30808(ObjSpidertent* this, GlobalContext* globalCtx) { + s32 phi_s4; + s32 i; + ObjSpidertentStruct* ptr2 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + Vec3f sp70; + Vec3s* hitPos; + ColliderTrisElement* ptr; + f32 temp_f0; + s32 phi_s1; + Vec3f sp54; + f32 phi_f20; + s32 phi_s0 = false; + + if (this->collider.base.acFlags & AC_HIT) { + Player* player = GET_PLAYER(globalCtx); + + this->collider.base.acFlags &= ~AC_HIT; + phi_s1 = 0; + phi_s4 = -1; + phi_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + ptr = &this->collider.elements[i]; + + if (ptr->info.bumperFlags & BUMP_HIT) { + sp54.x = ptr->info.bumper.hitPos.x; + sp54.y = ptr->info.bumper.hitPos.y; + sp54.z = ptr->info.bumper.hitPos.z; + + temp_f0 = Math3D_Vec3fDistSq(&sp54, &player->actor.world.pos); + if (temp_f0 < phi_f20) { + phi_f20 = temp_f0; + phi_s4 = i; + } + } + } + + if (phi_s4 >= 0) { + hitPos = &this->collider.elements[phi_s4].info.bumper.hitPos; + + sp70.x = hitPos->x; + sp70.y = hitPos->y; + sp70.z = hitPos->z; + } else { + Math_Vec3f_Copy(&sp70, &this->dyna.actor.world.pos); + } + phi_s0 = true; + } else if ((this->dyna.actor.xzDistToPlayer < ptr2->unk_24) && func_80B30480(this, globalCtx, &sp70)) { + phi_s0 = true; + } + + if (phi_s0) { + func_80B30410(this, &sp70); + func_80B30A2C(this); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void func_80B30A2C(ObjSpidertent* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + this->actionFunc = func_80B30A4C; +} + +void func_80B30A4C(ObjSpidertent* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + if (this->dyna.actor.cutscene >= 0) { + func_800B7298(globalCtx, &this->dyna.actor, 1); + } + Flags_SetSwitch(globalCtx, OBJSPIDERTENT_GET_7F00(&this->dyna.actor)); + func_80B30AD4(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void func_80B30AD4(ObjSpidertent* this) { + this->unk_3C1 = 80; + this->unk_3C6 = 0; + this->unk_3C7 = 0; + this->actionFunc = func_80B30AF8; +} + +#ifdef NON_MATCHING +void func_80B30AF8(ObjSpidertent* this, GlobalContext* globalCtx) { + ObjSpidertentStruct* temp_s0 = &D_80B31350[OBJSPIDERTENT_GET_1(&this->dyna.actor)]; + TriNorm* triNorm; + s32 i, j; + ObjSpidertentStruct2* ptr; + Vec3f sp60; + f32 sp5C; + + this->unk_3C6++; + + if (this->unk_3C6 < 40) { + if (this->unk_3C2 > 2) { + this->unk_3C2 -= 2; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 > 5) { + this->unk_3C3 -= 5; + } else { + this->unk_3C3 = 0; + } + + if (this->unk_3C4 > 5) { + this->unk_3C4 -= 5; + } else { + this->unk_3C4 = 0; + } + + if (this->unk_3C5 > 1) { + this->unk_3C5--; + } else { + this->unk_3C5 = 0; + } + } else { + if (this->unk_3C2 > 4) { + this->unk_3C2 -= 4; + } else { + this->unk_3C2 = 0; + } + + if (this->unk_3C3 < 255) { + this->unk_3C3++; + } else { + this->unk_3C3 = 255; + } + + if (this->unk_3C4 < 255) { + this->unk_3C4++; + } else { + this->unk_3C4 = 255; + } + + if (this->unk_3C5 > 10) { + this->unk_3C5 -= 10; + } else { + this->unk_3C5 = 0; + } + } + + this->unk_3C1--; + if (this->unk_3C1 == 40) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + + if (this->unk_3C1 >= 0x20) { + if (this->unk_3C7 > 0) { + this->unk_3C7--; + } else if (this->unk_3C1 >= 0x33) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 2); + } else { + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->unk_3C7 = Rand_S16Offset(2, 4); + } + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + this->unk_3B0[j] += D_80B313A0[j].unk_04; + if (temp_s0->unk_20 < this->unk_3B0[j]) { + this->unk_3C0 |= (1 << j); + } + } + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + triNorm = &this->collider.elements[i].dim; + + for (j = 0; j < ARRAY_COUNT(this->unk_3B0); j++) { + if (!(this->unk_3B0[j] < 5.0f) && !(this->unk_3C0 & (1 << j)) && + func_80B2FB94(&this->unk_3A4, this->unk_3B0[j], triNorm, &sp60, &sp5C)) { + func_80B300F4(this, globalCtx, triNorm, &sp60, sp5C, j); + } + } + } + } else if (this->unk_3C1 <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_MarkForDeath(&this->dyna.actor); + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") #endif -extern ColliderTrisElementInit D_80B31060[6]; -extern ColliderTrisInit D_80B311C8; -extern ColliderTrisElementInit D_80B311D8[6]; -extern ColliderTrisInit D_80B31340; -extern InitChainEntry D_80B31418[]; +void ObjSpidertent_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB10.s") + this->actionFunc(this, globalCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FB94.s") +void ObjSpidertent_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpidertent* this = THIS; + s32 params = OBJSPIDERTENT_GET_1(&this->dyna.actor); + s32 temp_f18 = this->unk_3C5 * (29.0f / 51); + Gfx* gfx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B2FC98.s") + OPEN_DISPS(globalCtx->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B300F4.s") + gfx = POLY_XLU_DISP; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30410.s") + gSPDisplayList(gfx++, &sSetupDL[6 * 25]); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gfx++, 0, 0xFF, this->unk_3C2, this->unk_3C3, this->unk_3C4, temp_f18); + gSPDisplayList(gfx++, D_80B31350[params].unk_00); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30480.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B307E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30A4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/func_80B30AF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spidertent/ObjSpidertent_Draw.s") + POLY_XLU_DISP = gfx; + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h index a40faa86a..9289bd365 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h @@ -7,9 +7,23 @@ struct ObjSpidertent; typedef void (*ObjSpidertentActionFunc)(struct ObjSpidertent*, GlobalContext*); +#define OBJSPIDERTENT_GET_1(thisx) ((thisx)->params & 1) +#define OBJSPIDERTENT_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + typedef struct ObjSpidertent { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x284]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ Vec3f unk_3A4; + /* 0x03B0 */ f32 unk_3B0[4]; + /* 0x03C0 */ u8 unk_3C0; + /* 0x03C1 */ s8 unk_3C1; + /* 0x03C2 */ u8 unk_3C2; + /* 0x03C3 */ u8 unk_3C3; + /* 0x03C4 */ u8 unk_3C4; + /* 0x03C5 */ u8 unk_3C5; + /* 0x03C6 */ s8 unk_3C6; + /* 0x03C7 */ s8 unk_3C7; /* 0x03C8 */ ObjSpidertentActionFunc actionFunc; } ObjSpidertent; // size = 0x3CC 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 cf7c48431..20f4a1c50 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -5,8 +5,9 @@ */ #include "z_obj_spinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSpinyroll*)thisx) @@ -15,7 +16,18 @@ void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A1E9C4(ObjSpinyroll* this); +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EAAC(ObjSpinyroll* this); +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EB40(ObjSpinyroll* this); +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1EC24(ObjSpinyroll* this); +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx); +void func_80A1ECC0(ObjSpinyroll* this); +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx); + const ActorInit Obj_Spinyroll_InitVars = { ACTOR_OBJ_SPINYROLL, ACTORCAT_PROP, @@ -28,121 +40,669 @@ const ActorInit Obj_Spinyroll_InitVars = { (ActorFunc)ObjSpinyroll_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[6] = { -static ColliderTrisElementInit D_80A1F040[6] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -60.0f, 0.0f, 17.0f }, { 60.0f, 40.0f, 17.0f }, { -60.0f, 40.0f, 17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 0.0f, -17.0f }, { -60.0f, 40.0f, -17.0f }, { 60.0f, 40.0f, -17.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f } } }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x04, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x04, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 60.0f, 20.0f, -12.0f }, { -60.0f, 20.0f, 12.0f }, { 60.0f, 20.0f, 12.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_80A1F1A8 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 6, D_80A1F040, // sTrisElementsInit, +static ColliderTrisInit sTrisInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + 6, + sTrisElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A1F204[] = { +f32 D_80A1F1B8[] = { 1.0f, 2.0f, 4.0f }; + +f32 D_80A1F1C4[] = { + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, +}; + +s16 D_80A1F1E4[] = { + 1, 10, 20, 30, 40, 50, 60, 70, +}; + +f32 D_80A1F1F4[] = { 30.0f, -30.0f }; + +f32 D_80A1F1FC[] = { 9.0f, -9.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; +s16 D_80A1F20C[] = { 0xFA0, -0xFA0 }; + +void func_80A1DA50(GlobalContext* globalCtx, ObjSpinyroll* this, Vec3f* arg2, Vec3f* arg3) { + Vec3f sp1C; + + Math_Vec3f_Sum(arg2, arg3, &sp1C); + Math_Vec3f_Scale(&sp1C, 0.5f); + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &sp1C); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); +} + +void func_80A1DAAC(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 sp18 = Math_CosS(arg2); + + arg0->x = (arg1->z * sp1C) + (arg1->x * sp18); + arg0->y = arg1->y; + arg0->z = (arg1->z * sp18) - (arg1->x * sp1C); +} + +void func_80A1DB2C(Actor* thisx) { + ObjSpinyroll* this = THIS; + s32 i; + s32 j; + s32 params = OBJSPINYROLL_GET_C000(&this->dyna.actor); + Vec3f sp7C[3]; + Vec3f sp70; + f32 temp = D_80A1F1B8[params]; + ColliderTrisElementInit* ptr; + + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + for (j = 0; j < ARRAY_COUNT(sp7C); j++) { + ptr = &sTrisInit.elements[i]; + + sp70.x = ptr->dim.vtx[j].x * temp; + sp70.y = ptr->dim.vtx[j].y; + sp70.z = ptr->dim.vtx[j].z; + + func_80A1DAAC(&sp7C[j], &sp70, this->dyna.actor.shape.rot.y); + Math_Vec3f_Sum(&sp7C[j], &this->dyna.actor.world.pos, &sp7C[j]); + } + Collider_SetTrisVertices(&this->collider, i, &sp7C[0], &sp7C[1], &sp7C[2]); + } +} + +void func_80A1DC5C(ObjSpinyroll* this) { + this->unk_4D8 += 0x5DC0; + Math_StepToF(&this->unk_4D4, 0.0f, 0.32f); + this->unk_4D0 = ((Math_SinS(this->unk_4D8) + 1.0f) * this->unk_4D4) + 24.0f; +} + +void func_80A1DCCC(ObjSpinyroll* this) { + f32 phi_f2; + + if (this->dyna.actor.speedXZ > 3.0f) { + phi_f2 = 3.0f; + } else { + phi_f2 = this->dyna.actor.speedXZ; + } + + if (this->unk_4D4 < phi_f2) { + this->unk_4D4 = phi_f2; + } +} + +void func_80A1DD18(ObjSpinyroll* this) { + f32 temp_f0; + Vec3f* sp20 = &this->unk_4AC[this->unk_4A8 ^ 1]; + + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_4AC[this->unk_4A8], &this->unk_4C4); + + temp_f0 = Math3D_Vec3fMagnitude(&this->unk_4C4); + if (temp_f0 < 0.01f) { + Math_Vec3f_Copy(&this->unk_4C4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_4C4, 1.0f / temp_f0); +} + +void func_80A1DE10(ObjSpinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_4AC[this->unk_4A8 ^ 1]); +} + +void func_80A1DE58(ObjSpinyroll* this) { + this->unk_4A8 = 0; + func_80A1DE10(this); + func_80A1DD18(this); +} + +void func_80A1DE84(ObjSpinyroll* this) { + this->unk_4A8 ^= 1; + func_80A1DE10(this); + func_80A1DD18(this); +} + +s32 func_80A1DEB8(ObjSpinyroll* this) { + s32 pad; + s32 sp30 = this->unk_4A8 ^ 1; + Vec3f sp24; + + Math_StepToF(&this->dyna.actor.speedXZ, 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; + + Math_Vec3f_Diff(&this->unk_4AC[sp30], &this->dyna.actor.world.pos, &sp24); + + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} + +void func_80A1DFA0(ObjSpinyroll* this) { + f32 temp_f0; + f32 phi_f12; + s32 i; + s32 j; + f32 temp_f2; + + this->unk_3A4.unk_F4 = (s32)(D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f * (1.0f / 58)) + 2; + + temp_f0 = (D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)] * 120.0f) - 2.0f; + temp_f2 = temp_f0 / (this->unk_3A4.unk_F4 - 1); + temp_f0 *= 0.5f; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + for (j = 0, phi_f12 = temp_f0; j < this->unk_3A4.unk_F4; j++, phi_f12 -= temp_f2) { + this->unk_3A4.unk_00[i].unk_00[j].unk_00 = phi_f12; + } + } +} + +#ifdef NON_MATCHING +// globalCtx not in s reg, something with ptr->unk_F0 = temp_s1; line +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 i; + s32 j; + ObjSpinyrollStruct2* ptr = &this->unk_3A4; + f32 temp_f0; + f32 temp_f20; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + ObjSpinyrollStruct* temp_s1; + f32 temp_f22; + f32 temp_f24; + f32 temp; + s32 sp98; + + spC8.y = this->dyna.actor.world.pos.y + 10.0f; + spBC.y = spC8.y; + sp98 = false; + temp_f20 = FLT_MAX; + ptr->unk_F0 = NULL; + + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + temp = D_80A1F1F4[i]; + temp_f22 = temp * this->unk_4C4.x; + temp_f24 = temp * this->unk_4C4.z; + temp_s1 = &ptr->unk_00[i]; + + for (j = 0; j < ptr->unk_F4; j++) { + spC8.x = + (temp_s1->unk_00[j].unk_00 * Math_CosS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.x; + spC8.z = + (temp_s1->unk_00[j].unk_00 * -Math_SinS(this->dyna.actor.world.rot.y)) + this->dyna.actor.world.pos.z; + + spBC.x = temp_f22 + spC8.x; + spBC.z = temp_f24 + spC8.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spC8, &spBC, &spB0, &temp_s1->unk_00[j].unk_04, 1, 0, 0, 1, + &temp_s1->unk_00[j].bgId, &this->dyna.actor, 0.0f)) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + func_80A1DA50(globalCtx, this, &spC8, &spB0); + } + + temp_f0 = Math3D_Vec3fDistSq(&spC8, &spB0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp98 = true; + Math_Vec3f_Diff(&spB0, &spBC, arg2); + ptr->unk_F0 = temp_s1; + } + } + } + } + + return sp98; +} +#else +s32 func_80A1E074(ObjSpinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") #endif -extern ColliderTrisElementInit D_80A1F040[6]; -extern ColliderTrisInit D_80A1F1A8; -extern InitChainEntry D_80A1F204[]; +s32 func_80A1E2D8(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000E68; + if (func_80A1E074(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DA50.s") +s32 func_80A1E334(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + f32 temp_f0 = BgCheck_EntityRaycastFloor5(colCtx, polyOut, bgId, &this->dyna.actor, arg4); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DAAC.s") + *arg1 = temp_f0; + return *arg1 > (BGCHECK_Y_MIN + 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DB2C.s") +s32 func_80A1E394(CollisionContext* colCtx, f32* arg1, CollisionPoly** polyOut, s32* bgId, Vec3f* arg4, + ObjSpinyroll* this) { + return BgCheck_EntityCheckCeiling(colCtx, arg1, arg4, 24.0f, polyOut, bgId, &this->dyna.actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DC5C.s") +#ifdef NON_MATCHING +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3) { + f32 temp_f20; + ObjSpinyrollStruct2* spC8; + f32 phi_f22; + ObjSpinyrollColFunc spC0; + s32 i; + s32 j; + Vec3f spAC; + Vec3f spA0; + Vec3f sp94; + ObjSpinyrollStruct* temp_s0; + f32 phi_f26; + s32 sp84; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DCCC.s") + spC8 = &this->unk_3A4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DD18.s") + if (this->unk_4C4.y > 0.0f) { + spC0 = func_80A1E394; + phi_f26 = this->dyna.actor.world.pos.y + 48.0f; + } else { + spC0 = func_80A1E334; + phi_f26 = this->dyna.actor.world.pos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE10.s") + sp84 = false; + sp94.y = this->dyna.actor.world.pos.y + 24.0f; + phi_f22 = FLT_MAX; + spC8->unk_F0 = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE58.s") + for (i = 0; i < ARRAY_COUNT(this->unk_3A4.unk_00); i++) { + sp94.z = D_80A1F1FC[i]; + temp_s0 = &spC8->unk_00[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DE84.s") + for (j = 0; j < spC8->unk_F4; j++) { + sp94.x = temp_s0->unk_00[j].unk_00; + func_80A1DAAC(&spAC, &sp94, this->dyna.actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DEB8.s") + spAC.x += this->dyna.actor.world.pos.x; + spAC.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1DFA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E074.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E2D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E334.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E394.s") + if (spC0(&globalCtx->colCtx, &spA0.y, &temp_s0->unk_00[j].unk_04, &temp_s0->unk_00[j].bgId, &spAC, this)) { + temp_f20 = fabsf(spA0.y - spAC.y); + if (temp_f20 <= 24.0f) { + if (arg3 && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA0.x = spAC.x; + spA0.z = spAC.z; + func_80A1DA50(globalCtx, this, &spAC, &spA0); + } + if (temp_f20 < phi_f22) { + sp84 = true; + *arg2 = spA0.y - phi_f26; + phi_f22 = temp_f20; + spC8->unk_F0 = temp_s0; + } + } + } + } + } + return sp84; +} +#else +s32 func_80A1E3D8(ObjSpinyroll* this, GlobalContext* globalCtx, f32* arg2, s32 arg3); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E3D8.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E648.s") +s32 func_80A1E648(ObjSpinyroll* this, GlobalContext* globalCtx, s32 arg2) { + f32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E694.s") + if (func_80A1E3D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.y += sp1C; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E6D4.s") +DynaPolyActor* func_80A1E694(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (this->unk_3A4.unk_F0 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_3A4.unk_F0->unk_00[0].bgId); + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Init.s") +s32 func_80A1E6D4(ObjSpinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0 = func_80A1E694(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Destroy.s") + if ((temp_v0 != NULL) && (Math3D_Vec3fDistSq(&temp_v0->actor.world.pos, &temp_v0->actor.prevPos) > SQ(0.01f))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9C4.s") +void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSpinyroll* this = THIS; + f32 sp44; + Path* path; + s32 pad2; + Vec3s* points; + Vec3s* sp34; + Vec3s* sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1E9E0.s") + sp44 = D_80A1F1B8[OBJSPINYROLL_GET_C000(&this->dyna.actor)]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA10.s") + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EA4C.s") + this->dyna.actor.scale.x = 0.1f * sp44; + this->dyna.actor.scale.y = 0.1f; + this->dyna.actor.scale.z = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAAC.s") + this->dyna.actor.uncullZoneScale = 250.0f * sp44; + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000E68); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EAE0.s") + Collider_InitTris(globalCtx, &this->collider); + Collider_SetTris(globalCtx, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB40.s") + if (OBJSPINYROLL_GET_7F(&this->dyna.actor) == OBJSPINYROLL_GET_7F_7F) { + func_80A1E9C4(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EB54.s") + this->dyna.actor.world.rot.y = 0; + func_80A1DFA0(this); + this->unk_4A4 = D_80A1F1C4[OBJSPINYROLL_GET_380(thisx)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC24.s") + path = &globalCtx->setupPathList[OBJSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1EC38.s") + sp34 = &points[0]; + sp30 = &points[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECC0.s") + Math_Vec3s_ToVec3f(&this->unk_4AC[0], sp34); + Math_Vec3s_ToVec3f(&this->unk_4AC[1], sp30); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_4AC[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/func_80A1ECD4.s") + if ((sp34->x == sp30->x) && (sp34->y != sp30->y) && (sp34->z == sp30->z)) { + this->unk_49C = true; + } else if (((sp34->x != sp30->x) && (sp34->y == sp30->y) && (sp34->z == sp30->z)) || + ((sp34->x == sp30->x) && (sp34->y == sp30->y) && (sp34->z != sp30->z))) { + this->unk_49C = false; + } else { + Actor_MarkForDeath(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Update.s") + func_80A1DE58(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A1EAAC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Spinyroll/ObjSpinyroll_Draw.s") +void ObjSpinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(globalCtx, &this->collider); +} + +void func_80A1E9C4(ObjSpinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A1E9E0; +} + +void func_80A1E9E0(ObjSpinyroll* this, GlobalContext* globalCtx) { + this->unk_4DA += 0x6E; + if (this->unk_4DA > 0xFA0) { + this->unk_4DA = 0xFA0; + } +} + +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; +} + +void func_80A1EA4C(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE)) { + if (this->unk_4E2 > 0) { + this->unk_4E2--; + if (this->unk_4E2 <= 0) { + func_80A1EAAC(this); + } + } + } +} + +void func_80A1EAAC(ObjSpinyroll* this) { + this->actionFunc = func_80A1EAE0; + this->unk_4DC = D_80A1F20C[this->unk_4A8]; + this->dyna.actor.speedXZ = 0.0f; +} + +void func_80A1EAE0(ObjSpinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_4DA, this->unk_4DC, 0x6E)) { + if (!this->unk_49C) { + func_80A1EB40(this); + } else { + func_80A1ECC0(this); + } + } +} + +void func_80A1EB40(ObjSpinyroll* this) { + this->actionFunc = func_80A1EB54; +} + +void func_80A1EB54(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E2D8(this, globalCtx, 1)) { + if (func_80A1E694(this, globalCtx) != NULL) { + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EC24(this); + } else { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } + } else if (sp24 != 0) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void func_80A1EC24(ObjSpinyroll* this) { + this->actionFunc = func_80A1EC38; +} + +void func_80A1EC38(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_4DA, 0, this->unk_4DE); + + if (func_80A1E2D8(this, globalCtx, 0) && func_80A1E6D4(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A1DE84(this); + func_80A1EA10(this); + } +} + +void func_80A1ECC0(ObjSpinyroll* this) { + this->actionFunc = func_80A1ECD4; +} + +void func_80A1ECD4(ObjSpinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A1DEB8(this); + + if (func_80A1E648(this, globalCtx, 1)) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x7D0; + func_80A1EA10(this); + } else if (sp24) { + func_80A1DE84(this); + func_80A1DCCC(this); + this->unk_4DE = 0x78; + func_80A1EA10(this); + } +} + +void ObjSpinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjSpinyroll* this = THIS; + + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_80A1DCCC(this); + } + + this->actionFunc(this, globalCtx); + + this->unk_4E0 += this->unk_4DA; + func_80A1DC5C(this); + func_80A1DB2C(thisx); + + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjSpinyroll* this = THIS; + f32 temp_f26; + f32 temp_f28; + s32 temp_s1 = OBJSPINYROLL_GET_C000(&this->dyna.actor); + s32 phi_s4; + f32 phi_f22; + f32 phi_f24; + s32 i; + f32 temp_f30; + Vec3s sp84; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + + temp_f26 = Math_CosS(this->dyna.actor.shape.rot.y) * 120.0f; + temp_f28 = Math_SinS(this->dyna.actor.shape.rot.y) * -120.0f; + temp_f30 = this->dyna.actor.world.pos.y + this->unk_4D0; + + if (temp_s1 == OBJSPINYROLL_GET_C000_0) { + phi_s4 = 1; + phi_f22 = this->dyna.actor.world.pos.x; + phi_f24 = this->dyna.actor.world.pos.z; + } else if (temp_s1 == OBJSPINYROLL_GET_C000_1) { + phi_s4 = 2; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 0.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 0.5f); + } else { + phi_s4 = 4; + phi_f22 = this->dyna.actor.world.pos.x - (temp_f26 * 1.5f); + phi_f24 = this->dyna.actor.world.pos.z - (temp_f28 * 1.5f); + } + + sp84.x = this->dyna.actor.shape.rot.x + this->unk_4E0; + sp84.y = this->dyna.actor.shape.rot.y; + sp84.z = this->dyna.actor.shape.rot.z; + + for (i = 0; i < phi_s4; i++) { + Matrix_SetStateRotationAndTranslation(phi_f22, temp_f30, phi_f24, &sp84); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + phi_f22 += temp_f26; + phi_f24 += temp_f28; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h index b06064316..b35627b13 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.h @@ -6,12 +6,54 @@ struct ObjSpinyroll; typedef void (*ObjSpinyrollActionFunc)(struct ObjSpinyroll*, GlobalContext*); +typedef s32 (*ObjSpinyrollColFunc)(CollisionContext*, f32*, CollisionPoly**, s32*, Vec3f*, struct ObjSpinyroll*); + +#define OBJSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJSPINYROLL_GET_C000(thisx) (((thisx)->params >> 0xE) & 3) + +#define OBJSPINYROLL_GET_7F_7F 0x7F +#define OBJSPINYROLL_GET_C000_0 0 +#define OBJSPINYROLL_GET_C000_1 1 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ CollisionPoly* unk_04; + /* 0x08 */ s32 bgId; +} ObjSpinyrollSubStruct; // size = 0xC + +typedef struct { + /* 0x00 */ ObjSpinyrollSubStruct unk_00[10]; +} ObjSpinyrollStruct; // size = 0x78 + +typedef struct { + /* 0x00 */ ObjSpinyrollStruct unk_00[2]; + /* 0xF0 */ ObjSpinyrollStruct* unk_F0; + /* 0xF4 */ s32 unk_F4; +} ObjSpinyrollStruct2; // size = 0xF8? typedef struct ObjSpinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x35C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderTris collider; + /* 0x017C */ ColliderTrisElement colliderElements[6]; + /* 0x03A4 */ ObjSpinyrollStruct2 unk_3A4; + ///* 0x0494 */ ObjSpinyrollStruct* unk_494; // alternative testing + ///* 0x0498 */ s32 unk_498; + /* 0x049C */ s32 unk_49C; /* 0x04A0 */ ObjSpinyrollActionFunc actionFunc; - /* 0x04A4 */ char unk_4A4[0x40]; + /* 0x04A4 */ f32 unk_4A4; + /* 0x04A8 */ s32 unk_4A8; + /* 0x04AC */ Vec3f unk_4AC[2]; + /* 0x04C4 */ Vec3f unk_4C4; + /* 0x04D0 */ f32 unk_4D0; + /* 0x04D4 */ f32 unk_4D4; + /* 0x04D8 */ s16 unk_4D8; + /* 0x04DA */ s16 unk_4DA; + /* 0x04DC */ s16 unk_4DC; + /* 0x04DE */ s16 unk_4DE; + /* 0x04E0 */ s16 unk_4E0; + /* 0x04E2 */ s16 unk_4E2; } ObjSpinyroll; // size = 0x4E4 extern const ActorInit Obj_Spinyroll_InitVars; 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 b8e576e39..7bea97826 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.c @@ -5,17 +5,71 @@ */ #include "z_obj_switch.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwitch*)thisx) +#define COS_OF_5_PI_DIV_8 -0.38268343f + void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this); +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this); +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this); +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this); + +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx); + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx); +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx); + +static TexturePtr sEyeSwitchTextures[][4] = { + { gEyeSwitchGoldOpenTex, gEyeSwitchGoldOpeningTex, gEyeSwitchGoldClosingTex, gEyeSwitchGoldClosedTex }, + { gEyeSwitchSilverOpenTex, gEyeSwitchSilverHalfTex, gEyeSwitchSilverClosedTex, gEyeSwitchSilverClosedTex }, +}; + +static s32 sIsSegmentTableInit = false; + const ActorInit Obj_Switch_InitVars = { ACTOR_OBJ_SWITCH, ACTORCAT_SWITCH, @@ -28,183 +82,969 @@ const ActorInit Obj_Switch_InitVars = { (ActorFunc)ObjSwitch_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CCD4[2] = { +static f32 sHeights[] = { 10.0f, 10.0f, 0.0f, 30.0f, 30.0f, 15.0f }; + +static f32 sScale[] = { 0.123f, 0.123f, 0.1f, 0.118f, 0.118f, 0.248f }; + +static ColliderTrisElementInit sRustyFloorTrisElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { -20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, 20.0f } } }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000400, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000400, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 20.0f, 19.0f, 20.0f }, { 20.0f, 19.0f, -20.0f }, { -20.0f, 19.0f, -20.0f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CD4C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CCD4, // sTrisElementsInit, +static ColliderTrisInit sRustyFloorTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sRustyFloorTrisElementsInit), + sRustyFloorTrisElementsInit, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_8093CD5C[2] = { +static ColliderTrisElementInit sEyeSwitchTrisElementsInit[2] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { -23.0f, 0.0f, 8.5f }, { 0.0f, -23.0f, 8.5f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x00003820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x00003820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { { { 0.0f, 23.0f, 8.5f }, { 0.0f, -23.0f, 8.5f }, { 23.0f, 0.0f, 8.5f } } }, }, }; -// static ColliderTrisInit sTrisInit = { -static ColliderTrisInit D_8093CDD4 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_TRIS, }, - 2, D_8093CD5C, // sTrisElementsInit, +static ColliderTrisInit sEyeSwitchTrisInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_TRIS, + }, + ARRAY_COUNT(sEyeSwitchTrisElementsInit), + sEyeSwitchTrisElementsInit, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_8093CDE4[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01CBFFBE, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x01CBFFBE, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 300, 0 }, 20 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_8093CE08 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, D_8093CDE4, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093CE18[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +static Color_RGB8 sSakonHideoutColor[2] = { { 250, 90, 60 }, { 255, 255, 255 } }; -extern ColliderTrisElementInit D_8093CCD4[2]; -extern ColliderTrisInit D_8093CD4C; -extern ColliderTrisElementInit D_8093CD5C[2]; -extern ColliderTrisInit D_8093CDD4; -extern ColliderJntSphElementInit D_8093CDE4[1]; -extern ColliderJntSphInit D_8093CE08; -extern InitChainEntry D_8093CE18[]; +static Gfx* sFloorSwitchDL[] = { gFloorSwitch1DL, gFloorSwitch3DL, gFloorSwitch2DL, gFloorSwitch2DL, gFloorSwitch1DL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ABD0.s") +static Gfx* sEyeSwitchDL[] = { gEyeSwitchGoldDL, gEyeSwitchSilverDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AC6C.s") +static AnimatedMaterial* sCrystalSwitchAnimatedMat; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093ADA8.s") +void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderJntSphInit* init) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE1C.s") + Collider_InitJntSph(globalCtx, &this->colliderJntSph); + Collider_SetJntSph(globalCtx, &this->colliderJntSph, &this->dyna.actor, init, this->colliderJntSphElements); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + (this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y), + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(this->dyna.actor.scale.x, this->dyna.actor.scale.y, this->dyna.actor.scale.z, MTXMODE_APPLY); + Collider_UpdateSpheres(0, &this->colliderJntSph); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE74.s") +void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, ColliderTrisInit* init) { + s32 pad; + s32 i; + s32 j; + Vec3f vtx[3]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AE88.s") + Collider_InitTris(globalCtx, &this->colliderTris); + Collider_SetTris(globalCtx, &this->colliderTris, &this->dyna.actor, init, this->colliderTrisElements); + Matrix_StatePush(); + Matrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y + + this->dyna.actor.shape.yOffset * this->dyna.actor.scale.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEC4.s") + for (i = 0; i < ARRAY_COUNT(this->colliderTrisElements); i++) { + if (this) {} + for (j = 0; j < ARRAY_COUNT(vtx); j++) { + Matrix_MultiplyVector3fByState(&init->elements[i].dim.vtx[j], &vtx[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vtx[0], &vtx[1], &vtx[2]); + } + Matrix_StatePop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AEF0.s") +Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, + this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y - 25.0f, this->dyna.actor.world.pos.z, + this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, + 0xFF32); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF1C.s") +void ObjSwitch_SetSwitchFlagState(ObjSwitch* this, GlobalContext* globalCtx, s32 setFlag) { + if (setFlag) { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093AF54.s") + Flags_SetSwitch(globalCtx, flag); + } else { + s32 flag = OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Init.s") + Flags_UnsetSwitch(globalCtx, flag); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Destroy.s") +void ObjSwitch_CrystalUpdateTimer(ObjSwitch* this) { + this->crystalAnimTimer++; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B648.s") +void ObjSwitch_StopCutscene(ObjSwitch* this) { + if (this->isPlayingCutscene) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->isPlayingCutscene = false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B668.s") +void ObjSwitch_PlayFootSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_FOOT_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B6F4.s") +void ObjSwitch_PlayDiamondSwitchSfx(ObjSwitch* this) { + if (this->sfxTimer <= 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_DIAMOND_SWITCH); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B710.s") +void ObjSwitch_SetFloorSwitchSnapPlayerState(ObjSwitch* this, s32 state) { + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->floorSwitchPlayerSnapState = state; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B92C.s") +void ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + Player* player; + f32 centerDisplacement; + s16 yaw; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B940.s") + if (globalCtx->actorCtx.unk5 & 0x80) { + player = GET_PLAYER(globalCtx); + // compute yawTowardsPlayer relative to model space + yaw = BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.shape.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9C0.s") + // clamps yaw to the range -45 to 45 degrees, such that 0 degrees follows along the apothem + yaw += 0x2000; + yaw &= 0x3FFF; + yaw -= 0x2000; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093B9E4.s") + // set centerDisplacement to the length of the apothem for the floor switch square + // only OBJSWITCH_TYPE_FLOOR and OBJSWITCH_TYPE_FLOOR_LARGE are supported + centerDisplacement = OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR ? 24.0f : 48.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB5C.s") + cos = Math_CosS(yaw); + if (fabsf(cos) > 0.01f) { + // compute how far to displace the player so that the player is touching an edge + centerDisplacement /= cos; + // if the player is already inside the square, don't move them + if (centerDisplacement < this->dyna.actor.xzDistToPlayer) { + player->actor.world.pos.x = + Math_SinS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.x; + player->actor.world.pos.z = + Math_CosS(this->dyna.actor.yawTowardsPlayer) * centerDisplacement + this->dyna.actor.world.pos.z; + } + player->linearVelocity = 0.0f; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BB70.s") +void ObjSwitch_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + s32 type; + u32 isSwitchFlagSet; + ObjSwitch* this = THIS; + s32 pad2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BBD0.s") + isSwitchFlagSet = Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)); + type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, sScale[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCC8.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.9f; + } else { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f; + } + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gFloorSwitchCol); + } + if (type == OBJSWITCH_TYPE_FLOOR) { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchUpScale = 33.0f / 200.0f / 3.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f / 3.0f; + } else { + this->floorSwitchUpScale = 33.0f / 200.0f; + this->floorSwitchDownScale = 33.0f / 2000.0f; + } + } + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (globalCtx->sceneNum == SCENE_SECOM) { + Color_RGB8* color = &sSakonHideoutColor[OBJ_SWITCH_GET_COLOR_ID(&this->dyna.actor)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BCDC.s") + this->color.r = color->r; + this->color.g = color->g; + this->color.b = color->b; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + } else { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + } + } + Actor_SetFocus(&this->dyna.actor, sHeights[type]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD34.s") + if (type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sRustyFloorTrisInit); + } else if (type == OBJSWITCH_TYPE_EYE) { + ObjSwitch_InitTrisCollider(this, globalCtx, &sEyeSwitchTrisInit); + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + ObjSwitch_InitJntSphCollider(this, globalCtx, &sJntSphInit); + } + if (type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + this->dyna.actor.targetMode = 4; + this->dyna.actor.flags |= 1; + } + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + if (ObjSwitch_SpawnIce(this, globalCtx) == NULL) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + } + this->sfxTimer = 0; + } else { + this->sfxTimer = 10; + } + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + this->dyna.actor.flags |= 0x80; + } + if (type == OBJSWITCH_TYPE_EYE) { + if (sIsSegmentTableInit == false) { + s32 i, j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BD4C.s") + sIsSegmentTableInit = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDAC.s") + for (i = 0; i < ARRAY_COUNT(sEyeSwitchTextures); i++) { + for (j = 0; j < ARRAY_COUNT(*sEyeSwitchTextures); j++) { + sEyeSwitchTextures[i][j] = Lib_SegmentedToVirtual(sEyeSwitchTextures[i][j]); + } + } + } + } + if (type == OBJSWITCH_TYPE_CRYSTAL) { + sCrystalSwitchAnimatedMat = Lib_SegmentedToVirtual(&gCrystalSwitchAnimatedMat); + } + if (OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + ObjSwitch_EyeSwitchFrozenInit(this); + } else if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchUpInit(this); + } else { + ObjSwitch_FloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_FloorSwitchDownInit(this); + } else { + ObjSwitch_FloorSwitchUpInit(this); + } + } + } else if (type == OBJSWITCH_TYPE_EYE) { + if (isSwitchFlagSet) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } + } else if (type == OBJSWITCH_TYPE_CRYSTAL || type == OBJSWITCH_TYPE_CRYSTAL_TARGETABLE) { + if (isSwitchFlagSet) { + ObjSwitch_CrystalSwitchOnInit(this); + } else { + ObjSwitch_CrystalSwitchOffInit(this); + } + } else if (type == OBJSWITCH_TYPE_FLOOR_LARGE) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchUpInit(this); + } else { + ObjSwitch_LargeFloorSwitchDownInit(this); + } + } else { + if (isSwitchFlagSet) { + ObjSwitch_LargeFloorSwitchDownInit(this); + } else { + ObjSwitch_LargeFloorSwitchUpInit(this); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BDC0.s") +void ObjSwitch_Destroy(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSwitch* this = THIS; + s32 type = OBJ_SWITCH_GET_TYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE10.s") + if (type == OBJSWITCH_TYPE_FLOOR || type == OBJSWITCH_TYPE_FLOOR_RUSTY || type == OBJSWITCH_TYPE_FLOOR_LARGE) { + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } + switch (type) { + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_EYE: + Collider_DestroyTris(globalCtx, &this->colliderTris); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + Collider_DestroyJntSph(globalCtx, &this->colliderJntSph); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BE2C.s") +void ObjSwitch_TryPlayCutsceneInit(ObjSwitch* this, GlobalContext* globalCtx, ObjSwitchSetupActionFunc actionFunc, + s32 nextSwitchFlagState) { + this->setupFunc = actionFunc; + this->nextSwitchFlagState = nextSwitchFlagState; + this->actionFunc = ObjSwitch_TryPlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BEF0.s") +void ObjSwitch_TryPlayCutscene(ObjSwitch* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + ObjSwitch_SetSwitchFlagState(this, globalCtx, this->nextSwitchFlagState); + if (this->floorSwitchPlayerSnapState == 1) { + this->floorSwitchPlayerSnapState = 2; + } + this->isPlayingCutscene = true; + this->setupFunc(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF04.s") +void ObjSwitch_FloorSwitchUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchUp; + this->dyna.actor.scale.y = this->floorSwitchUpScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF50.s") +void ObjSwitch_FloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093BF70.s") + if (OBJ_SWITCH_GET_TYPE(&this->dyna.actor) == OBJSWITCH_TYPE_FLOOR_RUSTY) { + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AT_HIT; + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + } + } else { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + s32 isSwitchFlagNotSet = + Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor)) ? false : true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0A4.s") + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, + isSwitchFlagNotSet); + } + break; + case OBJSWITCH_SUBTYPE_RESET: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchPushDownInit, true); + } + break; + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchPushDownInit(this); + } + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C0B8.s") +void ObjSwitch_FloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchPushDown; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C138.s") +void ObjSwitch_FloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.0495f; + if (this->dyna.actor.scale.y <= this->floorSwitchDownScale) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchDownInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C15C.s") +void ObjSwitch_FloorSwitchDownInit(ObjSwitch* this) { + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_FloorSwitchDown; + this->dyna.actor.scale.y = this->floorSwitchDownScale; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C23C.s") +void ObjSwitch_FloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + u32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C250.s") + switch (subType) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + if (globalCtx->sceneNum == SCENE_SECOM && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + case OBJSWITCH_SUBTYPE_RESET: + case OBJSWITCH_SUBTYPE_RESET_INVERTED: + if (!DynaPolyActor_IsInSwitchPressedState(&this->dyna) && + (Player_InCsMode(&globalCtx->state) == 0 || globalCtx->sceneNum == SCENE_SECOM)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (subType == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_FloorSwitchRiseUpInit(this); + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_FloorSwitchRiseUpInit, true); + } else { + ObjSwitch_FloorSwitchRiseUpInit(this); + } + } + } else { + if (globalCtx->sceneNum == SCENE_SECOM) { + this->floorSwitchReleaseTimer = 2; + } else { + this->floorSwitchReleaseTimer = 6; + } + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2B4.s") +void ObjSwitch_FloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_FloorSwitchRiseUp; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C2D4.s") +void ObjSwitch_FloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.0495f; + if (this->floorSwitchUpScale <= this->dyna.actor.scale.y) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_FloorSwitchUpInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3C8.s") +s32 ObjSwitch_IsEyeSwitchHit(ObjSwitch* this) { + Actor* acActor; + Actor* actor = &this->dyna.actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C3DC.s") + if ((this->colliderTris.base.acFlags & AC_HIT) && !(this->collisionFlags & AC_HIT)) { + acActor = this->colliderTris.base.ac; + if (acActor != NULL) { + Vec3f sp2C; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C460.s") + Matrix_StatePush(); + Matrix_RotateY(acActor->world.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(acActor->world.rot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(1.0f, &sp2C); + Matrix_RotateY(actor->shape.rot.y, MTXMODE_NEW); + Matrix_InsertXRotation_s(actor->shape.rot.x, MTXMODE_APPLY); + Matrix_InsertZRotation_s(actor->shape.rot.z, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledZ(1.0f, &sp20); + Matrix_StatePop(); + if ((Math3D_Parallel(&sp2C, &sp20) < COS_OF_5_PI_DIV_8)) { + return true; + } + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C488.s") +void ObjSwitch_EyeSwitchFrozenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchUnfrozen; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C584.s") +void ObjSwitch_EyeSwitchUnfrozen(ObjSwitch* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_EyeSwitchClosedInit(this); + } else { + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C598.s") +void ObjSwitch_EyeSwitchOpenInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpen; + this->eyeTexIndex = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Update.s") +void ObjSwitch_EyeSwitchOpen(ObjSwitch* this, GlobalContext* globalCtx) { + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchClosingInit, true); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C778.s") +void ObjSwitch_EyeSwitchClosingInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C888.s") +void ObjSwitch_EyeSwitchClosing(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchClosedInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C8B8.s") +void ObjSwitch_EyeSwitchClosedInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchClosed; + this->eyeTexIndex = 3; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093C99C.s") +void ObjSwitch_EyeSwitchClosed(ObjSwitch* this, GlobalContext* globalCtx) { + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_EyeSwitchOpeningInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (ObjSwitch_IsEyeSwitchHit(this) || OBJ_SWITCH_IS_FROZEN(&this->dyna.actor)) { + OBJ_SWITCH_UNSET_FROZEN(&this->dyna.actor); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_EyeSwitchOpeningInit, false); + } + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CA80.s") +void ObjSwitch_EyeSwitchOpeningInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_EyeSwitchOpening; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/func_8093CAC4.s") +void ObjSwitch_EyeSwitchOpening(ObjSwitch* this, GlobalContext* globalCtx) { + this->eyeTexIndex--; + if (this->eyeTexIndex <= 0) { + ObjSwitch_StopCutscene(this); + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_EyeSwitchOpenInit(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Switch/ObjSwitch_Draw.s") +void ObjSwitch_CrystalSwitchOffInit(ObjSwitch* this) { + this->color.r = 0; + this->color.g = 0; + this->color.b = 0; + this->actionFunc = ObjSwitch_CrystalSwitchOff; +} + +void ObjSwitch_CrystalSwitchOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + break; + case OBJSWITCH_SUBTYPE_SYNC: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + + } else if (Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOnInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOnInit, true); + } + ObjSwitch_CrystalUpdateTimer(this); + break; + } +} + +void ObjSwitch_CrystalSwitchTurnOnInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOn; +} + +void ObjSwitch_CrystalSwitchTurnOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + if (subType == OBJSWITCH_SUBTYPE_TOGGLE) { + ObjSwitch_CrystalUpdateTimer(this); + } + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOnInit(this); +} + +void ObjSwitch_CrystalSwitchOnInit(ObjSwitch* this) { + this->color.r = 255; + this->color.g = 255; + this->color.b = 255; + this->actionFunc = ObjSwitch_CrystalSwitchOn; +} + +void ObjSwitch_CrystalSwitchOn(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + s32 canActivate = switchHit && !(this->collisionFlags & AC_HIT) && (this->disableCrystalSwitchTimer <= 0); + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + switch (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)) { + case OBJSWITCH_SUBTYPE_ONCE: + case OBJSWITCH_SUBTYPE_SYNC: + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + this->disableCrystalSwitchTimer = 10; + ObjSwitch_CrystalSwitchTurnOffInit(this); + } + break; + case OBJSWITCH_SUBTYPE_TOGGLE: + if (canActivate) { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_CrystalSwitchTurnOffInit, false); + } + } + ObjSwitch_CrystalUpdateTimer(this); +} + +void ObjSwitch_CrystalSwitchTurnOffInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_CrystalSwitchTurnOff; +} + +void ObjSwitch_CrystalSwitchTurnOff(ObjSwitch* this, GlobalContext* globalCtx) { + s32 switchHit = (this->colliderJntSph.base.acFlags & AC_HIT) != 0; + + if (switchHit) { + this->disableCrystalSwitchTimer = 10; + } + ObjSwitch_StopCutscene(this); + ObjSwitch_CrystalUpdateTimer(this); + ObjSwitch_PlayDiamondSwitchSfx(this); + ObjSwitch_CrystalSwitchOffInit(this); +} + +void ObjSwitch_LargeFloorSwitchUpInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 0.2475f; + this->actionFunc = ObjSwitch_LargeFloorSwitchUp; +} + +void ObjSwitch_LargeFloorSwitchUp(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET) { + if (DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 1); + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchPushDownInit, true); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET_INVERTED && DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna)) { + ObjSwitch_SetFloorSwitchSnapPlayerState(this, 2); + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchPushDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchPushDownInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchPushDown; +} + +void ObjSwitch_LargeFloorSwitchPushDown(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y -= 0.074250005f; + if (this->dyna.actor.scale.y <= 33.0f / 2000.0f) { + ObjSwitch_PlayFootSwitchSfx(this); + func_8013ECE0(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchDownInit(this); + } +} + +void ObjSwitch_LargeFloorSwitchDownInit(ObjSwitch* this) { + this->dyna.actor.scale.y = 33.0f / 2000.0f; + this->floorSwitchReleaseTimer = 6; + this->actionFunc = ObjSwitch_LargeFloorSwitchDown; +} + +void ObjSwitch_LargeFloorSwitchDown(ObjSwitch* this, GlobalContext* globalCtx) { + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + if (subType == OBJSWITCH_SUBTYPE_ONCE) { + if (!Flags_GetSwitch(globalCtx, OBJ_SWITCH_GET_SWITCH_FLAG(&this->dyna.actor))) { + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } + } else if (subType == OBJSWITCH_SUBTYPE_RESET || subType == OBJSWITCH_SUBTYPE_RESET_INVERTED) { + if (!DynaPolyActor_IsInHeavySwitchPressedState(&this->dyna) && !Player_InCsMode(&globalCtx->state)) { + if (this->floorSwitchReleaseTimer <= 0) { + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_RESET) { + ObjSwitch_SetSwitchFlagState(this, globalCtx, false); + ObjSwitch_LargeFloorSwitchRiseUpInit(this); + } else { + ObjSwitch_TryPlayCutsceneInit(this, globalCtx, ObjSwitch_LargeFloorSwitchRiseUpInit, true); + } + } + } else { + this->floorSwitchReleaseTimer = 6; + } + } +} + +void ObjSwitch_LargeFloorSwitchRiseUpInit(ObjSwitch* this) { + this->actionFunc = ObjSwitch_LargeFloorSwitchRiseUp; +} + +void ObjSwitch_LargeFloorSwitchRiseUp(ObjSwitch* this, GlobalContext* globalCtx) { + this->dyna.actor.scale.y += 0.074250005f; + if (this->dyna.actor.scale.y >= 0.2475f) { + ObjSwitch_PlayFootSwitchSfx(this); + ObjSwitch_StopCutscene(this); + ObjSwitch_LargeFloorSwitchUpInit(this); + } +} + +void ObjSwitch_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSwitch* this = THIS; + + if (this->floorSwitchReleaseTimer > 0) { + this->floorSwitchReleaseTimer--; + } + if (this->sfxTimer > 0) { + this->sfxTimer--; + } + this->actionFunc(this, globalCtx); + if (this->floorSwitchPlayerSnapState != 0) { + s32 pad; + + dummy: + ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge(this, globalCtx); + if (this->floorSwitchPlayerSnapState == 2) { + this->floorSwitchPlayerSnapState = 0; + } + } + switch (OBJ_SWITCH_GET_TYPE(&this->dyna.actor)) { + case OBJSWITCH_TYPE_FLOOR: + case OBJSWITCH_TYPE_FLOOR_RUSTY: + case OBJSWITCH_TYPE_FLOOR_LARGE: + this->collisionFlags = this->dyna.stateFlags; + break; + case OBJSWITCH_TYPE_EYE: + this->collisionFlags = this->colliderTris.base.acFlags; + this->colliderTris.base.acFlags &= ~AC_HIT; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + break; + case OBJSWITCH_TYPE_CRYSTAL: + case OBJSWITCH_TYPE_CRYSTAL_TARGETABLE: + if (!Player_InCsMode(&globalCtx->state)) { + if (this->disableCrystalSwitchTimer > 0) { + this->disableCrystalSwitchTimer--; + } + } + if (this->disableCrystalSwitchTimer == 0) { + this->colliderJntSph.base.colType = sJntSphInit.base.colType; + } else { + this->colliderJntSph.base.colType = COLTYPE_NONE; + } + this->collisionFlags = this->colliderJntSph.base.acFlags; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderJntSph.base); + } +} + +void ObjSwitch_DrawFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + if (OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor) == OBJSWITCH_SUBTYPE_ONCE) { + Gfx* opa; + + OPEN_DISPS(globalCtx->state.gfxCtx); + opa = POLY_OPA_DISP; + gSPDisplayList(opa++, &sSetupDL[6 * 25]); + gSPMatrix(opa++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(opa++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(opa++, gFloorSwitch1DL); + POLY_OPA_DISP = opa; + CLOSE_DISPS(globalCtx->state.gfxCtx); + } else { + Gfx_DrawDListOpa(globalCtx, sFloorSwitchDL[OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor)]); + } +} + +void ObjSwitch_DrawRustyFloorSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, gRustyFloorSwitchDL); +} + +void ObjSwitch_DrawVisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_OPA_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_OPA_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawInvisibleEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad; + s32 subType = OBJ_SWITCH_GET_SUBTYPE(&this->dyna.actor); + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x08, sEyeSwitchTextures[subType][this->eyeTexIndex]); + gSPDisplayList(POLY_XLU_DISP++, sEyeSwitchDL[subType]); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_DrawEyeSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + if (OBJ_SWITCH_IS_INVISIBLE(&this->dyna.actor)) { + ObjSwitch_DrawInvisibleEyeSwitch(this, globalCtx); + } else { + ObjSwitch_DrawVisibleEyeSwitch(this, globalCtx); + } +} + +void ObjSwitch_DrawCrystalSwitch(ObjSwitch* this, GlobalContext* globalCtx) { + s32 pad[2]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_800B8118(&this->dyna.actor, globalCtx, 0); + AnimatedMat_DrawStep(globalCtx, sCrystalSwitchAnimatedMat, this->crystalAnimTimer); + func_8012C28C(globalCtx->state.gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchBaseDL); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, this->color.r, this->color.g, this->color.b, 255); + gSPDisplayList(POLY_OPA_DISP++, gCrystalSwitchCoreDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gCrystalSwitchDiamondDL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} + +void ObjSwitch_Draw(Actor* thisx, GlobalContext* globalCtx) { + static ObjSwitchDrawFunc drawFunc[] = { + ObjSwitch_DrawFloorSwitch, ObjSwitch_DrawRustyFloorSwitch, ObjSwitch_DrawEyeSwitch, + ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawCrystalSwitch, ObjSwitch_DrawFloorSwitch, + }; + ObjSwitch* this = THIS; + + drawFunc[OBJ_SWITCH_GET_TYPE(&this->dyna.actor)](this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h index 5d1134f12..42ee4207f 100644 --- a/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h +++ b/src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h @@ -5,7 +5,26 @@ struct ObjSwitch; -typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); +typedef void (*ObjSwitchActionFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchDrawFunc)(struct ObjSwitch* this, GlobalContext* globalCtx); +typedef void (*ObjSwitchSetupActionFunc)(struct ObjSwitch* this); + +typedef enum { + /* 0 */ OBJSWITCH_TYPE_FLOOR, + /* 1 */ OBJSWITCH_TYPE_FLOOR_RUSTY, // Unused, incomplete implementation + /* 2 */ OBJSWITCH_TYPE_EYE, + /* 3 */ OBJSWITCH_TYPE_CRYSTAL, + /* 4 */ OBJSWITCH_TYPE_CRYSTAL_TARGETABLE, + /* 5 */ OBJSWITCH_TYPE_FLOOR_LARGE +} ObjSwitchType; + +typedef enum { + /* 0 */ OBJSWITCH_SUBTYPE_ONCE, // Set Switch Flag when activated, stays activated + /* 1 */ OBJSWITCH_SUBTYPE_TOGGLE, // Toggle Switch Flag when activated + /* 2 */ OBJSWITCH_SUBTYPE_RESET, // Floor type only, set switch flag when pressed, unset when released + /* 3 */ OBJSWITCH_SUBTYPE_RESET_INVERTED, // Floor type only, set switch flag when not pressed, unset when pressed + /* 4 */ OBJSWITCH_SUBTYPE_SYNC // Crystal type only, syncronizes all crystal fl +} ObjSwitchSubType; #define OBJSWITCH_GET_33(thisx) ((thisx)->params & 0x33) #define OBJSWITCH_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) @@ -14,12 +33,41 @@ typedef void (*ObjSwitchActionFunc)(struct ObjSwitch*, GlobalContext*); #define OBJSWITCH_INVERSE_BLUE 0x30 typedef struct ObjSwitch { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSwitchActionFunc actionFunc; - /* 0x0160 */ char unk_160[0xF8]; + /* 0x0160 */ s16 floorSwitchReleaseTimer; + /* 0x0162 */ s16 disableCrystalSwitchTimer; + /* 0x0164 */ s8 eyeTexIndex; + /* 0x0165 */ s8 sfxTimer; + /* 0x0168 */ s32 crystalAnimTimer; + /* 0x016C */ Color_RGB8 color; + /* 0x016F */ u8 collisionFlags; + /* 0x0170 */ s8 floorSwitchPlayerSnapState; + /* 0x0171 */ s8 nextSwitchFlagState; + /* 0x0172 */ s8 isPlayingCutscene; + /* 0x0174 */ ObjSwitchSetupActionFunc setupFunc; + union { + struct { + /* 0x0178 */ ColliderJntSph colliderJntSph; + /* 0x0198 */ ColliderJntSphElement colliderJntSphElements[1]; + }; + struct { + /* 0x0178 */ ColliderTris colliderTris; + /* 0x0198 */ ColliderTrisElement colliderTrisElements[2]; + }; + }; + /* 0x0250 */ f32 floorSwitchUpScale; + /* 0x0254 */ f32 floorSwitchDownScale; } ObjSwitch; // size = 0x258 extern const ActorInit Obj_Switch_InitVars; +#define OBJ_SWITCH_GET_TYPE(thisx) ((thisx)->params&7) +#define OBJ_SWITCH_GET_SUBTYPE(thisx) ((thisx)->params >> 4 & 7) +#define OBJ_SWITCH_GET_SWITCH_FLAG(thisx) ((thisx)->params >> 8 & 0x7F) +#define OBJ_SWITCH_IS_FROZEN(thisx) ((thisx)->params >> 7 & 1) +#define OBJ_SWITCH_UNSET_FROZEN(thisx) ((thisx)->params &= ~(1 << 7)) +#define OBJ_SWITCH_IS_INVISIBLE(thisx) ((thisx)->params >> 3 & 1) +#define OBJ_SWITCH_GET_COLOR_ID(thisx) ((thisx)->home.rot.z&1) + #endif // Z_OBJ_SWITCH_H 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 3d94f31b6..cea97efe9 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -6,7 +6,7 @@ #include "z_obj_swprize.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjSwprize*)thisx) 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 5033a1dc0..2996ce5ae 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -9,7 +9,7 @@ #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" #include "objects/object_syokudai/object_syokudai.h" -#define FLAGS 0x00000410 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400) #define THIS ((ObjSyokudai*)thisx) @@ -221,7 +221,7 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { (flameColliderHurtboxActor->id == ACTOR_EN_ARROW)) { flameColliderHurtboxActor->params = 0; - ((EnArrow*)flameColliderHurtboxActor)->unk_1C0 = 0x800; + ((EnArrow*)flameColliderHurtboxActor)->collider.info.toucher.dmgFlags = 0x800; } } if ((this->snuffTimer > OBJ_SYOKUDAI_SNUFF_NEVER) && @@ -313,7 +313,8 @@ void ObjSyokudai_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); Matrix_InsertTranslation(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); - Matrix_RotateY(BINANG_ROT180(func_800DFCDC(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), MTXMODE_APPLY); + Matrix_RotateY(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), + MTXMODE_APPLY); Matrix_Scale(flameScale, flameScale, flameScale, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); diff --git a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c index d1e168447..65c984981 100644 --- a/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c +++ b/src/overlays/actors/ovl_Obj_Takaraya_Wall/z_obj_takaraya_wall.c @@ -6,7 +6,7 @@ #include "z_obj_takaraya_wall.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjTakarayaWall*)thisx) 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 bf535300b..0471b6bd7 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -6,7 +6,7 @@ #include "z_obj_toge.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjToge*)thisx) 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 1626f26c3..b46f2626e 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 @@ -7,7 +7,7 @@ #include "z_obj_tokei_step.h" #include "objects/object_tokei_step/object_tokei_step.h" -#define FLAGS 0x00400010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #define THIS ((ObjTokeiStep*)thisx) @@ -193,7 +193,7 @@ void ObjTokeiStep_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 0); if ((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) { + (globalCtx->csCtx.currentCsIndex == 0)) { DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gClocktowerPanelCol); ObjTokeiStep_InitSteps(this); ObjTokeiStep_SetupBeginOpen(this); @@ -221,9 +221,10 @@ void ObjTokeiStep_SetupBeginOpen(ObjTokeiStep* this) { void ObjTokeiStep_BeginOpen(ObjTokeiStep* this, GlobalContext* globalCtx) { CsCmdActorAction* action; - if (func_800EE29C(globalCtx, 0x86)) { - action = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x86)]; - if ((action->startFrame == globalCtx->csCtx.frames) && (action->unk0 != 0)) { + if (Cutscene_CheckActorAction(globalCtx, 134)) { + action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 134)]; + + if ((action->startFrame == globalCtx->csCtx.frames) && (action->action != 0)) { this->dyna.actor.draw = ObjTokeiStep_DrawOpen; ObjTokeiStep_SetupOpen(this); } @@ -250,7 +251,7 @@ void ObjTokeiStep_Open(ObjTokeiStep* this, GlobalContext* globalCtx) { } void ObjTokeiStep_SetupDoNothingOpen(ObjTokeiStep* this) { - this->dyna.actor.flags &= ~0x10; + this->dyna.actor.flags &= ~ACTOR_FLAG_10; this->actionFunc = ObjTokeiStep_DoNothingOpen; } 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 8e88b39c6..d13a3bb4d 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -32,7 +32,7 @@ #include "z_obj_tokeidai.h" #include "objects/object_obj_tokeidai/object_obj_tokeidai.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjTokeidai*)thisx) @@ -122,9 +122,9 @@ void ObjTokeidai_ExteriorGear_Init(ObjTokeidai* this, GlobalContext* globalCtx) ObjTokeidai_SetupClockOrExteriorGear(this); if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { ObjTokeidai_SetupTowerOpening(this); } else if ((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) { this->actionFunc = ObjTokeidai_ExteriorGear_OpenedIdle; @@ -141,9 +141,9 @@ void ObjTokeidai_TowerClock_Init(ObjTokeidai* this, GlobalContext* globalCtx) { ObjTokeidai_Clock_Init(this); if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 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; @@ -176,9 +176,9 @@ void ObjTokeidai_Counterweight_Init(ObjTokeidai* this, GlobalContext* globalCtx) } if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { + (globalCtx->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -336,7 +336,8 @@ void ObjTokeidai_ExteriorGear_Collapse(ObjTokeidai* this, GlobalContext* globalC } void ObjTokeidai_ExteriorGear_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 2) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 2) { this->actionFunc = ObjTokeidai_ExteriorGear_Collapse; this->actor.speedXZ = this->actor.scale.y * 5.0f; this->actor.velocity.y = 0.0f; @@ -403,7 +404,8 @@ void ObjTokeidai_TowerClock_SlideOff(ObjTokeidai* this, GlobalContext* globalCtx } void ObjTokeidai_TowerClock_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TowerClock_SlideOff; this->slidingClockFaceAngle = 0; this->aerialClockFaceSpeed = -0xD; @@ -420,7 +422,8 @@ void ObjTokeidai_Counterweight_Collapse(ObjTokeidai* this, GlobalContext* global } void ObjTokeidai_Counterweight_OpenedIdle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 3) { + if (Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 3) { this->actionFunc = ObjTokeidai_Counterweight_Collapse; this->xRotation = 0; this->actor.velocity.y = 0.0f; @@ -436,26 +439,28 @@ void ObjTokeidai_TerminaFieldWalls_Collapse(ObjTokeidai* this, GlobalContext* gl } void ObjTokeidai_TerminaFieldWalls_Idle(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 1) { + if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 1) { this->actionFunc = ObjTokeidai_TerminaFieldWalls_Collapse; } } void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, 0x84) != 0 && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 5) { + if (Cutscene_CheckActorAction(globalCtx, 132) != 0 && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 5) { gSaveContext.save.weekEventReg[8] |= 0x40; if (((globalCtx->sceneNum == SCENE_CLOCKTOWER) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0)) || + (globalCtx->csCtx.currentCsIndex == 0)) || ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 2) && - (globalCtx->csCtx.unk_12 == 0))) { - func_801A3F54(false); + (globalCtx->csCtx.currentCsIndex == 0))) { + Audio_SetCutsceneFlag(false); gSaveContext.save.cutscene = 0; gSaveContext.nextCutsceneIndex = 0; gSaveContext.respawnFlag = 2; globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.respawn[1].entranceIndex; + globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_RETURN].entranceIndex; globalCtx->unk_1887F = 2; - if (gSaveContext.respawn[1].playerParams == 0xCFF) { + if (gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0xCFF) { gSaveContext.nextTransition = 0x15; } else { gSaveContext.nextTransition = 2; @@ -588,7 +593,8 @@ void ObjTokeidai_TowerOpening_RaiseTower(ObjTokeidai* this, GlobalContext* globa } void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, GlobalContext* globalCtx) { - if ((func_800EE29C(globalCtx, 0x84) && globalCtx->csCtx.npcActions[func_800EE200(globalCtx, 0x84)]->unk0 == 4) || + if ((Cutscene_CheckActorAction(globalCtx, 132) && + globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 132)]->action == 4) || (gSaveContext.save.weekEventReg[8] & 0x40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } diff --git a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c index 325bd3f3e..b91cbcf7e 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -6,7 +6,7 @@ #include "z_obj_toudai.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjToudai*)thisx) 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 d767e8b3b..e19edead3 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -7,7 +7,7 @@ #include "z_obj_tree.h" #include "objects/object_tree/object_tree.h" -#define FLAGS 0x02000000 +#define FLAGS (ACTOR_FLAG_2000000) #define THIS ((ObjTree*)thisx) 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 e91c3387f..af00e5c64 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -6,7 +6,7 @@ #include "z_obj_tsubo.h" -#define FLAGS 0x04800010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_800000 | ACTOR_FLAG_4000000) #define THIS ((ObjTsubo*)thisx) 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 ee5222543..324d13e4b 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -6,7 +6,7 @@ #include "z_obj_um.h" -#define FLAGS 0x00000039 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjUm*)thisx) 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 8ed03a8ef..35371b605 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -6,7 +6,7 @@ #include "z_obj_usiyane.h" -#define FLAGS 0x00000020 +#define FLAGS (ACTOR_FLAG_20) #define THIS ((ObjUsiyane*)thisx) 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 4fc6200c5..8741fc01b 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 0x00000080 +#define FLAGS (ACTOR_FLAG_80) #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 c830c29d9..9c5d22bac 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -5,8 +5,9 @@ */ #include "z_obj_vspinyroll.h" +#include "objects/object_spinyroll/object_spinyroll.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjVspinyroll*)thisx) @@ -15,13 +16,17 @@ void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx); void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx); +void func_80A3CEC4(ObjVspinyroll* this); void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx); void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3CFAC(ObjVspinyroll* this); void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D024(ObjVspinyroll* this); void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D0E8(ObjVspinyroll* this); void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx); +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Vspinyroll_InitVars = { ACTOR_OBJ_VSPINYROLL, ACTORCAT_PROP, @@ -34,77 +39,419 @@ const ActorInit Obj_Vspinyroll_InitVars = { (ActorFunc)ObjVspinyroll_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A3D488 = { - { COLTYPE_METAL, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x00, 0x04 }, { 0x01C37BB6, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +f32 D_80A3D450[] = { 1.0f, 2.0f }; + +f32 D_80A3D458[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; + +s16 D_80A3D478[] = { 1, 10, 20, 30, 40, 50, 60, 70 }; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x00, 0x04 }, + { 0x01C37BB6, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 30, 120, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A3D4D4[] = { +f32 D_80A3D4B4[] = { 1.0f, 1.0f, -1.0f, -1.0f }; + +f32 D_80A3D4C4[] = { 29.0f, -29.0f, 29.0f, -29.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 500, ICHAIN_STOP), }; +s16 D_80A3D4DC[] = { 0xFA0, -0xFA0 }; + +void func_80A3C4E0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); + + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} + +void func_80A3C560(ObjVspinyroll* this) { + f32 magnitude; + Vec3f* sp20 = &this->unk_39C[this->unk_398 ^ 1]; + + Math_Vec3f_Diff(sp20, &this->dyna.actor.world.pos, &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Diff(sp20, &this->unk_39C[this->unk_398], &this->unk_3B4); + magnitude = Math3D_Vec3fMagnitude(&this->unk_3B4); + if (magnitude < 0.01f) { + Math_Vec3f_Copy(&this->unk_3B4, &gZeroVec3f); + return; + } + } + Math_Vec3f_Scale(&this->unk_3B4, 1.0f / magnitude); +} + +void func_80A3C658(ObjVspinyroll* this) { + this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &this->unk_39C[this->unk_398 ^ 1]); +} + +void func_80A3C6A0(ObjVspinyroll* this) { + this->unk_398 = 0; + func_80A3C658(this); + func_80A3C560(this); +} + +void func_80A3C6CC(ObjVspinyroll* this) { + this->unk_398 ^= 1; + func_80A3C658(this); + func_80A3C560(this); +} + +s32 func_80A3C700(ObjVspinyroll* this) { + s32 pad; + s32 sp30 = this->unk_398 ^ 1; + Vec3f sp24; + + Math_StepToF(&this->dyna.actor.speedXZ, 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; + + Math_Vec3f_Diff(&this->unk_39C[sp30], &this->dyna.actor.world.pos, &sp24); + return Math3D_LengthSquared(&sp24) < (SQ(this->dyna.actor.speedXZ) + 0.05f); +} + +void func_80A3C7E8(ObjVspinyroll* this) { + f32 phi_f2; + s32 i; + s32 j; + f32 tempf; + s32 index = D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f * (1.0f / 58.0f); + + index += 2; + this->unk_38C = index * 4; + + tempf = ((D_80A3D450[OBJVSPINYROLL_GET_4000(&this->dyna.actor)] * 120.0f) - 2.0f) / (index - 1); + phi_f2 = 1.0f; + + for (i = 0, j = 0; i < this->unk_38C; i++) { + this->unk_1A8[i].unk_00.x = D_80A3D4C4[j]; + this->unk_1A8[i].unk_00.y = phi_f2; + this->unk_1A8[i].unk_00.z = D_80A3D4B4[j]; + + j++; + if (j >= 4) { + j = 0; + phi_f2 += tempf; + } + } +} + +#ifdef NON_MATCHING +s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { + s32 pad; + ObjVspinyrollStruct2* ptr = &this->unk_1A8[0]; + s32 pad2; + s32 i; + Vec3f spE4; + Vec3f spD8; + Vec3f spCC; + Vec3f spC0; + Vec3f spB4; + Vec3f spA8; + f32 temp_f20 = FLT_MAX; + f32 temp_f0; + s32 sp9C; + + spE4.z = 0.0f; + sp9C = false; + this->unk_388 = NULL; + + for (i = 0; i < this->unk_38C; i++, ptr++) { + spE4.x = ptr->unk_00.x; + spE4.y = ptr->unk_00.y; + func_80A3C4E0(&spD8, &spE4, this->dyna.actor.world.rot.y); + + spD8.x += this->dyna.actor.world.pos.x; + spD8.y += this->dyna.actor.world.pos.y; + spD8.z += this->dyna.actor.world.pos.z; + + Math_Vec3f_Copy(&spCC, &spD8); + + spCC.x += 30.0f * this->unk_3B4.x; + spCC.z += 30.0f * this->unk_3B4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD8, &spCC, &spC0, &this->unk_1A8[i].collisionPoly, true, + false, false, true, &this->unk_1A8[i].bgId, &this->dyna.actor, 0.0f)) { + if ((arg3 != 0) && (this->dyna.actor.flags & ACTOR_FLAG_40)) { + spA8.x = ptr->unk_00.x * 0.2f; + spA8.y = ptr->unk_00.y; + spA8.z = 20.0f; + + func_80A3C4E0(&spB4, &spA8, this->dyna.actor.world.rot.y); + + spB4.x += this->dyna.actor.world.pos.x; + spB4.y += this->dyna.actor.world.pos.y; + spB4.z += this->dyna.actor.world.pos.z; + + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &spB4); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_IT_SHIELD_REFLECT_SW); + } + + temp_f0 = Math3D_Vec3fDistSq(&spD8, &spC0); + if (temp_f0 < temp_f20) { + temp_f20 = temp_f0; + sp9C = true; + Math_Vec3f_Diff(&spC0, &spCC, arg2); + this->unk_388 = ptr; + } + } + } + + return sp9C; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") #endif -extern ColliderCylinderInit D_80A3D488; -extern InitChainEntry D_80A3D4D4[]; +s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { + Vec3f sp1C; -extern UNK_TYPE D_06000460; -extern UNK_TYPE D_06000F80; + if (func_80A3C8D8(this, globalCtx, &sp1C, arg2)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C4E0.s") +DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (this->unk_388 != NULL) { + return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_388->bgId); + } + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C560.s") +s32 func_80A3CC30(ObjVspinyroll* this, GlobalContext* globalCtx) { + DynaPolyActor* actor = func_80A3CBF0(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C658.s") + if ((actor != NULL) && (Math3D_Vec3fDistSq(&actor->actor.world.pos, &actor->actor.prevPos) > 0.0001f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6A0.s") +void func_80A3CC84(f32 arg0) { + MtxF* matrix = Matrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C6CC.s") + matrix->wy += arg0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C700.s") +void ObjVspinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjVspinyroll* this = THIS; + s32 params = OBJVSPINYROLL_GET_4000(&this->dyna.actor); + f32 sp40 = D_80A3D450[params]; + s32 pad2; + Path* path; + Vec3s* points; + Vec3s* point1; + Vec3s* point2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C7E8.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3C8D8.s") + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.scale.y = 0.1f * sp40; + this->dyna.actor.scale.z = 0.1f; + this->dyna.actor.uncullZoneScale = 300.0f * sp40; + this->dyna.actor.scale.x = 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CB94.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_spinyroll_Colheader_000F80); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CBF0.s") + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC30.s") + if (params == OBJVSPINYROLL_4000_1) { + this->dyna.actor.draw = func_80A3D2C0; + this->collider.dim.height = 240; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CC84.s") + if (OBJVSPINYROLL_GET_7F(&this->dyna.actor) == OBJVSPINYROLL_7F_7F) { + func_80A3CEC4(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Init.s") + this->dyna.actor.world.rot.y = 0; + func_80A3C7E8(this); + this->unk_394 = D_80A3D458[OBJVSPINYROLL_GET_380(thisx)]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Destroy.s") + path = &globalCtx->setupPathList[OBJVSPINYROLL_GET_7F(&this->dyna.actor)]; + points = Lib_SegmentedToVirtual(path->points); + point1 = &points[0]; + point2 = &points[1]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEC4.s") + Math_Vec3s_ToVec3f(&this->unk_39C[0], point1); + Math_Vec3s_ToVec3f(&this->unk_39C[1], point2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CEE0.s") + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->unk_39C[0]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF10.s") + func_80A3C6A0(this); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + func_80A3CFAC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CF4C.s") +void ObjVspinyroll_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFAC.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3CFE0.s") +void func_80A3CEC4(ObjVspinyroll* this) { + this->dyna.actor.speedXZ = 0.0f; + this->actionFunc = func_80A3CEE0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D024.s") +void func_80A3CEE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + this->unk_3C0 += 0x6E; + if (this->unk_3C0 > 0xFA0) { + this->unk_3C0 = 0xFA0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D038.s") +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; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0E8.s") +void func_80A3CF4C(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4) && (this->unk_3C8 > 0)) { + this->unk_3C8--; + if (this->unk_3C8 <= 0) { + func_80A3CFAC(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D0FC.s") +void func_80A3CFAC(ObjVspinyroll* this) { + this->actionFunc = func_80A3CFE0; + this->unk_3C2 = D_80A3D4DC[this->unk_398]; + this->dyna.actor.speedXZ = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Update.s") +void func_80A3CFE0(ObjVspinyroll* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->unk_3C0, this->unk_3C2, 0x6E)) { + func_80A3D024(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/ObjVspinyroll_Draw.s") +void func_80A3D024(ObjVspinyroll* this) { + this->actionFunc = func_80A3D038; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Vspinyroll/func_80A3D2C0.s") +void func_80A3D038(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = func_80A3C700(this); + + if (func_80A3CB94(this, globalCtx, 1)) { + this->unk_3C4 = 0x7D0; + if (func_80A3CBF0(this, globalCtx) != NULL) { + func_80A3D0E8(this); + } else { + func_80A3C6CC(this); + func_80A3CF10(this); + } + } else if (sp24 != 0) { + func_80A3C6CC(this); + this->unk_3C4 = 120; + func_80A3CF10(this); + } +} + +void func_80A3D0E8(ObjVspinyroll* this) { + this->actionFunc = func_80A3D0FC; +} + +void func_80A3D0FC(ObjVspinyroll* this, GlobalContext* globalCtx) { + s32 sp24 = true; + + Math_ScaledStepToS(&this->unk_3C0, 0, this->unk_3C4); + if (func_80A3CB94(this, globalCtx, 0) && func_80A3CC30(this, globalCtx)) { + sp24 = false; + } + + if (sp24) { + func_80A3C6CC(this); + func_80A3CF10(this); + } +} + +void ObjVspinyroll_Update(Actor* thisx, GlobalContext* globalCtx2) { + GlobalContext* globalCtx = globalCtx2; + ObjVspinyroll* this = THIS; + + this->actionFunc(this, globalCtx); + + this->unk_3C6 += this->unk_3C0; + + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->dyna.actor.shape.rot.z + 0x4000, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x + this->unk_3C6, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_spinyroll_DL_000460); +} + +void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { + ObjVspinyroll* this = THIS; + Vec3s sp3C; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + sp3C.x = this->dyna.actor.shape.rot.x + this->unk_3C6; + sp3C.y = this->dyna.actor.shape.rot.y; + sp3C.z = this->dyna.actor.shape.rot.z + 0x4000; + + func_8012C28C(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, + this->dyna.actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateY(sp3C.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(sp3C.z, MTXMODE_APPLY); + Matrix_InsertXRotation_s(sp3C.x, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + func_80A3CC84(120.0f); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_spinyroll_DL_000460); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h index 371eb7b4f..af1048267 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.h @@ -7,11 +7,36 @@ struct ObjVspinyroll; typedef void (*ObjVspinyrollActionFunc)(struct ObjVspinyroll*, GlobalContext*); +#define OBJVSPINYROLL_GET_7F(thisx) ((thisx)->params & 0x7F) +#define OBJVSPINYROLL_GET_380(thisx) (((thisx)->params >> 7) & 7) +#define OBJVSPINYROLL_GET_1C00(thisx) (((thisx)->params >> 0xA) & 7) +#define OBJVSPINYROLL_GET_4000(thisx) (((thisx)->params >> 0xE) & 1) + +#define OBJVSPINYROLL_7F_7F 0x7F +#define OBJVSPINYROLL_4000_1 1 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ CollisionPoly* collisionPoly; + /* 0x10 */ s32 bgId; +} ObjVspinyrollStruct2; // size = 0x14 + typedef struct ObjVspinyroll { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x24C]; + /* 0x0000 */ DynaPolyActor dyna; + /* 0x015C */ ColliderCylinder collider; + /* 0x01A8 */ ObjVspinyrollStruct2 unk_1A8[24]; + /* 0x0388 */ ObjVspinyrollStruct2* unk_388; + /* 0x038C */ s32 unk_38C; /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; - /* 0x0394 */ char unk_394[0x38]; + /* 0x0394 */ f32 unk_394; + /* 0x0398 */ s32 unk_398; + /* 0x039C */ Vec3f unk_39C[2]; + /* 0x03B4 */ Vec3f unk_3B4; + /* 0x03C0 */ s16 unk_3C0; + /* 0x03C2 */ s16 unk_3C2; + /* 0x03C4 */ s16 unk_3C4; + /* 0x03C6 */ s16 unk_3C6; + /* 0x03C8 */ s16 unk_3C8; } ObjVspinyroll; // size = 0x3CC extern const ActorInit Obj_Vspinyroll_InitVars; 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 4832bc01a..fde0406f1 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -8,7 +8,7 @@ #include "objects/object_sek/object_sek.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ObjWarpstone*)thisx) @@ -110,7 +110,7 @@ s32 ObjWarpstone_BeginOpeningCutscene(ObjWarpstone* this, GlobalContext* globalC s32 ObjWarpstone_PlayOpeningCutscene(ObjWarpstone* this, GlobalContext* globalCtx) { if (this->openingCSTimer++ >= OBJ_WARPSTONE_TIMER_ACTIVATE_THRESHOLD) { ActorCutscene_Stop(this->dyna.actor.cutscene); - func_80143A10(OBJ_WARPSTONE_GET_ID(this)); + Sram_ActivateOwl(OBJ_WARPSTONE_GET_ID(this)); ObjWarpstone_SetupAction(this, ObjWarpstone_OpenedIdle); } else if (this->openingCSTimer < OBJ_WARPSTONE_TIMER_OPEN_THRESHOLD) { Math_StepToF(&this->dyna.actor.velocity.x, 0.01f, 0.001f); @@ -138,7 +138,7 @@ void ObjWarpstone_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->isTalking) { if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { this->isTalking = false; - } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (func_80147624(globalCtx))) { + } else if ((Message_GetState(&globalCtx->msgCtx) == 4) && (Message_ShouldAdvance(globalCtx))) { if (globalCtx->msgCtx.choiceIndex != 0) { func_8019F208(); globalCtx->msgCtx.msgMode = 0x4D; 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 063504026..37cfb99ab 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.h @@ -29,6 +29,6 @@ typedef struct ObjWarpstone { extern const ActorInit Obj_Warpstone_InitVars; #define OBJ_WARPSTONE_GET_ID(this) ((u16)(this->dyna.actor.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.playerData.owlActivationFlags) & (u16)gBitFlags[owlId]) #endif // Z_OBJ_WARPSTONE_H diff --git a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c index 02fc51e13..f72645e49 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c @@ -6,7 +6,7 @@ #include "z_obj_wind.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjWind*)thisx) 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 94f73d2a2..34d82523f 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -6,49 +6,123 @@ #include "z_obj_wturn.h" -#define FLAGS 0x02100010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) #define THIS ((ObjWturn*)thisx) void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx); void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx); +void func_808A7954(ObjWturn* this); void func_808A7968(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7A24(ObjWturn* this); void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx); void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx); +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx); void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Wturn_InitVars = { - ACTOR_OBJ_WTURN, - ACTORCAT_ITEMACTION, - FLAGS, - GAMEPLAY_KEEP, - sizeof(ObjWturn), - (ActorFunc)ObjWturn_Init, - (ActorFunc)Actor_Noop, - (ActorFunc)ObjWturn_Update, - (ActorFunc)NULL, + ACTOR_OBJ_WTURN, ACTORCAT_ITEMACTION, FLAGS, + GAMEPLAY_KEEP, sizeof(ObjWturn), (ActorFunc)ObjWturn_Init, + (ActorFunc)Actor_Noop, (ActorFunc)ObjWturn_Update, (ActorFunc)NULL, }; -#endif +void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Init.s") + func_808A7954(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7954.s") +void func_808A7954(ObjWturn* this) { + this->actionFunc = func_808A7968; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7968.s") +void func_808A7968(ObjWturn* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.ocarinaMode >= 28 && globalCtx->msgCtx.ocarinaMode < 39) { + Flags_UnsetSwitch(globalCtx, this->actor.params); + Actor_MarkForDeath(&this->actor); + } else if ((Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F40)) || + (!Flags_GetSwitch(globalCtx, this->actor.params) && (globalCtx->sceneNum == SCENE_F41))) { + func_808A7A24(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A24.s") +void func_808A7A24(ObjWturn* this) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + this->actionFunc = func_808A7A5C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7A5C.s") +void func_808A7A5C(ObjWturn* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + func_808A7AAC(this, globalCtx); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7AAC.s") +void func_808A7AAC(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f eye; + Vec3f at; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7BA0.s") + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_8016566C(140); + this->camId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + func_800B7298(globalCtx, &this->actor, 21); + at.x = player->actor.focus.pos.x; + at.z = player->actor.focus.pos.z; + at.y = player->actor.focus.pos.y; + eye.x = (Math_SinS(this->actor.shape.rot.y) * 150.0f) + at.x; + eye.z = (Math_CosS(this->actor.shape.rot.y) * 150.0f) + at.z; + eye.y = at.y + 4.0f; + Play_CameraSetAtEye(globalCtx, this->camId, &at, &eye); + this->actionFunc = func_808A7BA0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C04.s") +void func_808A7BA0(ObjWturn* this, GlobalContext* globalCtx) { + if (Math_ScaledStepToS(&this->actor.shape.rot.z, -0x8000, 0x0200)) { + func_808A7C04(this, globalCtx); + } + func_800B8FE8(&this->actor, NA_SE_EV_EARTHQUAKE - SFX_FLAG); + Play_CameraSetRoll(globalCtx, this->camId, this->actor.shape.rot.z); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/func_808A7C78.s") +void func_808A7C04(ObjWturn* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Wturn/ObjWturn_Update.s") + this->actor.world.pos.y += this->actor.playerHeightRel; + player->actor.shape.shadowAlpha = 0; + func_800B7298(globalCtx, &this->actor, 0x54); + func_800B8E58(player, NA_SE_VO_NAVY_ENEMY); + this->unk_14A = 0; + func_80165690(); + this->actionFunc = func_808A7C78; +} + +void func_808A7C78(ObjWturn* this, GlobalContext* globalCtx) { + static Vec3f D_808A7DC0 = { 0.0f, -1.0f, 0.0f }; + Camera* camera = Play_GetCamera(globalCtx, this->camId); + Player* player = GET_PLAYER(globalCtx); + + this->unk_14A++; + player->actor.world.pos.y = this->actor.world.pos.y + this->unk_14A * 4.0f; + Play_CameraSetAtEyeUp(globalCtx, this->camId, &player->actor.focus.pos, &camera->eye, &D_808A7DC0); + if (this->unk_14A == 1) { + globalCtx->unk_1887F = 0x40; + gSaveContext.nextTransition = 3; + gSaveContext.nextCutsceneIndex = 0; + if (globalCtx->sceneNum == 0x58) { + globalCtx->nextEntranceIndex = 0xAC00; + } else { + globalCtx->nextEntranceIndex = 0xAA10; + } + globalCtx->sceneLoadFlag = 0x14; + } +} + +void ObjWturn_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjWturn* this = THIS; + + this->actionFunc(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h index 0b0b8b375..0390ac7a8 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h @@ -10,7 +10,8 @@ typedef void (*ObjWturnActionFunc)(struct ObjWturn*, GlobalContext*); typedef struct ObjWturn { /* 0x0000 */ Actor actor; /* 0x0144 */ ObjWturnActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; + /* 0x0148 */ s16 camId; + /* 0x014A */ s16 unk_14A; } ObjWturn; // size = 0x14C extern const ActorInit Obj_Wturn_InitVars; 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 3c0fce631..7e9f6cb29 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -6,7 +6,7 @@ #include "z_obj_y2lift.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjY2lift*)thisx) 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 c9850690d..4bfced35c 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -6,7 +6,7 @@ #include "z_obj_y2shutter.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((ObjY2shutter*)thisx) diff --git a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c index ebce0d712..997941057 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -7,7 +7,7 @@ #include "z_obj_yado.h" #include "objects/object_yado_obj/object_yado_obj.h" -#define FLAGS 0x00000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #define THIS ((ObjYado*)thisx) @@ -38,7 +38,7 @@ void ObjYado_Init(Actor* thisx, GlobalContext* globalCtx) { ObjYado* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - D_80C16470 = (AnimatedMaterial*)Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); + D_80C16470 = Lib_SegmentedToVirtual(object_yado_obj_Matanimheader_0012E8); this->isNight = gSaveContext.save.isNight; } diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c index 5668371fb..3ed787918 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -5,17 +5,19 @@ */ #include "z_obj_yasi.h" +#include "objects/object_obj_yasi/object_obj_yasi.h" #define FLAGS 0x00000000 #define THIS ((ObjYasi*)thisx) +#define CAN_DROP_NUT(thisx) (thisx->params < 0) + void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx); void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Yasi_InitVars = { ACTOR_OBJ_YASI, ACTORCAT_PROP, @@ -28,25 +30,72 @@ const ActorInit Obj_Yasi_InitVars = { (ActorFunc)ObjYasi_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BB4D90[] = { +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP), }; -#endif +void ObjYasi_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -extern InitChainEntry D_80BB4D90[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_obj_yasi_Colheader_001428); -extern UNK_TYPE D_06000360; -extern UNK_TYPE D_06001428; + this->dyna.actor.home.rot.y = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Init.s") + if (OBJYASI_IS_WIDE(thisx)) { + this->dyna.actor.scale.x = 0.2f; + this->dyna.actor.scale.z = 0.2f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Destroy.s") +void ObjYasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Update.s") + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Yasi/ObjYasi_Draw.s") +void ObjYasi_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + s16 temp; + Vec3f dropPos; + + if (this->dyna.actor.home.rot.z != 0) { + if (CAN_DROP_NUT(thisx)) { + if (Rand_ZeroOne() < 0.5f) { + dropPos.x = this->dyna.actor.world.pos.x; + dropPos.y = this->dyna.actor.world.pos.y + 280.0f; + dropPos.z = this->dyna.actor.world.pos.z; + Item_DropCollectible(globalCtx, &dropPos, ITEM00_NUTS_1); + } + } + this->dyna.actor.home.rot.y = GET_PLAYER(globalCtx)->actor.shape.rot.y; + this->dyna.actor.home.rot.x = 400; + this->dyna.actor.home.rot.z = 0; + } + temp = (s16)(this->dyna.actor.shape.rot.x * 0.1f); + this->dyna.actor.home.rot.x -= temp; + this->dyna.actor.shape.rot.x += + BINANG_SUB(this->dyna.actor.home.rot.x, (s16)(this->dyna.actor.shape.rot.x * 0.08f)); +} + +void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + ObjYasi* this = THIS; + + Matrix_InsertTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, + MTXMODE_NEW); + + if (this->dyna.actor.shape.rot.x != 0) { + Matrix_RotateY(this->dyna.actor.home.rot.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->dyna.actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateY(BINANG_SUB(this->dyna.actor.shape.rot.y, this->dyna.actor.home.rot.y), MTXMODE_APPLY); + } else { + Matrix_RotateY(this->dyna.actor.shape.rot.y, MTXMODE_APPLY); + } + + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Gfx_DrawDListOpa(globalCtx, object_obj_yasi_DL_000360); +} diff --git a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h index 3671a776c..f4ab9ca9c 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -6,10 +6,11 @@ struct ObjYasi; typedef struct ObjYasi { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; } ObjYasi; // size = 0x15C extern const ActorInit Obj_Yasi_InitVars; +#define OBJYASI_IS_WIDE(thisx) ((thisx)->params & 1) + #endif // Z_OBJ_YASI_H diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 3195c7877..324e53fee 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -7,7 +7,7 @@ #include "z_object_kankyo.h" #include "objects/gameplay_keep/gameplay_keep.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((ObjectKankyo*)thisx) @@ -222,7 +222,7 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_14C[i].unk_08 = globalCtx->view.eye.z + (spC8 * 120.0f); this->unk_14C[i].unk_0C = (Rand_ZeroOne() - 0.5f) * (2.0f * temp_120); - temp_f22 = (func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; + temp_f22 = (Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.004f) + 60.0f; if (temp_f22 < 20.0f) { temp_f22 = 20.0f; } @@ -273,7 +273,7 @@ void func_808DC454(ObjectKankyo* this, GlobalContext* globalCtx) { this->unk_14C[i].unk_10 -= this->unk_14C[i].unk_18 - (spC0 * 3.0f * (globalCtx->envCtx.windSpeed / 100.0f)); - temp_f22 = (-func_800DFCB4(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; + temp_f22 = (-Camera_GetCamDirPitch(GET_ACTIVE_CAM(globalCtx)) * 0.012f) + 40.0f; if (temp_f22 < -40.0f) { temp_f22 = -40.0f; } @@ -349,10 +349,10 @@ void func_808DCBF8(ObjectKankyo* this, GlobalContext* globalCtx) { if (temp_f0 > 0.01f) { D_801F4E30 = 155.0f * temp_f0; - globalCtx->envCtx.unk_EA = 10; + globalCtx->envCtx.sandstormState = 10; } else { D_801F4E30 = 0; - globalCtx->envCtx.unk_EA = 10; + globalCtx->envCtx.sandstormState = 10; } func_808DC454(this, globalCtx); } @@ -514,7 +514,7 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { f32 temp_f2; f32 tempf; - if ((globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { + if ((globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || ((u8)globalCtx->envCtx.unk_E2 == 0)) { return; } @@ -592,7 +592,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { if (globalCtx->sceneNum == SCENE_KYOJINNOMA) { phi_f26 = 1.0f; } else { - tempA = func_800E031C(GET_ACTIVE_CAM(globalCtx)); + tempA = Camera_GetWaterYPos(GET_ACTIVE_CAM(globalCtx)); if (tempA != BGCHECK_Y_MIN) { tempA -= globalCtx->view.eye.y; phi_f26 = tempA / 4000.0f; @@ -602,7 +602,7 @@ void func_808DD970(Actor* thisx, GlobalContext* globalCtx2) { phi_f26 = CLAMP_MAX(phi_f26, 1.0f); - if (!(globalCtx->cameraPtrs[MAIN_CAM]->flags2 & 0x100) || (phi_f26 == 0.0f)) { + if (!(globalCtx->cameraPtrs[CAM_ID_MAIN]->flags2 & 0x100) || (phi_f26 == 0.0f)) { return; } } diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 4b1e1d8ba..18d28f8c7 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -6,7 +6,7 @@ #include "z_oceff_spot.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffSpot*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index 781e50605..1939b1ef0 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -6,7 +6,7 @@ #include "z_oceff_storm.h" -#define FLAGS 0x02000030 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((OceffStorm*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index b5dd2f290..1179f5ba2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index aee5dd446..61a1ae549 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe2.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe2*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index 0ef0a25e8..a8745c015 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe3.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe3*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index b9a89614b..b985aadad 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe4.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe4*)thisx) 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 8cac4317d..e39a4aa4c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe5.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe5*)thisx) diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c index c14a59e9f..a16821f00 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe6.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe6*)thisx) @@ -15,7 +15,6 @@ void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx); void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Oceff_Wipe6_InitVars = { ACTOR_OCEFF_WIPE6, ACTORCAT_ITEMACTION, @@ -28,12 +27,75 @@ const ActorInit Oceff_Wipe6_InitVars = { (ActorFunc)OceffWipe6_Draw, }; -#endif +#include "overlays/ovl_Oceff_Wipe6/ovl_Oceff_Wipe6.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Init.s") +void OceffWipe6_Init(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Update.s") +void OceffWipe6_Destroy(Actor* thisx, GlobalContext* globalCtx) { + func_80115D5C(&globalCtx->state); + globalCtx->msgCtx.unk120B0 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe6/OceffWipe6_Draw.s") +void OceffWipe6_Update(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(globalCtx)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void OceffWipe6_Draw(Actor* thisx, GlobalContext* globalCtx) { + OceffWipe6* this = THIS; + f32 z; + u8 alpha; + s32 i; + s32 counter; + Vec3f activeCamEye; + s32 pad; + Vec3f quakeOffset; + s32 pad2; + + activeCamEye = GET_ACTIVE_CAM(globalCtx)->eye; + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(globalCtx)); + + if (this->counter < 32) { + counter = this->counter; + z = Math_SinS(counter * 0x200) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + + for (i = 1; i < ARRAY_COUNT(gOceff6Vtx); i += 2) { + gOceff6Vtx[i].v.cn[3] = alpha; + } + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(activeCamEye.x + quakeOffset.x, activeCamEye.y + quakeOffset.y, + activeCamEye.z + quakeOffset.z, MTXMODE_NEW); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + Matrix_NormalizeXYZ(&globalCtx->billboardMtxF); + Matrix_InsertXRotation_s(0x708, MTXMODE_APPLY); + Matrix_InsertTranslation(0.0f, 0.0f, -z, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); + gSPDisplayList(POLY_XLU_DISP++, gOceff6DL); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h index 0b845e133..c37e3f9d4 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h @@ -7,7 +7,7 @@ struct OceffWipe6; typedef struct OceffWipe6 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe6; // size = 0x148 extern const ActorInit Oceff_Wipe6_InitVars; diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c index f03130343..da295b768 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -6,7 +6,7 @@ #include "z_oceff_wipe7.h" -#define FLAGS 0x02000010 +#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) #define THIS ((OceffWipe7*)thisx) 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 8072d9f44..38acb813e 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -6,7 +6,7 @@ #include "z_shot_sun.h" -#define FLAGS 0x00000009 +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((ShotSun*)thisx) 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 9dcf3ab15..51a2fa695 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -6,7 +6,7 @@ #include "z_tg_sw.h" -#define FLAGS 0x00000010 +#define FLAGS (ACTOR_FLAG_10) #define THIS ((TGSw*)thisx) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 6a5fa0423..bc3e3c1e8 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -12,6 +12,11 @@ extern UNK_TYPE D_06008860; extern UNK_TYPE D_0600BDD8; extern UNK_TYPE D_060178D0; +void Player_Init(Actor* thisx, GlobalContext* globalCtx); +void Player_Destroy(Actor* thisx, GlobalContext* globalCtx); +void Player_Update(Actor* thisx, GlobalContext* globalCtx); +void Player_Draw(Actor* thisx, GlobalContext* globalCtx); + #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DA90.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DABC.s") @@ -728,7 +733,7 @@ extern UNK_TYPE D_060178D0; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841A50.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841AC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Init.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80842510.s") @@ -754,15 +759,15 @@ extern UNK_TYPE D_060178D0; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844EF8.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808460B8.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Update.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808463C0.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80846460.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80846528.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Draw.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808470D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Destroy.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847190.s") 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 62c56c04b..29ac6b18b 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 @@ -1,31 +1,85 @@ /* * File: z_eff_en_ice_block.c * Overlay: ovl_Effect_En_Ice_Block - * Description: + * Description: Ice Shard (Pentagon shaped) thrown off of the Obj_Iceblock actor during growth animation + * Object Requirement: OBJECT_ICE_BLOCK */ #include "z_eff_en_ice_block.h" +#include "objects/object_ice_block/object_ice_block.h" #define PARAMS ((EffectEnIceBlockInitParams*)initParamsx) -s32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_En_Ice_Block_InitVars = { EFFECT_EN_ICE_BLOCK, EffectEnIceBlock_Init, }; -#endif +#define rObjId regs[0] +#define rScale regs[1] +#define rRot regs[2] +#define rRotVel regs[3] -extern UNK_TYPE D_06000A38; +u32 EffectEnIceBlock_CheckIceBlockObject(EffectSs* this, GlobalContext* globalCtx) { + if (((this->rObjId = Object_GetIndex(&globalCtx->objectCtx, OBJECT_ICE_BLOCK)) < 0) || + (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjId))) { + this->life = -1; + this->draw = NULL; + return false; + } else { + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/func_80A22D40.s") +u32 EffectEnIceBlock_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectEnIceBlockInitParams* params = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Init.s") + Math_Vec3f_Copy(&this->pos, ¶ms->pos); + Math_Vec3f_Copy(&this->velocity, ¶ms->velocity); + Math_Vec3f_Copy(&this->accel, ¶ms->accel); + this->rScale = params->scale; + this->rRot = Rand_ZeroOne() * 65535.0f; + this->rRotVel = (s32)(Rand_ZeroOne() * 512.0f) + 0x400; + this->life = 40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Draw.s") + this->draw = EffectEnIceBlock_Draw; + this->update = EffectEnIceBlock_Update; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_En_Ice_Block/EffectEnIceBlock_Update.s") + return 1; +} + +void EffectEnIceBlock_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + if (EffectEnIceBlock_CheckIceBlockObject(this, globalCtx)) { + f32 scale = this->rScale * 0.1f * 0.01f; + + OPEN_DISPS(gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x06, + globalCtx->objectCtx.status[this->rObjId].segment); // object: OBJECT_ICE_BLOCK + + func_8012C2DC(globalCtx->state.gfxCtx); + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_InsertMatrix(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_InsertZRotation_s(this->rRot, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, &gIceBlockShardEffectDL); + + CLOSE_DISPS(gfxCtx); + } +} + +void EffectEnIceBlock_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + this->rRot += this->rRotVel; + EffectEnIceBlock_CheckIceBlockObject(this, globalCtx); +} 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 d18f57bb7..41a8f92ff 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 @@ -5,23 +5,103 @@ */ #include "z_eff_ss_bubble.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rVecAdjX regs[1] +#define rVecAdjZ regs[2] #define PARAMS ((EffectSsBubbleInitParams*)initParamsx) -s32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsBubble_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Bubble_InitVars = { EFFECT_SS_BUBBLE, EffectSsBubble_Init, }; -#endif +static f32 sVecAdjMaximums[] = { 291.0f, 582.0f, 1600.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Init.s") +u32 EffectSsBubble_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBubbleInitParams* initParams = (EffectSsBubbleInitParams*)initParamsx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Draw.s") + { + TexturePtr tex = (Rand_ZeroOne() < 0.5f) ? gEffBubble1Tex : gEffBubble2Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bubble/EffectSsBubble_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->pos.x = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.x; + this->pos.y = (((Rand_ZeroOne() - 0.5f) * initParams->yPosRandScale) + initParams->yPosOffset) + initParams->pos.y; + this->pos.z = ((Rand_ZeroOne() - 0.5f) * initParams->xzPosRandScale) + initParams->pos.z; + Math_Vec3f_Copy(&this->vec, &this->pos); + this->life = 1; + this->rScale = (((Rand_ZeroOne() * 0.5f) + 1.0f) * initParams->scale) * 100.0f; + this->draw = EffectSsBubble_Draw; + this->update = EffectSsBubble_Update; + + return 1; +} + +void EffectSsBubble_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 150, 150, 150, 0); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBubble_Update(GlobalContext* globalCtx2, u32 index, EffectSs* this) { + WaterBox* waterBox; + f32 waterSurfaceY = this->pos.y; + Vec3f ripplePos; + GlobalContext* globalCtx = globalCtx2; + + if (!WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->pos.x, this->pos.z, &waterSurfaceY, &waterBox)) { + this->life = -1; + return; + } + if (waterSurfaceY < this->pos.y) { + ripplePos.x = this->pos.x; + ripplePos.y = waterSurfaceY; + ripplePos.z = this->pos.z; + EffectSsGRipple_Spawn(globalCtx, &ripplePos, 0, 80, 0); + this->life = -1; + label: + return; + } + if (((globalCtx->gameplayFrames + index) % 8) == 0) { + CollisionPoly* colPoly; + u32 speed; + s16 direction; + f32 rVecAdjMax; + + BgCheck_EntityRaycastFloor2_1(globalCtx, &globalCtx->colCtx, &colPoly, &this->pos); + speed = SurfaceType_GetConveyorSpeed(&globalCtx->colCtx, colPoly, BGCHECK_SCENE); + if ((speed != 0) && !SurfaceType_GetConveyorType(&globalCtx->colCtx, colPoly, BGCHECK_SCENE)) { + direction = SurfaceType_GetConveyorDirection(&globalCtx->colCtx, colPoly, BGCHECK_SCENE) << 0xA; + rVecAdjMax = sVecAdjMaximums[speed - 1]; + this->rVecAdjX = Math_SinS(direction) * rVecAdjMax; + this->rVecAdjZ = Math_CosS(direction) * rVecAdjMax; + } + } + this->vec.x += this->rVecAdjX / 100.0f; + this->vec.z += this->rVecAdjZ / 100.0f; + this->pos.x = ((Rand_ZeroOne() * 0.5f) - 0.25f) + this->vec.x; + this->accel.y = (Rand_ZeroOne() - 0.3f) * 0.2f; + this->pos.z = (Rand_ZeroOne() * 0.5f - 0.25f) + this->vec.z; + this->life++; +} 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 fe070b28d..d2ea02f7c 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 @@ -6,43 +6,59 @@ #include "z_eff_ss_kakera.h" +#define rReg0 regs[0] +#define rGravity regs[1] +#define rPitch regs[2] +#define rYaw regs[3] +#define rReg4 regs[4] +#define rReg5 regs[5] +#define rReg6 regs[6] +#define rScale regs[7] +#define rReg8 regs[8] +#define rReg9 regs[9] +#define rObjId regs[10] +#define rObjBankIndex regs[11] +#define rColorIndex regs[12] + #define PARAMS ((EffectSsKakeraInitParams*)initParamsx) u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_8097E130(EffectSs* this, GlobalContext* globalCtx); +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx); const EffectSsInit Effect_Ss_Kakera_InitVars = { EFFECT_SS_KAKERA, EffectSsKakera_Init, }; + KakeraColorStruct D_8097EAD8[] = { { 0, { 255, 255, 255 } }, { 0, { 235, 170, 130 } }, { 1, { 210, 190, 170 } }, }; + f32 D_8097EAE4[] = { 1.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f, 100.0f, 40.0f, 5.0f }; u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsKakeraInitParams* params = PARAMS; + EffectSsKakeraInitParams* initParams = PARAMS; - this->pos = params->pos; - this->velocity = params->velocity; - this->life = params->life; + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->life = initParams->life; this->priority = 101; - if (params->dList != NULL) { - this->gfx = params->dList; - switch (params->objId) { + if (initParams->dList != NULL) { + this->gfx = initParams->dList; + switch (initParams->objId) { case GAMEPLAY_KEEP: case GAMEPLAY_FIELD_KEEP: case GAMEPLAY_DANGEON_KEEP: - this->regs[10] = KAKERA_OBJECT_DEFAULT; + this->rObjId = KAKERA_OBJECT_DEFAULT; break; default: - this->regs[10] = params->objId; - func_8097E130(this, globalCtx); + this->rObjId = initParams->objId; + EffectSsKakera_CheckForObject(this, globalCtx); break; } } else { @@ -50,18 +66,18 @@ u32 EffectSsKakera_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi } this->draw = EffectSsKakera_Draw; this->update = EffectSsKakera_Update; - this->vec = params->unk_18; - this->regs[0] = params->unk_2C; - this->regs[1] = params->gravity; - this->regs[2] = Rand_ZeroOne() * 0x8000; - this->regs[3] = Rand_ZeroOne() * 0x8000; - this->regs[4] = params->unk_26; - this->regs[5] = params->unk_28; - this->regs[6] = params->unk_2A; - this->regs[7] = params->scale; - this->regs[8] = params->unk_30; - this->regs[9] = params->unk_32; - this->regs[12] = params->colorIdx; + this->vec = initParams->unk_18; + this->rReg0 = initParams->unk_2C; + this->rGravity = initParams->gravity; + this->rPitch = Rand_ZeroOne() * 0x8000; + this->rYaw = Rand_ZeroOne() * 0x8000; + this->rReg4 = initParams->unk_26; + this->rReg5 = initParams->unk_28; + this->rReg6 = initParams->unk_2A; + this->rScale = initParams->scale; + this->rReg8 = initParams->unk_30; + this->rReg9 = initParams->unk_32; + this->rColorIndex = initParams->colorIdx; return 1; } @@ -72,24 +88,24 @@ f32 func_8097DE30(f32 center, f32 range) { void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 pad; - f32 scale = this->regs[7] / 256.0f; - s32 colorIndex = this->regs[12]; + f32 scale = this->rScale / 256.0f; + s32 colorIndex = this->rColorIndex; OPEN_DISPS(gfxCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { + gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } else { - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[11]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); } } Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); - Matrix_RotateY(this->regs[3], MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->regs[2], MTXMODE_APPLY); + Matrix_RotateY(this->rYaw, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->rPitch, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - if ((((this->regs[4] >> 7) & 1) << 7) == 0x80) { + if ((((this->rReg4 >> 7) & 1) << 7) == 0x80) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C2DC(globalCtx->state.gfxCtx); if (colorIndex >= 0) { @@ -109,9 +125,9 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void func_8097E130(EffectSs* this, GlobalContext* globalCtx) { - this->regs[11] = Object_GetIndex(&globalCtx->objectCtx, this->regs[10]); - if ((this->regs[11] < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->regs[11]))) { +void EffectSsKakera_CheckForObject(EffectSs* this, GlobalContext* globalCtx) { + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, this->rObjId); + if ((this->rObjBankIndex < 0) || (!Object_IsLoaded(&globalCtx->objectCtx, this->rObjBankIndex))) { this->life = 0; this->draw = NULL; } @@ -127,9 +143,9 @@ void func_8097E19C(EffectSs* this) { f32 temp_f20; f32 temp_f2_2; - temp_f18 = this->regs[5] / 1024.0f; - temp_f20 = this->regs[6] / 1024.0f; - range = (this->regs[9] / 1024.0f) * 4.0f; + temp_f18 = this->rReg5 / 1024.0f; + temp_f20 = this->rReg6 / 1024.0f; + range = (this->rReg9 / 1024.0f) * 4.0f; temp_f2 = this->velocity.x - func_8097DE30(0.0f, range); temp_f16 = this->velocity.y - func_8097DE30(0.0f, range); temp_f12 = this->velocity.z - func_8097DE30(0.0f, range); @@ -187,7 +203,7 @@ f32 func_8097E400(f32 arg0, s32 index) { s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB0C[] = { 0.05f, 1.0f }; f32 phi_f0; - s32 index = this->regs[0] & 3; + s32 index = this->rReg0 & 3; if (index != 0) { if (distance > 1.0f) { @@ -198,23 +214,23 @@ s32 func_8097E420(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x += D_8097EB0C[index - 1] * diff->z * phi_f0; this->accel.z -= D_8097EB0C[index - 1] * diff->x * phi_f0; } - return 1; + return true; } s32 func_8097E4B0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB14[] = { 4.0f, 0.1f, 0.3f, 0.9f, -0.1f, -0.3f, -0.9f }; - s32 index = (this->regs[0] >> 2) & 7; + s32 index = (this->rReg0 >> 2) & 7; if (index != 0) { this->accel.y += D_8097EB14[index]; } - return 1; + return true; } s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { static f32 D_8097EB30[] = { 0.1f, 1.0f, 6.0f }; f32 phi_f0; - s32 index = (this->regs[0] >> 5) & 3; + s32 index = (this->rReg0 >> 5) & 3; if (index != 0) { if (distance > 1.0f) { @@ -225,32 +241,33 @@ s32 func_8097E4F0(EffectSs* this, Vec3f* diff, f32 distance) { this->accel.x -= diff->x * D_8097EB30[index - 1] * phi_f0; this->accel.z -= diff->z * D_8097EB30[index - 1] * phi_f0; } - return 1; + return true; } s32 func_8097E584(EffectSs* this, Vec3f* diff, f32 distance) { - static f32 (*D_8097EB3C[])(f32, - s32) = { func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, - func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400 }; + static f32 (*D_8097EB3C[])(f32, s32) = { + func_8097E368, func_8097E384, func_8097E384, func_8097E384, func_8097E3C0, + func_8097E3C0, func_8097E3C0, func_8097E400, func_8097E400, func_8097E400, + }; f32 center; f32 rand; s32 index; - index = (this->regs[0] >> 7) & 0xF; + index = (this->rReg0 >> 7) & 0xF; center = D_8097EB3C[index](distance, index); - rand = func_8097DE30(center, (this->regs[9] * center) / 1024.0f); + rand = func_8097DE30(center, (this->rReg9 * center) / 1024.0f); this->accel.x *= rand; this->accel.y *= rand; this->accel.z *= rand; this->accel.x += rand * 0.01f; this->accel.y += rand * 0.01f; this->accel.z += rand * 0.01f; - return 1; + return true; } s32 func_8097E660(EffectSs* this, Vec3f* diff, f32 distance) { - this->accel.y += this->regs[1] / 256.0f; - return 1; + this->accel.y += this->rGravity / 256.0f; + return true; } s32 func_8097E698(EffectSs* this) { @@ -265,21 +282,21 @@ s32 func_8097E698(EffectSs* this) { if (distance > 1000.0f) { return false; } - if (this->regs[0] != 0) { - if (func_8097E420(this, &diff, distance) == 0) { + if (this->rReg0 != 0) { + if (!func_8097E420(this, &diff, distance)) { return false; } - if (func_8097E4B0(this, &diff, distance) == 0) { + if (!func_8097E4B0(this, &diff, distance)) { return false; } - if (func_8097E4F0(this, &diff, distance) == 0) { + if (!func_8097E4F0(this, &diff, distance)) { return false; } - if (func_8097E584(this, &diff, distance) == 0) { + if (!func_8097E584(this, &diff, distance)) { return false; } } - if (func_8097E660(this, &diff, distance) == 0) { + if (!func_8097E660(this, &diff, distance)) { return false; } else { return true; @@ -290,41 +307,41 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { static f32 D_8097EB64[] = { 10.0f, 20.0f, 40.0f }; Player* player = GET_PLAYER(globalCtx); - if (this->regs[8] == 0) { - if ((((this->regs[4] >> 4) & 1) << 4) == (1 << 4)) { - if (this->pos.y <= (player->actor.floorHeight - ((this->regs[4] >> 2) & 3))) { - this->regs[9] = 0; - this->regs[0] = 0; - this->regs[4] &= ~0x60; + if (this->rReg8 == 0) { + if ((((this->rReg4 >> 4) & 1) << 4) == (1 << 4)) { + if (this->pos.y <= (player->actor.floorHeight - ((this->rReg4 >> 2) & 3))) { + this->rReg9 = 0; + this->rReg0 = 0; + this->rReg4 &= ~0x60; this->accel.x = this->accel.y = this->accel.z = 0.0f; this->velocity.x = this->velocity.y = this->velocity.z = 0.0f; - this->regs[5] = this->regs[9]; - this->regs[1] = this->regs[9]; + this->rReg5 = this->rReg9; + this->rGravity = this->rReg9; } } else { - if (this->pos.y <= ((player->actor.floorHeight - ((this->regs[4] >> 2) & 3)) - 600.0f)) { + if (this->pos.y <= ((player->actor.floorHeight - ((this->rReg4 >> 2) & 3)) - 600.0f)) { this->life = 0; } } } else { - switch (this->regs[4] & 3) { + switch (this->rReg4 & 3) { case 0: - this->regs[8] = 0; + this->rReg8 = 0; break; case 1: if ((this->velocity.y < 0.0f) && - (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3]))) { + (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3]))) { this->velocity.x *= func_8097DE30(0.9f, 0.2f); this->velocity.y *= -0.8f; this->velocity.z *= func_8097DE30(0.9f, 0.2f); - if (this->regs[8] > 0) { - this->regs[8]--; + if (this->rReg8 > 0) { + this->rReg8--; } } break; case 2: - if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->regs[4] >> 2) & 3])) { - this->regs[8] = 0; + if (BgCheck_SphVsFirstPoly(&globalCtx->colCtx, &this->pos, D_8097EB64[(this->rReg4 >> 2) & 3])) { + this->rReg8 = 0; } break; } @@ -332,18 +349,18 @@ void func_8097E7E0(EffectSs* this, GlobalContext* globalCtx) { } void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { - switch (((this->regs[4] >> 5) & 3) << 5) { + switch (((this->rReg4 >> 5) & 3) << 5) { case 0x20: - this->regs[2] += 0x47B; - this->regs[3] += 0x139; + this->rPitch += 0x47B; + this->rYaw += 0x139; break; case 0x40: - this->regs[2] += 0x1A7C; - this->regs[3] += 0x47B; + this->rPitch += 0x1A7C; + this->rYaw += 0x47B; break; case 0x60: - this->regs[2] += 0x3F27; - this->regs[3] += 0xCA1; + this->rPitch += 0x3F27; + this->rYaw += 0xCA1; break; } func_8097E19C(this); @@ -351,7 +368,7 @@ void EffectSsKakera_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) this->life = 0; } func_8097E7E0(this, globalCtx); - if (this->regs[10] != KAKERA_OBJECT_DEFAULT) { - func_8097E130(this, globalCtx); + if (this->rObjId != KAKERA_OBJECT_DEFAULT) { + EffectSsKakera_CheckForObject(this, globalCtx); } } 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 40c3d693c..ba2355d23 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 @@ -4,7 +4,10 @@ #include "global.h" typedef struct { - char unk_0[UNK_SIZE]; + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ CollisionPoly* unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ char unk_14[UNK_SIZE]; } EffectSsSbnInitParams; // size = ? extern const EffectSsInit Effect_Ss_Sbn_InitVars; 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 6d2d4c6dd..d4356f90c 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 @@ -5,23 +5,117 @@ */ #include "z_eff_ss_sibuki.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rPrimColorR regs[0] +#define rPrimColorG regs[1] +#define rPrimColorB regs[2] +#define rPrimColorA regs[3] +#define rEnvColorR regs[4] +#define rEnvColorG regs[5] +#define rEnvColorB regs[6] +#define rEnvColorA regs[7] +#define rMoveDelay regs[8] +#define rDirection regs[9] +#define rScale regs[10] #define PARAMS ((EffectSsSibukiInitParams*)initParamsx) -s32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Sibuki_InitVars = { EFFECT_SS_SIBUKI, EffectSsSibuki_Init, }; -#endif +u32 EffectSsSibuki_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSibukiInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Draw.s") + { + TexturePtr tex = (KREG(2) != 0) ? gEffBubble2Tex : gEffBubble1Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Sibuki/EffectSsSibuki_Update.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } + + this->life = ((s32)((Rand_ZeroOne() * (500.0f + KREG(64))) * 0.01f)) + KREG(65) + 10; + this->rMoveDelay = initParams->moveDelay + 1; + this->draw = EffectSsSibuki_Draw; + this->update = EffectSsSibuki_Update; + this->rDirection = initParams->direction; + this->rScale = initParams->scale; + this->rPrimColorR = 100; + this->rPrimColorG = 100; + this->rPrimColorB = 100; + this->rPrimColorA = 100; + this->rEnvColorR = 255; + this->rEnvColorG = 255; + this->rEnvColorB = 255; + this->rEnvColorA = 255; + + return 1; +} + +void EffectSsSibuki_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + gDPSetEnvColor(POLY_OPA_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSibuki_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { + Player* player = GET_PLAYER(globalCtx); + s32 pad[2]; + f32 xzVelScale; + + if (this->pos.y <= player->actor.floorHeight) { + this->life = 0; + } + + if (this->rMoveDelay != 0) { + this->rMoveDelay--; + + if (this->rMoveDelay == 0) { + s16 yaw = Camera_GetInputDirYaw(Play_GetCamera(globalCtx, CAM_ID_MAIN)); + + xzVelScale = ((200.0f + KREG(20)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(23) + 20.0f)); + + if (this->rDirection != 0) { + xzVelScale *= -1.0f; + } + + this->velocity.x = Math_CosS(yaw) * xzVelScale; + this->velocity.z = -Math_SinS(yaw) * xzVelScale; + + this->velocity.y = ((700.0f + KREG(21)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * (KREG(24) + 20.0f)); + this->accel.y = ((-100.0f + KREG(22)) * 0.01f) + ((0.1f * Rand_ZeroOne()) * KREG(25)); + + if (KREG(3) != 0) { + this->velocity.x *= (KREG(3) * 0.01f); + this->velocity.y *= (KREG(3) * 0.01f); + this->velocity.z *= (KREG(3) * 0.01f); + this->accel.y *= (KREG(4) * 0.01f); + } + } + } else { + if (this->rScale != 0) { + this->rScale = (this->rScale - KREG(26)) - 3; + } + } +} 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 c49059262..d26135729 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 @@ -7,6 +7,9 @@ #include "z_eff_ss_stick.h" #include "objects/gameplay_keep/gameplay_keep.h" +#define rObjBankIndex regs[0] +#define rYaw regs[1] + #define PARAMS ((EffectSsStickInitParams*)initParamsx) u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); @@ -19,16 +22,16 @@ const EffectSsInit Effect_Ss_Stick_InitVars = { }; u32 EffectSsStick_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { - EffectSsStickInitParams* params = PARAMS; + EffectSsStickInitParams* initParams = PARAMS; Vec3f pos; - this->regs[0] = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); - pos = params->pos; + this->rObjBankIndex = Object_GetIndex(&globalCtx->objectCtx, GAMEPLAY_KEEP); + pos = initParams->pos; this->pos = pos; this->vec = pos; - this->regs[1] = params->yaw; - this->velocity.x = Math_SinS(params->yaw) * 6.0f; - this->velocity.z = Math_CosS(params->yaw) * 6.0f; + this->rYaw = initParams->yaw; + this->velocity.x = Math_SinS(initParams->yaw) * 6.0f; + this->velocity.z = Math_CosS(initParams->yaw) * 6.0f; this->life = 20; this->draw = EffectSsStick_Draw; this->update = EffectSsStick_Update; @@ -42,14 +45,16 @@ void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; OPEN_DISPS(gfxCtx); + Matrix_InsertTranslation(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.0025f, 0.01f, MTXMODE_APPLY); - Matrix_InsertRotation(0, this->regs[1], 0, MTXMODE_APPLY); + Matrix_InsertRotation(0, this->rYaw, 0, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); func_8012C28C(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->regs[0]].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[this->rObjBankIndex].segment); gSPSegment(POLY_OPA_DISP++, 0x0C, D_801C0850); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0032B0); + gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); + CLOSE_DISPS(gfxCtx); } diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index 376260a69..0ac471162 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -193,7 +193,7 @@ void Daytelop_Draw(DaytelopContext* this) { void Daytelop_Main(GameState* thisx) { DaytelopContext* this = (DaytelopContext*)thisx; - func_8012CF0C(this->state.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x09, this->daytelopStaticFile); @@ -236,7 +236,7 @@ void Daytelop_Init(GameState* thisx) { if (gSaveContext.save.day < 9) { if (gSaveContext.save.day == 0) { - func_80143AC4(); + Sram_ClearFlagsAtDawnOfTheFirstDay(); } Sram_IncrementDay(); } diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h index eca743850..d77a5f334 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h @@ -1,5 +1,5 @@ -#ifndef _Z64_DAYTELOP_H_ -#define _Z64_DAYTELOP_H_ +#ifndef Z64_DAYTELOP_H +#define Z64_DAYTELOP_H #include "global.h" diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h index d2e71587d..78c4a9a62 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -1,12 +1,12 @@ -#ifndef _Z64_FILE_CHOOSE_H_ -#define _Z64_FILE_CHOOSE_H_ +#ifndef Z64_FILE_CHOOSE_H +#define Z64_FILE_CHOOSE_H #include "global.h" void FileChoose_Init(GameState* thisx); void FileChoose_Destroy(GameState* thisx); -typedef struct { +typedef struct FileChooseContext { /* 0x00000 */ GameState state; /* 0x000A4 */ Vtx* unk_A4; /* 0x000A8 */ u8* staticSegment; @@ -21,23 +21,35 @@ typedef struct { /* 0x242E0 */ EnvironmentContext envCtx; /* 0x243E0 */ Vtx* unk_243E0; /* 0x243E4 */ Vtx* unk_243E4; - /* 0x243E8 */ Vtx* unk_243E8; - /* 0x243EC */ Vtx* unk_243EC; - /* 0x243F0 */ Vtx* unk_243F0; - /* 0x243F4 */ u8 newf[6][4]; - /* 0x2440C */ u16 unk_2440C[4]; - /* 0x24414 */ u8 unk_24414[8][4]; - /* 0x24434 */ s16 healthCapacity[4]; - /* 0x2443C */ s16 health[4]; - /* 0x24444 */ u32 unk_24444[4]; - /* 0x24454 */ s8 unk_24454[4]; - /* 0x24458 */ u16 unk_24458[4]; - /* 0x24460 */ s16 unk_24460[4]; - /* 0x24468 */ u8 unk_24468[4]; - /* 0x2446C */ s16 rupees[4]; - /* 0x24474 */ u8 unk_24474[4]; - /* 0x24478 */ u8 unk_24478[4]; - /* 0x2447C */ u8 unk_2447C[4]; + /* 0x243E8 */ u8 newf2[2][6]; + /* 0x243F4 */ u8 newf[2][6]; + /* 0x24400 */ UNK_TYPE1 unk_24400[0xC]; + /* 0x2440C */ u16 unk_2440C[2]; + /* 0x24410 */ u16 unk_24410[2]; + /* 0x24414 */ u8 unk_24414[2][8]; // playername + /* 0x24424 */ u8 unk_24424[2][8]; // playername + /* 0x24434 */ s16 healthCapacity[2]; + /* 0x24438 */ u16 unk_24438[2]; + /* 0x2443C */ s16 health[2]; + /* 0x24440 */ u16 unk_24440[2]; + /* 0x24444 */ u32 unk_24444[2]; + /* 0x2444C */ u32 unk_2444C[2]; + /* 0x24454 */ s8 unk_24454[2]; + /* 0x24456 */ u8 unk_24456[2]; + /* 0x24458 */ u16 unk_24458[2]; + /* 0x2445C */ u16 unk_2445C[2]; + /* 0x24460 */ s16 unk_24460[2]; + /* 0x24464 */ s16 unk_24464[2]; + /* 0x24468 */ u8 unk_24468[2]; + /* 0x2446A */ u8 unk_2446A[2]; + /* 0x2446C */ s16 rupees[2]; + /* 0x24470 */ s16 unk_24470[2]; + /* 0x24474 */ s8 unk_24474[2]; + /* 0x24476 */ s8 unk_24476[2]; + /* 0x24478 */ s8 maskCount[2]; + /* 0x2447A */ s8 unk_2447A[2]; + /* 0x2447C */ s8 heartPieceCount[2]; + /* 0x2447E */ s8 unk_2447E[2]; /* 0x24480 */ s16 unk_24480; /* 0x24482 */ s16 unk_24482; /* 0x24484 */ s16 unk_24484; @@ -50,7 +62,7 @@ typedef struct { /* 0x24492 */ s16 unk_24492[3]; /* 0x24498 */ s16 unk_24498; /* 0x2449A */ s16 unk_2449A[6]; - /* 0x244A6 */ s16 unk_244A6; + /* 0x244A6 */ s16 fileNum; /* 0x244A8 */ s16 unk_244A8; /* 0x244AA */ s16 unk_244AA; /* 0x244AC */ s16 unk_244AC; @@ -101,4 +113,13 @@ typedef struct { /* 0x24550 */ s16 unk_24550; } FileChooseContext; // size = 0x24558 +// TODO: Confirm those values has the same meaning as their OoT counterparts +typedef enum { + /* 0x00 */ PAUSE_0, // PAUSE_ITEM + /* 0x01 */ PAUSE_1, // PAUSE_MAP + /* 0x02 */ PAUSE_2, // PAUSE_QUEST + /* 0x03 */ PAUSE_3, // PAUSE_EQUIP + /* 0x04 */ PAUSE_4 // PAUSE_WORLD_MAP +} PauseMenuPage; + #endif diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index 2d4f51006..f0dd8190e 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -13,7 +13,7 @@ void Opening_SetupForTitleCutscene(OpeningContext* this) { gSaveContext.eventInf[1] &= (u8)~0x80; gSaveContext.gameMode = 1; - func_80144890(); + Sram_InitNewSave(); gSaveContext.save.entranceIndex = openingEntrances[D_801BB12C]; gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = openingCutscenes[D_801BB12C]; @@ -37,7 +37,7 @@ void func_80803EA0(OpeningContext* this) { void Opening_Main(GameState* thisx) { OpeningContext* this = (OpeningContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 0, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, false, true, 0, 0, 0); Opening_SetupForTitleCutscene(this); func_80803EA0(this); } @@ -57,8 +57,8 @@ void Opening_Init(GameState* thisx) { this->gameState.destroy = Opening_Destroy; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index ea28e5e2b..53dbc266f 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -44,15 +44,15 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; } - gSaveContext.respawn[0].entranceIndex = 0xFFFF; + gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex = 0xFFFF; gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; - gSaveContext.respawn[4].entranceIndex = 0xFF; - gSaveContext.respawn[5].entranceIndex = 0xFF; - gSaveContext.respawn[6].entranceIndex = 0xFF; - gSaveContext.respawn[7].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_GORON].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entranceIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entranceIndex = 0xFF; D_801BDBB0 = 0; do { @@ -868,7 +868,7 @@ void Select_DrawLoadingScreen(SelectContext* this) { void Select_Draw(SelectContext* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; - func_8012CF0C(gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(gfxCtx, true, true, 0, 0, 0); SET_FULLSCREEN_VIEWPORT(&this->view); View_RenderView(&this->view, 0xF); diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 827c27387..afeafe09f 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -119,7 +119,7 @@ void Title_Draw(GameState* thisx) { void Title_Main(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_8012CF0C(this->gameState.gfxCtx, 1, 1, 0, 0, 0); + func_8012CF0C(this->gameState.gfxCtx, true, true, 0, 0, 0); OPEN_DISPS(this->gameState.gfxCtx); @@ -145,7 +145,7 @@ void Title_Main(GameState* thisx) { void Title_Destroy(GameState* thisx) { TitleContext* this = (TitleContext*)thisx; - func_80146E40(&this->gameState, &this->sramCtx); + Sram_InitSram(&this->gameState, &this->sramCtx); ShrinkWindow_Destroy(); CIC6105_Nop80081828(); } @@ -173,7 +173,7 @@ void Title_Init(GameState* thisx) { gSaveContext.fileNum = 0xFF; } - gSaveContext.unk_3F3F = 1; + gSaveContext.unk_3F3F = true; Sram_Alloc(thisx, &this->sramCtx); this->ult = 0; this->timer = 20; diff --git a/tools/ZAPD/.gitrepo b/tools/ZAPD/.gitrepo index 475415d99..5d67a3762 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 119a6883e6f795815744b9afd6a79084c619ddb6 - parent = 66a66f61b6368af0ed711803c54a963494329217 + commit = efae567d3917afa341bd843ba185b3bd66d57429 + parent = 22c6551083172f5c506aecf8c31ad761afbbd658 method = merge cmdver = 0.4.3 diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp new file mode 100644 index 000000000..b69f47321 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp @@ -0,0 +1,208 @@ +#include "CutsceneMM_Commands.h" + +#include +#include + +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +// Specific for command lists where each entry has size 8 bytes +const std::unordered_map csCommandsDescMM = { + {CutsceneMMCommands::CS_CMD_MISC, {"CS_MISC", "(0x%02X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SET_LIGHTING, {"CS_LIGHTING", "(0x%02X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX, {"CS_SCENE_TRANS_FX", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_MOTIONBLUR, {"CS_MOTIONBLUR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_GIVETATL, {"CS_GIVETATL", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYSEQ, {"CS_PLAYSEQ", "(0x%04X, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_130, {"CS_SCENE_UNK_130", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_131, {"CS_SCENE_UNK_131", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_132, {"CS_SCENE_UNK_132", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_STOPSEQ, {"CS_STOPSEQ", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_PLAYAMBIENCE, {"CS_PLAYAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_FADEAMBIENCE, {"CS_FADEAMBIENCE", "(0x%04X, %i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_TERMINATOR, {"CS_TERMINATOR", "(%i, %i, %i)"}}, + {CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES, + {"CS_CHOOSE_CREDITS_SCENES", "(%i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericMMCmd::CutsceneSubCommandEntry_GenericMMCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneMMCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ +} + +std::string CutsceneSubCommandEntry_GenericMMCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDescMM.find(commandId); + std::string entryFmt = "CS_UNK_DATA(0x%02X, %i, %i, %i)"; + + if (element != csCommandsDescMM.end()) + { + entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + } + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad); +} + +CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneMMCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDescMM.find(static_cast(commandID)); + + if (element != csCommandsDescMM.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneSubCommandEntry_Camera::CutsceneSubCommandEntry_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +std::string CutsceneSubCommandEntry_Camera::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X)", base, startFrame); +} + +size_t CutsceneSubCommandEntry_Camera::GetRawSize() const +{ + return 0x04; +} + +CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries / 4; i++) + { + auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_Camera::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_CAMERA_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeScreen::CutsceneSubCommandEntry_FadeScreen( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_FadeScreen::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESCREEN(0x%02X, %i, %i, %i, %i, %i)", base, startFrame, + endFrame, unk_06, unk_07, unk_08); +} + +size_t CutsceneSubCommandEntry_FadeScreen::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeScreen(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeScreen::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESCREEN_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_FadeSeq::CutsceneSubCommandEntry_FadeSeq( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_FadeSeq::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_FADESEQ(%i, %i, %i)", base, startFrame, endFrame); +} + +size_t CutsceneSubCommandEntry_FadeSeq::GetRawSize() const +{ + return 0x0C; +} + +CutsceneMMCommand_FadeSeq::CutsceneMMCommand_FadeSeq(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneMMCommand_FadeSeq::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_FADESEQ_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_NonImplemented::CutsceneSubCommandEntry_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ +} + +CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h new file mode 100644 index 000000000..c8ae4eb60 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.h @@ -0,0 +1,140 @@ +#pragma once + +#include "Cutscene_Commands.h" + +enum class CutsceneMMCommands +{ + /* 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_UNK_12D, + /* 0x130 */ CS_CMD_130 = 0x130, + /* 0x131 */ CS_CMD_131 = 0x131, + /* 0x132 */ CS_CMD_132 = 0x132, + /* 0x133 */ CS_CMD_STOPSEQ, + /* 0x134 */ CS_CMD_PLAYAMBIENCE, + /* 0x135 */ CS_CMD_FADEAMBIENCE, + /* 0x15E */ CS_CMD_TERMINATOR = 0x15E, + /* 0x15F */ CS_CMD_CHOOSE_CREDITS_SCENES, + /* 0x190 */ CS_CMD_RUMBLE = 0x190, +}; + +class CutsceneSubCommandEntry_GenericMMCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneMMCommands commandId; + + CutsceneSubCommandEntry_GenericMMCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetBodySourceCode() const override; +}; + +class CutsceneMMCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneMMCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneMMCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +// TODO: MM cutscene camera command is implemented as a placeholder until we better understand how +// it works +class CutsceneSubCommandEntry_Camera : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_Camera : public CutsceneCommand +{ +public: + CutsceneMMCommand_Camera(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeScreen : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeScreen : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeScreen(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_FadeSeq : public CutsceneSubCommandEntry +{ +public: + uint32_t unk_08; + + CutsceneSubCommandEntry_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneMMCommand_FadeSeq : public CutsceneCommand +{ +public: + CutsceneMMCommand_FadeSeq(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_NonImplemented : public CutsceneSubCommandEntry +{ +public: + CutsceneSubCommandEntry_NonImplemented(const std::vector& rawData, + offset_t rawDataIndex); +}; + +class CutsceneMMCommand_NonImplemented : public CutsceneCommand +{ +public: + CutsceneMMCommand_NonImplemented(const std::vector& rawData, offset_t rawDataIndex); +}; diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp new file mode 100644 index 000000000..a716176b9 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp @@ -0,0 +1,591 @@ +#include "Cutscene_Commands.h" + +#include +#include + +#include "CutsceneMM_Commands.h" +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +/* CutsceneSubCommandEntry */ + +CutsceneSubCommandEntry::CutsceneSubCommandEntry(const std::vector& rawData, + offset_t rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + pad = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); +} + +std::string CutsceneSubCommandEntry::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CMD_HH(0x%04X, 0x%04X), CMD_HH(0x%04X, 0x%04X)", base, startFrame, + endFrame, pad); +} + +size_t CutsceneSubCommandEntry::GetRawSize() const +{ + return 0x08; +} + +/* CutsceneCommand */ + +CutsceneCommand::CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex) +{ + numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); +} + +CutsceneCommand::~CutsceneCommand() +{ + for (auto& entry : entries) + { + delete entry; + } +} + +std::string CutsceneCommand::GetCommandMacro() const +{ + return StringHelper::Sprintf("CMD_W(0x%08X), CMD_W(0x%08X)", commandID, numEntries); +} + +std::string CutsceneCommand::GenerateSourceCode() const +{ + std::string result; + + result += GetCommandMacro(); + result += ",\n"; + + for (auto& entry : entries) + { + result += " "; + result += entry->GetBodySourceCode(); + result += ",\n"; + } + + return result; +} + +size_t CutsceneCommand::GetCommandSize() const +{ + size_t size = 0; + if (entries.size() > 0) + { + size = entries.at(0)->GetRawSize() * entries.size(); + } + else + { + size = 0x08 * numEntries; + } + return 0x08 + size; +} + +void CutsceneCommand::SetCommandID(uint32_t nCommandID) +{ + commandID = nCommandID; + + for (auto& entry : entries) + { + entry->commandID = commandID; + } +} + +// Specific for command lists where each entry has size 0x30 bytes +const std::unordered_map csCommandsDesc = { + {CutsceneCommands::Misc, + {"CS_MISC", "(0x%04X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::SetLighting, + {"CS_LIGHTING", "(0x%02X, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::PlayBGM, {"CS_PLAY_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::StopBGM, {"CS_STOP_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, + {CutsceneCommands::FadeBGM, {"CS_FADE_BGM", "(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i)"}}, +}; + +CutsceneSubCommandEntry_GenericCmd::CutsceneSubCommandEntry_GenericCmd( + const std::vector& rawData, offset_t rawDataIndex, CutsceneCommands cmdId) + : CutsceneSubCommandEntry(rawData, rawDataIndex), commandId(cmdId) +{ + word0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x0); + word1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x4); + + unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x8); + unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0xC); + unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x10); + unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x14); + unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x18); + unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x1C); + unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x20); + unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x24); + unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x28); + unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_GenericCmd::GetBodySourceCode() const +{ + const auto& element = csCommandsDesc.find(commandId); + + if (element != csCommandsDesc.end()) + { + std::string entryFmt = element->second.cmdMacro; + entryFmt += element->second.args; + + return StringHelper::Sprintf(entryFmt.c_str(), base, startFrame, endFrame, pad, unused1, + unused2, unused3, unused4, unused5, unused6, unused7, unused8, + unused9, unused10); + } + + return StringHelper::Sprintf("CS_UNK_DATA(0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, " + "0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X)", + word0, word1, unused1, unused2, unused3, unused4, unused5, unused6, + unused7, unused8, unused9, unused10); +} + +size_t CutsceneSubCommandEntry_GenericCmd::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector& rawData, + offset_t rawDataIndex, + CutsceneCommands cmdId) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + commandID = static_cast(cmdId); + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_GenericCmd(rawData, rawDataIndex, cmdId); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_GenericCmd::GetCommandMacro() const +{ + const auto& element = csCommandsDesc.find(static_cast(commandID)); + + if (element != csCommandsDesc.end()) + { + return StringHelper::Sprintf("%s_LIST(%i)", element->second.cmdMacro, numEntries); + } + + return StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%X, %i)", commandID, numEntries); +} + +CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + continueFlag = BitConverter::ToInt8BE(rawData, rawDataIndex + 0); + cameraRoll = BitConverter::ToInt8BE(rawData, rawDataIndex + 1); + nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); + + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); + + unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string CutsceneCameraPoint::GetBodySourceCode() const +{ + std::string result = ""; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + result += "CS_CAM_FOCUS_POINT"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + result += "CS_CAM_FOCUS_POINT_PLAYER"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + result += "CS_CAM_POS_PLAYER"; + } + else + { + result += "CS_CAM_POS"; + } + + std::string continueMacro = "CS_CMD_CONTINUE"; + if (continueFlag != 0) + continueMacro = "CS_CMD_STOP"; + + result += + StringHelper::Sprintf("(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X)", continueMacro.c_str(), + cameraRoll, nextPointFrame, viewAngle, posX, posY, posZ, unused); + return result; +} + +size_t CutsceneCameraPoint::GetRawSize() const +{ + return 0x10; +} + +CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); + + bool shouldContinue = true; + + uint32_t currentPtr = rawDataIndex + 8; + + while (shouldContinue) + { + CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); + entries.push_back(camPoint); + + if (camPoint->continueFlag == -1) + shouldContinue = false; + + currentPtr += camPoint->GetRawSize(); + } +} + +std::string CutsceneCommandSetCameraPos::GetCommandMacro() const +{ + std::string result; + + std::string listStr; + + if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + { + listStr = "CS_CAM_FOCUS_POINT_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + { + listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; + } + else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) + { + listStr = "CS_CAM_POS_PLAYER_LIST"; + } + else + { + listStr = "CS_CAM_POS_LIST"; + } + + result += StringHelper::Sprintf("%s(%i, %i)", listStr.c_str(), startFrame, endFrame); + + return result; +} + +size_t CutsceneCommandSetCameraPos::GetCommandSize() const +{ + return 0x0C + entries.at(0)->GetRawSize() * entries.size(); +} + +CutsceneSubCommandEntry_Rumble::CutsceneSubCommandEntry_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + unk_06 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x06); + unk_07 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x07); + unk_08 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x08); + unk_09 = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x09); + unk_0A = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0A); + unk_0B = BitConverter::ToUInt8BE(rawData, rawDataIndex + 0x0B); +} + +std::string CutsceneSubCommandEntry_Rumble::GetBodySourceCode() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X)", base, + startFrame, endFrame, unk_06, unk_07, unk_08); + } + + return StringHelper::Sprintf("CS_CMD_09(%i, %i, %i, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X)", + base, startFrame, endFrame, unk_06, unk_07, unk_08, unk_09, unk_0A, + unk_0B); +} + +size_t CutsceneSubCommandEntry_Rumble::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_Rumble::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + return StringHelper::Sprintf("CS_RUMBLE_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_CMD_09_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_SetTime::CutsceneSubCommandEntry_SetTime( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + hour = BitConverter::ToUInt8BE(rawData, rawDataIndex + 6); + minute = BitConverter::ToUInt8BE(rawData, rawDataIndex + 7); + unk_08 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); +} + +std::string CutsceneSubCommandEntry_SetTime::GetBodySourceCode() const +{ + return StringHelper::Sprintf("CS_TIME(%i, %i, %i, %i, %i, %i)", base, startFrame, endFrame, + hour, minute, unk_08); +} + +size_t CutsceneSubCommandEntry_SetTime::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_SetTime::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TIME_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_TextBox::CutsceneSubCommandEntry_TextBox( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + textId1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + textId2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); +} + +std::string CutsceneSubCommandEntry_TextBox::GetBodySourceCode() const +{ + if (type == 0xFFFF) + { + return StringHelper::Sprintf("CS_TEXT_NONE(%i, %i)", startFrame, endFrame); + } + if (type == 2) + { + return StringHelper::Sprintf("CS_TEXT_LEARN_SONG(%i, %i, %i, 0x%X)", base, startFrame, + endFrame, textId1); + } + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + switch (type) + { + case 0: + return StringHelper::Sprintf("CS_TEXT_DEFAULT(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 1: + return StringHelper::Sprintf("CS_TEXT_TYPE_1(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 3: + return StringHelper::Sprintf("CS_TEXT_TYPE_3(0x%X, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, textId1, textId2); + + case 4: + return StringHelper::Sprintf("CS_TEXT_BOSSES_REMAINS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + + case 5: + return StringHelper::Sprintf("CS_TEXT_ALL_NORMAL_MASKS(0x%X, %i, %i, 0x%X)", base, + startFrame, endFrame, textId1); + } + } + + return StringHelper::Sprintf("CS_TEXT_DISPLAY_TEXTBOX(0x%X, %i, %i, %i, 0x%X, 0x%X)", base, + startFrame, endFrame, type, textId1, textId2); +} + +size_t CutsceneSubCommandEntry_TextBox::GetRawSize() const +{ + return 0x0C; +} + +CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_TextBox::GetCommandMacro() const +{ + return StringHelper::Sprintf("CS_TEXT_LIST(%i)", numEntries); +} + +CutsceneSubCommandEntry_ActorAction::CutsceneSubCommandEntry_ActorAction( + const std::vector& rawData, offset_t rawDataIndex) + : CutsceneSubCommandEntry(rawData, rawDataIndex) +{ + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x6); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0x8); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0xA); + startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0xC); + startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x10); + startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x14); + endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x18); + endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x1C); + endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 0x20); + normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x24); + normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x28); + normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 0x2C); +} + +std::string CutsceneSubCommandEntry_ActorAction::GetBodySourceCode() const +{ + std::string result; + + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_ACTOR_ACTION"; + } + } + else + { + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + result = "CS_PLAYER_ACTION"; + } + else + { + result = "CS_NPC_ACTION"; + } + } + + result += + StringHelper::Sprintf("(%i, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, " + "%i, %i, %i, %i, %.11ef, %.11ef, %.11ef)", + base, startFrame, endFrame, rotX, rotY, rotZ, startPosX, startPosY, + startPosZ, endPosX, endPosY, endPosZ, normalX, normalY, normalZ); + return result; +} + +size_t CutsceneSubCommandEntry_ActorAction::GetRawSize() const +{ + return 0x30; +} + +CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + for (size_t i = 0; i < numEntries; i++) + { + auto* entry = new CutsceneSubCommandEntry_ActorAction(rawData, rawDataIndex); + entries.push_back(entry); + rawDataIndex += entry->GetRawSize(); + } +} + +std::string CutsceneCommand_ActorAction::GetCommandMacro() const +{ + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + if (static_cast(commandID) == + CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", numEntries); + } + return StringHelper::Sprintf("CS_ACTOR_ACTION_LIST(0x%03X, %i)", commandID, numEntries); + } + + if (static_cast(commandID) == CutsceneCommands::SetPlayerAction) + { + return StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i)", entries.size()); + } + return StringHelper::Sprintf("CS_NPC_ACTION_LIST(0x%03X, %i)", commandID, entries.size()); +} + +CutsceneCommand_Terminator::CutsceneCommand_Terminator(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate +} + +std::string CutsceneCommand_Terminator::GenerateSourceCode() const +{ + std::string result; + + result += StringHelper::Sprintf("CS_TERMINATOR(%i, %i, %i),\n", base, startFrame, endFrame); + + return result; +} + +size_t CutsceneCommand_Terminator::GetCommandSize() const +{ + return 0x10; +} + +CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, + offset_t rawDataIndex) + : CutsceneCommand(rawData, rawDataIndex) +{ + rawDataIndex += 4; + + base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); + startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); +} + +std::string CutsceneCommandSceneTransFX::GenerateSourceCode() const +{ + return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); +} + +size_t CutsceneCommandSceneTransFX::GetCommandSize() const +{ + return 0x10; +} diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h new file mode 100644 index 000000000..c46273587 --- /dev/null +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.h @@ -0,0 +1,267 @@ +#pragma once + +#include +#include +#include + +#include "Declaration.h" + +enum class CutsceneCommands +{ + SetCameraPos = 0x0001, + SetCameraFocus = 0x0002, + Misc = 0x0003, + SetLighting = 0x0004, + SetCameraPosLink = 0x0005, + SetCameraFocusLink = 0x0006, + Cmd07 = 0x0007, + Cmd08 = 0x0008, + Cmd09 = 0x0009, // Rumble + Textbox = 0x0013, + SetPlayerAction = 0x000A, + SetActorAction1 = 0x000F, + SetActorAction2 = 0x000E, + SetActorAction3 = 0x0019, + SetActorAction4 = 0x001D, + SetActorAction5 = 0x001E, + SetActorAction6 = 0x002C, + SetActorAction7 = 0x001F, + SetActorAction8 = 0x0031, + SetActorAction9 = 0x003E, + SetActorAction10 = 0x008F, + SetSceneTransFX = 0x002D, + PlayBGM = 0x0056, + StopBGM = 0x0057, + FadeBGM = 0x007C, + SetTime = 0x008C, + Terminator = 0x03E8, +}; + +typedef struct CsCommandListDescriptor +{ + const char* cmdMacro; + const char* args; +} CsCommandListDescriptor; + +class CutsceneSubCommandEntry +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t pad; + + uint32_t commandID; + + CutsceneSubCommandEntry(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneSubCommandEntry() = default; + + virtual std::string GetBodySourceCode() const; + + virtual size_t GetRawSize() const; +}; + +class CutsceneCommand +{ +public: + uint32_t commandID; + uint32_t commandIndex; + + uint32_t numEntries; + std::vector entries; + + CutsceneCommand(const std::vector& rawData, offset_t rawDataIndex); + virtual ~CutsceneCommand(); + + virtual std::string GetCommandMacro() const; + virtual std::string GenerateSourceCode() const; + virtual size_t GetCommandSize() const; + + virtual void SetCommandID(uint32_t nCommandID); +}; + +class CutsceneSubCommandEntry_GenericCmd : public CutsceneSubCommandEntry +{ +public: + CutsceneCommands commandId; + + uint32_t word0 = 0; + uint32_t word1 = 0; + + uint32_t unused1 = 0; + uint32_t unused2 = 0; + uint32_t unused3 = 0; + uint32_t unused4 = 0; + uint32_t unused5 = 0; + uint32_t unused6 = 0; + uint32_t unused7 = 0; + uint32_t unused8 = 0; + uint32_t unused9 = 0; + uint32_t unused10 = 0; + + CutsceneSubCommandEntry_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_GenericCmd : public CutsceneCommand +{ +public: + CutsceneCommand_GenericCmd(const std::vector& rawData, offset_t rawDataIndex, + CutsceneCommands cmdId); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCameraPoint : public CutsceneSubCommandEntry +{ +public: + int8_t continueFlag; + int8_t cameraRoll; + int16_t nextPointFrame; + float viewAngle; + int16_t posX, posY, posZ; + int16_t unused; + + CutsceneCameraPoint(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommandSetCameraPos : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unused; + + CutsceneCommandSetCameraPos(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; + + size_t GetCommandSize() const override; +}; + +class CutsceneCommandSceneTransFX : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + + CutsceneCommandSceneTransFX(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; + +class CutsceneSubCommandEntry_Rumble : public CutsceneSubCommandEntry +{ +public: + uint8_t unk_06; + uint8_t unk_07; + uint8_t unk_08; + uint8_t unk_09; + uint8_t unk_0A; + uint8_t unk_0B; + + CutsceneSubCommandEntry_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_Rumble : public CutsceneCommand +{ +public: + CutsceneCommand_Rumble(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_SetTime : public CutsceneSubCommandEntry +{ +public: + uint8_t hour; + uint8_t minute; + uint32_t unk_08; + + CutsceneSubCommandEntry_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_SetTime : public CutsceneCommand +{ +public: + CutsceneCommand_SetTime(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_TextBox : public CutsceneSubCommandEntry +{ +public: + uint16_t type; + uint16_t textId1; + uint16_t textId2; + + CutsceneSubCommandEntry_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_TextBox : public CutsceneCommand +{ +public: + CutsceneCommand_TextBox(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneSubCommandEntry_ActorAction : public CutsceneSubCommandEntry +{ +public: + uint16_t rotX, rotY, rotZ; + int32_t startPosX, startPosY, startPosZ; + int32_t endPosX, endPosY, endPosZ; + float normalX, normalY, normalZ; + + CutsceneSubCommandEntry_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + std::string GetBodySourceCode() const override; + + size_t GetRawSize() const override; +}; + +class CutsceneCommand_ActorAction : public CutsceneCommand +{ +public: + CutsceneCommand_ActorAction(const std::vector& rawData, offset_t rawDataIndex); + + std::string GetCommandMacro() const override; +}; + +class CutsceneCommand_Terminator : public CutsceneCommand +{ +public: + uint16_t base; + uint16_t startFrame; + uint16_t endFrame; + uint16_t unknown; + + CutsceneCommand_Terminator(const std::vector& rawData, offset_t rawDataIndex); + + std::string GenerateSourceCode() const override; + size_t GetCommandSize() const override; +}; diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index 71bb690c7..62f814b13 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -1,5 +1,9 @@ #include "ZCutscene.h" +#include + +#include "Globals.h" +#include "OtherStructs/CutsceneMM_Commands.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "WarningHandler.h" @@ -7,7 +11,7 @@ REGISTER_ZFILENODE(Cutscene, ZCutscene); -ZCutscene::ZCutscene(ZFile* nParent) : ZCutsceneBase(nParent) +ZCutscene::ZCutscene(ZFile* nParent) : ZResource(nParent) { } @@ -16,91 +20,20 @@ ZCutscene::~ZCutscene() for (CutsceneCommand* cmd : commands) delete cmd; } -CutsceneCommandSetCameraPos::~CutsceneCommandSetCameraPos() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSpecialAction::~CutsceneCommandSpecialAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandFadeBGM::~CutsceneCommandFadeBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandPlayBGM::~CutsceneCommandPlayBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandStopBGM::~CutsceneCommandStopBGM() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandEnvLighting::~CutsceneCommandEnvLighting() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown9::~CutsceneCommandUnknown9() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandUnknown::~CutsceneCommandUnknown() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandDayTime::~CutsceneCommandDayTime() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandTextbox::~CutsceneCommandTextbox() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandActorAction::~CutsceneCommandActorAction() -{ - for (auto e : entries) - delete e; -} - -CutsceneCommandSceneTransFX::~CutsceneCommandSceneTransFX() -{ -} std::string ZCutscene::GetBodySourceCode() const { std::string output = ""; - uint32_t curPtr = 0; output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),\n", commands.size(), endFrame); for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; - output += " " + cmd->GenerateSourceCode(curPtr); - curPtr += cmd->GetCommandSize(); + output += " " + cmd->GenerateSourceCode(); } - output += StringHelper::Sprintf(" CS_END(),\n", commands.size(), endFrame); + output += StringHelper::Sprintf(" CS_END(),", commands.size(), endFrame); return output; } @@ -115,12 +48,19 @@ size_t ZCutscene::GetRawDataSize() const for (size_t i = 0; i < commands.size(); i++) { CutsceneCommand* cmd = commands[i]; + size += cmd->GetCommandSize(); - size += 4; } // End - size += 8; + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + size += 4; + } + else + { + size += 8; + } return size; } @@ -135,153 +75,68 @@ void ZCutscene::ParseRawData() commands = std::vector(); endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; + offset_t currentPtr = rawDataIndex + 8; for (int32_t i = 0; i < numCommands; i++) { - int32_t id = BitConverter::ToInt32BE(rawData, currentPtr); + uint32_t id = BitConverter::ToUInt32BE(rawData, currentPtr); - if (id == -1) + if (id == 0xFFFFFFFF) break; - CutsceneCommands cmdID = (CutsceneCommands)GetCommandFromID(id); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("Cutscene Command: 0x%X (%i)\n", id, id); + } + currentPtr += 4; - int32_t numEntries = 1; + CutsceneCommand* cmd = nullptr; - for (int32_t j = 0; j < numEntries; j++) + if (Globals::Instance->game == ZGame::MM_RETAIL) { - CutsceneCommand* cmd = nullptr; - - switch (cmdID) - { - case CutsceneCommands::Cmd00: - break; - case CutsceneCommands::SetCameraPos: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocus: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SpecialAction: - cmd = new CutsceneCommandSpecialAction(rawData, currentPtr); - break; - case CutsceneCommands::SetLighting: - cmd = new CutsceneCommandEnvLighting(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraPosLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::SetCameraFocusLink: - cmd = new CutsceneCommandSetCameraPos(rawData, currentPtr); - break; - case CutsceneCommands::Cmd07: - break; - case CutsceneCommands::Cmd08: - break; - case CutsceneCommands::Cmd09: - cmd = new CutsceneCommandUnknown9(rawData, currentPtr); - break; - case CutsceneCommands::Textbox: - cmd = new CutsceneCommandTextbox(rawData, currentPtr); - break; - case CutsceneCommands::Unknown: - cmd = new CutsceneCommandUnknown(rawData, currentPtr); - break; - case CutsceneCommands::SetActorAction0: - case CutsceneCommands::SetActorAction1: - case CutsceneCommands::SetActorAction2: - case CutsceneCommands::SetActorAction3: - case CutsceneCommands::SetActorAction4: - case CutsceneCommands::SetActorAction5: - case CutsceneCommands::SetActorAction6: - case CutsceneCommands::SetActorAction7: - case CutsceneCommands::SetActorAction8: - case CutsceneCommands::SetActorAction9: - case CutsceneCommands::SetActorAction10: - cmd = new CutsceneCommandActorAction(rawData, currentPtr); - break; - case CutsceneCommands::SetSceneTransFX: - cmd = new CutsceneCommandSceneTransFX(rawData, currentPtr); - break; - case CutsceneCommands::Nop: - cmd = new CutsceneCommandNop(rawData, currentPtr); - break; - case CutsceneCommands::PlayBGM: - cmd = new CutsceneCommandPlayBGM(rawData, currentPtr); - break; - case CutsceneCommands::StopBGM: - cmd = new CutsceneCommandStopBGM(rawData, currentPtr); - break; - case CutsceneCommands::FadeBGM: - cmd = new CutsceneCommandFadeBGM(rawData, currentPtr); - break; - case CutsceneCommands::SetTime: - cmd = new CutsceneCommandDayTime(rawData, currentPtr); - break; - case CutsceneCommands::Terminator: - cmd = new CutsceneCommandTerminator(rawData, currentPtr); - break; - case CutsceneCommands::End: - cmd = new CutsceneCommandEnd(rawData, currentPtr); - break; - case CutsceneCommands::Error: - HANDLE_WARNING_RESOURCE(WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("cutscene command error %d", cmdID), - ""); - break; - } - - cmd->commandIndex = i; - cmd->commandID = (uint32_t)id; - currentPtr += (uint32_t)cmd->GetCommandSize(); - - commands.push_back(cmd); + cmd = GetCommandMM(id, currentPtr); } + else + { + cmd = GetCommandOoT(id, currentPtr); + } + + if (cmd == nullptr) + { + HANDLE_WARNING_RESOURCE( + WarningType::NotImplemented, parent, this, rawDataIndex, + StringHelper::Sprintf("Cutscene command not implemented"), + StringHelper::Sprintf("Command ID: 0x%X\nIndex: %d\ncurrentPtr-rawDataIndex: 0x%X", + id, i, currentPtr - rawDataIndex)); + cmd = new CutsceneMMCommand_NonImplemented(rawData, currentPtr); + } + + assert(cmd != nullptr); + + cmd->commandIndex = i; + cmd->SetCommandID(id); + size_t commmandSize = cmd->GetCommandSize(); + if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) + { + printf("\t Command size: 0x%zX (%zu)\n", commmandSize, commmandSize); + } + currentPtr += commmandSize - 4; + + commands.push_back(cmd); } } -CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) +CutsceneCommand* ZCutscene::GetCommandOoT(uint32_t id, offset_t currentPtr) const { + CutsceneCommands cmdID = static_cast(id); + + const auto& rawData = parent->GetRawData(); + switch (id) { - case 0x0003: - return CutsceneCommands::SpecialAction; - case 0x0004: - return CutsceneCommands::SetLighting; - case 0x0056: - return CutsceneCommands::PlayBGM; - case 0x0057: - return CutsceneCommands::StopBGM; - case 0x007C: - return CutsceneCommands::FadeBGM; - case 0x0009: - return CutsceneCommands::Cmd09; - case 0x0013: - return CutsceneCommands::Textbox; - case 0x008C: - return CutsceneCommands::SetTime; - case 0x0001: - return CutsceneCommands::SetCameraPos; - case 0x0002: - return CutsceneCommands::SetCameraFocus; - case 0x0005: - return CutsceneCommands::SetCameraPosLink; - case 0x0006: - return CutsceneCommands::SetCameraFocusLink; - case 0x0007: - return CutsceneCommands::Cmd07; - case 0x0008: - return CutsceneCommands::Cmd08; - case 0x03E8: - return CutsceneCommands::Terminator; - case 0xFFFF: - return CutsceneCommands::End; - case 0x002D: - return CutsceneCommands::SetSceneTransFX; - case 10: - return CutsceneCommands::SetActorAction0; - case 15: + case 10: // CutsceneCommands::SetPlayerAction + case 15: // CutsceneCommands::SetActorAction1 case 17: case 18: case 23: @@ -299,8 +154,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 138: case 139: case 144: - return CutsceneCommands::SetActorAction1; - case 14: + case 14: // CutsceneCommands::SetActorAction2 case 16: case 24: case 35: @@ -318,8 +172,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 125: case 131: case 141: - return CutsceneCommands::SetActorAction2; - case 25: + case 25: // CutsceneCommands::SetActorAction3 case 36: case 41: case 50: @@ -332,8 +185,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 121: case 126: case 132: - return CutsceneCommands::SetActorAction3; - case 29: + case 29: // CutsceneCommands::SetActorAction4 case 37: case 42: case 51: @@ -346,8 +198,7 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 108: case 127: case 133: - return CutsceneCommands::SetActorAction4; - case 30: + case 30: // CutsceneCommands::SetActorAction5 case 38: case 43: case 47: @@ -356,16 +207,14 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 83: case 128: case 135: - return CutsceneCommands::SetActorAction5; - case 44: + case 44: // CutsceneCommands::SetActorAction6 case 55: case 77: case 84: case 90: case 129: case 136: - return CutsceneCommands::SetActorAction6; - case 31: + case 31: // CutsceneCommands::SetActorAction7 case 52: case 57: case 58: @@ -373,19 +222,17 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 115: case 130: case 137: - return CutsceneCommands::SetActorAction7; - case 49: + case 49: // CutsceneCommands::SetActorAction8 case 60: case 89: case 111: case 114: case 134: case 142: - return CutsceneCommands::SetActorAction8; - case 62: - return CutsceneCommands::SetActorAction9; - case 143: - return CutsceneCommands::SetActorAction10; + case 62: // CutsceneCommands::SetActorAction9 + case 143: // CutsceneCommands::SetActorAction10 + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case 0x0B: case 0x0D: case 0x1A: @@ -403,835 +250,120 @@ CutsceneCommands ZCutscene::GetCommandFromID(int32_t id) case 0x70: case 0x71: case 0x4A: - return CutsceneCommands::Unknown; + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); } - HANDLE_WARNING_RESOURCE( - WarningType::NotImplemented, parent, this, rawDataIndex, - StringHelper::Sprintf("could not identify cutscene command. ID 0x%04X", id), ""); - - return CutsceneCommands::Error; -} - -ZResourceType ZCutscene::GetResourceType() const -{ - return ZResourceType::Cutscene; -} - -CutsceneCommand::CutsceneCommand([[maybe_unused]] const std::vector& rawData, - [[maybe_unused]] uint32_t rawDataIndex) -{ -} - -CutsceneCommand::~CutsceneCommand() -{ -} - -std::string CutsceneCommand::GetCName() -{ - return "SCmdCutsceneData"; -} - -std::string CutsceneCommand::GenerateSourceCode(uint32_t baseAddress) -{ - return StringHelper::Sprintf("%s CutsceneData%04XCmd%02X = { 0x%02X,", GetCName().c_str(), - baseAddress, commandIndex, commandID); -} - -size_t CutsceneCommand::GetCommandSize() -{ - return 4; -} - -CutsceneCameraPoint::CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex) -{ - continueFlag = rawData.at(rawDataIndex + 0); - cameraRoll = rawData.at(rawDataIndex + 1); - nextPointFrame = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - viewAngle = BitConverter::ToFloatBE(rawData, rawDataIndex + 4); - - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 8); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 10); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 12); - - unused = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -CutsceneCommandSetCameraPos::CutsceneCommandSetCameraPos(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - - entries = std::vector(); - - bool shouldContinue = true; - - uint32_t currentPtr = rawDataIndex + 8; - - while (shouldContinue) + switch (cmdID) { - CutsceneCameraPoint* camPoint = new CutsceneCameraPoint(rawData, currentPtr); - entries.push_back(camPoint); + case CutsceneCommands::Misc: + case CutsceneCommands::SetLighting: + case CutsceneCommands::PlayBGM: + case CutsceneCommands::StopBGM: + case CutsceneCommands::FadeBGM: + return new CutsceneCommand_GenericCmd(rawData, currentPtr, cmdID); - if (camPoint->continueFlag == -1) - shouldContinue = false; + case CutsceneCommands::SetCameraPos: + case CutsceneCommands::SetCameraFocus: + case CutsceneCommands::SetCameraPosLink: + case CutsceneCommands::SetCameraFocusLink: + return new CutsceneCommandSetCameraPos(rawData, currentPtr); - currentPtr += 16; + case CutsceneCommands::Cmd07: + break; + case CutsceneCommands::Cmd08: + break; + case CutsceneCommands::Cmd09: + return new CutsceneCommand_Rumble(rawData, currentPtr); + case CutsceneCommands::Textbox: + return new CutsceneCommand_TextBox(rawData, currentPtr); + + case CutsceneCommands::SetPlayerAction: + case CutsceneCommands::SetActorAction1: + case CutsceneCommands::SetActorAction2: + case CutsceneCommands::SetActorAction3: + case CutsceneCommands::SetActorAction4: + case CutsceneCommands::SetActorAction5: + case CutsceneCommands::SetActorAction6: + case CutsceneCommands::SetActorAction7: + case CutsceneCommands::SetActorAction8: + case CutsceneCommands::SetActorAction9: + case CutsceneCommands::SetActorAction10: + break; + + case CutsceneCommands::SetSceneTransFX: + return new CutsceneCommandSceneTransFX(rawData, currentPtr); + + case CutsceneCommands::SetTime: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneCommands::Terminator: + return new CutsceneCommand_Terminator(rawData, currentPtr); } + + return nullptr; } -// TODO -std::string CutsceneCommandSetCameraPos::GetCName() +CutsceneCommand* ZCutscene::GetCommandMM(uint32_t id, offset_t currentPtr) const { - return ""; -} + CutsceneMMCommands cmdID = static_cast(id); -std::string CutsceneCommandSetCameraPos::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; + const auto& rawData = parent->GetRawData(); - std::string listStr; - std::string posStr; - - if (commandID == (int32_t)CutsceneCommands::SetCameraFocus) + if (((id >= 100) && (id < 150)) || (id == 201) || ((id >= 450) && (id < 600))) { - listStr = "CS_CAM_FOCUS_POINT_LIST"; - posStr = "CS_CAM_FOCUS_POINT"; + return new CutsceneCommand_ActorAction(rawData, currentPtr); } - else if (commandID == (int32_t)CutsceneCommands::SetCameraFocusLink) + + switch (cmdID) { - listStr = "CS_CAM_FOCUS_POINT_PLAYER_LIST"; - posStr = "CS_CAM_FOCUS_POINT_PLAYER"; - } - else if (commandID == (int32_t)CutsceneCommands::SetCameraPosLink) - { - listStr = "CS_CAM_POS_PLAYER_LIST"; - posStr = "CS_CAM_POS_PLAYER"; - } - else - { - listStr = "CS_CAM_POS_LIST"; - posStr = "CS_CAM_POS"; + case CutsceneMMCommands::CS_CMD_MISC: + case CutsceneMMCommands::CS_CMD_SET_LIGHTING: + case CutsceneMMCommands::CS_CMD_SCENE_TRANS_FX: + case CutsceneMMCommands::CS_CMD_MOTIONBLUR: + case CutsceneMMCommands::CS_CMD_GIVETATL: + case CutsceneMMCommands::CS_CMD_PLAYSEQ: + case CutsceneMMCommands::CS_CMD_130: + case CutsceneMMCommands::CS_CMD_131: + case CutsceneMMCommands::CS_CMD_132: + case CutsceneMMCommands::CS_CMD_STOPSEQ: + case CutsceneMMCommands::CS_CMD_PLAYAMBIENCE: + case CutsceneMMCommands::CS_CMD_FADEAMBIENCE: + case CutsceneMMCommands::CS_CMD_TERMINATOR: + case CutsceneMMCommands::CS_CMD_CHOOSE_CREDITS_SCENES: + + case CutsceneMMCommands::CS_CMD_UNK_FA: + case CutsceneMMCommands::CS_CMD_UNK_FE: + case CutsceneMMCommands::CS_CMD_UNK_FF: + case CutsceneMMCommands::CS_CMD_UNK_100: + case CutsceneMMCommands::CS_CMD_UNK_101: + case CutsceneMMCommands::CS_CMD_UNK_102: + case CutsceneMMCommands::CS_CMD_UNK_103: + case CutsceneMMCommands::CS_CMD_UNK_104: + case CutsceneMMCommands::CS_CMD_UNK_105: + case CutsceneMMCommands::CS_CMD_UNK_108: + case CutsceneMMCommands::CS_CMD_UNK_109: + case CutsceneMMCommands::CS_CMD_UNK_12D: + return new CutsceneMMCommand_GenericCmd(rawData, currentPtr, cmdID); + + case CutsceneMMCommands::CS_CMD_TEXTBOX: + return new CutsceneCommand_TextBox(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_CAMERA: + return new CutsceneMMCommand_Camera(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESCREEN: + return new CutsceneMMCommand_FadeScreen(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_FADESEQ: + return new CutsceneMMCommand_FadeSeq(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SETTIME: + return new CutsceneCommand_SetTime(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_SET_PLAYER_ACTION: + return new CutsceneCommand_ActorAction(rawData, currentPtr); + case CutsceneMMCommands::CS_CMD_RUMBLE: + return new CutsceneCommand_Rumble(rawData, currentPtr); } - result += StringHelper::Sprintf("%s(%i, %i),\n", listStr.c_str(), startFrame, endFrame); - - for (size_t i = 0; i < entries.size(); i++) - { - std::string continueMacro = "CS_CMD_CONTINUE"; - if (entries[i]->continueFlag != 0) - continueMacro = "CS_CMD_STOP"; - result += StringHelper::Sprintf(" %s(%s, 0x%02X, %i, %ff, %i, %i, %i, 0x%04X),\n", - posStr.c_str(), continueMacro.c_str(), - entries[i]->cameraRoll, entries[i]->nextPointFrame, - entries[i]->viewAngle, entries[i]->posX, entries[i]->posY, - entries[i]->posZ, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandSetCameraPos::GetCommandSize() -{ - return 8 + (entries.size() * 16); -} - -MusicFadeEntry::MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unknown8 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 36); // Macro hardcodes it as zero - unknown9 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 40); // Macro hardcodes it as zero - unknown10 = BitConverter::ToUInt32BE(rawData, - rawDataIndex + 44); // Macro hardcodes it as zero -} - -CutsceneCommandFadeBGM::CutsceneCommandFadeBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicFadeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandFadeBGM::GetCName() -{ - return "CsCmdMusicFade"; -} - -std::string CutsceneCommandFadeBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_FADE_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_FADE_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -size_t CutsceneCommandFadeBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30 * entries.size(); -} - -MusicChangeEntry::MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - sequence = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unknown1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unknown2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unknown3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unknown4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unknown5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unknown6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unknown7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandPlayBGM::CutsceneCommandPlayBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandPlayBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_PLAY_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_PLAY_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->sequence, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->unknown0, entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, - entries[i]->unknown4, entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandPlayBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandPlayBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -CutsceneCommandStopBGM::CutsceneCommandStopBGM(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - uint32_t numEntries = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (uint32_t i = 0; i < numEntries; i++) - { - entries.push_back(new MusicChangeEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandStopBGM::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_STOP_BGM_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_STOP_BGM(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->sequence, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unknown0, - entries[i]->unknown1, entries[i]->unknown2, entries[i]->unknown3, entries[i]->unknown4, - entries[i]->unknown5, entries[i]->unknown6, entries[i]->unknown7); - } - - return result; -} - -std::string CutsceneCommandStopBGM::GetCName() -{ - return "CsCmdMusicChange"; -} - -size_t CutsceneCommandStopBGM::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 0x30; -} - -EnvLightingEntry::EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - setting = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); -} - -CutsceneCommandEnvLighting::CutsceneCommandEnvLighting(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new EnvLightingEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandEnvLighting::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_LIGHTING_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_LIGHTING(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", entries[i]->setting, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, entries[i]->unused1, - entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, entries[i]->unused5, - entries[i]->unused6, entries[i]->unused7); - } - - return result; -} - -std::string CutsceneCommandEnvLighting::GetCName() -{ - return "CsCmdEnvLighting"; -} - -size_t CutsceneCommandEnvLighting::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -Unknown9Entry::Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unk2 = rawData[rawDataIndex + 6]; - unk3 = rawData[rawDataIndex + 7]; - unk4 = rawData[rawDataIndex + 8]; - unused0 = rawData[rawDataIndex + 10]; - unused1 = rawData[rawDataIndex + 11]; - ; -} - -CutsceneCommandUnknown9::CutsceneCommandUnknown9(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new Unknown9Entry(rawData, rawDataIndex)); - rawDataIndex += 0x0C; - } -} - -std::string CutsceneCommandUnknown9::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_CMD_09_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf("\t\tCS_CMD_09(%i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->unk2, entries[i]->unk3, - entries[i]->unk4, entries[i]->unused0, entries[i]->unused1); - } - - return result; -} - -std::string CutsceneCommandUnknown9::GetCName() -{ - return "CsCmdUnknown9"; -} - -size_t CutsceneCommandUnknown9::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -UnkEntry::UnkEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - unused0 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused11 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandUnknown::CutsceneCommandUnknown(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new UnkEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandUnknown::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_UNK_DATA_LIST(0x%02X, %i),\n", commandID, entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_UNK_DATA(%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i),\n", - entries[i]->unused0, entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, - entries[i]->unused4, entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, - entries[i]->unused8, entries[i]->unused9, entries[i]->unused10, entries[i]->unused11); - } - - return result; -} - -std::string CutsceneCommandUnknown::GetCName() -{ - return "CsCmdUnknown1A"; -} - -size_t CutsceneCommandUnknown::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -DayTimeEntry::DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - hour = rawData[rawDataIndex + 6]; - minute = rawData[rawDataIndex + 7]; - unused = rawData[rawDataIndex + 8]; -} - -CutsceneCommandDayTime::CutsceneCommandDayTime(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new DayTimeEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandDayTime::GetCName() -{ - return "CsCmdDayTime"; -} - -std::string CutsceneCommandDayTime::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TIME_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - " CS_TIME(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, entries[i]->startFrame, - entries[i]->endFrame, entries[i]->hour, entries[i]->minute, entries[i]->unused); - } - - return result; -} - -size_t CutsceneCommandDayTime::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -TextboxEntry::TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - textID1 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - textID2 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); -} - -CutsceneCommandTextbox::CutsceneCommandTextbox(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new TextboxEntry(rawData, rawDataIndex)); - rawDataIndex += 12; - } -} - -std::string CutsceneCommandTextbox::GetCName() -{ - return "CsCmdTextbox"; -} - -std::string CutsceneCommandTextbox::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TEXT_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - if (entries[i]->base == 0xFFFF) - { - result += StringHelper::Sprintf(" CS_TEXT_NONE(%i, %i),\n", - entries[i]->startFrame, entries[i]->endFrame); - } - else - { - result += StringHelper::Sprintf( - " CS_TEXT_DISPLAY_TEXTBOX(%i, %i, %i, %i, %i, %i),\n", entries[i]->base, - entries[i]->startFrame, entries[i]->endFrame, entries[i]->type, entries[i]->textID1, - entries[i]->textID2); - } - } - - return result; -} - -size_t CutsceneCommandTextbox::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 12); -} - -ActorAction::ActorAction(const std::vector& rawData, uint32_t rawDataIndex) -{ - action = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - startPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 12); - startPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 16); - startPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 20); - endPosX = BitConverter::ToInt32BE(rawData, rawDataIndex + 24); - endPosY = BitConverter::ToInt32BE(rawData, rawDataIndex + 28); - endPosZ = BitConverter::ToInt32BE(rawData, rawDataIndex + 32); - normalX = BitConverter::ToFloatBE(rawData, rawDataIndex + 36); - normalY = BitConverter::ToFloatBE(rawData, rawDataIndex + 40); - normalZ = BitConverter::ToFloatBE(rawData, rawDataIndex + 44); -} - -CutsceneCommandActorAction::CutsceneCommandActorAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new ActorAction(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandActorAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - std::string subCommand; - - if (commandID == 10) - { - result += StringHelper::Sprintf("CS_PLAYER_ACTION_LIST(%i),\n", entries.size()); - subCommand = "CS_PLAYER_ACTION"; - } - else - { - result += StringHelper::Sprintf("CS_NPC_ACTION_LIST(%i, %i),\n", commandID, entries.size()); - subCommand = "CS_NPC_ACTION"; - } - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\t%s(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %.11ef, " - "%.11ef, %.11ef),\n", - subCommand.c_str(), entries[i]->action, entries[i]->startFrame, entries[i]->endFrame, - entries[i]->rotX, entries[i]->rotY, entries[i]->rotZ, entries[i]->startPosX, - entries[i]->startPosY, entries[i]->startPosZ, entries[i]->endPosX, entries[i]->endPosY, - entries[i]->endPosZ, entries[i]->normalX, entries[i]->normalY, entries[i]->normalZ); - } - - return result; -} - -std::string CutsceneCommandActorAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandActorAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (entries.size() * 0x30); -} - -CutsceneCommandTerminator::CutsceneCommandTerminator(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unknown = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); // endFrame duplicate -} - -std::string CutsceneCommandTerminator::GetCName() -{ - return "CsCmdBase"; -} - -std::string CutsceneCommandTerminator::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_TERMINATOR(0x%04X, %i, %i),\n", base, startFrame, endFrame); - - return result; -} - -size_t CutsceneCommandTerminator::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -CutsceneCommandEnd::CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandEnd::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_END(),\n"); - - return result; -} - -std::string CutsceneCommandEnd::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandEnd::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -SpecialActionEntry::SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); - unused0 = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - unused1 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 8); - unused2 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 12); - unused3 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 16); - unused4 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 20); - unused5 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 24); - unused6 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 28); - unused7 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 32); - unused8 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 36); - unused9 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 40); - unused10 = BitConverter::ToUInt32BE(rawData, rawDataIndex + 44); -} - -CutsceneCommandSpecialAction::CutsceneCommandSpecialAction(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - int32_t numEntries = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - - rawDataIndex += 4; - - for (int32_t i = 0; i < numEntries; i++) - { - entries.push_back(new SpecialActionEntry(rawData, rawDataIndex)); - rawDataIndex += 0x30; - } -} - -std::string CutsceneCommandSpecialAction::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - std::string result; - - result += StringHelper::Sprintf("CS_MISC_LIST(%i),\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - result += StringHelper::Sprintf( - "\t\tCS_MISC(0x%04X, %i, %i, 0x%04X, 0x%04X, 0x%04X, %i, %i, %i, %i, %i, %i, %i, " - "%i),\n", - entries[i]->base, entries[i]->startFrame, entries[i]->endFrame, entries[i]->unused0, - entries[i]->unused1, entries[i]->unused2, entries[i]->unused3, entries[i]->unused4, - entries[i]->unused5, entries[i]->unused6, entries[i]->unused7, entries[i]->unused8, - entries[i]->unused9, entries[i]->unused10); - } - - return result; -} - -std::string CutsceneCommandSpecialAction::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSpecialAction::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + (0x30 * entries.size()); -} - -CutsceneCommandNop::CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandNop::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandNop::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 6; -} - -CutsceneCommandSceneTransFX::CutsceneCommandSceneTransFX(const std::vector& rawData, - uint32_t rawDataIndex) - : CutsceneCommand(rawData, rawDataIndex) -{ - rawDataIndex += 4; - - base = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - startFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); - endFrame = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); -} - -std::string CutsceneCommandSceneTransFX::GenerateSourceCode([[maybe_unused]] uint32_t baseAddress) -{ - return StringHelper::Sprintf("CS_SCENE_TRANS_FX(%i, %i, %i),\n", base, startFrame, endFrame); -} - -std::string CutsceneCommandSceneTransFX::GetCName() -{ - return "CsCmdBase"; -} - -size_t CutsceneCommandSceneTransFX::GetCommandSize() -{ - return CutsceneCommand::GetCommandSize() + 8; -} - -ZCutsceneBase::ZCutsceneBase(ZFile* nParent) : ZResource(nParent) -{ + return nullptr; } -Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::string& bodyStr) +Declaration* ZCutscene::DeclareVar(const std::string& prefix, const std::string& bodyStr) { std::string auxName = name; @@ -1245,7 +377,12 @@ Declaration* ZCutsceneBase::DeclareVar(const std::string& prefix, const std::str return decl; } -std::string ZCutsceneBase::GetSourceTypeName() const +std::string ZCutscene::GetSourceTypeName() const { return "CutsceneData"; } + +ZResourceType ZCutscene::GetResourceType() const +{ + return ZResourceType::Cutscene; +} diff --git a/tools/ZAPD/ZAPD/ZCutscene.h b/tools/ZAPD/ZAPD/ZCutscene.h index 8e901e307..098f3ad86 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.h +++ b/tools/ZAPD/ZAPD/ZCutscene.h @@ -3,422 +3,13 @@ #include #include #include -#include "ZFile.h" -#include "ZResource.h" #include "tinyxml2.h" -enum class CutsceneCommands -{ - Cmd00 = 0x0000, - SetCameraPos = 0x0001, - SetCameraFocus = 0x0002, - SpecialAction = 0x0003, - SetLighting = 0x0004, - SetCameraPosLink = 0x0005, - SetCameraFocusLink = 0x0006, - Cmd07 = 0x0007, - Cmd08 = 0x0008, - Cmd09 = 0x0009, - Unknown = 0x001A, - Textbox = 0x0013, - SetActorAction0 = 0x000A, - SetActorAction1 = 0x000F, - SetActorAction2 = 0x000E, - SetActorAction3 = 0x0019, - SetActorAction4 = 0x001D, - SetActorAction5 = 0x001E, - SetActorAction6 = 0x002C, - SetActorAction7 = 0x001F, - SetActorAction8 = 0x0031, - SetActorAction9 = 0x003E, - SetActorAction10 = 0x008F, - SetSceneTransFX = 0x002D, - Nop = 0x000B, - PlayBGM = 0x0056, - StopBGM = 0x0057, - FadeBGM = 0x007C, - SetTime = 0x008C, - Terminator = 0x03E8, - End = 0xFFFF, - Error = 0xFEAF, -}; +#include "OtherStructs/Cutscene_Commands.h" +#include "ZFile.h" +#include "ZResource.h" -class CutsceneCameraPoint -{ -public: - int8_t continueFlag; - int8_t cameraRoll; - int16_t nextPointFrame; - float viewAngle; - int16_t posX, posY, posZ; - int16_t unused; - - CutsceneCameraPoint(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommand -{ -public: - uint32_t commandID; - uint32_t commandIndex; - virtual ~CutsceneCommand(); - CutsceneCommand(const std::vector& rawData, uint32_t rawDataIndex); - virtual std::string GetCName(); - virtual std::string GenerateSourceCode(uint32_t baseAddress); - virtual size_t GetCommandSize(); -}; - -class CutsceneCommandSetCameraPos : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused; - - std::vector entries; - ~CutsceneCommandSetCameraPos(); - CutsceneCommandSetCameraPos(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class SpecialActionEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - - SpecialActionEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandSpecialAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandSpecialAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandSpecialAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicFadeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - uint32_t unknown8; - uint32_t unknown9; - uint32_t unknown10; - - MusicFadeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandFadeBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandFadeBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandFadeBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class MusicChangeEntry -{ -public: - uint16_t sequence; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown0; - uint32_t unknown1; - uint32_t unknown2; - uint32_t unknown3; - uint32_t unknown4; - uint32_t unknown5; - uint32_t unknown6; - uint32_t unknown7; - - MusicChangeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandPlayBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandPlayBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandPlayBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandStopBGM : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandStopBGM(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandStopBGM(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class EnvLightingEntry -{ -public: - uint16_t setting; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - - EnvLightingEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandEnvLighting : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandEnvLighting(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandEnvLighting(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandSceneTransFX : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - ~CutsceneCommandSceneTransFX(); - CutsceneCommandSceneTransFX(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class Unknown9Entry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unk2; - uint16_t unk3; - uint16_t unk4; - uint8_t unused0; - uint8_t unused1; - - Unknown9Entry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown9 : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown9(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown9(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class UnkEntry -{ -public: - uint32_t unused0; - uint32_t unused1; - uint32_t unused2; - uint32_t unused3; - uint32_t unused4; - uint32_t unused5; - uint32_t unused6; - uint32_t unused7; - uint32_t unused8; - uint32_t unused9; - uint32_t unused10; - uint32_t unused11; - - UnkEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandUnknown : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandUnknown(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandUnknown(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class DayTimeEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint8_t hour; - uint8_t minute; - uint8_t unused; - - DayTimeEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandDayTime : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandDayTime(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandDayTime(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class TextboxEntry -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t type; - uint16_t textID1; - uint16_t textID2; - - TextboxEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandTextbox : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandTextbox(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandTextbox(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class ActorAction -{ -public: - uint16_t action; - uint16_t startFrame; - uint16_t endFrame; - int16_t rotX, rotY, rotZ; - int32_t startPosX, startPosY, startPosZ; - int32_t endPosX, endPosY, endPosZ; - float normalX, normalY, normalZ; - - ActorAction(const std::vector& rawData, uint32_t rawDataIndex); -}; - -class CutsceneCommandActorAction : public CutsceneCommand -{ -public: - std::vector entries; - - CutsceneCommandActorAction(const std::vector& rawData, uint32_t rawDataIndex); - ~CutsceneCommandActorAction(); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandTerminator : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - uint16_t unknown; - - CutsceneCommandTerminator(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandEnd : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandEnd(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - std::string GenerateSourceCode(uint32_t baseAddress); - size_t GetCommandSize(); -}; - -class CutsceneCommandNop : public CutsceneCommand -{ -public: - uint16_t base; - uint16_t startFrame; - uint16_t endFrame; - - CutsceneCommandNop(const std::vector& rawData, uint32_t rawDataIndex); - std::string GetCName(); - size_t GetCommandSize(); -}; - -class ZCutsceneBase : public ZResource -{ -public: - ZCutsceneBase(ZFile* nParent); - - Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; - - std::string GetSourceTypeName() const override; -}; - -class ZCutscene : public ZCutsceneBase +class ZCutscene : public ZResource { public: ZCutscene(ZFile* nParent); @@ -426,15 +17,20 @@ public: void ParseRawData() override; + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; size_t GetRawDataSize() const override; + std::string GetSourceTypeName() const override; ZResourceType GetResourceType() const override; - CutsceneCommands GetCommandFromID(int32_t id); - int32_t numCommands; int32_t endFrame; std::vector commands; + +protected: + CutsceneCommand* GetCommandOoT(uint32_t id, offset_t currentPtr) const; + CutsceneCommand* GetCommandMM(uint32_t id, offset_t currentPtr) const; }; diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp b/tools/ZAPD/ZAPD/ZCutsceneMM.cpp deleted file mode 100644 index d0208bc07..000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "ZCutsceneMM.h" - -#include "Utils/BitConverter.h" -#include "Utils/StringHelper.h" - -ZCutsceneMM::ZCutsceneMM(ZFile* nParent) : ZCutsceneBase(nParent) -{ -} - -ZCutsceneMM::~ZCutsceneMM() -{ - for (CutsceneCommand* cmd : commands) - delete cmd; -} - -std::string ZCutsceneMM::GetBodySourceCode() const -{ - std::string output; - - output += StringHelper::Sprintf(" CS_BEGIN_CUTSCENE(%i, %i),", numCommands, endFrame); - - for (size_t i = 0; i < data.size(); i++) - { - if ((i % 4) == 0) - output += "\n "; - output += StringHelper::Sprintf("0x%08X, ", data[i]); - } - - return output; -} - -size_t ZCutsceneMM::GetRawDataSize() const -{ - return 8 + data.size() * 4; -} - -void ZCutsceneMM::ParseRawData() -{ - const auto& rawData = parent->GetRawData(); - - numCommands = BitConverter::ToInt32BE(rawData, rawDataIndex + 0); - commands = std::vector(); - - endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); - uint32_t currentPtr = rawDataIndex + 8; - uint32_t lastData = 0; - - // TODO currently cutscenes aren't being parsed, so just consume words until we see an end - // marker. - do - { - lastData = BitConverter::ToInt32BE(rawData, currentPtr); - data.push_back(lastData); - currentPtr += 4; - } while (lastData != 0xFFFFFFFF); -} - -ZResourceType ZCutsceneMM::GetResourceType() const -{ - return ZResourceType::Cutscene; -} diff --git a/tools/ZAPD/ZAPD/ZCutsceneMM.h b/tools/ZAPD/ZAPD/ZCutsceneMM.h deleted file mode 100644 index 44b108d6c..000000000 --- a/tools/ZAPD/ZAPD/ZCutsceneMM.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include -#include -#include "ZCutscene.h" -#include "ZFile.h" -#include "tinyxml2.h" - -class ZCutsceneMM : public ZCutsceneBase -{ -public: - ZCutsceneMM(ZFile* nParent); - virtual ~ZCutsceneMM(); - - std::string GetBodySourceCode() const override; - - size_t GetRawDataSize() const override; - - void ParseRawData() override; - ZResourceType GetResourceType() const override; - -protected: - int32_t numCommands; - int32_t endFrame; - std::vector commands; - - std::vector data; -}; diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index d9733f326..b81399e2a 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -695,7 +695,7 @@ bool ZFile::GetDeclarationArrayIndexedName(segptr_t segAddress, size_t elementSi return true; } -Declaration* ZFile::GetDeclaration(uint32_t address) const +Declaration* ZFile::GetDeclaration(offset_t address) const { if (declarations.find(address) != declarations.end()) return declarations.at(address); @@ -703,7 +703,7 @@ Declaration* ZFile::GetDeclaration(uint32_t address) const return nullptr; } -Declaration* ZFile::GetDeclarationRanged(uint32_t address) const +Declaration* ZFile::GetDeclarationRanged(offset_t address) const { for (const auto decl : declarations) { @@ -714,7 +714,7 @@ Declaration* ZFile::GetDeclarationRanged(uint32_t address) const return nullptr; } -bool ZFile::HasDeclaration(uint32_t address) +bool ZFile::HasDeclaration(offset_t address) { assert(GETSEGNUM(address) == 0); return declarations.find(address) != declarations.end(); diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index 365c7bbbb..275e27f1b 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -81,9 +81,9 @@ public: const std::string& expectedType, std::string& declName) const; - Declaration* GetDeclaration(uint32_t address) const; - Declaration* GetDeclarationRanged(uint32_t address) const; - bool HasDeclaration(uint32_t address); + Declaration* GetDeclaration(offset_t address) const; + Declaration* GetDeclarationRanged(offset_t address) const; + bool HasDeclaration(offset_t address); std::string GetHeaderInclude() const; std::string GetZRoomHeaderInclude() const; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index e51e550b0..3820203ef 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -10,53 +10,65 @@ SetCutscenes::SetCutscenes(ZFile* nParent) : ZRoomCommand(nParent) { } -SetCutscenes::~SetCutscenes() -{ - for (ZCutsceneBase* cutscene : cutscenes) - delete cutscene; -} - void SetCutscenes::ParseRawData() { ZRoomCommand::ParseRawData(); - std::string output; numCutscenes = cmdArg1; - if (Globals::Instance->game == ZGame::OOT_RETAIL || Globals::Instance->game == ZGame::OOT_SW97) - { - ZCutscene* cutscene = new ZCutscene(parent); - cutscene->ExtractFromFile(segmentOffset); - auto decl = parent->GetDeclaration(segmentOffset); - if (decl == nullptr) - { - cutscene->DeclareVar(zRoom->GetName().c_str(), ""); - } - - cutscenes.push_back(cutscene); - } - else + if (Globals::Instance->game == ZGame::MM_RETAIL) { int32_t currentPtr = segmentOffset; - std::string declaration; for (uint8_t i = 0; i < numCutscenes; i++) { CutsceneEntry entry(parent->GetRawData(), currentPtr); cutsceneEntries.push_back(entry); currentPtr += 8; + } + } +} - // TODO: don't hardcode %sCutsceneData_%06X, look up for the declared name instead - declaration += StringHelper::Sprintf( - " { %sCutsceneData_%06X, 0x%04X, 0x%02X, 0x%02X },", zRoom->GetName().c_str(), - entry.segmentOffset, entry.exit, entry.entrance, entry.flag); +void SetCutscenes::DeclareReferences(const std::string& prefix) +{ + std::string varPrefix = name; + if (varPrefix == "") + varPrefix = prefix; - if (i < numCutscenes - 1) + if (Globals::Instance->game == ZGame::MM_RETAIL) + { + std::string declaration; + size_t i = 0; + + for (const auto& entry : cutsceneEntries) + { + if (entry.segmentPtr != SEGMENTED_NULL && + GETSEGNUM(entry.segmentPtr) == parent->segment) + { + offset_t csOffset = Seg2Filespace(entry.segmentPtr, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) + { + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); + } + } + + std::string csName; + Globals::Instance->GetSegmentedPtrName(entry.segmentPtr, parent, "CutsceneData", + csName); + + declaration += + StringHelper::Sprintf(" { %s, 0x%04X, 0x%02X, 0x%02X },", csName.c_str(), + entry.exit, entry.entrance, entry.flag); + + if (i + 1 < numCutscenes) declaration += "\n"; - ZCutsceneMM* cutscene = new ZCutsceneMM(parent); - cutscene->ExtractFromFile(entry.segmentOffset); - cutscenes.push_back(cutscene); + i++; } parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, @@ -65,19 +77,19 @@ void SetCutscenes::ParseRawData() zRoom->GetName().c_str(), segmentOffset), cutsceneEntries.size(), declaration); } - - for (ZCutsceneBase* cutscene : cutscenes) + else { - if (cutscene->GetRawDataIndex() != 0) + if (cmdArg2 != SEGMENTED_NULL && GETSEGNUM(cmdArg2) == parent->segment) { - Declaration* decl = parent->GetDeclaration(cutscene->GetRawDataIndex()); - if (decl == nullptr) + offset_t csOffset = Seg2Filespace(cmdArg2, parent->baseAddress); + if (!parent->HasDeclaration(csOffset)) { - cutscene->GetSourceOutputCode(zRoom->GetName()); - } - else if (decl->text == "") - { - decl->text = cutscene->GetBodySourceCode(); + auto* cutscene = new ZCutscene(parent); + cutscene->ExtractFromFile(csOffset); + cutscene->SetName(cutscene->GetDefaultName(varPrefix)); + cutscene->DeclareVar(varPrefix, ""); + cutscene->DeclareReferences(varPrefix); + parent->AddResource(cutscene); } } } @@ -86,11 +98,15 @@ void SetCutscenes::ParseRawData() std::string SetCutscenes::GetBodySourceCode() const { std::string listName; - Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); if (Globals::Instance->game == ZGame::MM_RETAIL) + { + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneEntry", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_LIST(%i, %s)", numCutscenes, listName.c_str()); + } + + Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "CutsceneData", listName); return StringHelper::Sprintf("SCENE_CMD_CUTSCENE_DATA(%s)", listName.c_str()); } @@ -105,7 +121,7 @@ RoomCommand SetCutscenes::GetRoomCommand() const } CutsceneEntry::CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex) - : segmentOffset(GETSEGOFFSET(BitConverter::ToInt32BE(rawData, rawDataIndex + 0))), + : segmentPtr(BitConverter::ToInt32BE(rawData, rawDataIndex + 0)), exit(BitConverter::ToInt16BE(rawData, rawDataIndex + 4)), entrance(rawData[rawDataIndex + 6]), flag(rawData[rawDataIndex + 7]) { diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h index ad032bbe6..81a622c5b 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.h @@ -1,7 +1,6 @@ #pragma once #include "ZCutscene.h" -#include "ZCutsceneMM.h" #include "ZRoom/ZRoomCommand.h" class CutsceneEntry @@ -9,7 +8,7 @@ class CutsceneEntry public: CutsceneEntry(const std::vector& rawData, uint32_t rawDataIndex); - uint32_t segmentOffset; + segptr_t segmentPtr; uint16_t exit; uint8_t entrance; uint8_t flag; @@ -18,14 +17,13 @@ public: class SetCutscenes : public ZRoomCommand { public: - std::vector cutscenes; std::vector cutsceneEntries; // (MM Only) uint8_t numCutscenes; // (MM Only) SetCutscenes(ZFile* nParent); - ~SetCutscenes(); void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; std::string GetBodySourceCode() const override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp index 7027fa1f9..20138dd4d 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -104,9 +104,8 @@ std::string RomFile::GetBodySourceCode() const if (!isFirst) declaration += "\n"; - declaration += - StringHelper::Sprintf("\t{ (u32)_%sSegmentRomStart, (u32)_%sSegmentRomEnd },", - roomName.c_str(), roomName.c_str()); + declaration += StringHelper::Sprintf("\t{ _%sSegmentRomStart, _%sSegmentRomEnd },", + roomName.c_str(), roomName.c_str()); isFirst = false; } } diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index ff4333129..b3f7ce8c0 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -159,8 +159,8 @@ std::string ZSkeleton::GetBodySourceCode() const return StringHelper::Sprintf("\n\t%s, %s\n", limbArrayName.c_str(), countStr.c_str()); case ZSkeletonType::Flex: - return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), countStr.c_str(), - dListCount); + return StringHelper::Sprintf("\n\t{ %s, %s }, %i\n", limbArrayName.c_str(), + countStr.c_str(), dListCount); } // TODO: Throw exception? diff --git a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h index 98c46bc79..ac82c24ca 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h +++ b/tools/ZAPD/ZAPDUtils/Utils/BitConverter.h @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt index 015e7e88a..cc7b36b5e 100644 --- a/tools/ZAPDConfigs/MM/SymbolMap_MM.txt +++ b/tools/ZAPDConfigs/MM/SymbolMap_MM.txt @@ -1 +1 @@ -8012DB20 gMtxClear \ No newline at end of file +801D1DE0 gIdentityMtx diff --git a/tools/actorfixer.py b/tools/actorfixer.py index 990d67251..8c2c48a5f 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -213,7 +213,8 @@ animdict = { "func_800BE2B8": "Actor_SetDropFlagJntSph", "Actor_TitleCardCreate": "TitleCard_InitBossName", "func_800B867C": "Actor_TextboxIsClosing", - "func_800BDC5C": "Actor_ChangeAnimation", + "func_800BDC5C": "Actor_ChangeAnimationByInfo", + "Actor_ChangeAnimation(": "Actor_ChangeAnimationByInfo(", "func_80152498": "Message_GetState", "func_800B8898": "Actor_GetScreenPos", "Audio_PlayActorSound2": "Actor_PlaySfxAtPos", @@ -231,6 +232,8 @@ animdict = { "MainHeap_Init": "ZeldaArena_Init", "MainHeap_Cleanup": "ZeldaArena_Cleanup", "MainHeap_IsInitialized": "ZeldaArena_IsInitialized", + "func_80138300": "Skin_GetLimbPos", + "func_8013835C": "Skin_GetVertexPos", # "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", # "BgCheck_AddActorMesh": "DynaPoly_SetBgActor", # "BgCheck_RemoveActorMesh": "DynaPoly_DeleteBgActor", @@ -246,6 +249,8 @@ animdict = { "BgCheck_CreateVertexFromVec3f": "BgCheck_Vec3fToVec3s", "BgCheck_PolygonGetMinY": "CollisionPoly_GetMinY", "BgCheck_PolygonGetNormal": "CollisionPoly_GetNormalF", + "BcCheck3_BgActorInit": "DynaPolyActor_Init", + "BgCheck3_LoadMesh": "DynaPolyActor_LoadMesh", "func_800C01B8": "CollisionPoly_GetPointDistanceFromPlane", "BgCheck_CreateTriNormFromPolygon": "CollisionPoly_GetVertices", "func_800C02C0": "CollisionPoly_GetVerticesByBgId", @@ -378,6 +383,33 @@ animdict = { "func_8017F9C0": "Math3D_XZInSphere", "func_8017FA34": "Math3D_XYInSphere", "func_8017FAA8": "Math3D_YZInSphere", + "func_800DFB14": "Camera_ChangeDataIdx", + "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_801694DC": "Play_CreateSubCamera", + "Play_GetActiveCameraIndex": "Play_GetActiveCamId", + "func_80169590": "Play_CameraChangeStatus", + "func_80169600": "Play_ClearCamera", + "func_80169668": "Play_ClearAllSubCameras", + "func_8016981C": "Play_CameraSetAtEyeUp", + "func_80169940": "Play_CameraSetFov", + "func_80169988": "Play_CameraSetRoll", + "func_801699D4": "Play_CopyCamera", + "func_80169AC0": "Play_CameraChangeSetting", + "func_80169BC4": "Play_CameraGetUID", + "func_80169C64": "Play_GetCsCamDataSetting", + "func_80169C84": "Play_GetCsCamDataVec3s", + "convert_scene_number_among_shared_scenes": "Play_GetOriginalSceneNumber", + "func_80169D40": "Play_SaveCycleSceneFlags", + "func_80169DCC": "Play_SetRespawnData", + "func_80169E6C": "Play_SetupRespawnPoint", + "func_8016A0AC": "Play_IsUnderwater", + "func_801690CC": "Play_InCsMode", + "func_8017D2FC": "Math3D_LineSegVsPlane", "func_8013A7C0": "SubS_FindDoor", "func_8013E640": "SubS_FindActorCustom", "func_ActorCategoryIterateById": "SubS_FindActor", @@ -385,10 +417,71 @@ animdict = { "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", + "func_800F5A8C": "Environment_LerpWeight", + "func_801A3F54": "Audio_SetCutsceneFlag", + "func_800EA0D4": "Cutscene_Start", + "func_800EA0EC": "Cutscene_End", + "func_800EDE34": "Cutscene_ActorTranslate", + "func_800EDF24": "Cutscene_ActorTranslateAndYaw", + "func_800EDF78": "Cutscene_ActorTranslateAndYawSmooth", + "func_800EE0CC": "Cutscene_ActorTranslateXZAndYawSmooth", + "func_800EE1D8": "Cutscene_GetSceneSetupIndex", + "func_800EE200": "Cutscene_GetActorActionIndex", + "func_800EE29C": "Cutscene_CheckActorAction", + "func_800EE2F4": "Cutscene_IsPlaying", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", "func_8013AB00": "SubS_DrawTransformFlex", "func_8013A860": "SubS_DrawTransformFlexLimb", + "func_8013BC6C": "SubS_ChangeAnimationByInfoS", + "func_8013E1C8": "SubS_ChangeAnimationBySpeedInfo", + "func_8013D9C8": "SubS_FillLimbRotTables", + "func_80114E90": "Inventory_HasEmptyBottle", + "func_80114F2C": "Interface_HasItemInBottle", + "func_80123C90": "Player_SetEquipmentData", + "Quake2_ClearType": "Distortion_ClearType", + "Quake2_SetType": "Distortion_SetType", + "Quake2_SetCountdown": "Distortion_SetCountdown", + "func_800BE680": "Actor_DrawDamageEffects", + "func_8013E2D4": "SubS_StartActorCutscene", + "func_8013E3B8": "SubS_FillCutscenesList", + "func_8013AED4": "SubS_UpdateFlags", + "func_8013D8DC": "SubS_IsObjectLoaded", + "func_8013D924": "SubS_GetObjectIndex", + "func_8013D5E8": "SubS_AngleDiffLessEqual", + "func_8012F22C": "Inventory_GetSkullTokenCount", + "func_8013DCE0": "SubS_ActorPathing_Init", + "func_8013DE04": "SubS_ActorPathing_Update", + "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", + "func_8013E054": "SubS_ActorPathing_MoveWithGravity", + "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", + "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", + "func_8013BB34": "SubS_GetAdditionalPath", + "func_8013BD40": "SubS_HasReachedPoint", + "func_8013BEDC": "SubS_GetDayDependentPath", + "func_8013C8B8": "SubS_CopyPointFromPathCheckBounds", + "func_8013D648": "SubS_GetPathByIndex", + "func_8013D68C": "SubS_CopyPointFromPath", + "func_8013D720": "SubS_GetDistSqAndOrientPoints", + "func_8013D768": "SubS_MoveActorToPoint", + "func_8013D83C": "SubS_GetDistSqAndOrientPath", + "func_8013DB90": "SubS_IsFloorAbove", + "func_8013DC40": "SubS_CopyPointFromPathList", + "func_8013DCCC": "SubS_GetPathCount", + + "func_80147624": "Message_ShouldAdvance", + "func_80147734": "Message_ShouldAdvanceSilent", + "func_80149EBC": "Message_FindMessage", + "func_8014CC14": "Message_LoadChar", + "func_801518B0": "Message_StartTextbox", + "func_801588D0": "Message_FindMessageNES", + "func_80158988": "Message_LoadCharNES", + "func_80158A24": "Message_LoadPluralRupeesNES", + "func_80158C04": "Message_LoadLocalizedRupeesNES", + "func_80158D98": "Message_LoadRupeesNES", + "func_80158FB0": "Message_LoadTimeNES", + "func_8015926C": "Message_LoadAreaTextNES", + "func_8015E750": "Message_FindCreditsMessage", # Structs members @@ -408,11 +501,34 @@ animdict = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", + "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", - "globalCtx->mf_187FC": "globalCtx->billboardMtxF", - "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", + "gSaveContext.weekEventReg": "gSaveContext.save.weekEventReg", + "gSaveContext.playerForm": "gSaveContext.save.playerForm", + "gSaveContext.day": "gSaveContext.save.day", + "gSaveContext.isNight": "gSaveContext.save.isNight", + "gSaveContext.naviTimer": "gSaveContext.save.playerData.tatlTimer", + "gSaveContext.tatlTimer": "gSaveContext.save.playerData.tatlTimer", + "gSaveContext.rupees": "gSaveContext.save.playerData.rupees", + "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", + "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", + "gSaveContext.doubleDefense": "gSaveContext.save.playerData.doubleDefense", + "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", + "gSaveContext.inventory": "gSaveContext.save.inventory", + "gSaveContext.equippedMask": "gSaveContext.save.equippedMask", + "gSaveContext.entranceIndex": "gSaveContext.save.entranceIndex", + "gSaveContext.time": "gSaveContext.save.time", + "gSaveContext.unk_14": "gSaveContext.save.daySpeed", + "gSaveContext.unk_FE6": "gSaveContext.save.bombersCaughtNum", + "gSaveContext.unk_FE7": "gSaveContext.save.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", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", "player->unk_384": "player->getItemId", @@ -420,16 +536,40 @@ animdict = { "player->unk_388": "player->interactRangeActor", "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", - "player->unk_A87": "player->exchangeItemId", + "csCtx.npcActions": "csCtx.actorActions", + "csCtx->npcActions": "csCtx->actorActions", + "csCtx.unk_12": "csCtx.currentCsIndex", + "globalCtx->mf_187FC": "globalCtx->billboardMtxF", + "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", + "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", + "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", + "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", + "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", + "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", + "gSaveContext.unk_1016": "gSaveContext.jinxTimer", + "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", + "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", + "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", + "globalCtx->msgCtx.unk11F04": "globalCtx->msgCtx.currentTextId", - # Variables - "D_0407D590": "gGameplayKeepDrawFlameDL", - "D_801D15B0": "gZeroVec3f", - "D_801D15BC": "gZeroVec3s", - "D_801D1DE0": "gIdentityMtx", - "D_801D1E20": "gIdentityMtxF", + "D_801D15B0" : "gZeroVec3f", + "D_801D15BC" : "gZeroVec3s", + "D_801D1DE0" : "gIdentityMtx", + "D_801D1E20" : "gIdentityMtxF", + "D_04020658" : "gameplay_keep_Anim_020658", + "D_04022B28" : "gDoorSkel", + "D_04023100" : "gDoorCol", + # Structs + "ActorAnimationEntry": "AnimationInfo", + "ActorAnimationEntryS": "AnimationInfoS", + "struct_80B8E1A8": "AnimationSpeedInfo", + + # Macros + "CUR_EQUIP_VALUE_VOID": "GET_CUR_EQUIP_VALUE", + "CUR_UPG_VALUE_VOID": "GET_CUR_UPG_VALUE", "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", } @@ -467,20 +607,20 @@ def replace_anim_all(repo): for filename in files: if(filename.endswith('.s')): file = subdir + os.sep + filename - replace_anim(file) + replace_anim(file) for subdir, dirs, files in os.walk(repo + os.sep + 'data'): for filename in files: if(filename.endswith('.s')): file = subdir + os.sep + filename replace_anim(file) - + for subdir, dirs, files in os.walk(repo + os.sep + 'docs'): for filename in files: if(filename.endswith('.md')): file = subdir + os.sep + filename replace_anim(file) - + for subdir, dirs, files in os.walk(repo + os.sep + 'tools' + os.sep + 'sizes'): for filename in files: if(filename.endswith('.csv')): diff --git a/tools/asm-differ/.gitrepo b/tools/asm-differ/.gitrepo index 48e215c08..8d0a6445d 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 = 6f8f80b719359d018a2b734288c977aae6538870 - parent = 91a6e9f647d2035eba281d286c78f089f70f269f + commit = 1236288d1520335c2bfb672078fec65084d7cb5c + parent = 2c5690701a350c7e7c3d6252dff925ad65d59910 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 6695f71ac..ccc4afc0e 100644 --- a/tools/asm-differ/.pre-commit-config.yaml +++ b/tools/asm-differ/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.1.0 hooks: - id: black - language_version: python3.6 diff --git a/tools/asm-differ/README.md b/tools/asm-differ/README.md index 4a7f329b3..205310d39 100644 --- a/tools/asm-differ/README.md +++ b/tools/asm-differ/README.md @@ -11,10 +11,10 @@ Nice differ for assembly code. Currently supports MIPS, PPC, AArch64, and ARM32; ## Usage -Create a file `diff_settings.sh` in some directory (see the one in this repo for an example). Then from that directory, run +Create a file `diff_settings.py` in some directory (see the one in this repo for an example). Then from that directory, run ```bash -/path/to/diff.sh [flags] (function|rom addr) +/path/to/diff.py [flags] (function|rom addr) ``` Recommended flags are `-mwo` (automatically run `make` on source file changes, and include symbols in diff). See `--help` for more details. diff --git a/tools/asm-differ/diff.py b/tools/asm-differ/diff.py index 9781420bb..4b5bc892e 100755 --- a/tools/asm-differ/diff.py +++ b/tools/asm-differ/diff.py @@ -109,6 +109,15 @@ if __name__ == "__main__": help="""Diff .o files rather than a whole binary. This makes it possible to see symbol names. (Recommended)""", ) + parser.add_argument( + "-f", + "--objfile", + dest="objfile", + type=str, + help="""File path for an object file being diffed. When used + the map file isn't searched for the function given. Useful for dynamically + linked libraries.""", + ) parser.add_argument( "-e", "--elf", @@ -132,6 +141,14 @@ if __name__ == "__main__": help="""Tweak --source handling to make it work with binutils < 2.33. Implies --source.""", ) + parser.add_argument( + "-j", + "--section", + dest="diff_section", + default=".text", + metavar="SECTION", + help="Diff restricted to a given output section.", + ) parser.add_argument( "-L", "--line-numbers", @@ -356,6 +373,7 @@ except ModuleNotFoundError as e: class ProjectSettings: arch_str: str objdump_executable: str + objdump_flags: List[str] build_command: List[str] map_format: str mw_build_dir: str @@ -365,6 +383,7 @@ class ProjectSettings: source_directories: Optional[List[str]] source_extensions: List[str] show_line_numbers_default: bool + disassemble_all: bool @dataclass @@ -379,8 +398,10 @@ class Config: # Build/objdump options diff_obj: bool + objfile: Optional[str] make: bool source_old_binutils: bool + diff_section: str inlines: bool max_function_size_lines: int max_function_size_bytes: int @@ -422,9 +443,11 @@ def create_project_settings(settings: Dict[str, Any]) -> ProjectSettings: "source_extensions", [".c", ".h", ".cpp", ".hpp", ".s"] ), objdump_executable=get_objdump_executable(settings.get("objdump_executable")), + objdump_flags=settings.get("objdump_flags", []), map_format=settings.get("map_format", "gnu"), mw_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), ) @@ -461,8 +484,10 @@ def create_config(args: argparse.Namespace, project: ProjectSettings) -> Config: arch=arch, # Build/objdump options diff_obj=args.diff_obj, + objfile=args.objfile, make=args.make, source_old_binutils=args.source_old_binutils, + diff_section=args.diff_section, inlines=args.inlines, max_function_size_lines=args.max_lines, max_function_size_bytes=args.max_lines * 4, @@ -518,7 +543,7 @@ def get_arch(arch_str: str) -> "ArchSettings": raise ValueError(f"Unknown architecture: {arch_str}") -BUFFER_CMD: List[str] = ["tail", "-c", str(10 ** 9)] +BUFFER_CMD: List[str] = ["tail", "-c", str(10**9)] # -S truncates long lines instead of wrapping them # -R interprets color escape sequences @@ -809,12 +834,7 @@ class JsonFormatter(Formatter): return {"text": s, "format": f.name.lower()} elif isinstance(f, RotationFormat): attrs = asdict(f) - attrs.update( - { - "text": s, - "format": "rotation", - } - ) + attrs.update({"text": s, "format": "rotation"}) return attrs else: static_assert_unreachable(f) @@ -962,7 +982,7 @@ def restrict_to_function(dump: str, fn_name: str) -> str: return "" -def serialize_data_references(references: List[Tuple[int, int, str]]) -> str: +def serialize_rodata_references(references: List[Tuple[int, int, str]]) -> str: return "".join( f"DATAREF {text_offset} {from_offset} {from_section}\n" for (text_offset, from_offset, from_section) in references @@ -991,7 +1011,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - flags, target, restrict = cmd try: out = subprocess.run( - [project.objdump_executable] + config.arch.arch_flags + flags + [target], + [project.objdump_executable] + + config.arch.arch_flags + + project.objdump_flags + + flags + + [target], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -1009,11 +1033,11 @@ def run_objdump(cmd: ObjdumpCommand, config: Config, project: ProjectSettings) - with open(target, "rb") as f: obj_data = f.read() - return preprocess_objdump_out(restrict, obj_data, out) + return preprocess_objdump_out(restrict, obj_data, out, config) def preprocess_objdump_out( - restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str + restrict: Optional[str], obj_data: Optional[bytes], objdump_out: str, config: Config ) -> str: """ Preprocess the output of objdump into a format that `process()` expects. @@ -1033,13 +1057,16 @@ def preprocess_objdump_out( out = out.rstrip("\n") if obj_data: - out = serialize_data_references(parse_elf_data_references(obj_data)) + out + out = ( + serialize_rodata_references(parse_elf_rodata_references(obj_data, config)) + + out + ) return out def search_map_file( - fn_name: str, project: ProjectSettings + fn_name: str, project: ProjectSettings, config: Config ) -> Tuple[Optional[str], Optional[int]]: if not project.mapfile: fail(f"No map file configured; cannot find function {fn_name}.") @@ -1059,7 +1086,7 @@ def search_map_file( cands = [] last_line = "" for line in lines: - if line.startswith(" .text"): + if line.startswith(" " + config.diff_section): cur_objfile = line.split()[3] if "load address" in line: tokens = last_line.split() + line.split() @@ -1084,9 +1111,12 @@ def search_map_file( re.compile( # ram elf rom r" \S+ \S+ (\S+) (\S+) . " - + fn_name - # object name - + r"(?: \(entry of \.(?:init|text)\))? \t(\S+)" + + re.escape(fn_name) + + r"(?: \(entry of " + + re.escape(config.diff_section) + + r"\))? \t" + # object name + + "(\S+)" ), contents, ) @@ -1121,7 +1151,9 @@ def search_map_file( return None, None -def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: +def parse_elf_rodata_references( + data: bytes, config: Config +) -> List[Tuple[int, int, str]]: e_ident = data[:16] if e_ident[:4] != b"\x7FELF": return [] @@ -1134,7 +1166,6 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: is_little_endian = e_ident[5] == 1 str_end = "<" if is_little_endian else ">" str_off = "I" if is_32bit else "Q" - sym_size = {"B": 1, "H": 2, "I": 4, "Q": 8} def read(spec: str, offset: int) -> Tuple[int, ...]: spec = spec.replace("P", str_off) @@ -1186,7 +1217,12 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: assert len(symtab_sections) == 1 symtab = sections[symtab_sections[0]] - text_sections = [i for i in range(e_shnum) if sec_names[i] == b".text" and sections[i].sh_size != 0] + section_name = config.diff_section.encode("utf-8") + text_sections = [ + i + for i in range(e_shnum) + if sec_names[i] == section_name and sections[i].sh_size != 0 + ] if len(text_sections) != 1: return [] text_section = text_sections[0] @@ -1195,11 +1231,10 @@ def parse_elf_data_references(data: bytes) -> List[Tuple[int, int, str]]: for s in sections: if s.sh_type == SHT_REL or s.sh_type == SHT_RELA: if s.sh_info == text_section: - # Skip .text -> .text references + # Skip section_name -> section_name references continue sec_name = sec_names[s.sh_info].decode("latin1") - if sec_name == ".mwcats.text": - # Skip Metrowerks CATS Utility section + if sec_name != ".rodata": continue sec_base = sections[s.sh_info].sh_offset for i in range(0, s.sh_size, s.sh_entsize): @@ -1257,11 +1292,16 @@ def dump_elf( f"--stop-address={end_addr}", ] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + flags2 = [ f"--disassemble={diff_elf_symbol}", ] - objdump_flags = ["-drz", "-j", ".text"] + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( project.myimg, (objdump_flags + flags1, project.baseimg, None), @@ -1283,7 +1323,10 @@ def dump_objfile( if start.startswith("0"): fail("numerical start address not supported with -o; pass a function name") - objfile, _ = search_map_file(start, project) + objfile = config.objfile + if not objfile: + objfile, _ = search_map_file(start, project, config) + if not objfile: fail("Not able to find .o file for function.") @@ -1297,7 +1340,12 @@ def dump_objfile( if not os.path.isfile(refobjfile): fail(f'Please ensure an OK .o file exists at "{refobjfile}".') - objdump_flags = ["-drz", "-j", ".text"] + if project.disassemble_all: + disassemble_flag = "-D" + else: + disassemble_flag = "-d" + + objdump_flags = [disassemble_flag, "-rz", "-j", config.diff_section] return ( objfile, (objdump_flags, refobjfile, start), @@ -1314,7 +1362,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) + _, start_addr = search_map_file(start, project, config) if start_addr is None: fail("Not able to find function in map file.") if end is not None: @@ -1333,6 +1381,7 @@ def dump_binary( (objdump_flags + flags2, project.myimg, None), ) + # Example: "ldr r4, [pc, #56] ; (4c )" ARM32_LOAD_POOL_PATTERN = r"(ldr\s+r([0-9]|1[0-3]),\s+\[pc,.*;\s*)(\([a-fA-F0-9]+.*\))" @@ -1363,7 +1412,7 @@ class AsmProcessor: class AsmProcessorMIPS(AsmProcessor): def process_reloc(self, row: str, prev: str) -> str: arch = self.config.arch - if "R_MIPS_NONE" in row: + 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. @@ -1378,12 +1427,9 @@ class AsmProcessorMIPS(AsmProcessor): # 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 - and not imm.startswith("0x") - ): - imm = "0x" + imm - repl += "+" + imm if int(imm, 0) > 0 else imm + if mnemonic in arch.instructions_with_address_immediates: + imm = hex(int(imm, 16)) + repl += ("" if imm.startswith("-") else "+") + imm if "R_MIPS_LO16" in row: repl = f"%lo({repl})" elif "R_MIPS_HI16" in row: @@ -1398,6 +1444,12 @@ class AsmProcessorMIPS(AsmProcessor): # Branch to glabel. This gives confusing output, but there's not much # we can do here. pass + elif "R_MIPS_GPREL16" in row: + repl = f"%gp_rel({repl})" + elif "R_MIPS_GOT16" in row: + repl = f"%got({repl})" + elif "R_MIPS_CALL16" in row: + repl = f"%call16({repl})" else: assert False, f"unknown relocation type '{row}' for line '{prev}'" return before + repl + after @@ -1544,6 +1596,7 @@ class ArchSettings: big_endian: Optional[bool] = True delay_slot_instructions: Set[str] = field(default_factory=set) + MIPS_BRANCH_LIKELY_INSTRUCTIONS = { "beql", "bnel", @@ -1651,10 +1704,13 @@ PPC_BRANCH_INSTRUCTIONS = { MIPS_SETTINGS = ArchSettings( name="mips", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"<.*?>"), - re_reg=re.compile( - r"\$?\b(a[0-7]|t[0-9]|s[0-8]|at|v[01]|f[12]?[0-9]|f3[01]|kt?[01]|fp|ra|zero)\b" - ), + re_comment=re.compile(r"<.*>"), + # Includes: + # - General purpose registers v0..1, a0..7, t0..9, s0..8, zero, at, fp, k0..1/kt0..1 + # - Float registers f0..31, or fv0..1, fa0..7, ft0..15, fs0..8 plus odd complements + # (actually used number depends on ABI) + # sp, gp should not be in this list + 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)\([^)]*\)"), @@ -1672,7 +1728,7 @@ MIPSEL_SETTINGS = replace(MIPS_SETTINGS, name="mipsel", big_endian=False) ARM32_SETTINGS = ArchSettings( name="arm32", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), # Includes: # - General purpose registers: r0..13 # - Frame pointer registers: lr (r14), pc (r15) @@ -1690,26 +1746,33 @@ ARM32_SETTINGS = ArchSettings( proc=AsmProcessorARM32, ) +ARMEL_SETTINGS = replace(ARM32_SETTINGS, name="armel", big_endian=False) + AARCH64_SETTINGS = ArchSettings( name="aarch64", re_int=re.compile(r"[0-9]+"), - re_comment=re.compile(r"(<.*?>|//.*$)"), - # GPRs and FP registers: X0-X30, W0-W30, [DSHQ]0..31 + re_comment=re.compile(r"(<.*>|//.*$)"), + # GPRs and FP registers: X0-X30, W0-W30, [BHSDVQ]0..31 + # (FP registers may be followed by data width and number of elements, e.g. V0.4S) # The zero registers and SP should not be in this list. - re_reg=re.compile(r"\$?\b([dshq][12]?[0-9]|[dshq]3[01]|[xw][12]?[0-9]|[xw]30)\b"), + re_reg=re.compile( + r"\$?\b([bhsdvq]([12]?[0-9]|3[01])(\.\d\d?[bhsdvq])?|[xw][12]?[0-9]|[xw]30)\b" + ), re_sprel=re.compile(r"sp, #-?(0x[0-9a-fA-F]+|[0-9]+)\b"), re_large_imm=re.compile(r"-?[1-9][0-9]{2,}|-?0x[0-9a-f]{3,}"), re_imm=re.compile(r"(?|//.*$)"), + re_comment=re.compile(r"(<.*>|//.*$)"), re_reg=re.compile(r"\$?\b([rf][0-9]+)\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,}"), @@ -1724,6 +1787,7 @@ ARCH_SETTINGS = [ MIPS_SETTINGS, MIPSEL_SETTINGS, ARM32_SETTINGS, + ARMEL_SETTINGS, AARCH64_SETTINGS, PPC_SETTINGS, ] @@ -1743,6 +1807,7 @@ def hexify_int(row: str, pat: Match[str], arch: ArchSettings) -> str: def parse_relocated_line(line: str) -> Tuple[str, str, str]: + # Pick out the last argument for c in ",\t ": if c in line: ind2 = line.rindex(c) @@ -1751,6 +1816,7 @@ def parse_relocated_line(line: str) -> Tuple[str, str, str]: raise Exception(f"failed to parse relocated line: {line}") before = line[: ind2 + 1] after = line[ind2 + 1 :] + # Move an optional ($reg) part of it to 'after' ind2 = after.find("(") if ind2 == -1: imm, after = after, "" @@ -1879,8 +1945,15 @@ def process(dump: str, config: Config) -> List[Line]: row_parts = [part.lstrip() for part in row.split(" ", 1)] mnemonic = row_parts[0].strip() - if mnemonic not in arch.instructions_with_address_immediates: - row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + addr = "" + if mnemonic in arch.instructions_with_address_immediates: + row, addr = split_off_address(row) + # objdump prefixes addresses with 0x/-0x if they don't resolve to some + # symbol + offset. Strip that. + addr = addr.replace("0x", "") + + row = re.sub(arch.re_int, lambda m: hexify_int(row, m, arch), row) + row += addr # Let 'original' be 'row' with relocations applied, while we continue # transforming 'row' into a coarser version that ignores registers and @@ -1900,9 +1973,6 @@ def process(dump: str, config: Config) -> List[Line]: scorable_line = normalized_original if not config.score_stack_differences: scorable_line = re.sub(arch.re_sprel, "addr(sp)", scorable_line) - if mnemonic in arch.branch_instructions: - # Replace the final argument with "" - scorable_line = re.sub(r"[^, \t]+$", "", scorable_line) if skip_next: skip_next = False @@ -1925,8 +1995,6 @@ def process(dump: str, config: Config) -> List[Line]: branch_target = None if mnemonic in arch.branch_instructions: branch_target = int(row_parts[1].strip().split(",")[-1], 16) - if mnemonic in arch.branch_likely_instructions: - branch_target -= 4 output.append( Line( @@ -1974,7 +2042,9 @@ def split_off_address(line: str) -> Tuple[str, str]: parts = line.split(",") if len(parts) < 2: parts = line.split(None, 1) - off = len(line) - len(parts[-1]) + if len(parts) < 2: + parts.append("") + off = len(line) - len(parts[-1].strip()) return line[:off], line[off:] @@ -1990,7 +2060,7 @@ def diff_sequences( ) -> List[Tuple[str, int, int, int, int]]: if ( algorithm != "levenshtein" - or len(seq1) * len(seq2) > 4 * 10 ** 8 + or len(seq1) * len(seq2) > 4 * 10**8 or len(seq1) + len(seq2) >= 0x110000 ): return diff_sequences_difflib(seq1, seq2) @@ -2177,10 +2247,15 @@ class Diff: def trim_nops(lines: List[Line], arch: ArchSettings) -> List[Line]: lines = lines[:] - while lines and lines[-1].mnemonic == "nop" and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions): + while ( + lines + and lines[-1].mnemonic == "nop" + and (len(lines) == 1 or lines[-2].mnemonic not in arch.delay_slot_instructions) + ): lines.pop() return lines + def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: if config.show_source: import cxxfilt @@ -2212,7 +2287,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) - score = score_diff_lines(diffed_lines, config) max_score = len(lines1) * config.penalty_deletion line_num_base = -1 @@ -2281,10 +2355,15 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: line2_line = line_num_2to1[line2.line_num] line2_target = (line2_line[0] + (target - line2.line_num), 0) - # Set the key for three-way diffing to a normalized version. + # Adjust the branch target for scoring and three-way diffing. norm2, norm_branch2 = split_off_address(line2.normalized_original) - if norm_branch2 != "": - line2.normalized_original = norm2 + str(line2_target) + if norm_branch2 != "": + retargetted = hex(line2_target[0]).replace("0x", "") + if line2_target[1] != 0: + retargetted += f"+{line2_target[1]}" + line2.normalized_original = norm2 + retargetted + sc_base, _ = split_off_address(line2.scorable_line) + line2.scorable_line = sc_base + retargetted same_target = line2_target == (line1.branch_target, 0) else: # Do a naive comparison for non-branches (e.g. function calls). @@ -2444,6 +2523,7 @@ def do_diff(lines1: List[Line], lines2: List[Line], config: Config) -> Diff: ) ) + score = score_diff_lines(diffed_lines, config) output = output[config.skip_lines :] return Diff(lines=output, score=score, max_score=max_score) diff --git a/tools/asm-processor/asm_processor.py b/tools/asm-processor/asm_processor.py index 6923752be..544b1b1b7 100644 --- a/tools/asm-processor/asm_processor.py +++ b/tools/asm-processor/asm_processor.py @@ -783,6 +783,13 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende else: min_instr_count = 2 skip_instr_count = 1 + elif opt == 'O0': + if framepointer: + min_instr_count = 8 + skip_instr_count = 8 + else: + min_instr_count = 4 + skip_instr_count = 4 elif opt == 'g': if framepointer: min_instr_count = 7 @@ -792,7 +799,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende skip_instr_count = 4 else: if opt != 'g3': - raise Failure("must pass one of -g, -O1, -O2, -O2 -g3") + raise Failure("must pass one of -g, -O0, -O1, -O2, -O2 -g3") if framepointer: min_instr_count = 4 skip_instr_count = 4 @@ -813,6 +820,7 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende ] is_cutscene_data = False + is_early_include = False for line_no, raw_line in enumerate(f, 1): raw_line = raw_line.rstrip() @@ -832,44 +840,51 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende global_asm = None else: global_asm.process_line(raw_line, output_enc) + elif line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: + global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) + start_index = len(output_lines) + elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) + and line.endswith('")')): + fname = line[line.index('(') + 2 : -2] + out_dependencies.append(fname) + global_asm = GlobalAsmBlock(fname) + with open(fname, encoding=input_enc) as f: + for line2 in f: + global_asm.process_line(line2.rstrip(), output_enc) + src, fn = global_asm.finish(state) + output_lines[-1] = ''.join(src) + asm_functions.append(fn) + global_asm = None + elif line == '#pragma asmproc recurse': + # C includes qualified as + # #pragma asmproc recurse + # #include "file.c" + # will be processed recursively when encountered + is_early_include = True + elif is_early_include: + # Previous line was a #pragma asmproc recurse + is_early_include = False + if not line.startswith("#include "): + raise Failure("#pragma asmproc recurse must be followed by an #include ") + fpath = os.path.dirname(f.name) + 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) + include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') + output_lines[-1] = include_src.getvalue() + include_src.close() else: - if line in ['GLOBAL_ASM(', '#pragma GLOBAL_ASM(']: - global_asm = GlobalAsmBlock("GLOBAL_ASM block at line " + str(line_no)) - start_index = len(output_lines) - elif ((line.startswith('GLOBAL_ASM("') or line.startswith('#pragma GLOBAL_ASM("')) - and line.endswith('")')): - fname = line[line.index('(') + 2 : -2] - out_dependencies.append(fname) - global_asm = GlobalAsmBlock(fname) - with open(fname, encoding=input_enc) as f: - for line2 in f: - global_asm.process_line(line2.rstrip(), output_enc) - src, fn = global_asm.finish(state) - output_lines[-1] = ''.join(src) - asm_functions.append(fn) - global_asm = None - elif line.startswith('#include "') and line.endswith('" EARLY'): - # C includes qualified with EARLY (i.e. #include "file.c" EARLY) will be - # processed recursively when encountered - fpath = os.path.dirname(f.name) - fname = os.path.join(fpath, line[line.index(' ') + 2 : -7]) - 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) - include_src.write('#line ' + str(line_no + 1) + ' "' + f.name + '"') - output_lines[-1] = include_src.getvalue() - include_src.close() - else: - # This is a hack to replace all floating-point numbers in an array of a particular type - # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation - if cutscene_data_regexpr.search(line) is not None: - is_cutscene_data = True - elif line.endswith("};"): - is_cutscene_data = False - if is_cutscene_data: - raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) - output_lines[-1] = raw_line + # This is a hack to replace all floating-point numbers in an array of a particular type + # (in this case CutsceneData) with their corresponding IEEE-754 hexadecimal representation + if cutscene_data_regexpr.search(line) is not None: + is_cutscene_data = True + elif line.endswith("};"): + is_cutscene_data = False + if is_cutscene_data: + raw_line = re.sub(float_regexpr, repl_float_hex, raw_line) + output_lines[-1] = raw_line if print_source: if isinstance(print_source, StringIO): @@ -877,7 +892,14 @@ def parse_source(f, opt, framepointer, mips1, input_enc, output_enc, out_depende print_source.write(line + '\n') else: for line in output_lines: - print_source.write(line.encode(output_enc) + b'\n') + try: + line_encoded = line.encode(output_enc) + except UnicodeEncodeError: + print("Failed to encode a line to", output_enc) + print("The line:", line) + print("The line, utf-8-encoded:", line.encode("utf-8")) + raise + print_source.write(line_encoded + b'\n') print_source.flush() if print_source != sys.stdout.buffer: print_source.close() @@ -1239,6 +1261,7 @@ def run_wrapped(argv, outfile, functions): parser.add_argument('-mips1', dest='mips1', action='store_true') parser.add_argument('-g3', dest='g3', 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') group.add_argument('-O2', dest='opt', action='store_const', const='O2') group.add_argument('-g', dest='opt', action='store_const', const='g') diff --git a/tools/asm-processor/build.py b/tools/asm-processor/build.py index 493afd4d5..480dec9ed 100755 --- a/tools/asm-processor/build.py +++ b/tools/asm-processor/build.py @@ -10,30 +10,49 @@ dir_path = os.path.dirname(os.path.realpath(__file__)) prelude = os.path.join(dir_path, "prelude.inc") all_args = sys.argv[1:] -sep1 = all_args.index('--') -sep2 = all_args.index('--', sep1+1) +sep0 = [index for index, arg in enumerate(all_args) if not arg.startswith("-")][0] +sep1 = all_args.index("--") +sep2 = all_args.index("--", sep1 + 1) -compiler = all_args[:sep1] +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 = all_args[sep1 + 1 : sep2] +assembler_sh = " ".join(shlex.quote(x) for x in assembler) -compile_args = all_args[sep2+1:] +compile_args = all_args[sep2 + 1 :] in_file = compile_args[-1] -out_ind = compile_args.index('-o') +out_ind = compile_args.index("-o") out_file = compile_args[out_ind + 1] del compile_args[-1] del compile_args[out_ind + 1] del compile_args[out_ind] in_dir = os.path.split(os.path.realpath(in_file))[0] -opt_flags = [x for x in compile_args if x in ['-g3', '-g', '-O1', '-O2', '-framepointer']] +opt_flags = [ + x for x in compile_args if x in ["-g3", "-g", "-O0", "-O1", "-O2", "-framepointer"] +] +if "-mips2" not in compile_args: + opt_flags.append("-mips1") -preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c', delete=False) +asmproc_flags += opt_flags + [in_file] + +# Drop .mdebug and .gptab sections from resulting binaries. This makes +# resulting .o files much smaller and speeds up builds, but loses line +# number debug data. +# asmproc_flags += ["--drop-mdebug-gptab"] + +# Convert encoding before compiling. +# asmproc_flags += ["--input-enc", "utf-8", "--output-enc", "euc-jp"] + +preprocessed_file = tempfile.NamedTemporaryFile( + prefix="preprocessed", suffix=".c", delete=False +) try: - asmproc_flags = opt_flags + [in_file, '--input-enc', 'utf-8', '--output-enc', 'euc-jp'] - compile_cmdline = compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name] + compile_cmdline = ( + compiler + compile_args + ["-I", in_dir, "-o", out_file, preprocessed_file.name] + ) functions, deps = asm_processor.run(asmproc_flags, outfile=preprocessed_file) try: @@ -41,13 +60,24 @@ try: except subprocess.CalledProcessError as e: print("Failed to compile file " + in_file + ". Command line:") print() - print(' '.join(shlex.quote(x) for x in compile_cmdline)) + 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, '--assembler', assembler_sh, '--asm-prelude', prelude], functions=functions) + asm_processor.run( + asmproc_flags + + [ + "--post-process", + out_file, + "--assembler", + assembler_sh, + "--asm-prelude", + prelude, + ], + functions=functions, + ) deps_file = out_file[:-2] + ".asmproc.d" if deps: diff --git a/tools/asm-processor/prelude.inc b/tools/asm-processor/prelude.inc index 1ec8c6036..3e58ff149 100644 --- a/tools/asm-processor/prelude.inc +++ b/tools/asm-processor/prelude.inc @@ -1,5 +1,43 @@ .set noat .set noreorder .set gp=64 -.include "macro.inc" +.macro glabel label + .global \label + \label: +.endm + +# Float register aliases (o32 ABI, odd ones are rarely used) + +.set $fv0, $f0 +.set $fv0f, $f1 +.set $fv1, $f2 +.set $fv1f, $f3 +.set $ft0, $f4 +.set $ft0f, $f5 +.set $ft1, $f6 +.set $ft1f, $f7 +.set $ft2, $f8 +.set $ft2f, $f9 +.set $ft3, $f10 +.set $ft3f, $f11 +.set $fa0, $f12 +.set $fa0f, $f13 +.set $fa1, $f14 +.set $fa1f, $f15 +.set $ft4, $f16 +.set $ft4f, $f17 +.set $ft5, $f18 +.set $ft5f, $f19 +.set $fs0, $f20 +.set $fs0f, $f21 +.set $fs1, $f22 +.set $fs1f, $f23 +.set $fs2, $f24 +.set $fs2f, $f25 +.set $fs3, $f26 +.set $fs3f, $f27 +.set $fs4, $f28 +.set $fs4f, $f29 +.set $fs5, $f30 +.set $fs5f, $f31 diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index e0b7705ea..cb634d138 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -2,31 +2,49 @@ import argparse, ast, math, os, re, struct import bisect -from mips_isa import * -from multiprocessing import * +import multiprocessing from pathlib import Path +import mips_isa + +# Consider implementing gpr naming too, but already uses abi names by default +fpr_name_options = { + "numeric": mips_isa.numeric_fpr_names, + "o32": mips_isa.o32_fpr_names, +} parser = argparse.ArgumentParser() parser.add_argument( "-j", dest="jobs", type=int, default=1, help="number of processes to run at once" ) parser.add_argument( - "--full", - "-f", - dest="full", + "-a", + "--all", + dest="all", action="store_true", default=False, help="Decompile all files regardless of whether they are used or not", ) +parser.add_argument( + "-f", + "--files", + dest="files", + nargs="+", + required=False, + help="Optional list of files to diassemble separated by a space. This is a whitelist, all files will be skipped besides the ones listed here if used.", +) +parser.add_argument("--reg-names", choices=fpr_name_options.keys(), help="How to name registers in the output") args = parser.parse_args() jobs = args.jobs +mips_isa.mips_fpr_names = fpr_name_options.get(args.reg_names, mips_isa.mips_fpr_names) + + ASM_OUT = "asm/" DATA_OUT = "data/" -def discard_decomped_files(files_spec): +def discard_decomped_files(files_spec, include_files): root_path = Path(__file__).parent.parent.parent with open(root_path / "spec", "r") as f: @@ -38,6 +56,12 @@ def discard_decomped_files(files_spec): for f in files_spec: name, _, type, _, file_list = f + force_include = False + if include_files: + if not any([x in name for x in include_files]): + continue + force_include = True + # Find the beginseg for this file i = 0 while i < len(spec): @@ -92,6 +116,7 @@ def discard_decomped_files(files_spec): if "GLOBAL_ASM" in f2.read(): include = True + include |= force_include if include: new_files[offset] = file included = True @@ -107,71 +132,71 @@ def discard_decomped_files(files_spec): MIPS_BRANCH_LIKELY_INSNS = [ - MIPS_INS_BEQL, - MIPS_INS_BGEZALL, - MIPS_INS_BGEZL, - MIPS_INS_BGTZL, - MIPS_INS_BLEZL, - MIPS_INS_BLTZALL, - MIPS_INS_BLTZL, - MIPS_INS_BNEL, - MIPS_INS_BC1TL, - MIPS_INS_BC1FL, + mips_isa.MIPS_INS_BEQL, + mips_isa.MIPS_INS_BGEZALL, + mips_isa.MIPS_INS_BGEZL, + mips_isa.MIPS_INS_BGTZL, + mips_isa.MIPS_INS_BLEZL, + mips_isa.MIPS_INS_BLTZALL, + mips_isa.MIPS_INS_BLTZL, + mips_isa.MIPS_INS_BNEL, + mips_isa.MIPS_INS_BC1TL, + mips_isa.MIPS_INS_BC1FL, ] MIPS_BRANCH_INSNS = [ *MIPS_BRANCH_LIKELY_INSNS, - MIPS_INS_BEQ, - MIPS_INS_BGEZ, - MIPS_INS_BGEZAL, - MIPS_INS_BGTZ, - MIPS_INS_BNE, - MIPS_INS_BLTZ, - MIPS_INS_BLTZAL, - MIPS_INS_BLEZ, - MIPS_INS_BC1T, - MIPS_INS_BC1F, - MIPS_INS_BEQZ, - MIPS_INS_BNEZ, - MIPS_INS_B, + mips_isa.MIPS_INS_BEQ, + mips_isa.MIPS_INS_BGEZ, + mips_isa.MIPS_INS_BGEZAL, + mips_isa.MIPS_INS_BGTZ, + mips_isa.MIPS_INS_BNE, + mips_isa.MIPS_INS_BLTZ, + mips_isa.MIPS_INS_BLTZAL, + mips_isa.MIPS_INS_BLEZ, + mips_isa.MIPS_INS_BC1T, + mips_isa.MIPS_INS_BC1F, + mips_isa.MIPS_INS_BEQZ, + mips_isa.MIPS_INS_BNEZ, + mips_isa.MIPS_INS_B, ] -MIPS_JUMP_INSNS = [MIPS_INS_JAL, MIPS_INS_JALR, MIPS_INS_J, MIPS_INS_JR] +MIPS_JUMP_INSNS = [mips_isa.MIPS_INS_JAL, mips_isa.MIPS_INS_JALR, mips_isa.MIPS_INS_J, mips_isa.MIPS_INS_JR] -MIPS_FP_LOAD_INSNS = [MIPS_INS_LWC1, MIPS_INS_LDC1] +MIPS_FP_LOAD_INSNS = [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_LDC1] -MIPS_FP_STORE_INSNS = [MIPS_INS_SWC1, MIPS_INS_SDC1] +MIPS_FP_STORE_INSNS = [mips_isa.MIPS_INS_SWC1, mips_isa.MIPS_INS_SDC1] MIPS_FP_LOAD_STORE_INSNS = [*MIPS_FP_LOAD_INSNS, *MIPS_FP_STORE_INSNS] MIPS_STORE_INSNS = [ - MIPS_INS_SB, - MIPS_INS_SH, - MIPS_INS_SW, - MIPS_INS_SWL, - MIPS_INS_SWR, - MIPS_INS_SD, - MIPS_INS_SDL, - MIPS_INS_SDR, - MIPS_INS_SC, - MIPS_INS_SCD, + mips_isa.MIPS_INS_SB, + mips_isa.MIPS_INS_SH, + mips_isa.MIPS_INS_SW, + mips_isa.MIPS_INS_SWL, + mips_isa.MIPS_INS_SWR, + mips_isa.MIPS_INS_SD, + mips_isa.MIPS_INS_SDL, + mips_isa.MIPS_INS_SDR, + mips_isa.MIPS_INS_SC, + mips_isa.MIPS_INS_SCD, *MIPS_FP_STORE_INSNS, ] MIPS_LOAD_STORE_INSNS = [ - MIPS_INS_LB, - MIPS_INS_LBU, - MIPS_INS_LH, - MIPS_INS_LHU, - MIPS_INS_LW, - MIPS_INS_LWL, - MIPS_INS_LWR, - MIPS_INS_LWU, - MIPS_INS_LD, - MIPS_INS_LDL, - MIPS_INS_LDR, - MIPS_INS_LL, - MIPS_INS_LLD, + mips_isa.MIPS_INS_LB, + mips_isa.MIPS_INS_LBU, + mips_isa.MIPS_INS_LH, + mips_isa.MIPS_INS_LHU, + mips_isa.MIPS_INS_LW, + mips_isa.MIPS_INS_LWL, + mips_isa.MIPS_INS_LWR, + mips_isa.MIPS_INS_LWU, + mips_isa.MIPS_INS_LD, + mips_isa.MIPS_INS_LDL, + mips_isa.MIPS_INS_LDR, + mips_isa.MIPS_INS_LL, + mips_isa.MIPS_INS_LLD, *MIPS_STORE_INSNS, *MIPS_FP_LOAD_STORE_INSNS, ] @@ -600,7 +625,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # assert insn.value_forname(insn.fields[0]) is not None # print(f"insn: {insn.mnemonic}, rt: {insn.rt}, first: {insn.value_forname(insn.fields[0])}") - # assert insn.id not in [MIPS_INS_ORI, MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) + # assert insn.id not in [MIPS_INS_ORI, mips_isa.MIPS_INS_ADDIU, *MIPS_LOAD_STORE_INSNS] or insn.rt == insn.value_forname(insn.fields[0]) if ( delay_slot @@ -621,9 +646,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insns = [] for i, raw_insn in enumerate(raw_insns, 0): - insn = decode_insn(raw_insn, vram + i * 4) + insn = mips_isa.decode_insn(raw_insn, vram + i * 4) - if insn.id == MIPS_INS_JR and insn.rs != MIPS_REG_RA: + if insn.id == mips_isa.MIPS_INS_JR and insn.rs != mips_isa.MIPS_REG_RA: # It's hard to find when two jump tables next to each other end, so do a naive first pass # to try and find as many jump tables as possible. # Luckily IDO has a very homogeneous output for jump tables for which it is very unlikely @@ -636,9 +661,9 @@ def find_symbols_in_text(section, rodata_section, data_regions): insn_m2 = insns[-2] insn_m3 = insns[-3] if ( - insn_m1.id == MIPS_INS_LW - and insn_m2.id == MIPS_INS_ADDU - and insn_m3.id == MIPS_INS_LUI + insn_m1.id == mips_isa.MIPS_INS_LW + and insn_m2.id == mips_isa.MIPS_INS_ADDU + and insn_m3.id == mips_isa.MIPS_INS_LUI ): prospective_jtbls.add((insn_m3.imm << 0x10) + insn_m1.imm) insns.append(insn) @@ -659,7 +684,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated jump targets give us functions in this section """ assert ( - insn.id == MIPS_INS_JAL + insn.id == mips_isa.MIPS_INS_JAL ), f"R_MIPS_26 applied to {insn.mnemonic} when it should be JAL" put_symbol(symbols_dict, "functions", insn.target) elif reloc[1] == 5: # R_MIPS_HI16 @@ -667,7 +692,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %hi gives us %hi values to match with associated %lo """ assert ( - insn.id == MIPS_INS_LUI + insn.id == mips_isa.MIPS_INS_LUI ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be LUI" prev_hi = insn.imm hi_vram = vram + reloc[2] @@ -676,7 +701,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): Relocated %lo + a %hi to match with gives us relocated symbols in data sections """ assert ( - insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS + insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS ), f"R_MIPS_HI16 applied to {insn.mnemonic} when it should be ADDIU or a load/store" symbol_value = (prev_hi << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) @@ -742,16 +767,16 @@ def find_symbols_in_text(section, rodata_section, data_regions): if insn.id in MIPS_BRANCH_INSNS: func_branch_labels.add(insn.offset) delayed_insn = insn - elif insn.id == MIPS_INS_ERET: + elif insn.id == mips_isa.MIPS_INS_ERET: put_symbol(symbols_dict, "functions", vaddr + 4) elif insn.id in MIPS_JUMP_INSNS: - if insn.id == MIPS_INS_JAL: + if insn.id == mips_isa.MIPS_INS_JAL: # mark function at target put_symbol(symbols_dict, "functions", insn.target) - elif insn.id == MIPS_INS_J: + elif insn.id == mips_isa.MIPS_INS_J: # mark label at target func_branch_labels.add(insn.target) - elif insn.id == MIPS_INS_JR: + elif insn.id == mips_isa.MIPS_INS_JR: # check if anything branches past it in either branch or jtbl labels if vaddr >= max(func_branch_labels, default=0) and vaddr >= max( func_jtbl_labels, default=0 @@ -777,7 +802,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): symbols_dict, "functions", vaddr + 8 + n_padding * 4 ) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: """ Process LUI instruction @@ -794,34 +819,34 @@ def find_symbols_in_text(section, rodata_section, data_regions): save_tracker(delayed_insn.offset, {insn.rt: (vaddr, insn.imm)}) else: lui_tracker.update({insn.rt: (vaddr, insn.imm)}) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: # try match with tracked lui and mark symbol hi_vram, imm_value = lui_tracker.get( - insn.rs if insn.id == MIPS_INS_ADDIU else insn.base, (None, None) + insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base, (None, None) ) # if a match was found, validate and record the symbol, TODO improve validation if hi_vram != None and ( (((imm_value >> 0x8) & 0xF) != 0 and imm_value < 0x1000) or (imm_value >= 0x8000 and imm_value < 0x80D0) or (imm_value >= 0xA400 and imm_value < 0xA480) - or (imm_value < 0x0400 and insn.id == MIPS_INS_ADDIU) + or (imm_value < 0x0400 and insn.id == mips_isa.MIPS_INS_ADDIU) ): lo_vram = vaddr symbol_value = (imm_value << 0x10) + insn.imm put_symbols(symbols_dict, "symbols", {hi_vram: symbol_value}) put_symbols(symbols_dict, "symbols", {lo_vram: symbol_value}) - if insn.id == MIPS_INS_LW: + if insn.id == mips_isa.MIPS_INS_LW: # try find jr within the same block cur_idx = i lookahead_insn = insns[cur_idx] # TODO fix vaddr here # still in same block unless one of these instructions are found while lookahead_insn.id not in [ *MIPS_BRANCH_INSNS, - MIPS_INS_JAL, - MIPS_INS_JALR, - MIPS_INS_J, + mips_isa.MIPS_INS_JAL, + mips_isa.MIPS_INS_JALR, + mips_isa.MIPS_INS_J, ]: - if lookahead_insn.id == MIPS_INS_JR: + if lookahead_insn.id == mips_isa.MIPS_INS_JR: if lookahead_insn.rs == ( insn.ft if insn.id in MIPS_FP_LOAD_STORE_INSNS @@ -869,24 +894,24 @@ def find_symbols_in_text(section, rodata_section, data_regions): if cur_idx >= len(raw_insns): break lookahead_insn = insns[cur_idx] # TODO fix vaddr here - elif insn.id == MIPS_INS_LD: # doubleword loads + elif insn.id == mips_isa.MIPS_INS_LD: # doubleword loads put_symbol(symbols_dict, "dwords", symbol_value) - elif insn.id in [MIPS_INS_LWC1, MIPS_INS_SWC1]: # float load/stores + elif insn.id in [mips_isa.MIPS_INS_LWC1, mips_isa.MIPS_INS_SWC1]: # float load/stores # add float put_symbol(symbols_dict, "floats", symbol_value) - elif insn.id in [MIPS_INS_LDC1, MIPS_INS_SDC1]: # double load/stores + elif insn.id in [mips_isa.MIPS_INS_LDC1, mips_isa.MIPS_INS_SDC1]: # double load/stores # add double put_symbol(symbols_dict, "doubles", symbol_value) elif ( - insn.id == MIPS_INS_ADDIU and vaddr % 4 == 0 + insn.id == mips_isa.MIPS_INS_ADDIU and vaddr % 4 == 0 ): # strings seem to only ever be 4-byte aligned # add possible string put_symbol(symbols_dict, "prospective_strings", symbol_value) # clear lui tracking state if register is clobbered by the addiu/load instruction itself - # insn.rt == (insn.rs if insn.id == MIPS_INS_ADDIU else insn.base) and + # insn.rt == (insn.rs if insn.id == mips_isa.MIPS_INS_ADDIU else insn.base) and if insn.id not in MIPS_STORE_INSNS and insn.id not in MIPS_FP_LOAD_INSNS: clobber_conditionally(insn) - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: # try match with tracked lui and mark constant hi_vram, imm_value = lui_tracker.get(insn.rs, (None, None)) if hi_vram != None: # found match @@ -901,7 +926,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): else: # clear lui tracking if register is clobbered by something unrelated if ( - insn.id == MIPS_INS_ADDU + insn.id == mips_isa.MIPS_INS_ADDU and insn.rs in lui_tracker.keys() and (insn.rd == insn.rs) ): @@ -914,35 +939,35 @@ def find_symbols_in_text(section, rodata_section, data_regions): pass # insns listed either write to fprs/cop0 or don't write to any elif insn.id not in [ - MIPS_INS_MTC0, - MIPS_INS_MTC1, - MIPS_INS_DMTC1, - MIPS_INS_MULT, - MIPS_INS_MULTU, - MIPS_INS_DMULT, - MIPS_INS_DMULTU, - MIPS_INS_DIV, - MIPS_INS_DIVU, - MIPS_INS_DDIV, - MIPS_INS_DDIVU, - MIPS_INS_MTHI, - MIPS_INS_MTLO, - MIPS_INS_CTC1, - MIPS_INS_NOP, - MIPS_INS_BREAK, - MIPS_INS_TLBP, - MIPS_INS_TLBR, - MIPS_INS_TLBWI, - MIPS_INS_MOV_S, - MIPS_INS_MOV_D, - MIPS_INS_C_LT_S, - MIPS_INS_C_LT_D, - MIPS_INS_DIV_S, - MIPS_INS_MUL_S, - MIPS_INS_TRUNC_W_S, - MIPS_INS_CVT_S_W, - MIPS_INS_SUB_S, - MIPS_INS_ADD_S, + mips_isa.MIPS_INS_MTC0, + mips_isa.MIPS_INS_MTC1, + mips_isa.MIPS_INS_DMTC1, + mips_isa.MIPS_INS_MULT, + mips_isa.MIPS_INS_MULTU, + mips_isa.MIPS_INS_DMULT, + mips_isa.MIPS_INS_DMULTU, + mips_isa.MIPS_INS_DIV, + mips_isa.MIPS_INS_DIVU, + mips_isa.MIPS_INS_DDIV, + mips_isa.MIPS_INS_DDIVU, + mips_isa.MIPS_INS_MTHI, + mips_isa.MIPS_INS_MTLO, + mips_isa.MIPS_INS_CTC1, + mips_isa.MIPS_INS_NOP, + mips_isa.MIPS_INS_BREAK, + mips_isa.MIPS_INS_TLBP, + mips_isa.MIPS_INS_TLBR, + mips_isa.MIPS_INS_TLBWI, + mips_isa.MIPS_INS_MOV_S, + mips_isa.MIPS_INS_MOV_D, + mips_isa.MIPS_INS_C_LT_S, + mips_isa.MIPS_INS_C_LT_D, + mips_isa.MIPS_INS_DIV_S, + mips_isa.MIPS_INS_MUL_S, + mips_isa.MIPS_INS_TRUNC_W_S, + mips_isa.MIPS_INS_CVT_S_W, + mips_isa.MIPS_INS_SUB_S, + mips_isa.MIPS_INS_ADD_S, ]: clobber_conditionally(insn) @@ -985,18 +1010,18 @@ def find_symbols_in_text(section, rodata_section, data_regions): part += ", " op_str.append(part) - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: op_str = [op_str] instr["rt"] = insn.rt - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs instr["ft"] = insn.ft instr["base"] = insn.base - elif insn.id == MIPS_INS_ORI: + elif insn.id == mips_isa.MIPS_INS_ORI: op_str = [op_str] instr["rt"] = insn.rt instr["rs"] = insn.rs @@ -1016,13 +1041,13 @@ def find_symbols_in_text(section, rodata_section, data_regions): if delay_slot and delayed_insn is not None: if ( - delayed_insn.id == MIPS_INS_JAL - or delayed_insn.id == MIPS_INS_JALR - or (delayed_insn.id == MIPS_INS_JR and delayed_insn.rs == MIPS_REG_RA) + delayed_insn.id == mips_isa.MIPS_INS_JAL + or delayed_insn.id == mips_isa.MIPS_INS_JALR + or (delayed_insn.id == mips_isa.MIPS_INS_JR and delayed_insn.rs == mips_isa.MIPS_REG_RA) ): # destroy lui tracking state lui_tracker.clear() - elif delayed_insn.id == MIPS_INS_JR and vaddr == next_jtbl_jr + 4: + elif delayed_insn.id == mips_isa.MIPS_INS_JR and vaddr == next_jtbl_jr + 4: # save lui tracking state for each jtbl label for label in individual_jtbl_labels[next_jtbl_jr]: save_tracker(label, lui_tracker.copy()) @@ -1031,7 +1056,7 @@ def find_symbols_in_text(section, rodata_section, data_regions): # save lui tracking state save_tracker(delayed_insn.offset, lui_tracker.copy()) # destroy current lui tracking state for unconditional branches - if delayed_insn.id == MIPS_INS_B: + if delayed_insn.id == mips_isa.MIPS_INS_B: lui_tracker.clear() delayed_insn = None @@ -1250,35 +1275,35 @@ def fixup_text_symbols(data, vram, data_regions, info): else: line += op_part - elif insn["id"] == MIPS_INS_LUI: + elif insn["id"] == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, %hi({proper_name(symbol_value)})" ) else: constant_value = constants.get(vaddr, None) if constant_value is not None: line += ( - f"{mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn['rt']]}, (0x{constant_value:08X} >> 16)" ) else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: + elif insn["id"] == mips_isa.MIPS_INS_ADDIU or insn["id"] in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn["id"] == MIPS_INS_ADDIU: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" + if insn["id"] == mips_isa.MIPS_INS_ADDIU: + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, %lo({proper_name(symbol_value)})" else: - line += f"{mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn['base']]})" + line += f"{mips_isa.mips_fpr_names[insn['ft']] if insn['id'] in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn['rt']]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn['base']]})" else: line += entry["op"][0] - elif insn["id"] == MIPS_INS_ORI: + elif insn["id"] == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - line += f"{mips_gpr_names[insn['rt']]}, {mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" + line += f"{ mips_isa.mips_gpr_names[insn['rt']]}, { mips_isa.mips_gpr_names[insn['rs']]}, (0x{constant_value:08X} & 0xFFFF)" else: line += entry["op"][0] @@ -1314,7 +1339,7 @@ def disassemble_text(data, vram, data_regions, info): for i, raw_insn in enumerate(raw_insns, 0): i *= 4 vaddr = vram + i - insn = decode_insn(raw_insns[i // 4], vaddr) + insn = mips_isa.decode_insn(raw_insns[i // 4], vaddr) mnemonic = insn.mnemonic op_str = insn.op_str @@ -1374,27 +1399,27 @@ def disassemble_text(data, vram, data_regions, info): op_str_parts.append(insn.format_field(field)) op_str = ", ".join(op_str_parts) delayed_insn = insn - elif insn.id == MIPS_INS_LUI: + elif insn.id == mips_isa.MIPS_INS_LUI: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, %hi({proper_name(symbol_value)})" else: constant_value = constants.get(vaddr, None) if constant_value is not None: op_str = ( - f"{mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" + f"{ mips_isa.mips_gpr_names[insn.rt]}, (0x{constant_value:08X} >> 16)" ) - elif insn.id == MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: + elif insn.id == mips_isa.MIPS_INS_ADDIU or insn.id in MIPS_LOAD_STORE_INSNS: symbol_value = symbols.get(vaddr, None) if symbol_value is not None: - if insn.id == MIPS_INS_ADDIU: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" + if insn.id == mips_isa.MIPS_INS_ADDIU: + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, %lo({proper_name(symbol_value)})" else: - op_str = f"{mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({mips_gpr_names[insn.base]})" - elif insn.id == MIPS_INS_ORI: + op_str = f"{mips_isa.mips_fpr_names[insn.ft] if insn.id in MIPS_FP_LOAD_STORE_INSNS else mips_isa.mips_gpr_names[insn.rt]}, %lo({proper_name(symbol_value)})({ mips_isa.mips_gpr_names[insn.base]})" + elif insn.id == mips_isa.MIPS_INS_ORI: constant_value = constants.get(vaddr, None) if constant_value is not None: - op_str = f"{mips_gpr_names[insn.rt]}, {mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" + op_str = f"{ mips_isa.mips_gpr_names[insn.rt]}, { mips_isa.mips_gpr_names[insn.rs]}, (0x{constant_value:08X} & 0xFFFF)" if delay_slot: mnemonic = " " + mnemonic @@ -2190,17 +2215,24 @@ for segment in files_spec: new[offset] = name full_file_list[segment[0]] = new -if args.full: +if args.all: + new_spec = [] for segment in files_spec: + if args.files and not any( + [file_name in segment[0] for file_name in args.files] + ): + continue for offset, name in segment[4].items(): if name == "": name = f"{segment[2]}_{offset:08X}" segment[4][offset] = name + new_spec.append(segment) + files_spec = new_spec else: # Prune old_file_count = sum([len(f[4].keys()) for f in files_spec]) - files_spec = discard_decomped_files(files_spec) + files_spec = discard_decomped_files(files_spec, args.files) new_file_count = sum([len(f[4].keys()) for f in files_spec]) @@ -2335,7 +2367,7 @@ for segment in files_spec: del files_spec[:] -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) # Find symbols for each segment for section in all_sections: if section[-1]["name"] == "makerom": @@ -2371,7 +2403,7 @@ for section in all_sections: pool.close() pool.join() -pool = get_context("fork").Pool(jobs) +pool = multiprocessing.get_context("fork").Pool(jobs) for section in all_sections: if section[-1]["type"] == "makerom": continue @@ -2396,7 +2428,7 @@ for section in all_sections: vrom_addrs = {addr for _, addr in vrom_variables} # Textual disassembly for each segment -with get_context("fork").Pool(jobs) as p: +with multiprocessing.get_context("fork").Pool(jobs) as p: p.map( disassemble_segment, [ @@ -2413,193 +2445,201 @@ rodata_symbols_regex = re.compile(r"(?<=\n)glabel (.+)(?=\n)") asm_symbols_regex = re.compile(r"%(?:lo|hi)\((.+?)\)") # Split files and migrate rodata that should be migrated -for root, dirs, files in os.walk(ASM_OUT): - for f in files: - if "non_matchings" in root: - continue - asm_path = os.path.join(root, f) - rodata_path = ( - asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) - .replace(ASM_OUT, DATA_OUT) - .replace(".text.s", ".rodata.s") +for file in Path(ASM_OUT).glob("**/*.s"): + asm_path = str(file) + + if "non_matchings" in asm_path: + continue + + if file.parts[1] == "overlays": + name = file.parts[2] + else: + name = file.parts[1] + + if not any([name == section[-1]["name"] for section in all_sections]): + continue + + rodata_path = ( + asm_path.replace(ASM_OUT + "overlays/", DATA_OUT) + .replace(ASM_OUT, DATA_OUT) + .replace(".text.s", ".rodata.s") + ) + + print(asm_path) + + asm = "" + with open(asm_path, "r") as infile: + asm = infile.read() + + rodata = "" + if os.path.exists(rodata_path): + # print(rodata_path) + with open(rodata_path, "r") as rodata_file: + rodata = rodata_file.read() + + rodata_info = list(zip(rodata_syms(rodata), rodata_blocks(rodata))) + + # populate rdata and late_rodata lists + first_late_rodata = find_late_rodata_start(rodata_info) + rdata_info = [] + late_rodata_info = [] + target = rdata_info # first populate rdata + for sym, block in rodata_info: + # now populate late_rodata, if there is any + if sym == first_late_rodata: + target = late_rodata_info + target.append((sym, block)) + + # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) + + function_info = list( + zip( + [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], + func_regex.split(asm)[1:], ) + ) - print(asm_path) + rdata_map = {} + late_rodata_map = {} - asm = "" - with open(asm_path, "r") as infile: - asm = infile.read() + # pass 1 to resolve rodata splits + if rodata != "": + last_fn = None - rodata = "" - if os.path.exists(rodata_path): - # print(rodata_path) - with open(rodata_path, "r") as rodata_file: - rodata = rodata_file.read() + referenced_in = {} # key=rodata label , value=function label - rodata_info = list(zip(rodata_syms(rodata), rodata_blocks(rodata))) + for sym, _ in rodata_info: + all_refs = [ + label for label, body in function_info if "%lo(" + sym + ")" in body + ] + # ignore multiple refs, take only the first + referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) - # populate rdata and late_rodata lists - first_late_rodata = find_late_rodata_start(rodata_info) - rdata_info = [] - late_rodata_info = [] - target = rdata_info # first populate rdata - for sym, block in rodata_info: - # now populate late_rodata, if there is any - if sym == first_late_rodata: - target = late_rodata_info - target.append((sym, block)) + def do_splits(out_dict, info): + first = True + last_ref = None + cr = None + for sym, block in info: + ref = referenced_in[sym] + if first: + cr = ref or sym - # print([(sym,block.split("\n")[1:]) for sym,block in zip(rdata_syms,rdata_blocks)]) + if ref is not None and not first: + if ref != last_ref: + # existing function + cr = ref + elif last_ref is not None: + # new GLOBAL_ASM + cr = sym - function_info = list( - zip( - [s.replace("glabel", "").strip() for s in func_regex.findall(asm)], - func_regex.split(asm)[1:], - ) - ) + # add to output + if cr not in out_dict.keys(): + out_dict.update({cr: []}) + out_dict[cr].append((sym, block)) - rdata_map = {} - late_rodata_map = {} + # setup next iter + last_ref = ref + first = False + + do_splits(rdata_map, rdata_info) + do_splits(late_rodata_map, late_rodata_info) + + # all output files, order is irrelevant at this point + all_output = set([label for label, _ in function_info]).union( + set(rdata_map.keys()), set(late_rodata_map.keys()) + ) + + # pass 2 to output splits + for label in all_output: + fn_body = dict(function_info).get(label, None) + + text_out = "" + rodata_out = "" + + if fn_body is not None: + text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" - # pass 1 to resolve rodata splits if rodata != "": - last_fn = None + rdata = rdata_map.get(label, None) + late_rodata = late_rodata_map.get(label, None) - referenced_in = {} # key=rodata label , value=function label - - for sym, _ in rodata_info: - all_refs = [ - label for label, body in function_info if "%lo(" + sym + ")" in body - ] - # ignore multiple refs, take only the first - referenced_in.update({sym: all_refs[0] if len(all_refs) != 0 else None}) - - def do_splits(out_dict, info): - first = True - last_ref = None - cr = None - for sym, block in info: - ref = referenced_in[sym] - if first: - cr = ref or sym - - if ref is not None and not first: - if ref != last_ref: - # existing function - cr = ref - elif last_ref is not None: - # new GLOBAL_ASM - cr = sym - - # add to output - if cr not in out_dict.keys(): - out_dict.update({cr: []}) - out_dict[cr].append((sym, block)) - - # setup next iter - last_ref = ref - first = False - - do_splits(rdata_map, rdata_info) - do_splits(late_rodata_map, late_rodata_info) - - # all output files, order is irrelevant at this point - all_output = set([label for label, _ in function_info]).union( - set(rdata_map.keys()), set(late_rodata_map.keys()) - ) - - # pass 2 to output splits - for label in all_output: - fn_body = dict(function_info).get(label, None) - - text_out = "" - rodata_out = "" - - if fn_body is not None: - text_out = "glabel " + label.strip() + "\n" + fn_body.strip() + "\n" - - if rodata != "": - rdata = rdata_map.get(label, None) - late_rodata = late_rodata_map.get(label, None) - - # check for late_rodata_alignment - late_rodata_alignment = "" - if fn_body is not None and late_rodata is not None: - ratio = late_rodata_size( - [block for _, block in late_rodata] - ) / text_block_size(fn_body) - if ratio > 1.0 / 3: - # print(f"{label} : {ratio}") - # TODO hack: getting the address from a comment - first_block_split = late_rodata[0][1].split(" */ .") - vaddr = None - if first_block_split[1].startswith( - "float" - ) or first_block_split[1].startswith("double"): - vaddr = first_block_split[0].split(" ")[-2] - else: - vaddr = first_block_split[0].split(" ")[-1] - assert vaddr is not None - vaddr = int(vaddr, 16) - if vaddr not in [ - 0x801E0E28, - 0x80C1C2B0, - 0x80AA7820, - 0x80AA3CC0, - 0x80AA418C, - 0x80BE0160, - 0x80B591D8, - 0x80B59610, - 0x80B59780, - 0x80964E00, - 0x80964F10, - 0x80BB40A0, - 0x80952038, - 0x80AFB920, - 0x80AFBBFC, - 0x80AFBE28, - 0x80983320, - ]: - # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with - # comparatively tiny functions, can we swat these programmatically? - late_rodata_alignment = f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" - - rdata_out = "" - if rdata is not None: - rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) - - late_rodata_out = "" - if late_rodata is not None: - late_rodata_out = ( - ".late_rodata\n" - + late_rodata_alignment - + "".join([block for _, block in late_rodata]) - ) - - rodata_out = ( - rdata_out - + late_rodata_out - + ( - "\n.text\n" - if ( - (rdata is not None or late_rodata is not None) - and fn_body is not None + # check for late_rodata_alignment + late_rodata_alignment = "" + if fn_body is not None and late_rodata is not None: + ratio = late_rodata_size( + [block for _, block in late_rodata] + ) / text_block_size(fn_body) + if ratio > 1.0 / 3: + # print(f"{label} : {ratio}") + # TODO hack: getting the address from a comment + first_block_split = late_rodata[0][1].split(" */ .") + vaddr = None + if first_block_split[1].startswith("float") or first_block_split[ + 1 + ].startswith("double"): + vaddr = first_block_split[0].split(" ")[-2] + else: + vaddr = first_block_split[0].split(" ")[-1] + assert vaddr is not None + vaddr = int(vaddr, 16) + if vaddr not in [ + 0x801E0E28, + 0x80C1C2B0, + 0x80AA7820, + 0x80AA3CC0, + 0x80AA418C, + 0x80BE0160, + 0x80B591D8, + 0x80B59610, + 0x80B59780, + 0x80964E00, + 0x80964F10, + 0x80BB40A0, + 0x80952038, + 0x80AFB920, + 0x80AFBBFC, + 0x80AFBE28, + 0x80983320, + ]: + # hacks for especially badly behaved rodata, TODO these are ALL jumptables associated with + # comparatively tiny functions, can we swat these programmatically? + late_rodata_alignment = ( + f".late_rodata_alignment {'8' if vaddr % 8 == 0 else '4'}\n" ) - else "" - ) + + rdata_out = "" + if rdata is not None: + rdata_out = ".rdata\n" + "".join([block for _, block in rdata]) + + late_rodata_out = "" + if late_rodata is not None: + late_rodata_out = ( + ".late_rodata\n" + + late_rodata_alignment + + "".join([block for _, block in late_rodata]) ) - all_out = rodata_out + text_out - - # write it out - out_path = ( - root.replace(ASM_OUT, f"{ASM_OUT}/non_matchings/") - + "/" - + ((f.replace(".text.s", "") + "/") if "overlays" not in root else "") + rodata_out = ( + rdata_out + + late_rodata_out + + ( + "\n.text\n" + if ( + (rdata is not None or late_rodata is not None) + and fn_body is not None + ) + else "" + ) ) - os.makedirs(out_path, exist_ok=True) - with open(out_path + label + ".s", "w") as outfile: - outfile.write(all_out.strip() + "\n") - # remove rodata and unsplit file - # TODO + all_out = rodata_out + text_out + + # write it out + out_path = Path(asm_path.replace(ASM_OUT, f"{ASM_OUT}non_matchings/")).parent + if out_path.parts[2] not in ("overlays", "makerom"): + out_path /= file.name.split(".")[0] + out_path.mkdir(parents=True, exist_ok=True) + + out_path /= label + ".s" + with open(out_path, "w") as outfile: + outfile.write(all_out.strip() + "\n") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 9cc4d20fe..7cb0f2be1 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -524,6 +524,7 @@ 0x801BA200 : "z_collision_check", 0x801BA550 : "z_debug_display", 0x801BB090 : "z_debug_mode", + 0x801BB120 : "z_demo", 0x801BB170 : "z_draw", 0x801BC240 : "z_eff_footmark", 0x801BC2A0 : "", @@ -560,8 +561,9 @@ 0x801C5DD0 : "z_vimode", 0x801C5E30 : "z_vr_box", 0x801C5FC0 : "z_sram_NES", + 0x801C6A70 : "z_message", 0x801D0470 : "z_message_nes", - 0x801D0B50 : "", + 0x801D0B50 : "z_player_call", 0x801D0B70 : "z_kaleido_manager", 0x801D0BB0 : "", 0x801D0C80 : "z_fbdemo", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4bd9a7aaa..fb76c370a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12,8 +12,8 @@ 0x80080514:("Idle_ThreadEntry",), 0x800805E0:("ViConfig_UpdateVi",), 0x80080748:("ViConfig_UpdateBlack",), - 0x80080790:("DmaMgr_DMARomToRam",), - 0x800808D4:("DmaMgr_DmaCallback0",), + 0x80080790:("DmaMgr_DmaRomToRam",), + 0x800808D4:("DmaMgr_DmaHandler",), 0x800808F4:("DmaMgr_FindDmaEntry",), 0x80080950:("DmaMgr_TranslateVromToRom",), 0x800809BC:("DmaMgr_FindDmaIndex",), @@ -158,12 +158,12 @@ 0x80086280:("__assert",), 0x800862B4:("func_800862B4",), 0x800862E0:("SystemArena_MallocMin1",), - 0x80086310:("SystemArena_FreeNull",), - 0x8008633C:("func_8008633C",), - 0x800863AC:("func_800863AC",), - 0x8008641C:("func_8008641C",), - 0x800864EC:("func_800864EC",), - 0x80086588:("func_80086588",), + 0x80086310:("SystemArena_FreeNullCheck",), + 0x8008633C:("SystemArena_RunBlockFunc",), + 0x800863AC:("SystemArena_RunBlockFunc1",), + 0x8008641C:("SystemArena_RunBlockFunc8",), + 0x800864EC:("SystemArena_RunBlockFunc1Reverse",), + 0x80086588:("SystemArena_RunInits",), 0x800865F8:("SystemArena_Init",), 0x80086620:("PadSetup_Init",), 0x80086760:("func_80086760",), @@ -867,7 +867,7 @@ 0x800BCB70:("Actor_SetColorFilter",), 0x800BCBF4:("func_800BCBF4",), 0x800BCC68:("func_800BCC68",), - 0x800BCCDC:("func_800BCCDC",), + 0x800BCCDC:("Actor_GetClosestPosOnPath",), 0x800BD2B4:("func_800BD2B4",), 0x800BD384:("func_800BD384",), 0x800BD6B8:("func_800BD6B8",), @@ -877,7 +877,7 @@ 0x800BD9E0:("func_800BD9E0",), 0x800BDAA0:("func_800BDAA0",), 0x800BDB6C:("func_800BDB6C",), - 0x800BDC5C:("Actor_ChangeAnimation",), + 0x800BDC5C:("Actor_ChangeAnimationByInfo",), 0x800BDCF4:("func_800BDCF4",), 0x800BDFB0:("Actor_Noop",), 0x800BDFC0:("Gfx_DrawDListOpa",), @@ -893,7 +893,7 @@ 0x800BE568:("func_800BE568",), 0x800BE5CC:("func_800BE5CC",), 0x800BE63C:("func_800BE63C",), - 0x800BE680:("func_800BE680",), + 0x800BE680:("Actor_DrawDamageEffects",), 0x800BF7CC:("Actor_SpawnIceEffects",), 0x800BF9A0:("ActorOverlayTable_FaultPrint",), 0x800BFA78:("ActorOverlayTable_FaultAddrConv",), @@ -1272,13 +1272,13 @@ 0x800DF86C:("func_800DF86C",), 0x800DF8EC:("func_800DF8EC",), 0x800DFAC8:("func_800DFAC8",), - 0x800DFB14:("func_800DFB14",), + 0x800DFB14:("Camera_ChangeDataIdx",), 0x800DFC1C:("func_800DFC1C",), 0x800DFC40:("func_800DFC40",), - 0x800DFC68:("func_800DFC68",), + 0x800DFC68:("Camera_GetInputDirYaw",), 0x800DFC90:("func_800DFC90",), - 0x800DFCB4:("func_800DFCB4",), - 0x800DFCDC:("func_800DFCDC",), + 0x800DFCB4:("Camera_GetCamDirPitch",), + 0x800DFCDC:("Camera_GetCamDirYaw",), 0x800DFD04:("func_800DFD04",), 0x800DFD78:("func_800DFD78",), 0x800DFEF0:("func_800DFEF0",), @@ -1290,13 +1290,13 @@ 0x800DFFAC:("func_800DFFAC",), 0x800E007C:("func_800E007C",), 0x800E01AC:("func_800E01AC",), - 0x800E01B8:("func_800E01B8",), + 0x800E01B8:("Camera_GetQuakeOffset",), 0x800E01DC:("func_800E01DC",), 0x800E0228:("func_800E0228",), 0x800E0238:("func_800E0238",), - 0x800E02AC:("func_800E02AC",), - 0x800E0308:("func_800E0308",), - 0x800E031C:("func_800E031C",), + 0x800E02AC:("Camera_SetToTrackActor",), + 0x800E0308:("Camera_SetTargetActor",), + 0x800E031C:("Camera_GetWaterYPos",), 0x800E0348:("func_800E0348",), 0x800E03A0:("DamageTable_Get",), 0x800E03CC:("DamageTable_Clear",), @@ -1534,36 +1534,36 @@ 0x800E9E94:("func_800E9E94",), 0x800E9F78:("func_800E9F78",), 0x800EA060:("Cutscene_Init",), - 0x800EA0D4:("func_800EA0D4",), - 0x800EA0EC:("func_800EA0EC",), - 0x800EA110:("Cutscene_StepCutscene1",), - 0x800EA15C:("Cutscene_StepCutscene2",), - 0x800EA210:("Cutscene_Nop800EA210",), + 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:("func_800EA324",), - 0x800EABAC:("func_800EABAC",), - 0x800EAC08:("func_800EAC08",), - 0x800EAC44:("func_800EAC44",), - 0x800EAC94:("func_800EAC94",), - 0x800EAD14:("func_800EAD14",), + 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:("func_800EAECC",), - 0x800EAF20:("func_800EAF20",), - 0x800EAFE0:("func_800EAFE0",), - 0x800EB1DC:("func_800EB1DC",), - 0x800EB364:("func_800EB364",), - 0x800EB4B4:("func_800EB4B4",), - 0x800EB6F8:("func_800EB6F8",), - 0x800EBB68:("func_800EBB68",), - 0x800EBCD0:("func_800EBCD0",), - 0x800EBD60:("func_800EBD60",), - 0x800EC678:("func_800EC678",), - 0x800EC6D4:("func_800EC6D4",), - 0x800EC924:("func_800EC924",), + 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",), + 0x800EC6D4:("Cutscene_CountNormalMasks",), + 0x800EC924:("Cutscene_Command_Textbox",), 0x800ECD7C:("func_800ECD7C",), 0x800ECE40:("Cutscene_ProcessCommands",), 0x800ED980:("func_800ED980",), @@ -1571,17 +1571,17 @@ 0x800EDA04:("func_800EDA04",), 0x800EDA84:("func_800EDA84",), 0x800EDBE0:("func_800EDBE0",), - 0x800EDDB0:("nop_800EDDB0",), + 0x800EDDB0:("func_800EDDB0",), 0x800EDDBC:("func_800EDDBC",), - 0x800EDDCC:("func_800EDDCC",), - 0x800EDE34:("func_800EDE34",), - 0x800EDF24:("func_800EDF24",), - 0x800EDF78:("func_800EDF78",), - 0x800EE0CC:("func_800EE0CC",), - 0x800EE1D8:("func_800EE1D8",), - 0x800EE200:("func_800EE200",), - 0x800EE29C:("func_800EE29C",), - 0x800EE2F4:("func_800EE2F4",), + 0x800EDDCC:("Cutscene_LoadCutsceneData",), + 0x800EDE34:("Cutscene_ActorTranslate",), + 0x800EDF24:("Cutscene_ActorTranslateAndYaw",), + 0x800EDF78:("Cutscene_ActorTranslateAndYawSmooth",), + 0x800EE0CC:("Cutscene_ActorTranslateXZAndYawSmooth",), + 0x800EE1D8:("Cutscene_GetSceneSetupIndex",), + 0x800EE200:("Cutscene_GetActorActionIndex",), + 0x800EE29C:("Cutscene_CheckActorAction",), + 0x800EE2F4:("Cutscene_IsPlaying",), 0x800EE320:("GetItem_Draw",), 0x800EE364:("func_800EE364",), 0x800EE400:("func_800EE400",), @@ -1699,7 +1699,7 @@ 0x800F4540:("Jpeg_ParseMarkers",), 0x800F470C:("Jpeg_Decode",), 0x800F4A10:("func_800F4A10",), - 0x800F4C0C:("func_800F4C0C",), + 0x800F4C0C:("KaleidoSetup_Update",), 0x800F4E20:("KaleidoSetup_Init",), 0x800F4F28:("KaleidoSetup_Destroy",), 0x800F4F40:("Font_LoadChar",), @@ -1710,7 +1710,7 @@ 0x800F50D4:("func_800F50D4",), 0x800F510C:("Kankyo_Init",), 0x800F5954:("func_800F5954",), - 0x800F5A8C:("func_800F5A8C",), + 0x800F5A8C:("Environment_LerpWeight",), 0x800F5B10:("func_800F5B10",), 0x800F5CD0:("func_800F5CD0",), 0x800F6834:("func_800F6834",), @@ -1738,7 +1738,7 @@ 0x800FAC20:("func_800FAC20",), 0x800FAF74:("func_800FAF74",), 0x800FB010:("func_800FB010",), - 0x800FB320:("func_800FB320",), + 0x800FB320:("Environment_AddLightningBolts",), 0x800FB388:("func_800FB388",), 0x800FB758:("func_800FB758",), 0x800FB9B4:("func_800FB9B4",), @@ -2608,23 +2608,23 @@ 0x801378B8:("Animation_OnFrame",), 0x801378E0:("SkelAnime_Free",), 0x8013792C:("SkelAnime_CopyFrameTable",), - 0x80137970:("func_80137970",), - 0x80137B34:("func_80137B34",), - 0x80137EBC:("func_80137EBC",), - 0x80137F58:("func_80137F58",), - 0x80138050:("func_80138050",), + 0x80137970:("Skin_UpdateVertices",), + 0x80137B34:("Skin_ApplyLimbModifications",), + 0x80137EBC:("Skin_DrawAnimatedLimb",), + 0x80137F58:("Skin_DrawLimb",), + 0x80138050:("Skin_DrawImpl",), 0x80138228:("func_80138228",), 0x80138258:("func_80138258",), 0x8013828C:("func_8013828C",), 0x801382C4:("func_801382C4",), - 0x80138300:("func_80138300",), - 0x8013835C:("func_8013835C",), - 0x80138410:("func_80138410",), - 0x80138424:("func_80138424",), - 0x8013859C:("func_8013859C",), - 0x80138700:("func_80138700",), + 0x80138300:("Skin_GetLimbPos",), + 0x8013835C:("Skin_GetVertexPos",), + 0x80138410:("Skin_Setup",), + 0x80138424:("Skin_InitAnimatedLimb",), + 0x8013859C:("Skin_Init",), + 0x80138700:("Skin_Free",), 0x801387D4:("func_801387D4",), - 0x801388E4:("func_801388E4",), + 0x801388E4:("Skin_ApplyAnimTransformations",), 0x80138BA0:("SkinMatrix_Vec3fMtxFMultXYZW",), 0x80138C88:("SkinMatrix_Vec3fMtxFMultXYZ",), 0x80138D38:("SkinMatrix_MtxFMtxFMult",), @@ -2660,49 +2660,49 @@ 0x8013AB00:("SubS_DrawTransformFlex",), 0x8013AD6C:("func_8013AD6C",), 0x8013AD9C:("func_8013AD9C",), - 0x8013AED4:("func_8013AED4",), + 0x8013AED4:("SubS_UpdateFlags",), 0x8013AF00:("func_8013AF00",), 0x8013B010:("func_8013B010",), 0x8013B0C8:("func_8013B0C8",), 0x8013B350:("func_8013B350",), 0x8013B6B0:("func_8013B6B0",), 0x8013B878:("func_8013B878",), - 0x8013BB34:("func_8013BB34",), + 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), - 0x8013BC6C:("func_8013BC6C",), - 0x8013BD40:("func_8013BD40",), - 0x8013BEDC:("func_8013BEDC",), + 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), + 0x8013BD40:("SubS_HasReachedPoint",), + 0x8013BEDC:("SubS_GetDayDependentPath",), 0x8013C068:("func_8013C068",), 0x8013C624:("func_8013C624",), - 0x8013C8B8:("func_8013C8B8",), + 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), 0x8013CC2C:("func_8013CC2C",), 0x8013CD64:("func_8013CD64",), 0x8013CF04:("func_8013CF04",), 0x8013D0E0:("func_8013D0E0",), 0x8013D2E0:("func_8013D2E0",), - 0x8013D5E8:("func_8013D5E8",), - 0x8013D648:("func_8013D648",), - 0x8013D68C:("func_8013D68C",), - 0x8013D720:("func_8013D720",), - 0x8013D768:("func_8013D768",), - 0x8013D83C:("func_8013D83C",), - 0x8013D8DC:("func_8013D8DC",), - 0x8013D924:("func_8013D924",), + 0x8013D5E8:("SubS_AngleDiffLessEqual",), + 0x8013D648:("SubS_GetPathByIndex",), + 0x8013D68C:("SubS_CopyPointFromPath",), + 0x8013D720:("SubS_GetDistSqAndOrientPoints",), + 0x8013D768:("SubS_MoveActorToPoint",), + 0x8013D83C:("SubS_GetDistSqAndOrientPath",), + 0x8013D8DC:("SubS_IsObjectLoaded",), + 0x8013D924:("SubS_GetObjectIndex",), 0x8013D960:("SubS_FindActor",), - 0x8013D9C8:("func_8013D9C8",), - 0x8013DB90:("func_8013DB90",), - 0x8013DC40:("func_8013DC40",), - 0x8013DCCC:("func_8013DCCC",), - 0x8013DCE0:("func_8013DCE0",), - 0x8013DE04:("func_8013DE04",), - 0x8013DF3C:("func_8013DF3C",), - 0x8013E054:("func_8013E054",), - 0x8013E07C:("func_8013E07C",), - 0x8013E0A4:("func_8013E0A4",), - 0x8013E1C8:("func_8013E1C8",), - 0x8013E2D4:("func_8013E2D4",), - 0x8013E3B8:("func_8013E3B8",), + 0x8013D9C8:("SubS_FillLimbRotTables",), + 0x8013DB90:("SubS_IsFloorAbove",), + 0x8013DC40:("SubS_CopyPointFromPathList",), + 0x8013DCCC:("SubS_GetPathCount",), + 0x8013DCE0:("SubS_ActorPathing_Init",), + 0x8013DE04:("SubS_ActorPathing_Update",), + 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), + 0x8013E054:("SubS_ActorPathing_MoveWithGravity",), + 0x8013E07C:("SubS_ActorPathing_MoveWithoutGravityReverse",), + 0x8013E0A4:("SubS_ActorPathing_SetNextPoint",), + 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), + 0x8013E2D4:("SubS_StartActorCutscene",), + 0x8013E3B8:("SubS_FillCutscenesList",), 0x8013E4B0:("func_8013E4B0",), 0x8013E5CC:("func_8013E5CC",), 0x8013E640:("SubS_FindActorCustom",), @@ -2787,30 +2787,30 @@ 0x80143624:("SkyboxDraw_SetColors",), 0x80143668:("SkyboxDraw_Draw",), 0x80143A04:("SkyboxDraw_Noop",), - 0x80143A10:("func_80143A10",), - 0x80143A54:("func_80143A54",), - 0x80143AC4:("func_80143AC4",), - 0x80143B0C:("func_80143B0C",), + 0x80143A10:("Sram_ActivateOwl",), + 0x80143A54:("Sram_ClearHighscores",), + 0x80143AC4:("Sram_ClearFlagsAtDawnOfTheFirstDay",), + 0x80143B0C:("Sram_SaveEndOfCycle",), 0x80144574:("Sram_IncrementDay",), 0x801445E4:("Sram_CalcChecksum",), - 0x80144628:("func_80144628",), + 0x80144628:("Sram_ResetSave",), 0x80144684:("Sram_GenerateRandomSaveFields",), - 0x80144890:("func_80144890",), + 0x80144890:("Sram_InitNewSave",), 0x80144968:("Sram_InitDebugSave",), 0x80144A94:("func_80144A94",), - 0x80144E78:("func_80144E78",), + 0x80144E78:("Sram_OpenSave",), 0x8014546C:("func_8014546C",), 0x80145698:("func_80145698",), 0x801457CC:("func_801457CC",), 0x80146580:("func_80146580",), 0x80146628:("func_80146628",), - 0x80146AA0:("func_80146AA0",), + 0x80146AA0:("Sram_InitSave",), 0x80146DF8:("func_80146DF8",), - 0x80146E40:("func_80146E40",), + 0x80146E40:("Sram_InitSram",), 0x80146E70:("Sram_Alloc",), 0x80146EBC:("func_80146EBC",), - 0x80146EE8:("func_80146EE8",), - 0x80146F5C:("func_80146F5C",), + 0x80146EE8:("Sram_SaveSpecialEnterClockTown",), + 0x80146F5C:("Sram_SaveSpecialNewDay",), 0x80147008:("func_80147008",), 0x80147020:("func_80147020",), 0x80147068:("func_80147068",), @@ -2822,8 +2822,8 @@ 0x8014750C:("Sram_nop8014750C",), 0x80147520:("func_80147520",), 0x80147564:("func_80147564",), - 0x80147624:("func_80147624",), - 0x80147734:("func_80147734",), + 0x80147624:("Message_ShouldAdvance",), + 0x80147734:("Message_ShouldAdvanceSilent",), 0x801477B4:("func_801477B4",), 0x80147818:("func_80147818",), 0x80147F18:("func_80147F18",), @@ -2837,12 +2837,12 @@ 0x801496C8:("func_801496C8",), 0x8014995C:("func_8014995C",), 0x80149C18:("func_80149C18",), - 0x80149EBC:("func_80149EBC",), + 0x80149EBC:("Message_FindMessage",), 0x80149F74:("func_80149F74",), 0x8014AAD0:("func_8014AAD0",), 0x8014ADBC:("func_8014ADBC",), 0x8014C70C:("func_8014C70C",), - 0x8014CC14:("func_8014CC14",), + 0x8014CC14:("Message_LoadChar",), 0x8014CCB4:("func_8014CCB4",), 0x8014CDF0:("func_8014CDF0",), 0x8014CFDC:("func_8014CFDC",), @@ -2852,7 +2852,7 @@ 0x80150A84:("func_80150A84",), 0x80150D08:("func_80150D08",), 0x801514B0:("func_801514B0",), - 0x801518B0:("func_801518B0",), + 0x801518B0:("Message_StartTextbox",), 0x80151938:("func_80151938",), 0x80151A68:("func_80151A68",), 0x80151BB4:("func_80151BB4",), @@ -2874,24 +2874,24 @@ 0x8015680C:("func_8015680C",), 0x801586A4:("func_801586A4",), 0x801586D4:("Message_Init",), - 0x801588D0:("func_801588D0",), - 0x80158988:("func_80158988",), - 0x80158A24:("func_80158A24",), - 0x80158C04:("func_80158C04",), - 0x80158D98:("func_80158D98",), - 0x80158FB0:("func_80158FB0",), - 0x8015926C:("func_8015926C",), + 0x801588D0:("Message_FindMessageNES",), + 0x80158988:("Message_LoadCharNES",), + 0x80158A24:("Message_LoadPluralRupeesNES",), + 0x80158C04:("Message_LoadLocalizedRupeesNES",), + 0x80158D98:("Message_LoadRupeesNES",), + 0x80158FB0:("Message_LoadTimeNES",), + 0x8015926C:("Message_LoadAreaTextNES",), 0x80159438:("func_80159438",), 0x8015966C:("func_8015966C",), 0x8015B198:("func_8015B198",), - 0x8015E750:("func_8015E750",), + 0x8015E750:("Message_FindCreditsMessage",), 0x8015E7EC:("func_8015E7EC",), 0x8015F8A8:("func_8015F8A8",), - 0x80160A90:("func_80160A90",), - 0x80160AF8:("func_80160AF8",), - 0x80160B40:("func_80160B40",), - 0x80160B80:("func_80160B80",), - 0x80160BC0:("func_80160BC0",), + 0x80160A90:("PlayerCall_InitFuncPtrs",), + 0x80160AF8:("PlayerCall_Init",), + 0x80160B40:("PlayerCall_Destroy",), + 0x80160B80:("PlayerCall_Update",), + 0x80160BC0:("PlayerCall_Draw",), 0x80160C00:("ShrinkWindow_SetLetterboxTarget",), 0x80160C14:("ShrinkWindow_GetLetterboxTarget",), 0x80160C28:("ShrinkWindow_SetLetterboxMagnitude",), @@ -2998,7 +2998,7 @@ 0x80168090:("Play_Draw",), 0x80168DAC:("func_80168DAC",), 0x80168F64:("Play_Update",), - 0x801690CC:("func_801690CC",), + 0x801690CC:("Play_InCsMode",), 0x80169100:("func_80169100",), 0x801691F0:("func_801691F0",), 0x80169220:("Play_LoadScene",), @@ -3006,28 +3006,28 @@ 0x801692C4:("func_801692C4",), 0x801693D4:("Play_SceneInit",), 0x80169474:("func_80169474",), - 0x801694DC:("func_801694DC",), - 0x80169584:("Play_GetActiveCameraIndex",), - 0x80169590:("func_80169590",), - 0x80169600:("func_80169600",), - 0x80169668:("func_80169668",), + 0x801694DC:("Play_CreateSubCamera",), + 0x80169584:("Play_GetActiveCamId",), + 0x80169590:("Play_CameraChangeStatus",), + 0x80169600:("Play_ClearCamera",), + 0x80169668:("Play_ClearAllSubCameras",), 0x801696D4:("Play_GetCamera",), 0x8016970C:("Play_CameraSetAtEye",), - 0x8016981C:("func_8016981C",), - 0x80169940:("func_80169940",), - 0x80169988:("func_80169988",), - 0x801699D4:("func_801699D4",), + 0x8016981C:("Play_CameraSetAtEyeUp",), + 0x80169940:("Play_CameraSetFov",), + 0x80169988:("Play_CameraSetRoll",), + 0x801699D4:("Play_CopyCamera",), 0x80169A50:("func_80169A50",), - 0x80169AC0:("func_80169AC0",), + 0x80169AC0:("Play_CameraChangeSetting",), 0x80169AFC:("func_80169AFC",), - 0x80169BC4:("func_80169BC4",), + 0x80169BC4:("Play_CameraGetUID",), 0x80169BF8:("func_80169BF8",), - 0x80169C64:("func_80169C64",), - 0x80169C84:("func_80169C84",), - 0x80169CBC:("convert_scene_number_among_shared_scenes",), - 0x80169D40:("func_80169D40",), - 0x80169DCC:("func_80169DCC",), - 0x80169E6C:("func_80169E6C",), + 0x80169C64:("Play_GetCsCamDataSetting",), + 0x80169C84:("Play_GetCsCamDataVec3s",), + 0x80169CBC:("Play_GetOriginalSceneNumber",), + 0x80169D40:("Play_SaveCycleSceneFlags",), + 0x80169DCC:("Play_SetRespawnData",), + 0x80169E6C:("Play_SetupRespawnPoint",), 0x80169ECC:("func_80169ECC",), 0x80169EFC:("func_80169EFC",), 0x80169F78:("func_80169F78",), @@ -3035,9 +3035,9 @@ 0x80169FFC:("func_80169FFC",), 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), - 0x8016A0AC:("func_8016A0AC",), + 0x8016A0AC:("Play_IsUnderwater",), 0x8016A168:("func_8016A168",), - 0x8016A178:("func_8016A178",), + 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), 0x8016A268:("func_8016A268",), 0x8016A2C8:("Play_Init",), 0x8016AC10:("func_8016AC10",), @@ -3320,7 +3320,7 @@ 0x8017D020:("Math3D_TriChkLineSegParaZIntersect",), 0x8017D1AC:("func_8017D1AC",), 0x8017D220:("func_8017D220",), - 0x8017D2FC:("func_8017D2FC",), + 0x8017D2FC:("Math3D_LineSegVsPlane",), 0x8017D404:("func_8017D404",), 0x8017D568:("Math3D_TriSetCoords",), 0x8017D618:("Math3D_IsPointInSphere",), @@ -3548,138 +3548,138 @@ 0x8018AE34:("func_8018AE34",), 0x8018B0F0:("func_8018B0F0",), 0x8018B10C:("func_8018B10C",), - 0x8018B250:("func_8018B250",), - 0x8018B318:("func_8018B318",), - 0x8018B3FC:("func_8018B3FC",), - 0x8018B474:("func_8018B474",), - 0x8018B4F8:("func_8018B4F8",), - 0x8018B520:("func_8018B520",), - 0x8018B578:("func_8018B578",), + 0x8018B250:("AudioHeap_ResetLoadStatus",), + 0x8018B318:("AudioHeap_DiscardFont",), + 0x8018B3FC:("AudioHeap_ReleaseNotesForFont",), + 0x8018B474:("AudioHeap_DiscardSequence",), + 0x8018B4F8:("AudioHeap_WritebackDCache",), + 0x8018B520:("AudioHeap_AllocZeroedAttemptExternal",), + 0x8018B578:("AudioHeap_AllocAttemptExternal",), 0x8018B5D0:("AudioHeap_AllocDmaMemory",), - 0x8018B608:("func_8018B608",), - 0x8018B640:("func_8018B640",), - 0x8018B69C:("func_8018B69C",), - 0x8018B6E8:("func_8018B6E8",), - 0x8018B740:("func_8018B740",), - 0x8018B768:("func_8018B768",), - 0x8018B77C:("func_8018B77C",), - 0x8018B7AC:("func_8018B7AC",), - 0x8018B7BC:("func_8018B7BC",), - 0x8018B8FC:("func_8018B8FC",), - 0x8018B95C:("func_8018B95C",), - 0x8018B9E0:("func_8018B9E0",), - 0x8018BA64:("func_8018BA64",), - 0x8018BB28:("func_8018BB28",), - 0x8018BBEC:("func_8018BBEC",), - 0x8018C380:("func_8018C380",), - 0x8018C3D8:("func_8018C3D8",), + 0x8018B608:("AudioHeap_AllocDmaMemoryZeroed",), + 0x8018B640:("AudioHeap_AllocZeroed",), + 0x8018B69C:("AudioHeap_TestAlloc",), + 0x8018B6E8:("AudioHeap_Alloc",), + 0x8018B740:("AudioHeap_AllocPoolInit",), + 0x8018B768:("AudioHeap_ClearPersistentCache",), + 0x8018B77C:("AudioHeap_ClearTemporaryCache",), + 0x8018B7AC:("AudioHeap_ResetPool",), + 0x8018B7BC:("AudioHeap_PopCache",), + 0x8018B8FC:("AudioHeap_InitMainPool",), + 0x8018B95C:("AudioHeap_InitSessionPool",), + 0x8018B9E0:("AudioHeap_InitCachePool",), + 0x8018BA64:("AudioHeap_InitPersistentCache",), + 0x8018BB28:("AudioHeap_InitTemporaryCache",), + 0x8018BBEC:("AudioHeap_AllocCached",), + 0x8018C380:("AudioHeap_SearchCaches",), + 0x8018C3D8:("AudioHeap_SearchRegularCaches",), 0x8018C4E4:("func_8018C4E4",), - 0x8018C8B8:("func_8018C8B8",), - 0x8018C8E8:("func_8018C8E8",), - 0x8018C93C:("func_8018C93C",), - 0x8018C994:("func_8018C994",), - 0x8018CB70:("func_8018CB70",), - 0x8018CB78:("func_8018CB78",), - 0x8018CC3C:("func_8018CC3C",), - 0x8018CCA8:("func_8018CCA8",), - 0x8018CFAC:("func_8018CFAC",), - 0x8018D57C:("func_8018D57C",), - 0x8018D5D4:("func_8018D5D4",), - 0x8018D658:("func_8018D658",), - 0x8018D6C8:("func_8018D6C8",), - 0x8018D760:("func_8018D760",), - 0x8018DA50:("func_8018DA50",), - 0x8018DBC4:("func_8018DBC4",), - 0x8018DCB4:("func_8018DCB4",), - 0x8018DCF8:("func_8018DCF8",), - 0x8018DD98:("func_8018DD98",), - 0x8018DDD4:("func_8018DDD4",), - 0x8018DF24:("func_8018DF24",), - 0x8018DFE0:("func_8018DFE0",), - 0x8018E00C:("func_8018E00C",), - 0x8018E03C:("func_8018E03C",), - 0x8018E2A8:("func_8018E2A8",), - 0x8018E344:("func_8018E344",), - 0x8018E8C8:("func_8018E8C8",), - 0x8018EB60:("func_8018EB60",), - 0x8018EC4C:("func_8018EC4C",), - 0x8018EF88:("func_8018EF88",), + 0x8018C8B8:("AudioHeap_ClearFilter",), + 0x8018C8E8:("AudioHeap_LoadLowPassFilter",), + 0x8018C93C:("AudioHeap_LoadHighPassFilter",), + 0x8018C994:("AudioHeap_LoadFilter",), + 0x8018CB70:("AudioHeap_UpdateReverb",), + 0x8018CB78:("AudioHeap_UpdateReverbs",), + 0x8018CC3C:("AudioHeap_ClearAiBuffers",), + 0x8018CCA8:("AudioHeap_ResetStep",), + 0x8018CFAC:("AudioHeap_Init",), + 0x8018D57C:("AudioHeap_SearchPermanentCache",), + 0x8018D5D4:("AudioHeap_AllocPermanent",), + 0x8018D658:("AudioHeap_AllocSampleCache",), + 0x8018D6C8:("AudioHeap_InitSampleCaches",), + 0x8018D760:("AudioHeap_AllocTemporarySampleCacheEntry",), + 0x8018DA50:("AudioHeap_UnapplySampleCacheForFont",), + 0x8018DBC4:("AudioHeap_DiscardSampleCacheEntry",), + 0x8018DCB4:("AudioHeap_UnapplySampleCache",), + 0x8018DCF8:("AudioHeap_AllocPersistentSampleCacheEntry",), + 0x8018DD98:("AudioHeap_DiscardSampleCacheForFont",), + 0x8018DDD4:("AudioHeap_DiscardSampleCaches",), + 0x8018DF24:("AudioHeap_ChangeStorage",), + 0x8018DFE0:("AudioHeap_DiscardSampleBank",), + 0x8018E00C:("AudioHeap_ApplySampleBankCache",), + 0x8018E03C:("AudioHeap_ApplySampleBankCacheInternal",), + 0x8018E2A8:("AudioHeap_DiscardSampleBanks",), + 0x8018E344:("AudioHeap_SetReverbData",), + 0x8018E8C8:("AudioHeap_InitReverb",), + 0x8018EB60:("AudioLoad_DecreaseSampleDmaTtls",), + 0x8018EC4C:("AudioLoad_DmaSampleData",), + 0x8018EF88:("AudioLoad_InitSampleDmaBuffers",), 0x8018F220:("AudioLoad_IsFontLoadComplete",), - 0x8018F298:("func_8018F298",), - 0x8018F310:("func_8018F310",), - 0x8018F388:("func_8018F388",), - 0x8018F3B8:("func_8018F3B8",), - 0x8018F3E8:("func_8018F3E8",), - 0x8018F448:("func_8018F448",), - 0x8018F478:("func_8018F478",), - 0x8018F4D8:("func_8018F4D8",), - 0x8018F588:("func_8018F588",), - 0x8018F604:("func_8018F604",), - 0x8018F6F0:("func_8018F6F0",), - 0x8018F7C0:("func_8018F7C0",), - 0x8018F7F8:("func_8018F7F8",), - 0x8018F83C:("func_8018F83C",), - 0x8018F880:("func_8018F880",), - 0x8018F8C4:("func_8018F8C4",), - 0x8018F908:("func_8018F908",), - 0x8018F9B8:("func_8018F9B8",), + 0x8018F298:("AudioLoad_IsSeqLoadComplete",), + 0x8018F310:("AudioLoad_IsSampleLoadComplete",), + 0x8018F388:("AudioLoad_SetFontLoadStatus",), + 0x8018F3B8:("AudioLoad_SetSeqLoadStatus",), + 0x8018F3E8:("AudioLoad_SetSampleFontLoadStatusAndApplyCaches",), + 0x8018F448:("AudioLoad_SetSampleFontLoadStatus",), + 0x8018F478:("AudioLoad_InitTable",), + 0x8018F4D8:("AudioLoad_SyncLoadSeqFonts",), + 0x8018F588:("AudioLoad_SyncLoadSeqParts",), + 0x8018F604:("AudioLoad_SyncLoadSample",), + 0x8018F6F0:("AudioLoad_SyncLoadInstrument",), + 0x8018F7C0:("AudioLoad_AsyncLoad",), + 0x8018F7F8:("AudioLoad_AsyncLoadSeq",), + 0x8018F83C:("AudioLoad_AsyncLoadSampleBank",), + 0x8018F880:("AudioLoad_AsyncLoadFont",), + 0x8018F8C4:("AudioLoad_GetFontsForSequence",), + 0x8018F908:("AudioLoad_DiscardSeqFonts",), + 0x8018F9B8:("AudioLoad_DiscardFont",), 0x8018FA60:("func_8018FA60",), - 0x8018FAD0:("func_8018FAD0",), - 0x8018FB20:("func_8018FB20",), - 0x8018FB78:("func_8018FB78",), - 0x8018FCCC:("func_8018FCCC",), - 0x8018FD20:("func_8018FD20",), - 0x8018FD40:("func_8018FD40",), - 0x8018FE5C:("func_8018FE5C",), - 0x8018FF60:("func_8018FF60",), - 0x80190204:("func_80190204",), - 0x80190240:("func_80190240",), - 0x80190294:("func_80190294",), - 0x801902D8:("func_801902D8",), - 0x80190544:("func_80190544",), - 0x80190668:("func_80190668",), - 0x8019067C:("func_8019067C",), - 0x80190754:("func_80190754",), - 0x8019075C:("func_8019075C",), - 0x8019077C:("func_8019077C",), - 0x80190B08:("func_80190B08",), - 0x80190B38:("func_80190B38",), - 0x80190B44:("func_80190B44",), - 0x80190B50:("func_80190B50",), - 0x80190BB0:("func_80190BB0",), - 0x80190F50:("func_80190F50",), - 0x80190F64:("func_80190F64",), - 0x80191134:("func_80191134",), - 0x801911C4:("func_801911C4",), - 0x801911CC:("func_801911CC",), - 0x80191240:("func_80191240",), - 0x801913C8:("func_801913C8",), - 0x8019144C:("func_8019144C",), - 0x80191460:("func_80191460",), - 0x80191568:("func_80191568",), - 0x80191598:("func_80191598",), - 0x8019161C:("func_8019161C",), - 0x80191740:("func_80191740",), - 0x80191864:("func_80191864",), - 0x80191870:("func_80191870",), - 0x801919AC:("func_801919AC",), - 0x80191B40:("func_80191B40",), - 0x80191BD0:("func_80191BD0",), - 0x80191C40:("func_80191C40",), - 0x80191C54:("func_80191C54",), - 0x80191D94:("func_80191D94",), - 0x8019218C:("func_8019218C",), - 0x80192340:("func_80192340",), - 0x80192388:("func_80192388",), - 0x801924BC:("func_801924BC",), - 0x80192514:("func_80192514",), - 0x80192990:("func_80192990",), - 0x80192AD0:("func_80192AD0",), - 0x80192AD8:("func_80192AD8",), - 0x80192AE0:("func_80192AE0",), - 0x80192AE8:("func_80192AE8",), - 0x80192B54:("func_80192B54",), - 0x80192BAC:("func_80192BAC",), + 0x8018FAD0:("AudioLoad_SyncInitSeqPlayer",), + 0x8018FB20:("AudioLoad_SyncInitSeqPlayerSkipTicks",), + 0x8018FB78:("AudioLoad_SyncInitSeqPlayerInternal",), + 0x8018FCCC:("AudioLoad_SyncLoadSeq",), + 0x8018FD20:("AudioLoad_GetSampleBank",), + 0x8018FD40:("AudioLoad_TrySyncLoadSampleBank",), + 0x8018FE5C:("AudioLoad_SyncLoadFont",), + 0x8018FF60:("AudioLoad_SyncLoad",), + 0x80190204:("AudioLoad_GetRealTableIndex",), + 0x80190240:("AudioLoad_SearchCaches",), + 0x80190294:("AudioLoad_GetLoadTable",), + 0x801902D8:("AudioLoad_RelocateFont",), + 0x80190544:("AudioLoad_SyncDma",), + 0x80190668:("AudioLoad_SyncDmaUnkMedium",), + 0x8019067C:("AudioLoad_Dma",), + 0x80190754:("AudioLoad_Unused1",), + 0x8019075C:("AudioLoad_SyncLoadSimple",), + 0x8019077C:("AudioLoad_AsyncLoadInner",), + 0x80190B08:("AudioLoad_ProcessLoads",), + 0x80190B38:("AudioLoad_SetDmaHandler",), + 0x80190B44:("AudioLoad_SetUnusedHandler",), + 0x80190B50:("AudioLoad_InitSoundFontMeta",), + 0x80190BB0:("AudioLoad_Init",), + 0x80190F50:("AudioLoad_InitSlowLoads",), + 0x80190F64:("AudioLoad_SlowLoadSample",), + 0x80191134:("AudioLoad_GetFontSample",), + 0x801911C4:("AudioLoad_Unused2",), + 0x801911CC:("AudioLoad_FinishSlowLoad",), + 0x80191240:("AudioLoad_ProcessSlowLoads",), + 0x801913C8:("AudioLoad_DmaSlowCopy",), + 0x8019144C:("AudioLoad_DmaSlowCopyUnkMedium",), + 0x80191460:("AudioLoad_SlowLoadSeq",), + 0x80191568:("AudioLoad_InitAsyncLoads",), + 0x80191598:("AudioLoad_StartAsyncLoadUnkMedium",), + 0x8019161C:("AudioLoad_StartAsyncLoad",), + 0x80191740:("AudioLoad_ProcessAsyncLoads",), + 0x80191864:("AudioLoad_ProcessAsyncLoadUnkMedium",), + 0x80191870:("AudioLoad_FinishAsyncLoad",), + 0x801919AC:("AudioLoad_ProcessAsyncLoad",), + 0x80191B40:("AudioLoad_AsyncDma",), + 0x80191BD0:("AudioLoad_AsyncDmaRamUnloaded",), + 0x80191C40:("AudioLoad_AsyncDmaUnkMedium",), + 0x80191C54:("AudioLoad_RelocateSample",), + 0x80191D94:("AudioLoad_RelocateFontAndPreloadSamples",), + 0x8019218C:("AudioLoad_ProcessSamplePreloads",), + 0x80192340:("AudioLoad_AddToSampleSet",), + 0x80192388:("AudioLoad_GetSamplesForFont",), + 0x801924BC:("AudioLoad_AddUsedSample",), + 0x80192514:("AudioLoad_PreloadSamplesForFont",), + 0x80192990:("AudioLoad_LoadPermanentSamples",), + 0x80192AD0:("AudioLoad_Unused3",), + 0x80192AD8:("AudioLoad_Unused4",), + 0x80192AE0:("AudioLoad_Unused5",), + 0x80192AE8:("AudioLoad_ScriptLoad",), + 0x80192B54:("AudioLoad_ProcessScriptLoads",), + 0x80192BAC:("AudioLoad_InitScriptLoads",), 0x80192BE0:("func_80192BE0",), 0x80192C00:("func_80192C00",), 0x8019319C:("func_8019319C",), @@ -3689,7 +3689,7 @@ 0x8019380C:("func_8019380C",), 0x80193858:("func_80193858",), 0x8019387C:("func_8019387C",), - 0x801938A0:("func_801938A0",), + 0x801938A0:("Audio_QueueCmdS8",), 0x801938D0:("func_801938D0",), 0x80193900:("func_80193900",), 0x80193990:("func_80193990",), @@ -3718,8 +3718,8 @@ 0x80194528:("func_80194528",), 0x80194548:("func_80194548",), 0x80194568:("func_80194568",), - 0x80194668:("func_80194668",), - 0x801946E4:("func_801946E4",), + 0x80194668:("Audio_NextRandom",), + 0x801946E4:("Audio_InitMesgQueues",), 0x80194710:("Audio_InvalDCache",), 0x80194750:("Audio_WritebackDCache",), 0x80194790:("func_80194790",), @@ -3777,7 +3777,7 @@ 0x80197B14:("func_80197B14",), 0x80197C0C:("func_80197C0C",), 0x80197C8C:("func_80197C8C",), - 0x80197D24:("func_80197D24",), + 0x80197D24:("AudioSeq_SequencePlayerDisableAsFinished",), 0x80197D4C:("AudioSeq_SequencePlayerDisable",), 0x80197E08:("AudioSeq_AudioListPushBack",), 0x80197E48:("AudioSeq_AudioListPopBack",), @@ -3799,23 +3799,23 @@ 0x8019A0BC:("func_8019A0BC",), 0x8019AA3C:("func_8019AA3C",), 0x8019AAF0:("func_8019AAF0",), - 0x8019AB40:("func_8019AB40",), - 0x8019AC10:("func_8019AC10",), + 0x8019AB40:("AudioSeq_ResetSequencePlayer",), + 0x8019AC10:("AudioSeq_InitSequencePlayerChannels",), 0x8019ACEC:("func_8019ACEC",), - 0x8019ADBC:("func_8019ADBC",), + 0x8019ADBC:("AudioSeq_InitSequencePlayers",), 0x8019AE40:("func_8019AE40",), 0x8019AEC0:("func_8019AEC0",), 0x8019AF00:("func_8019AF00",), 0x8019AF58:("func_8019AF58",), 0x8019AFE8:("func_8019AFE8",), 0x8019B02C:("func_8019B02C",), - 0x8019B074:("func_8019B074",), + 0x8019B074:("AudioOcarina_MapSongFromNotesToButtons",), 0x8019B144:("func_8019B144",), 0x8019B378:("func_8019B378",), 0x8019B38C:("func_8019B38C",), 0x8019B3D0:("func_8019B3D0",), 0x8019B4B8:("func_8019B4B8",), - 0x8019B544:("func_8019B544",), + 0x8019B544:("AudioOcarina_StartDefault",), 0x8019B568:("func_8019B568",), 0x8019B5AC:("func_8019B5AC",), 0x8019B5EC:("func_8019B5EC",), @@ -3828,7 +3828,7 @@ 0x8019C1D0:("func_8019C1D0",), 0x8019C268:("func_8019C268",), 0x8019C2E4:("func_8019C2E4",), - 0x8019C300:("func_8019C300",), + 0x8019C300:("AudioOcarina_SetInstrumentId",), 0x8019C398:("func_8019C398",), 0x8019C5A0:("func_8019C5A0",), 0x8019C8D8:("func_8019C8D8",), @@ -3838,12 +3838,12 @@ 0x8019CEBC:("func_8019CEBC",), 0x8019CF6C:("func_8019CF6C",), 0x8019CF78:("func_8019CF78",), - 0x8019CF9C:("func_8019CF9C",), + 0x8019CF9C:("AudioOcarina_GetPlaybackStaff",), 0x8019CFA8:("func_8019CFA8",), - 0x8019D134:("func_8019D134",), - 0x8019D26C:("func_8019D26C",), - 0x8019D488:("func_8019D488",), - 0x8019D4F8:("func_8019D4F8",), + 0x8019D134:("AudioOcarina_TerminaWallValidateNotes",), + 0x8019D26C:("AudioOcarina_TerminaWallGenerateNotes",), + 0x8019D488:("AudioOcarina_MemoryGameSetNumNotes",), + 0x8019D4F8:("AudioOcarina_MemoryGameGenerateNotes",), 0x8019D600:("func_8019D600",), 0x8019D758:("func_8019D758",), 0x8019D864:("func_8019D864",), @@ -3897,18 +3897,18 @@ 0x8019FE74:("func_8019FE74",), 0x8019FEDC:("func_8019FEDC",), 0x8019FF38:("func_8019FF38",), - 0x8019FF9C:("func_8019FF9C",), - 0x801A0048:("func_801A0048",), - 0x801A00EC:("func_801A00EC",), + 0x8019FF9C:("Audio_PlaySfxForRiver",), + 0x801A0048:("Audio_PlaySfxForWaterfall",), + 0x801A00EC:("Audio_StepFreqLerp",), 0x801A0124:("func_801A0124",), 0x801A0184:("func_801A0184",), 0x801A01C4:("func_801A01C4",), 0x801A0204:("func_801A0204",), 0x801A0238:("func_801A0238",), - 0x801A026C:("func_801A026C",), - 0x801A0318:("func_801A0318",), - 0x801A0450:("func_801A0450",), - 0x801A046C:("func_801A046C",), + 0x801A026C:("Audio_SetGanonsTowerBgmVolumeLevel",), + 0x801A0318:("Audio_SetGanonsTowerBgmVolume",), + 0x801A0450:("Audio_LowerMainBgmVolume",), + 0x801A046C:("Audio_UpdateRiverSoundVolumes",), 0x801A0554:("func_801A0554",), 0x801A05E4:("func_801A05E4",), 0x801A05F0:("func_801A05F0",), @@ -3916,9 +3916,9 @@ 0x801A0810:("func_801A0810",), 0x801A0868:("func_801A0868",), 0x801A09D4:("func_801A09D4",), - 0x801A0C70:("func_801A0C70",), - 0x801A0C90:("func_801A0C90",), - 0x801A0CB0:("func_801A0CB0",), + 0x801A0C70:("Audio_ClearSariaBgm",), + 0x801A0C90:("Audio_ClearSariaBgmAtPos",), + 0x801A0CB0:("Audio_SplitBgmChannels",), 0x801A0E44:("func_801A0E44",), 0x801A1290:("func_801A1290",), 0x801A1348:("func_801A1348",), @@ -3935,8 +3935,8 @@ 0x801A1F88:("func_801A1F88",), 0x801A1FB4:("func_801A1FB4",), 0x801A2090:("func_801A2090",), - 0x801A21FC:("func_801A21FC",), - 0x801A2460:("func_801A2460",), + 0x801A21FC:("Audio_PlaySariaBgm",), + 0x801A2460:("Audio_ClearSariaBgm2",), 0x801A246C:("func_801A246C",), 0x801A2544:("func_801A2544",), 0x801A257C:("func_801A257C",), @@ -3978,7 +3978,7 @@ 0x801A3D98:("func_801A3D98",), 0x801A3E38:("func_801A3E38",), 0x801A3EC0:("func_801A3EC0",), - 0x801A3F54:("func_801A3F54",), + 0x801A3F54:("Audio_SetCutsceneFlag",), 0x801A3F6C:("func_801A3F6C",), 0x801A3FB4:("func_801A3FB4",), 0x801A3FFC:("func_801A3FFC",), @@ -4050,7 +4050,7 @@ 0x801A7794:("func_801A7794",), 0x801A7828:("func_801A7828",), 0x801A787C:("func_801A787C",), - 0x801A78E4:("func_801A78E4",), + 0x801A78E4:("Audio_IsSfxPlaying",), 0x801A794C:("func_801A794C",), 0x801A7B10:("func_801A7B10",), 0x801A7D04:("func_801A7D04",), @@ -4061,7 +4061,7 @@ 0x801A8ABC:("func_801A8ABC",), 0x801A8B14:("func_801A8B14",), 0x801A8B2C:("func_801A8B2C",), - 0x801A8BD0:("func_801A8BD0",), + 0x801A8BD0:("Audio_SetVolumeScale",), 0x801A8D5C:("func_801A8D5C",), 0x801A9768:("func_801A9768",), 0x801A982C:("func_801A982C",), @@ -4602,7 +4602,7 @@ 0x80841744:("func_80841744",), 0x8084182C:("func_8084182C",), 0x80841A50:("func_80841A50",), - 0x80841AC4:("func_80841AC4",), + 0x80841AC4:("Player_Init",), 0x80842510:("func_80842510",), 0x808425B4:("func_808425B4",), 0x808426F0:("func_808426F0",), @@ -4615,11 +4615,11 @@ 0x80844784:("func_80844784",), 0x80844D80:("func_80844D80",), 0x80844EF8:("func_80844EF8",), - 0x808460B8:("func_808460B8",), + 0x808460B8:("Player_Update",), 0x808463C0:("func_808463C0",), 0x80846460:("func_80846460",), - 0x80846528:("func_80846528",), - 0x808470D4:("func_808470D4",), + 0x80846528:("Player_Draw",), + 0x808470D4:("Player_Destroy",), 0x80847190:("func_80847190",), 0x8084748C:("func_8084748C",), 0x808475B4:("func_808475B4",), @@ -4893,7 +4893,7 @@ 0x80863188:("EnTest_Init",), 0x80863310:("EnTest_Destroy",), 0x8086333C:("EnTest_Update",), - 0x808634B8:("func_808634B8",), + 0x808634B8:("EnTest_OverrideKeyframeDraw",), 0x808636A8:("EnTest_Draw",), 0x80863870:("EnGirlA_SetupAction",), 0x8086387C:("EnGirlA_InitObjIndex",), @@ -4960,7 +4960,7 @@ 0x808670F0:("func_808670F0",), 0x80867144:("func_80867144",), 0x8086732C:("EnDoor_Update",), - 0x80867350:("func_80867350",), + 0x80867350:("EnDoor_OverrideLimbDraw",), 0x808674B0:("EnDoor_Draw",), 0x80867BD0:("func_80867BD0",), 0x80867BDC:("func_80867BDC",), @@ -5108,40 +5108,40 @@ 0x80872BC0:("func_80872BC0",), 0x80874810:("EnWallmas_Init",), 0x80874A28:("EnWallmas_Destroy",), - 0x80874A88:("func_80874A88",), - 0x80874B04:("func_80874B04",), - 0x80874B88:("func_80874B88",), - 0x80874BE4:("func_80874BE4",), - 0x80874D1C:("func_80874D1C",), - 0x80874DE8:("func_80874DE8",), - 0x80874F14:("func_80874F14",), - 0x80874FD8:("func_80874FD8",), - 0x80875014:("func_80875014",), - 0x80875054:("func_80875054",), - 0x808750B8:("func_808750B8",), - 0x80875108:("func_80875108",), - 0x808751C4:("func_808751C4",), - 0x8087520C:("func_8087520C",), - 0x80875248:("func_80875248",), - 0x808752CC:("func_808752CC",), - 0x808753F0:("func_808753F0",), - 0x80875484:("func_80875484",), - 0x80875518:("func_80875518",), - 0x8087556C:("func_8087556C",), - 0x808755A8:("func_808755A8",), - 0x80875638:("func_80875638",), - 0x808756AC:("func_808756AC",), - 0x8087571C:("func_8087571C",), - 0x808758C8:("func_808758C8",), - 0x80875910:("func_80875910",), - 0x8087596C:("func_8087596C",), - 0x808759B8:("func_808759B8",), - 0x80875A0C:("func_80875A0C",), - 0x80875A74:("func_80875A74",), + 0x80874A88:("EnWallmas_Freeze",), + 0x80874B04:("EnWallmas_ThawIfFrozen",), + 0x80874B88:("EnWallmas_TimerInit",), + 0x80874BE4:("EnWallmas_WaitToDrop",), + 0x80874D1C:("EnWallmas_SetupDrop",), + 0x80874DE8:("EnWallmas_Drop",), + 0x80874F14:("EnWallmas_SetupLand",), + 0x80874FD8:("EnWallmas_Land",), + 0x80875014:("EnWallmas_SetupStand",), + 0x80875054:("EnWallmas_Stand",), + 0x808750B8:("EnWallmas_SetupWalk",), + 0x80875108:("EnWallmas_Walk",), + 0x808751C4:("EnWallmas_SetupJumpToCeiling",), + 0x8087520C:("EnWallmas_JumpToCeiling",), + 0x80875248:("EnWallmas_SetupReturnToCeiling",), + 0x808752CC:("EnWallmas_ReturnToCeiling",), + 0x808753F0:("EnWallmas_SetupDamage",), + 0x80875484:("EnWallmas_Damage",), + 0x80875518:("EnWallmas_SetupCooldown",), + 0x8087556C:("EnWallmas_Cooldown",), + 0x808755A8:("EnWallmas_SetupDie",), + 0x80875638:("EnWallmas_Die",), + 0x808756AC:("EnWallmas_SetupTakePlayer",), + 0x8087571C:("EnWallmas_TakePlayer",), + 0x808758C8:("EnWallmas_ProximityOrSwitchInit",), + 0x80875910:("EnWallmas_WaitForProximity",), + 0x8087596C:("EnWallmas_WaitForSwitchFlag",), + 0x808759B8:("EnWallmas_SetupStun",), + 0x80875A0C:("EnWallmas_Stun",), + 0x80875A74:("EnWallmas_Update",), 0x80875CF4:("EnWallmas_Update",), - 0x80875F04:("func_80875F04",), - 0x808760A4:("func_808760A4",), - 0x80876118:("func_80876118",), + 0x80875F04:("EnWallmas_DrawShadow",), + 0x808760A4:("EnWallmas_OverrideLimbDraw",), + 0x80876118:("EnWallmas_PostLimbDraw",), 0x80876268:("EnWallmas_Draw",), 0x80876670:("EnDodongo_Init",), 0x808768D0:("EnDodongo_Destroy",), @@ -5206,82 +5206,82 @@ 0x8087AF48:("EnFirefly_OverrideLimbDraw",), 0x8087AF98:("EnFirefly_PostLimbDraw",), 0x8087B320:("EnFirefly_Draw",), - 0x8087B730:("func_8087B730",), - 0x8087B784:("func_8087B784",), + 0x8087B730:("EnHorse_RaceWaypointPos",), + 0x8087B784:("EnHorse_RotateToPoint",), 0x8087B7C0:("func_8087B7C0",), - 0x8087C0AC:("func_8087C0AC",), + 0x8087C0AC:("EnHorse_PlayWalkingSound",), 0x8087C178:("func_8087C178",), 0x8087C1C0:("func_8087C1C0",), - 0x8087C208:("func_8087C208",), + 0x8087C208:("EnHorse_SlopeSpeedMultiplier",), 0x8087C288:("func_8087C288",), 0x8087C2B8:("func_8087C2B8",), 0x8087C38C:("func_8087C38C",), - 0x8087C43C:("func_8087C43C",), - 0x8087C590:("func_8087C590",), - 0x8087C8B8:("func_8087C8B8",), - 0x8087C8D0:("func_8087C8D0",), - 0x8087C8E0:("func_8087C8E0",), - 0x8087C9D4:("func_8087C9D4",), - 0x8087C9EC:("func_8087C9EC",), + 0x8087C43C:("EnHorse_IdleAnimSounds",), + 0x8087C590:("EnHorse_Spawn",), + 0x8087C8B8:("EnHorse_ResetCutscene",), + 0x8087C8D0:("EnHorse_ResetRace",), + 0x8087C8E0:("EnHorse_PlayerCanMove",), + 0x8087C9D4:("EnHorse_ResetHorsebackArchery",), + 0x8087C9EC:("EnHorse_ClearDustFlags",), 0x8087C9F8:("func_8087C9F8",), 0x8087CA04:("func_8087CA04",), 0x8087CA14:("EnHorse_Init",), 0x8087D540:("func_8087D540",), 0x8087D69C:("EnHorse_Destroy",), - 0x8087D70C:("func_8087D70C",), - 0x8087D75C:("func_8087D75C",), - 0x8087D814:("func_8087D814",), - 0x8087D988:("func_8087D988",), - 0x8087DDEC:("func_8087DDEC",), - 0x8087DE28:("func_8087DE28",), - 0x8087DF64:("func_8087DF64",), - 0x8087E080:("func_8087E080",), - 0x8087E0A4:("func_8087E0A4",), - 0x8087E18C:("func_8087E18C",), - 0x8087E2A8:("func_8087E2A8",), - 0x8087E350:("func_8087E350",), - 0x8087E564:("func_8087E564",), - 0x8087E5B4:("func_8087E5B4",), - 0x8087E5D8:("func_8087E5D8",), - 0x8087E684:("func_8087E684",), - 0x8087E6D8:("func_8087E6D8",), - 0x8087E92C:("func_8087E92C",), - 0x8087E9D0:("func_8087E9D0",), - 0x8087EA1C:("func_8087EA1C",), - 0x8087EB54:("func_8087EB54",), - 0x8087EB78:("func_8087EB78",), - 0x8087EC20:("func_8087EC20",), - 0x8087EC78:("func_8087EC78",), - 0x8087ED10:("func_8087ED10",), - 0x8087EEC4:("func_8087EEC4",), - 0x8087F078:("func_8087F078",), - 0x8087F1FC:("func_8087F1FC",), - 0x8087F39C:("func_8087F39C",), - 0x8087F590:("func_8087F590",), - 0x8087F5B4:("func_8087F5B4",), - 0x8087F658:("func_8087F658",), - 0x8087F9A0:("func_8087F9A0",), - 0x8087F9C4:("func_8087F9C4",), - 0x8087FB08:("func_8087FB08",), - 0x8087FB14:("func_8087FB14",), - 0x8087FD94:("func_8087FD94",), - 0x8087FDB8:("func_8087FDB8",), - 0x8087FF08:("func_8087FF08",), - 0x8087FF14:("func_8087FF14",), - 0x808801A8:("func_808801A8",), - 0x808801F8:("func_808801F8",), - 0x808802D0:("func_808802D0",), - 0x808804A4:("func_808804A4",), - 0x808804CC:("func_808804CC",), - 0x80880500:("func_80880500",), - 0x80880534:("func_80880534",), - 0x808806DC:("func_808806DC",), - 0x80880844:("func_80880844",), - 0x80880978:("func_80880978",), - 0x80880D50:("func_80880D50",), - 0x80880DA8:("func_80880DA8",), - 0x80880E00:("func_80880E00",), - 0x80881128:("func_80881128",), + 0x8087D70C:("EnHorse_RotateToPlayer",), + 0x8087D75C:("EnHorse_Freeze",), + 0x8087D814:("EnHorse_Frozen",), + 0x8087D988:("EnHorse_UpdateSpeed",), + 0x8087DDEC:("EnHorse_StartMountedIdleResetAnim",), + 0x8087DE28:("EnHorse_StartMountedIdle",), + 0x8087DF64:("EnHorse_MountedIdle",), + 0x8087E080:("EnHorse_MountedIdleAnim",), + 0x8087E0A4:("EnHorse_MountedIdleWhinney",), + 0x8087E18C:("EnHorse_MountedIdleWhinneying",), + 0x8087E2A8:("EnHorse_StartTurning",), + 0x8087E350:("EnHorse_MountedTurn",), + 0x8087E564:("EnHorse_StartWalkingFromIdle",), + 0x8087E5B4:("EnHorse_StartWalkingInterruptable",), + 0x8087E5D8:("EnHorse_StartWalking",), + 0x8087E684:("EnHorse_MountedWalkingReset",), + 0x8087E6D8:("EnHorse_MountedWalk",), + 0x8087E92C:("EnHorse_StartTrotting",), + 0x8087E9D0:("EnHorse_MountedTrotReset",), + 0x8087EA1C:("EnHorse_MountedTrot",), + 0x8087EB54:("EnHorse_StartGallopingInterruptable",), + 0x8087EB78:("EnHorse_StartGalloping",), + 0x8087EC20:("EnHorse_MountedGallopReset",), + 0x8087EC78:("EnHorse_JumpLanding",), + 0x8087ED10:("EnHorse_MountedGallop",), + 0x8087EEC4:("EnHorse_StartRearing",), + 0x8087F078:("EnHorse_MountedRearing",), + 0x8087F1FC:("EnHorse_StartBraking",), + 0x8087F39C:("EnHorse_Stopping",), + 0x8087F590:("EnHorse_StartReversingInterruptable",), + 0x8087F5B4:("EnHorse_StartReversing",), + 0x8087F658:("EnHorse_Reverse",), + 0x8087F9A0:("EnHorse_LowJumpInit",), + 0x8087F9C4:("EnHorse_StartLowJump",), + 0x8087FB08:("EnHorse_Stub1",), + 0x8087FB14:("EnHorse_LowJump",), + 0x8087FD94:("EnHorse_HighJumpInit",), + 0x8087FDB8:("EnHorse_StartHighJump",), + 0x8087FF08:("EnHorse_Stub2",), + 0x8087FF14:("EnHorse_HighJump",), + 0x808801A8:("EnHorse_InitInactive",), + 0x808801F8:("EnHorse_Inactive",), + 0x808802D0:("EnHorse_PlayIdleAnimation",), + 0x808804A4:("EnHorse_ChangeIdleAnimation",), + 0x808804CC:("EnHorse_ResetIdleAnimation",), + 0x80880500:("EnHorse_StartIdleRidable",), + 0x80880534:("EnHorse_Idle",), + 0x808806DC:("EnHorse_StartMovingAnimation",), + 0x80880844:("EnHorse_SetFollowAnimation",), + 0x80880978:("EnHorse_FollowPlayer",), + 0x80880D50:("EnHorse_InitIngoHorse",), + 0x80880DA8:("EnHorse_SetIngoAnimation",), + 0x80880E00:("EnHorse_UpdateIngoHorseAnim",), + 0x80881128:("EnHorse_UpdateIngoRace",), 0x8088126C:("func_8088126C",), 0x80881290:("func_80881290",), 0x80881398:("func_80881398",), @@ -5289,26 +5289,26 @@ 0x80881634:("func_80881634",), 0x8088168C:("func_8088168C",), 0x808819D8:("func_808819D8",), - 0x80881BDC:("func_80881BDC",), - 0x80881C54:("func_80881C54",), - 0x80881DA4:("func_80881DA4",), - 0x80881DC8:("func_80881DC8",), - 0x80881F10:("func_80881F10",), - 0x80881F48:("func_80881F48",), - 0x808821C8:("func_808821C8",), - 0x808822CC:("func_808822CC",), - 0x8088247C:("func_8088247C",), - 0x80882564:("func_80882564",), - 0x808826B4:("func_808826B4",), - 0x80882820:("func_80882820",), - 0x808829D0:("func_808829D0",), - 0x808829F4:("func_808829F4",), - 0x80882A44:("func_80882A44",), - 0x80882B9C:("func_80882B9C",), - 0x80882D8C:("func_80882D8C",), - 0x80882DC0:("func_80882DC0",), - 0x80883104:("func_80883104",), - 0x80883308:("func_80883308",), + 0x80881BDC:("EnHorse_CsMoveInit",), + 0x80881C54:("EnHorse_CsMoveToPoint",), + 0x80881DA4:("EnHorse_CsSetAnimHighJump",), + 0x80881DC8:("EnHorse_CsPlayHighJumpAnim",), + 0x80881F10:("EnHorse_CsJumpInit",), + 0x80881F48:("EnHorse_CsJump",), + 0x808821C8:("EnHorse_CsRearingInit",), + 0x808822CC:("EnHorse_CsRearing",), + 0x8088247C:("EnHorse_WarpMoveInit",), + 0x80882564:("EnHorse_CsWarpMoveToPoint",), + 0x808826B4:("EnHorse_CsWarpRearingInit",), + 0x80882820:("EnHorse_CsWarpRearing",), + 0x808829D0:("EnHorse_InitCutscene",), + 0x808829F4:("EnHorse_GetCutsceneFunctionIndex",), + 0x80882A44:("EnHorse_CutsceneUpdate",), + 0x80882B9C:("EnHorse_UpdateHbaRaceInfo",), + 0x80882D8C:("EnHorse_InitHorsebackArchery",), + 0x80882DC0:("EnHorse_UpdateHbaAnim",), + 0x80883104:("EnHorse_UpdateHorsebackArchery",), + 0x80883308:("EnHorse_FleePlayer",), 0x80883B70:("func_80883B70",), 0x80883BEC:("func_80883BEC",), 0x80883CB0:("func_80883CB0",), @@ -5338,29 +5338,29 @@ 0x80884A40:("func_80884A40",), 0x80884D04:("func_80884D04",), 0x80884E0C:("func_80884E0C",), - 0x80885060:("func_80885060",), - 0x808850DC:("func_808850DC",), - 0x80885220:("func_80885220",), - 0x808853E0:("func_808853E0",), - 0x8088598C:("func_8088598C",), - 0x80885A80:("func_80885A80",), - 0x80885AF4:("func_80885AF4",), - 0x80885B4C:("func_80885B4C",), - 0x80885C90:("func_80885C90",), - 0x80885DA4:("func_80885DA4",), + 0x80885060:("EnHorse_Vec3fOffset",), + 0x808850DC:("EnHorse_CalcFloorHeight",), + 0x80885220:("EnHorse_ObstructMovement",), + 0x808853E0:("EnHorse_CheckFloors",), + 0x8088598C:("EnHorse_MountDismount",), + 0x80885A80:("EnHorse_StickDirection",), + 0x80885AF4:("EnHorse_UpdateStick",), + 0x80885B4C:("EnHorse_ResolveCollision",), + 0x80885C90:("EnHorse_BgCheckSlowMoving",), + 0x80885DA4:("EnHorse_UpdateBgCheckInfo",), 0x80886C00:("func_80886C00",), - 0x80886DC4:("func_80886DC4",), - 0x80886FA8:("func_80886FA8",), - 0x808870A4:("func_808870A4",), - 0x808871A0:("func_808871A0",), - 0x80887270:("func_80887270",), + 0x80886DC4:("EnHorse_RegenBoost",), + 0x80886FA8:("EnHorse_UpdatePlayerDir",), + 0x808870A4:("EnHorse_TiltBody",), + 0x808871A0:("EnHorse_UpdateConveyors",), + 0x80887270:("EnHorse_RandInt",), 0x808872A4:("EnHorse_Update",), - 0x80887D20:("func_80887D20",), - 0x80887D60:("func_80887D60",), - 0x80887E64:("func_80887E64",), - 0x80887EBC:("func_80887EBC",), - 0x80887F58:("func_80887F58",), - 0x80888C48:("func_80888C48",), + 0x80887D20:("EnHorse_PlayerDirToMountSide",), + 0x80887D60:("EnHorse_MountSideCheck",), + 0x80887E64:("EnHorse_GetMountSide",), + 0x80887EBC:("EnHorse_RandomOffset",), + 0x80887F58:("EnHorse_PostDraw",), + 0x80888C48:("EnHorse_OverrideLimbDraw",), 0x80888D18:("func_80888D18",), 0x80888D78:("EnHorse_Draw",), 0x8088A240:("EnArrow_Init",), @@ -5642,12 +5642,12 @@ 0x808A03E8:("func_808A03E8",), 0x808A0458:("EnBubble_Update",), 0x808A04D4:("EnBubble_Draw",), - 0x808A08F0:("func_808A08F0",), + 0x808A08F0:("DoorShutter_SetupAction",), 0x808A0900:("func_808A0900",), - 0x808A0974:("func_808A0974",), + 0x808A0974:("DoorShutter_SetupDoor",), 0x808A0B10:("DoorShutter_Init",), 0x808A0CD0:("DoorShutter_Destroy",), - 0x808A0D0C:("func_808A0D0C",), + 0x808A0D0C:("DoorShutter_SetupType",), 0x808A0D90:("func_808A0D90",), 0x808A0E28:("func_808A0E28",), 0x808A0F88:("func_808A0F88",), @@ -5666,7 +5666,7 @@ 0x808A1C50:("func_808A1C50",), 0x808A1CC4:("DoorShutter_Update",), 0x808A1D68:("func_808A1D68",), - 0x808A1E14:("func_808A1E14",), + 0x808A1E14:("DoorShutter_Draw",), 0x808A24D0:("EnBoom_SetupAction",), 0x808A24DC:("func_808A24DC",), 0x808A2700:("EnBoom_Init",), @@ -5688,7 +5688,7 @@ 0x808A3A44:("EnMinifrog_Jump",), 0x808A3B04:("EnMinifrog_TurnToPlayer",), 0x808A3B3C:("EnMinifrog_TurnToMissingFrog",), - 0x808A3B74:("EnMinifrog_SetCamera",), + 0x808A3B74:("EnMinifrog_SpawnDust",), 0x808A3DA8:("EnMinifrog_ReturnFrogCutscene",), 0x808A3F88:("EnMinifrog_SpawnGrowAndShrink",), 0x808A4040:("EnMinifrog_Idle",), @@ -5802,10 +5802,10 @@ 0x808AAB30:("EnOssan_UpdateStickDirectionPromptAnim",), 0x808AACE0:("EnOssan_WaitForBlink",), 0x808AAD14:("EnOssan_Blink",), - 0x808AADB4:("EnOssan_InitCuriosityShopMan",), - 0x808AAE1C:("EnOssan_InitPartTimeWorker",), - 0x808AAE84:("EnOssan_GetWelcomeCuriosityShopMan",), - 0x808AAFB0:("EnOssan_GetWelcomePartTimeWorker",), + 0x808AADB4:("EnOssan_CuriosityShopMan_Init",), + 0x808AAE1C:("EnOssan_PartTimeWorker_Init",), + 0x808AAE84:("EnOssan_CuriosityShopMan_GetWelcome",), + 0x808AAFB0:("EnOssan_PartTimerWorker_GetWelcome",), 0x808AB0B0:("EnOssan_SetHaveMet",), 0x808AB16C:("EnOssan_InitShop",), 0x808AB404:("EnOssan_GetCutscenes",), @@ -5813,12 +5813,12 @@ 0x808AB52C:("EnOssan_DrawCursor",), 0x808AB78C:("EnOssan_DrawTextRec",), 0x808AB928:("EnOssan_DrawStickDirectionPrompts",), - 0x808ABCD0:("EnOssan_OverrideLimbDrawCuriosityShopMan",), - 0x808ABD10:("EnOssan_OverrideLimbDrawPartTimeWorker",), - 0x808ABD60:("EnOssan_PostLimbDrawCuriosityShopMan",), - 0x808ABE18:("EnOssan_PostLimbDrawPartTimeWorker",), - 0x808ABE58:("EnOssan_DrawCuriosityShopMan",), - 0x808ABF30:("EnOssan_DrawPartTimeWorker",), + 0x808ABCD0:("EnOssan_CuriosityShopMan_OverrideLimbDraw",), + 0x808ABD10:("EnOssan_PartTimeWorker_OverrideLimbDraw",), + 0x808ABD60:("EnOssan_CuriosityShopMan_PostLimbDraw",), + 0x808ABE18:("EnOssan_PartTimeWorker_PostLimbDraw",), + 0x808ABE58:("EnOssan_CuriosityShopMan_Draw",), + 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), 0x808ACB58:("func_808ACB58",), @@ -5873,11 +5873,11 @@ 0x808AF8F8:("EnBombf_Draw",), 0x808AFCD0:("EnAm_Init",), 0x808AFDF8:("EnAm_Destroy",), - 0x808AFE38:("func_808AFE38",), + 0x808AFE38:("EnAm_SpawnEffects",), 0x808AFF9C:("func_808AFF9C",), - 0x808B0040:("func_808B0040",), - 0x808B00D8:("func_808B00D8",), - 0x808B0124:("func_808B0124",), + 0x808B0040:("EnAm_RemoveEnemyTexture",), + 0x808B00D8:("EnAm_WakeUp",), + 0x808B0124:("EnAm_ApplyEnemyTexture",), 0x808B0208:("func_808B0208",), 0x808B0358:("func_808B0358",), 0x808B03C0:("func_808B03C0",), @@ -5889,15 +5889,15 @@ 0x808B05C8:("func_808B05C8",), 0x808B0640:("func_808B0640",), 0x808B066C:("func_808B066C",), - 0x808B06D0:("func_808B06D0",), + 0x808B06D0:("EnAm_TakeDamage",), 0x808B07A8:("func_808B07A8",), 0x808B0820:("func_808B0820",), 0x808B0894:("func_808B0894",), 0x808B0AD0:("func_808B0AD0",), 0x808B0B4C:("func_808B0B4C",), - 0x808B0B9C:("func_808B0B9C",), + 0x808B0B9C:("EnAm_UpdateDamage",), 0x808B0CC8:("EnAm_Update",), - 0x808B0EA4:("func_808B0EA4",), + 0x808B0EA4:("EnAm_PostLimbDraw",), 0x808B0F98:("EnAm_Draw",), 0x808B1330:("EnDekubaba_Init",), 0x808B1504:("EnDekubaba_Destroy",), @@ -5971,7 +5971,7 @@ 0x808B74D8:("func_808B74D8",), 0x808B751C:("func_808B751C",), 0x808B75B0:("BgBreakwall_Init",), - 0x808B767C:("func_808B767C",), + 0x808B767C:("BgBreakwall_Destroy",), 0x808B76CC:("func_808B76CC",), 0x808B77D0:("func_808B77D0",), 0x808B77E0:("func_808B77E0",), @@ -5984,7 +5984,7 @@ 0x808B7A90:("func_808B7A90",), 0x808B7B54:("func_808B7B54",), 0x808B7D34:("func_808B7D34",), - 0x808B7FE4:("func_808B7FE4",), + 0x808B7FE4:("BgBreakwall_Draw",), 0x808B8490:("DoorWarp1_SetupAction",), 0x808B849C:("func_808B849C",), 0x808B8568:("func_808B8568",), @@ -6113,37 +6113,37 @@ 0x808C1918:("ArmsHook_Draw",), 0x808C1D40:("EnBb_Init",), 0x808C1E68:("EnBb_Destroy",), - 0x808C1E94:("func_808C1E94",), - 0x808C1F00:("func_808C1F00",), - 0x808C1F74:("func_808C1F74",), - 0x808C1FF4:("func_808C1FF4",), - 0x808C20D4:("func_808C20D4",), - 0x808C2238:("func_808C2238",), - 0x808C2344:("func_808C2344",), - 0x808C23EC:("func_808C23EC",), - 0x808C254C:("func_808C254C",), - 0x808C25E0:("func_808C25E0",), - 0x808C272C:("func_808C272C",), - 0x808C28CC:("func_808C28CC",), - 0x808C2A00:("func_808C2A00",), - 0x808C2B1C:("func_808C2B1C",), - 0x808C2B94:("func_808C2B94",), - 0x808C2BD0:("func_808C2BD0",), - 0x808C2C38:("func_808C2C38",), - 0x808C2CB4:("func_808C2CB4",), - 0x808C2CF0:("func_808C2CF0",), - 0x808C2D78:("func_808C2D78",), - 0x808C2E34:("func_808C2E34",), + 0x808C1E94:("EnBb_CheckForWall",), + 0x808C1F00:("EnBb_Freeze",), + 0x808C1F74:("EnBb_Thaw",), + 0x808C1FF4:("EnBb_UpdateStateForFlying",), + 0x808C20D4:("EnBb_SetupFlyIdle",), + 0x808C2238:("EnBb_FlyIdle",), + 0x808C2344:("EnBb_SetupAttack",), + 0x808C23EC:("EnBb_Attack",), + 0x808C254C:("EnBb_SetupDown",), + 0x808C25E0:("EnBb_Down",), + 0x808C272C:("EnBb_SetupDead",), + 0x808C28CC:("EnBb_Dead",), + 0x808C2A00:("EnBb_SetupDamage",), + 0x808C2B1C:("EnBb_Damage",), + 0x808C2B94:("EnBb_SetupFrozen",), + 0x808C2BD0:("EnBb_Frozen",), + 0x808C2C38:("EnBb_SetupWaitForRevive",), + 0x808C2CB4:("EnBb_WaitForRevive",), + 0x808C2CF0:("EnBb_SetupRevive",), + 0x808C2D78:("EnBb_Revive",), + 0x808C2E34:("EnBb_UpdateDamage",), 0x808C30A0:("EnBb_Update",), - 0x808C32EC:("func_808C32EC",), - 0x808C3324:("func_808C3324",), + 0x808C32EC:("EnBb_OverrideLimbDraw",), + 0x808C3324:("EnBb_PostLimbDraw",), 0x808C351C:("EnBb_Draw",), 0x808C3A50:("BgKeikokuSpr_Init",), 0x808C3A78:("BgKeikokuSpr_Destroy",), 0x808C3A88:("BgKeikokuSpr_Update",), 0x808C3A98:("BgKeikokuSpr_Draw",), - 0x808C3C00:("func_808C3C00",), - 0x808C3D28:("func_808C3D28",), + 0x808C3C00:("EnWood02_SpawnZoneCheck",), + 0x808C3D28:("EnWood02_SpawnOffspring",), 0x808C3F30:("EnWood02_Init",), 0x808C4414:("EnWood02_Destroy",), 0x808C4458:("func_808C4458",), @@ -6258,8 +6258,8 @@ 0x808CCCF0:("func_808CCCF0",), 0x808CCDE4:("func_808CCDE4",), 0x808CCEE4:("EnVm_Update",), - 0x808CD020:("func_808CD020",), - 0x808CD08C:("func_808CD08C",), + 0x808CD020:("EnVm_OverrideLimbDraw",), + 0x808CD08C:("EnVm_PostLimbDraw",), 0x808CD238:("EnVm_Draw",), 0x808CD740:("DemoEffect_Init",), 0x808CD8E8:("DemoEffect_Destroy",), @@ -6344,49 +6344,49 @@ 0x808D3754:("func_808D3754",), 0x808D3E20:("EnRd_Init",), 0x808D414C:("EnRd_Destroy",), - 0x808D4190:("func_808D4190",), - 0x808D41FC:("func_808D41FC",), - 0x808D4260:("func_808D4260",), - 0x808D4308:("func_808D4308",), - 0x808D43AC:("func_808D43AC",), - 0x808D45D4:("func_808D45D4",), - 0x808D4660:("func_808D4660",), - 0x808D47DC:("func_808D47DC",), - 0x808D4868:("func_808D4868",), - 0x808D49E4:("func_808D49E4",), - 0x808D4A90:("func_808D4A90",), - 0x808D4B20:("func_808D4B20",), - 0x808D4CA8:("func_808D4CA8",), - 0x808D4DC4:("func_808D4DC4",), - 0x808D4E60:("func_808D4E60",), - 0x808D4FE0:("func_808D4FE0",), - 0x808D506C:("func_808D506C",), - 0x808D53C0:("func_808D53C0",), - 0x808D5440:("func_808D5440",), - 0x808D5660:("func_808D5660",), - 0x808D56E4:("func_808D56E4",), - 0x808D586C:("func_808D586C",), - 0x808D58CC:("func_808D58CC",), - 0x808D5C54:("func_808D5C54",), - 0x808D5CCC:("func_808D5CCC",), - 0x808D5D88:("func_808D5D88",), - 0x808D5DF4:("func_808D5DF4",), - 0x808D5E98:("func_808D5E98",), - 0x808D5F18:("func_808D5F18",), - 0x808D6008:("func_808D6008",), - 0x808D6054:("func_808D6054",), - 0x808D60B0:("func_808D60B0",), - 0x808D6130:("func_808D6130",), - 0x808D616C:("func_808D616C",), - 0x808D6200:("func_808D6200",), - 0x808D6310:("func_808D6310",), - 0x808D6388:("func_808D6388",), - 0x808D64D0:("func_808D64D0",), - 0x808D65BC:("func_808D65BC",), - 0x808D66A0:("func_808D66A0",), - 0x808D6814:("func_808D6814",), - 0x808D6A94:("func_808D6A94",), - 0x808D6B64:("func_808D6B64",), + 0x808D4190:("EnRd_UpdateParentForOtherRedeads",), + 0x808D41FC:("EnRd_ShouldNotDance",), + 0x808D4260:("EnRd_SetupDanceIfConditionsMet",), + 0x808D4308:("EnRd_SetupIdle",), + 0x808D43AC:("EnRd_Idle",), + 0x808D45D4:("EnRd_SetupSquattingDance",), + 0x808D4660:("EnRd_SquattingDance",), + 0x808D47DC:("EnRd_SetupClappingDance",), + 0x808D4868:("EnRd_ClappingDance",), + 0x808D49E4:("EnRd_EndClappingOrSquattingDanceWhenPlayerIsClose",), + 0x808D4A90:("EnRd_SetupPirouette",), + 0x808D4B20:("EnRd_Pirouette",), + 0x808D4CA8:("EnRd_EndPirouetteWhenPlayerIsClose",), + 0x808D4DC4:("EnRd_SetupRiseFromCoffin",), + 0x808D4E60:("EnRd_RiseFromCoffin",), + 0x808D4FE0:("EnRd_SetupWalkToPlayer",), + 0x808D506C:("EnRd_WalkToPlayer",), + 0x808D53C0:("EnRd_SetupWalkToHome",), + 0x808D5440:("EnRd_WalkToHome",), + 0x808D5660:("EnRd_SetupWalkToParent",), + 0x808D56E4:("EnRd_WalkToParent",), + 0x808D586C:("EnRd_SetupGrab",), + 0x808D58CC:("EnRd_Grab",), + 0x808D5C54:("EnRd_SetupAttemptPlayerFreeze",), + 0x808D5CCC:("EnRd_AttemptPlayerFreeze",), + 0x808D5D88:("EnRd_SetupGrabFail",), + 0x808D5DF4:("EnRd_GrabFail",), + 0x808D5E98:("EnRd_SetupTurnAwayAndShakeHead",), + 0x808D5F18:("EnRd_TurnAwayAndShakeHead",), + 0x808D6008:("EnRd_SetupStandUp",), + 0x808D6054:("EnRd_StandUp",), + 0x808D60B0:("EnRd_SetupCrouch",), + 0x808D6130:("EnRd_Crouch",), + 0x808D616C:("EnRd_SetupDamage",), + 0x808D6200:("EnRd_Damage",), + 0x808D6310:("EnRd_SetupDead",), + 0x808D6388:("EnRd_Dead",), + 0x808D64D0:("EnRd_SetupStunned",), + 0x808D65BC:("EnRd_Stunned",), + 0x808D66A0:("EnRd_TurnTowardsPlayer",), + 0x808D6814:("EnRd_UpdateDamage",), + 0x808D6A94:("EnRd_UpdateCollision",), + 0x808D6B64:("EnRd_UpdateEffect",), 0x808D6C10:("EnRd_Update",), 0x808D6DA0:("EnRd_OverrideLimbDraw",), 0x808D6DFC:("EnRd_PostLimbDraw",), @@ -6539,17 +6539,17 @@ 0x808E2444:("func_808E2444",), 0x808E24B4:("BgCtowerRot_Update",), 0x808E24D8:("BgCtowerRot_Draw",), - 0x808E2600:("func_808E2600",), - 0x808E26C8:("func_808E26C8",), + 0x808E2600:("MirRay_SetupCollider",), + 0x808E26C8:("MirRay_MakeShieldLight",), 0x808E286C:("MirRay_Init",), 0x808E2B04:("MirRay_Destroy",), 0x808E2B7C:("MirRay_Update",), - 0x808E2C68:("func_808E2C68",), - 0x808E2E1C:("func_808E2E1C",), - 0x808E2FF8:("func_808E2FF8",), - 0x808E30FC:("func_808E30FC",), + 0x808E2C68:("MirRay_SetIntensity",), + 0x808E2E1C:("MirRay_SetupReflectionPolys",), + 0x808E2FF8:("MirRay_RemoveSimilarReflections",), + 0x808E30FC:("MirRay_ReflectedBeam",), 0x808E36A4:("MirRay_Draw",), - 0x808E3984:("func_808E3984",), + 0x808E3984:("MirRay_CheckInFrustum",), 0x808E3EF0:("EnSb_Init",), 0x808E3FF0:("EnSb_Destroy",), 0x808E401C:("EnSb_SpawnBubbles",), @@ -6749,17 +6749,17 @@ 0x808F69B4:("EnIn_Draw",), 0x808F74B0:("EnBomChu_Init",), 0x808F7580:("EnBomChu_Destroy",), - 0x808F75D0:("func_808F75D0",), - 0x808F77E4:("func_808F77E4",), - 0x808F7868:("func_808F7868",), - 0x808F7944:("func_808F7944",), - 0x808F79D4:("func_808F79D4",), - 0x808F7A84:("func_808F7A84",), - 0x808F7E74:("func_808F7E74",), - 0x808F7FA0:("func_808F7FA0",), - 0x808F7FD0:("func_808F7FD0",), - 0x808F8080:("func_808F8080",), - 0x808F818C:("func_808F818C",), + 0x808F75D0:("EnBomChu_UpdateFloorPoly",), + 0x808F77E4:("EnBomChu_UpdateRotation",), + 0x808F7868:("EnBomChu_WaitForRelease",), + 0x808F7944:("EnBomChu_IsOnCollisionPoly",), + 0x808F79D4:("EnBomChu_SetupMove",), + 0x808F7A84:("EnBomChu_Move",), + 0x808F7E74:("EnBomChu_Explode",), + 0x808F7FA0:("EnBomChu_WaitForDeath",), + 0x808F7FD0:("EnBomChu_ActorCoordsToWorld",), + 0x808F8080:("EnBomChu_SpawnRipplesAndSplashes",), + 0x808F818C:("EnBomChu_HandleNonSceneCollision",), 0x808F83B8:("EnBomChu_Update",), 0x808F8714:("EnBomChu_Draw",), 0x808F8AA0:("func_808F8AA0",), @@ -6912,8 +6912,8 @@ 0x8091A5A0:("func_8091A5A0",), 0x8091A7B0:("func_8091A7B0",), 0x8091A8A0:("func_8091A8A0",), - 0x8091A8C4:("func_8091A8C4",), - 0x8091A8F4:("func_8091A8F4",), + 0x8091A8C4:("EnInsect_XZDistanceSquared",), + 0x8091A8F4:("EnInsect_InBottleRange",), 0x8091A9E4:("func_8091A9E4",), 0x8091AA78:("EnInsect_Init",), 0x8091AC4C:("EnInsect_Destroy",), @@ -7000,12 +7000,12 @@ 0x80920340:("ArrowFire_SetupAction",), 0x8092034C:("ArrowFire_Init",), 0x809203F8:("ArrowFire_Destroy",), - 0x80920440:("func_80920440",), + 0x80920440:("FireArrow_ChargeAndWait",), 0x80920534:("FireArrow_Lerp",), - 0x8092058C:("func_8092058C",), - 0x809207A0:("func_809207A0",), + 0x8092058C:("FireArrow_Hit",), + 0x809207A0:("FireArrow_Fly",), 0x809208F4:("ArrowFire_Update",), - 0x80920948:("func_80920948",), + 0x80920948:("FireArrow_SetQuadVerticies",), 0x80920A24:("ArrowFire_Draw",), 0x80922430:("ArrowIce_SetupAction",), 0x8092243C:("ArrowIce_Init",), @@ -7019,10 +7019,10 @@ 0x80924300:("ArrowLight_SetupAction",), 0x8092430C:("ArrowLight_Init",), 0x80924388:("ArrowLight_Destroy",), - 0x809243AC:("func_809243AC",), - 0x809244A0:("func_809244A0",), - 0x809244F8:("func_809244F8",), - 0x809246C4:("func_809246C4",), + 0x809243AC:("ArrowLight_Charge",), + 0x809244A0:("ArrowLight_Lerp",), + 0x809244F8:("ArrowLight_Hit",), + 0x809246C4:("ArrowLight_Fly",), 0x80924818:("ArrowLight_Update",), 0x8092486C:("ArrowLight_Draw",), 0x809261B0:("ObjKibako_SpawnCollectible",), @@ -7251,37 +7251,37 @@ 0x809340BC:("func_809340BC",), 0x80934178:("func_80934178",), 0x80934464:("func_80934464",), - 0x809349E0:("func_809349E0",), - 0x80934AB4:("func_80934AB4",), - 0x80934F58:("func_80934F58",), - 0x80934FFC:("func_80934FFC",), - 0x809350C4:("func_809350C4",), - 0x809350F8:("func_809350F8",), - 0x8093517C:("func_8093517C",), - 0x809351A0:("func_809351A0",), - 0x809354F8:("func_809354F8",), - 0x809355A4:("func_809355A4",), - 0x8093561C:("func_8093561C",), + 0x809349E0:("EnKusa_ApplySway",), + 0x80934AB4:("EnKusa_Sway",), + 0x80934F58:("EnKusa_SnapToFloor",), + 0x80934FFC:("EnKusa_DropCollectible",), + 0x809350C4:("EnKusa_UpdateVelY",), + 0x809350F8:("EnKusa_RandScaleVecToZero",), + 0x8093517C:("EnKusa_SetScaleSmall",), + 0x809351A0:("EnKusa_SpawnFragments",), + 0x809354F8:("EnKusa_SpawnBugs",), + 0x809355A4:("EnKusa_GetWaterBox",), + 0x8093561C:("EnKusa_InitCollider",), 0x80935674:("EnKusa_Init",), 0x80935898:("EnKusa_Destroy",), - 0x809358C4:("func_809358C4",), - 0x809358D8:("func_809358D8",), - 0x80935988:("func_80935988",), - 0x809359AC:("func_809359AC",), - 0x80935B94:("func_80935B94",), - 0x80935BBC:("func_80935BBC",), - 0x80935CE8:("func_80935CE8",), - 0x80935D64:("func_80935D64",), - 0x80936120:("func_80936120",), - 0x80936168:("func_80936168",), - 0x809361A4:("func_809361A4",), - 0x809361B4:("func_809361B4",), - 0x80936220:("func_80936220",), - 0x80936290:("func_80936290",), - 0x809362D8:("func_809362D8",), + 0x809358C4:("EnKusa_SetupWaitObject",), + 0x809358D8:("EnKusa_WaitObject",), + 0x80935988:("EnKusa_SetupInteract",), + 0x809359AC:("EnKusa_WaitForInteract",), + 0x80935B94:("EnKusa_SetupLiftedUp",), + 0x80935BBC:("EnKusa_LiftedUp",), + 0x80935CE8:("EnKusa_SetupFall",), + 0x80935D64:("EnKusa_Fall",), + 0x80936120:("EnKusa_SetupCut",), + 0x80936168:("EnKusa_CutWaitRegrow",), + 0x809361A4:("EnKusa_DoNothing",), + 0x809361B4:("EnKusa_SetupUprootedWaitRegrow",), + 0x80936220:("EnKusa_UprootedWaitRegrow",), + 0x80936290:("EnKusa_SetupRegrow",), + 0x809362D8:("EnKusa_Regrow",), 0x80936370:("EnKusa_Update",), - 0x80936414:("func_80936414",), - 0x809365CC:("func_809365CC",), + 0x80936414:("EnKusa_DrawBush",), + 0x809365CC:("EnKusa_DrawGrass",), 0x80936CF0:("func_80936CF0",), 0x80936D58:("func_80936D58",), 0x80936F04:("func_80936F04",), @@ -7361,62 +7361,62 @@ 0x8093A3F4:("ObjBombiwa_Update",), 0x8093A418:("func_8093A418",), 0x8093A608:("func_8093A608",), - 0x8093ABD0:("func_8093ABD0",), - 0x8093AC6C:("func_8093AC6C",), - 0x8093ADA8:("func_8093ADA8",), - 0x8093AE1C:("func_8093AE1C",), - 0x8093AE74:("func_8093AE74",), - 0x8093AE88:("func_8093AE88",), - 0x8093AEC4:("func_8093AEC4",), - 0x8093AEF0:("func_8093AEF0",), - 0x8093AF1C:("func_8093AF1C",), - 0x8093AF54:("func_8093AF54",), + 0x8093ABD0:("ObjSwitch_InitJntSphCollider",), + 0x8093AC6C:("ObjSwitch_InitTrisCollider",), + 0x8093ADA8:("ObjSwitch_SpawnIce",), + 0x8093AE1C:("ObjSwitch_SetSwitchFlagState",), + 0x8093AE74:("ObjSwitch_CrystalUpdateTimer",), + 0x8093AE88:("ObjSwitch_StopCutscene",), + 0x8093AEC4:("ObjSwitch_PlayFootSwitchSfx",), + 0x8093AEF0:("ObjSwitch_PlayDiamondSwitchSfx",), + 0x8093AF1C:("ObjSwitch_SetFloorSwitchSnapPlayerState",), + 0x8093AF54:("ObjSwitch_FloorSwitchSnapPlayerToSwitchEdge",), 0x8093B084:("ObjSwitch_Init",), 0x8093B59C:("ObjSwitch_Destroy",), - 0x8093B648:("func_8093B648",), - 0x8093B668:("func_8093B668",), - 0x8093B6F4:("func_8093B6F4",), - 0x8093B710:("func_8093B710",), - 0x8093B92C:("func_8093B92C",), - 0x8093B940:("func_8093B940",), - 0x8093B9C0:("func_8093B9C0",), - 0x8093B9E4:("func_8093B9E4",), - 0x8093BB5C:("func_8093BB5C",), - 0x8093BB70:("func_8093BB70",), - 0x8093BBD0:("func_8093BBD0",), - 0x8093BCC8:("func_8093BCC8",), - 0x8093BCDC:("func_8093BCDC",), - 0x8093BD34:("func_8093BD34",), - 0x8093BD4C:("func_8093BD4C",), - 0x8093BDAC:("func_8093BDAC",), - 0x8093BDC0:("func_8093BDC0",), - 0x8093BE10:("func_8093BE10",), - 0x8093BE2C:("func_8093BE2C",), - 0x8093BEF0:("func_8093BEF0",), - 0x8093BF04:("func_8093BF04",), - 0x8093BF50:("func_8093BF50",), - 0x8093BF70:("func_8093BF70",), - 0x8093C0A4:("func_8093C0A4",), - 0x8093C0B8:("func_8093C0B8",), - 0x8093C138:("func_8093C138",), - 0x8093C15C:("func_8093C15C",), - 0x8093C23C:("func_8093C23C",), - 0x8093C250:("func_8093C250",), - 0x8093C2B4:("func_8093C2B4",), - 0x8093C2D4:("func_8093C2D4",), - 0x8093C3C8:("func_8093C3C8",), - 0x8093C3DC:("func_8093C3DC",), - 0x8093C460:("func_8093C460",), - 0x8093C488:("func_8093C488",), - 0x8093C584:("func_8093C584",), - 0x8093C598:("func_8093C598",), + 0x8093B648:("ObjSwitch_TryPlayCutsceneInit",), + 0x8093B668:("ObjSwitch_TryPlayCutscene",), + 0x8093B6F4:("ObjSwitch_FloorSwitchUpInit",), + 0x8093B710:("ObjSwitch_FloorSwitchUp",), + 0x8093B92C:("ObjSwitch_FloorSwitchPushDownInit",), + 0x8093B940:("ObjSwitch_FloorSwitchPushDown",), + 0x8093B9C0:("ObjSwitch_FloorSwitchDownInit",), + 0x8093B9E4:("ObjSwitch_FloorSwitchDown",), + 0x8093BB5C:("ObjSwitch_FloorSwitchRiseUpInit",), + 0x8093BB70:("ObjSwitch_FloorSwitchRiseUp",), + 0x8093BBD0:("ObjSwitch_IsEyeSwitchHit",), + 0x8093BCC8:("ObjSwitch_EyeSwitchFrozenInit",), + 0x8093BCDC:("ObjSwitch_EyeSwitchUnfrozen",), + 0x8093BD34:("ObjSwitch_EyeSwitchOpenInit",), + 0x8093BD4C:("ObjSwitch_EyeSwitchOpen",), + 0x8093BDAC:("ObjSwitch_EyeSwitchClosingInit",), + 0x8093BDC0:("ObjSwitch_EyeSwitchClosing",), + 0x8093BE10:("ObjSwitch_EyeSwitchClosedInit",), + 0x8093BE2C:("ObjSwitch_EyeSwitchClosed",), + 0x8093BEF0:("ObjSwitch_EyeSwitchOpeningInit",), + 0x8093BF04:("ObjSwitch_EyeSwitchOpening",), + 0x8093BF50:("ObjSwitch_CrystalSwitchOffInit",), + 0x8093BF70:("ObjSwitch_CrystalSwitchOff",), + 0x8093C0A4:("ObjSwitch_CrystalSwitchTurnOnInit",), + 0x8093C0B8:("ObjSwitch_CrystalSwitchTurnOn",), + 0x8093C138:("ObjSwitch_CrystalSwitchOnInit",), + 0x8093C15C:("ObjSwitch_CrystalSwitchOn",), + 0x8093C23C:("ObjSwitch_CrystalSwitchTurnOffInit",), + 0x8093C250:("ObjSwitch_CrystalSwitchTurnOff",), + 0x8093C2B4:("ObjSwitch_LargeFloorSwitchUpInit",), + 0x8093C2D4:("ObjSwitch_LargeFloorSwitchUp",), + 0x8093C3C8:("ObjSwitch_LargeFloorSwitchPushDownInit",), + 0x8093C3DC:("ObjSwitch_LargeFloorSwitchPushDown",), + 0x8093C460:("ObjSwitch_LargeFloorSwitchDownInit",), + 0x8093C488:("ObjSwitch_LargeFloorSwitchDown",), + 0x8093C584:("ObjSwitch_LargeFloorSwitchRiseUpInit",), + 0x8093C598:("ObjSwitch_LargeFloorSwitchRiseUp",), 0x8093C5FC:("ObjSwitch_Update",), - 0x8093C778:("func_8093C778",), - 0x8093C888:("func_8093C888",), - 0x8093C8B8:("func_8093C8B8",), - 0x8093C99C:("func_8093C99C",), - 0x8093CA80:("func_8093CA80",), - 0x8093CAC4:("func_8093CAC4",), + 0x8093C778:("ObjSwitch_DrawFloorSwitch",), + 0x8093C888:("ObjSwitch_DrawRustyFloorSwitch",), + 0x8093C8B8:("ObjSwitch_DrawVisibleEyeSwitch",), + 0x8093C99C:("ObjSwitch_DrawInvisibleEyeSwitch",), + 0x8093CA80:("ObjSwitch_DrawEyeSwitch",), + 0x8093CAC4:("ObjSwitch_DrawCrystalSwitch",), 0x8093CC24:("ObjSwitch_Draw",), 0x8093D3C0:("func_8093D3C0",), 0x8093D628:("ObjLift_Init",), @@ -7652,10 +7652,10 @@ 0x809533A0:("func_809533A0",), 0x8095345C:("func_8095345C",), 0x8095359C:("EnHs_Update",), - 0x8095376C:("func_8095376C",), - 0x80953848:("func_80953848",), + 0x8095376C:("EnHs_OverrideLimbDraw",), + 0x80953848:("EnHs_PostLimbDraw",), 0x80953888:("EnHs_Draw",), - 0x80953A90:("func_80953A90",), + 0x80953A90:("BgIngate_FindActor",), 0x80953B40:("func_80953B40",), 0x80953BEC:("func_80953BEC",), 0x80953DA8:("func_80953DA8",), @@ -7686,7 +7686,7 @@ 0x80958974:("func_80958974",), 0x80958BE4:("func_80958BE4",), 0x80958CA8:("EnAttackNiw_Update",), - 0x80958F6C:("func_80958F6C",), + 0x80958F6C:("EnAttackNiw_OverrideLimbDraw",), 0x8095909C:("EnAttackNiw_Draw",), 0x809592E0:("func_809592E0",), 0x80959390:("EnMk_Init",), @@ -7702,8 +7702,8 @@ 0x80959D28:("func_80959D28",), 0x80959E18:("func_80959E18",), 0x8095A028:("EnMk_Update",), - 0x8095A150:("func_8095A150",), - 0x8095A198:("func_8095A198",), + 0x8095A150:("EnMk_OverrideLimbDraw",), + 0x8095A198:("EnMk_PostLimbDraw",), 0x8095A1D8:("EnMk_Draw",), 0x8095A510:("func_8095A510",), 0x8095A560:("EnOwl_Init",), @@ -7929,23 +7929,23 @@ 0x80967608:("func_80967608",), 0x809676A4:("EnWeatherTag_Update",), 0x80967784:("EnWeatherTag_Draw",), - 0x809679D0:("func_809679D0",), - 0x80967A48:("func_80967A48",), - 0x80967AB4:("func_80967AB4",), + 0x809679D0:("EnAni_DefaultBlink",), + 0x80967A48:("EnAni_WaitForEyeClose",), + 0x80967AB4:("EnAni_WaitForEyeOpen",), 0x80967B1C:("EnAni_Init",), 0x80967CE0:("EnAni_Destroy",), - 0x80967D20:("func_80967D20",), - 0x80967DA0:("func_80967DA0",), - 0x80967DCC:("func_80967DCC",), - 0x80967E34:("func_80967E34",), - 0x80967E90:("func_80967E90",), - 0x80967F20:("func_80967F20",), - 0x80967FA4:("func_80967FA4",), - 0x809680B0:("func_809680B0",), - 0x80968164:("func_80968164",), + 0x80967D20:("EnAni_SetText",), + 0x80967DA0:("EnAni_IdleStanding",), + 0x80967DCC:("EnAni_Talk",), + 0x80967E34:("EnAni_IdleInPain",), + 0x80967E90:("EnAni_FallOverInPain",), + 0x80967F20:("EnAni_LandOnFoot",), + 0x80967FA4:("EnAni_FallToGround",), + 0x809680B0:("EnAni_LoseBalance",), + 0x80968164:("EnAni_HangInTree",), 0x809682A8:("EnAni_Update",), - 0x80968504:("func_80968504",), - 0x8096854C:("func_8096854C",), + 0x80968504:("EnAni_OverrideLimbDraw",), + 0x8096854C:("EnAni_PostLimbDraw",), 0x8096858C:("EnAni_Draw",), 0x809687B0:("EnJs_Init",), 0x809689D4:("EnJs_Destroy",), @@ -8201,7 +8201,7 @@ 0x8097DCA0:("EffectSsKakera_Init",), 0x8097DE30:("func_8097DE30",), 0x8097DE6C:("EffectSsKakera_Draw",), - 0x8097E130:("func_8097E130",), + 0x8097E130:("EffectSsKakera_CheckForObject",), 0x8097E19C:("func_8097E19C",), 0x8097E34C:("func_8097E34C",), 0x8097E368:("func_8097E368",), @@ -8573,23 +8573,23 @@ 0x8099AA84:("func_8099AA84",), 0x8099AB30:("EnCrow_Init",), 0x8099AC2C:("EnCrow_Destroy",), - 0x8099AC58:("func_8099AC58",), - 0x8099AC8C:("func_8099AC8C",), - 0x8099B098:("func_8099B098",), - 0x8099B0CC:("func_8099B0CC",), - 0x8099B318:("func_8099B318",), - 0x8099B384:("func_8099B384",), - 0x8099B584:("func_8099B584",), - 0x8099B6AC:("func_8099B6AC",), - 0x8099B6C4:("func_8099B6C4",), - 0x8099B778:("func_8099B778",), - 0x8099B838:("func_8099B838",), - 0x8099B8EC:("func_8099B8EC",), - 0x8099B9E8:("func_8099B9E8",), - 0x8099BAB4:("func_8099BAB4",), + 0x8099AC58:("EnCrow_SetupFlyIdle",), + 0x8099AC8C:("EnCrow_FlyIdle",), + 0x8099B098:("EnCrow_SetupDiveAttack",), + 0x8099B0CC:("EnCrow_DiveAttack",), + 0x8099B318:("EnCrow_CheckIfFrozen",), + 0x8099B384:("EnCrow_SetupDamaged",), + 0x8099B584:("EnCrow_Damaged",), + 0x8099B6AC:("EnCrow_SetupDie",), + 0x8099B6C4:("EnCrow_Die",), + 0x8099B778:("EnCrow_SetupTurnAway",), + 0x8099B838:("EnCrow_TurnAway",), + 0x8099B8EC:("EnCrow_SetupRespawn",), + 0x8099B9E8:("EnCrow_Respawn",), + 0x8099BAB4:("EnCrow_UpdateDamage",), 0x8099BB84:("EnCrow_Update",), - 0x8099BE48:("func_8099BE48",), - 0x8099BF20:("func_8099BF20",), + 0x8099BE48:("EnCrow_OverrideLimbDraw",), + 0x8099BF20:("EnCrow_PostLimbDraw",), 0x8099BFA4:("EnCrow_Draw",), 0x8099C290:("func_8099C290",), 0x8099C328:("func_8099C328",), @@ -8989,14 +8989,14 @@ 0x809BD858:("func_809BD858",), 0x809C0760:("EnWarptag_Init",), 0x809C0824:("EnWarptag_Destroy",), - 0x809C085C:("func_809C085C",), - 0x809C08E0:("func_809C08E0",), - 0x809C09A0:("func_809C09A0",), - 0x809C0A20:("func_809C0A20",), - 0x809C0AB4:("func_809C0AB4",), - 0x809C0E30:("func_809C0E30",), + 0x809C085C:("EnWarpTag_CheckDungeonKeepObject",), + 0x809C08E0:("EnWarpTag_WaitForPlayer",), + 0x809C09A0:("EnWarpTag_Unused809C09A0",), + 0x809C0A20:("EnWarpTag_Unused809C0A20",), + 0x809C0AB4:("EnWarpTag_RespawnPlayer",), + 0x809C0E30:("EnWarpTag_GrottoReturn",), 0x809C0F18:("EnWarptag_Update",), - 0x809C0F3C:("func_809C0F3C",), + 0x809C0F3C:("EnWarpTag_Draw",), 0x809C10B0:("func_809C10B0",), 0x809C1124:("func_809C1124",), 0x809C1158:("func_809C1158",), @@ -9078,7 +9078,7 @@ 0x809C5BA0:("func_809C5BA0",), 0x809C5BF4:("func_809C5BF4",), 0x809C5E14:("EnBomBowlMan_Update",), - 0x809C5F44:("func_809C5F44",), + 0x809C5F44:("EnBomBowlMan_OverrideLimbDraw",), 0x809C5FC4:("EnBomBowlMan_Draw",), 0x809C64C0:("func_809C64C0",), 0x809C6578:("EnSyatekiMan_Init",), @@ -9134,40 +9134,40 @@ 0x809CABC0:("func_809CABC0",), 0x809CACD0:("func_809CACD0",), 0x809CADE8:("EnSyatekiCrow_Update",), - 0x809CAE5C:("func_809CAE5C",), - 0x809CAF2C:("func_809CAF2C",), + 0x809CAE5C:("EnSyatekiCrow_OverrideLimbDraw",), + 0x809CAF2C:("EnSyatekiCrow_PostLimbDraw",), 0x809CAFEC:("EnSyatekiCrow_Draw",), 0x809CB200:("EnBoj04_Init",), 0x809CB210:("EnBoj04_Destroy",), 0x809CB220:("EnBoj04_Update",), 0x809CB230:("EnBoj04_Draw",), - 0x809CB290:("func_809CB290",), - 0x809CB404:("func_809CB404",), + 0x809CB290:("EnCne01_UpdateModel",), + 0x809CB404:("EnCne01_TestIsTalking",), 0x809CB4A0:("func_809CB4A0",), - 0x809CB520:("func_809CB520",), - 0x809CB5A0:("func_809CB5A0",), - 0x809CB5D8:("func_809CB5D8",), - 0x809CB5FC:("func_809CB5FC",), + 0x809CB520:("EnCne01_FinishInit",), + 0x809CB5A0:("EnCne01_Walk",), + 0x809CB5D8:("EnCne01_FaceForward",), + 0x809CB5FC:("EnCne01_Talk",), 0x809CB72C:("EnCne01_Init",), 0x809CB86C:("EnCne01_Destroy",), 0x809CB898:("EnCne01_Update",), - 0x809CB920:("func_809CB920",), - 0x809CBBC8:("func_809CBBC8",), - 0x809CBCA0:("func_809CBCA0",), + 0x809CB920:("EnCne01_OverrideLimbDraw",), + 0x809CBBC8:("EnCne01_PostLimbDraw",), + 0x809CBCA0:("EnCne01_TransformLimbDraw",), 0x809CBCB4:("EnCne01_Draw",), - 0x809CC060:("func_809CC060",), - 0x809CC1D4:("func_809CC1D4",), + 0x809CC060:("EnBba01_UpdateModel",), + 0x809CC1D4:("EnBba01_TestIsTalking",), 0x809CC270:("func_809CC270",), - 0x809CC2F0:("func_809CC2F0",), - 0x809CC370:("func_809CC370",), - 0x809CC3A8:("func_809CC3A8",), - 0x809CC3CC:("func_809CC3CC",), + 0x809CC2F0:("EnBba01_FinishInit",), + 0x809CC370:("EnBba01_Walk",), + 0x809CC3A8:("EnBba01_FaceFoward",), + 0x809CC3CC:("EnBba01_Talk",), 0x809CC4FC:("EnBba01_Init",), 0x809CC63C:("EnBba01_Destroy",), 0x809CC668:("EnBba01_Update",), - 0x809CC6F0:("func_809CC6F0",), - 0x809CC984:("func_809CC984",), - 0x809CCA5C:("func_809CCA5C",), + 0x809CC6F0:("EnBba01_OverrideLimbDraw",), + 0x809CC984:("EnBba01_PostLimbDraw",), + 0x809CCA5C:("EnBba01_TransformLimbDraw",), 0x809CCA70:("EnBba01_Draw",), 0x809CCDE0:("func_809CCDE0",), 0x809CCE98:("func_809CCE98",), @@ -9198,22 +9198,22 @@ 0x809CEEAC:("func_809CEEAC",), 0x809CEF0C:("BgSpdweb_Update",), 0x809CEF30:("BgSpdweb_Draw",), - 0x809CF350:("func_809CF350",), - 0x809CF394:("func_809CF394",), - 0x809CF444:("func_809CF444",), - 0x809CF4EC:("func_809CF4EC",), - 0x809CF67C:("func_809CF67C",), - 0x809CF848:("func_809CF848",), - 0x809CF8EC:("func_809CF8EC",), - 0x809CF950:("func_809CF950",), - 0x809CF9A0:("func_809CF9A0",), - 0x809CFA00:("func_809CFA00",), - 0x809CFA54:("func_809CFA54",), - 0x809CFBC4:("func_809CFBC4",), - 0x809CFC38:("func_809CFC38",), - 0x809CFD98:("func_809CFD98",), - 0x809CFE28:("func_809CFE28",), - 0x809CFF94:("func_809CFF94",), + 0x809CF350:("EnMttag_IsInFinishLine",), + 0x809CF394:("EnMttag_CheckPlayerCheatStatus",), + 0x809CF444:("EnMttag_AreFourRaceGoronsPresent",), + 0x809CF4EC:("EnMttag_GetCurrentCheckpoint",), + 0x809CF67C:("EnMttag_UpdateCheckpoints",), + 0x809CF848:("EnMttag_ExitRace",), + 0x809CF8EC:("EnMttag_ShowFalseStartMessage",), + 0x809CF950:("EnMttag_ShowCantWinMessage",), + 0x809CF9A0:("EnMttag_ShowIntroCutscene",), + 0x809CFA00:("EnMttag_WaitForIntroCutsceneToEnd",), + 0x809CFA54:("EnMttag_RaceStart",), + 0x809CFBC4:("EnMttag_IsAnyRaceGoronOverFinishLine",), + 0x809CFC38:("EnMttag_Race",), + 0x809CFD98:("EnMttag_RaceFinish",), + 0x809CFE28:("EnMttag_PotentiallyRestartRace",), + 0x809CFF94:("EnMttag_HandleCantWinChoice",), 0x809D0090:("EnMttag_Init",), 0x809D0138:("EnMttag_Destroy",), 0x809D0168:("EnMttag_Update",), @@ -9315,52 +9315,52 @@ 0x809DD2F8:("func_809DD2F8",), 0x809DD934:("func_809DD934",), 0x809DEAC4:("func_809DEAC4",), - 0x809E2760:("func_809E2760",), - 0x809E2788:("func_809E2788",), - 0x809E2880:("func_809E2880",), - 0x809E299C:("func_809E299C",), - 0x809E2AB4:("func_809E2AB4",), - 0x809E2B8C:("func_809E2B8C",), - 0x809E2C1C:("func_809E2C1C",), - 0x809E2C3C:("func_809E2C3C",), - 0x809E2D64:("func_809E2D64",), - 0x809E2DA0:("func_809E2DA0",), + 0x809E2760:("Boss03_PlayUnderwaterSfx",), + 0x809E2788:("Boss03_SpawnEffectWetSpot",), + 0x809E2880:("Boss03_SpawnEffectDroplet",), + 0x809E299C:("Boss03_SpawnEffectSplash",), + 0x809E2AB4:("Boss03_SpawnEffectBubble",), + 0x809E2B8C:("Boss03_UpdateSphereElement",), + 0x809E2C1C:("Boss03_SeedRand",), + 0x809E2C3C:("Boss03_RandZeroOne",), + 0x809E2D64:("Boss03_FindActorDblueMovebg",), + 0x809E2DA0:("Boss03_SpawnDust",), 0x809E2F7C:("Boss03_Init",), 0x809E343C:("Boss03_Destroy",), 0x809E344C:("func_809E344C",), 0x809E34B8:("func_809E34B8",), - 0x809E38EC:("func_809E38EC",), - 0x809E3968:("func_809E3968",), - 0x809E3D34:("func_809E3D34",), - 0x809E3D98:("func_809E3D98",), - 0x809E4180:("func_809E4180",), - 0x809E421C:("func_809E421C",), - 0x809E4674:("func_809E4674",), - 0x809E475C:("func_809E475C",), - 0x809E4910:("func_809E4910",), - 0x809E497C:("func_809E497C",), - 0x809E4C34:("func_809E4C34",), - 0x809E4C90:("func_809E4C90",), - 0x809E4E2C:("func_809E4E2C",), - 0x809E4E80:("func_809E4E80",), - 0x809E5ADC:("func_809E5ADC",), - 0x809E5B64:("func_809E5B64",), - 0x809E65F4:("func_809E65F4",), - 0x809E6640:("func_809E6640",), - 0x809E69A4:("func_809E69A4",), - 0x809E6A38:("func_809E6A38",), - 0x809E6B70:("func_809E6B70",), - 0x809E6BC0:("func_809E6BC0",), - 0x809E6CB4:("func_809E6CB4",), + 0x809E38EC:("Boss03_SetupChasePlayer",), + 0x809E3968:("Boss03_ChasePlayer",), + 0x809E3D34:("Boss03_SetupCatchPlayer",), + 0x809E3D98:("Boss03_CatchPlayer",), + 0x809E4180:("Boss03_SetupChewPlayer",), + 0x809E421C:("Boss03_ChewPlayer",), + 0x809E4674:("Boss03_SetupPrepareCharge",), + 0x809E475C:("Boss03_PrepareCharge",), + 0x809E4910:("Boss03_SetupCharge",), + 0x809E497C:("Boss03_Charge",), + 0x809E4C34:("Boss03_SetupJumpOverPlatform",), + 0x809E4C90:("Boss03_JumpOverPlatform",), + 0x809E4E2C:("Boss03_SetupIntroCutscene",), + 0x809E4E80:("Boss03_IntroCutscene",), + 0x809E5ADC:("Boss03_SetupDeathCutscene",), + 0x809E5B64:("Boss03_DeathCutscene",), + 0x809E65F4:("Boss03_SetupSpawnSmallFishesCutscene",), + 0x809E6640:("Boss03_SpawnSmallFishesCutscene",), + 0x809E69A4:("Boss03_SetupStunned",), + 0x809E6A38:("Boss03_Stunned",), + 0x809E6B70:("Boss03_SetupDamaged",), + 0x809E6BC0:("Boss03_Damaged",), + 0x809E6CB4:("Boss03_UpdateCollision",), 0x809E70EC:("Boss03_Update",), - 0x809E7920:("func_809E7920",), - 0x809E79C4:("func_809E79C4",), - 0x809E7AA8:("func_809E7AA8",), + 0x809E7920:("Boss03_SetObject",), + 0x809E79C4:("Boss03_OverrideLimbDraw",), + 0x809E7AA8:("Boss03_PostLimbDraw",), 0x809E7C0C:("Boss03_Draw",), - 0x809E7D00:("func_809E7D00",), - 0x809E81E4:("func_809E81E4",), - 0x809E8810:("func_809E8810",), - 0x809E8BEC:("func_809E8BEC",), + 0x809E7D00:("Boss03_UpdateEffects",), + 0x809E81E4:("Boss03_DrawEffects",), + 0x809E8810:("Boss03_SeaweedUpdate",), + 0x809E8BEC:("Boss03_SeaweedDraw",), 0x809EC040:("func_809EC040",), 0x809EC0D0:("Boss04_Init",), 0x809EC534:("Boss04_Destroy",), @@ -9605,7 +9605,7 @@ 0x80A0C938:("EnSob1_GetTalkOption",), 0x80A0CA38:("EnSob1_GetWelcome",), 0x80A0CC88:("EnSob1_GetGoodbye",), - 0x80A0CCEC:("EnSob1_EndInteractionBombShop",), + 0x80A0CCEC:("EnSob1_BombShopkeeper_EndInteraction",), 0x80A0CD48:("EnSob1_SpawnShopItems",), 0x80A0CE10:("EnSob1_GetObjIndices",), 0x80A0CED4:("EnSob1_Init",), @@ -9654,27 +9654,27 @@ 0x80A0EEC8:("EnSob1_UpdateItemSelectedProperty",), 0x80A0EF48:("EnSob1_UpdateCursorAnim",), 0x80A0F014:("EnSob1_UpdateStickDirectionPromptAnim",), - 0x80A0F1C4:("EnSob1_GetXZAngleAndDistanceSqToPoint",), + 0x80A0F1C4:("EnSob1_GetDistSqAndOrient",), 0x80A0F284:("EnSob1_GetCutscenes",), 0x80A0F2C8:("EnSob1_WaitForBlink",), 0x80A0F2FC:("EnSob1_Blink",), 0x80A0F39C:("EnSob1_ChangeObject",), 0x80A0F3D4:("EnSob1_AreObjectsLoaded",), - 0x80A0F470:("EnSob1_InitZoraShopkeeper",), - 0x80A0F554:("EnSob1_InitGoronShopkeeper",), - 0x80A0F638:("EnSob1_InitBombShopkeeper",), + 0x80A0F470:("EnSob1_ZoraShopkeeper_Init",), + 0x80A0F554:("EnSob1_GoronShopkeeper_Init",), + 0x80A0F638:("EnSob1_BombShopkeeper_Init",), 0x80A0F6B0:("EnSob1_InitShop",), 0x80A0FA0C:("EnSob1_Update",), 0x80A0FADC:("EnSob1_DrawCursor",), 0x80A0FD4C:("EnSob1_DrawTextRec",), 0x80A0FEE8:("EnSob1_DrawStickDirectionPrompt",), - 0x80A10290:("EnSob1_OverrideLimbDrawZoraShopkeeper",), - 0x80A102C8:("EnSob1_OverrideLimbDrawBombShopkeeper",), - 0x80A10308:("EnSob1_PostLimbDrawBombShopkeeper",), + 0x80A10290:("EnSob1_ZoraShopkeeper_OverrideLimbDraw",), + 0x80A102C8:("EnSob1_BombShopkeeper_OverrideLimbDraw",), + 0x80A10308:("EnSob1_BombShopkeeper_PostLimbDraw",), 0x80A10344:("EnSob1_EndDList",), - 0x80A10368:("EnSob1_DrawZoraShopkeeper",), - 0x80A104E4:("EnSob1_DrawGoronShopkeeper",), - 0x80A10608:("EnSob1_DrawBombShopkeeper",), + 0x80A10368:("EnSob1_ZoraShopkeeper_Draw",), + 0x80A104E4:("EnSob1_GoronShopkeeper_Draw",), + 0x80A10608:("EnSob1_BombShopkeeper_Draw",), 0x80A10FD0:("func_80A10FD0",), 0x80A11144:("func_80A11144",), 0x80A1143C:("func_80A1143C",), @@ -9787,23 +9787,23 @@ 0x80A1A220:("ObjRaillift_Draw",), 0x80A1A330:("ObjRaillift_DrawDekuFlowerPlatform",), 0x80A1A360:("ObjRaillift_DrawDekuFlowerPlatformColorful",), - 0x80A1A500:("func_80A1A500",), - 0x80A1A56C:("func_80A1A56C",), - 0x80A1A750:("func_80A1A750",), + 0x80A1A500:("BgNumaHana_SpawnOpenFlowerCollisionChild",), + 0x80A1A56C:("BgNumaHana_UpdatePetalPosRots",), + 0x80A1A750:("BgNumaHana_UpdateSettleRotation",), 0x80A1A7CC:("BgNumaHana_Init",), 0x80A1A9AC:("BgNumaHana_Destroy",), - 0x80A1AA14:("func_80A1AA14",), - 0x80A1AA28:("func_80A1AA28",), - 0x80A1AA38:("func_80A1AA38",), - 0x80A1AA4C:("func_80A1AA4C",), - 0x80A1AAE8:("func_80A1AAE8",), - 0x80A1AB00:("func_80A1AB00",), - 0x80A1ABD8:("func_80A1ABD8",), - 0x80A1ABF0:("func_80A1ABF0",), - 0x80A1ACCC:("func_80A1ACCC",), - 0x80A1ACE0:("func_80A1ACE0",), - 0x80A1AE08:("func_80A1AE08",), - 0x80A1AE1C:("func_80A1AE1C",), + 0x80A1AA14:("BgNumaHana_SetupDoNothing",), + 0x80A1AA28:("BgNumaHana_DoNothing",), + 0x80A1AA38:("BgNumaHana_SetupClosedIdle",), + 0x80A1AA4C:("BgNumaHana_ClosedIdle",), + 0x80A1AAE8:("BgNumaHana_SetupUnfoldInnerPetals",), + 0x80A1AB00:("BgNumaHana_UnfoldInnerPetals",), + 0x80A1ABD8:("BgNumaHana_SetupUnfoldOuterPetals",), + 0x80A1ABF0:("BgNumaHana_UnfoldOuterPetals",), + 0x80A1ACCC:("BgNumaHana_SetupRaiseFlower",), + 0x80A1ACE0:("BgNumaHana_RaiseFlower",), + 0x80A1AE08:("BgNumaHana_SetupOpenedIdle",), + 0x80A1AE1C:("BgNumaHana_OpenedIdle",), 0x80A1AE6C:("BgNumaHana_Update",), 0x80A1AF68:("BgNumaHana_Draw",), 0x80A1B3D0:("func_80A1B3D0",), @@ -9892,8 +9892,8 @@ 0x80A20858:("func_80A20858",), 0x80A208F8:("func_80A208F8",), 0x80A20A50:("EnSyatekiWf_Update",), - 0x80A20CF4:("func_80A20CF4",), - 0x80A20D10:("func_80A20D10",), + 0x80A20CF4:("EnSyatekiWf_OverrideLimbDraw",), + 0x80A20D10:("EnSyatekiWf_PostLimbDraw",), 0x80A20DA4:("EnSyatekiWf_Draw",), 0x80A21150:("func_80A21150",), 0x80A211F4:("func_80A211F4",), @@ -9925,7 +9925,7 @@ 0x80A227C0:("func_80A227C0",), 0x80A22880:("ObjSkateblock_Update",), 0x80A228D8:("ObjSkateblock_Draw",), - 0x80A22D40:("func_80A22D40",), + 0x80A22D40:("EffectEnIceBlock_CheckIceBlockObject",), 0x80A22DB8:("EffectEnIceBlock_Init",), 0x80A22E94:("EffectEnIceBlock_Draw",), 0x80A22FE4:("EffectEnIceBlock_Update",), @@ -9963,8 +9963,8 @@ 0x80A25440:("func_80A25440",), 0x80A25598:("ObjIceblock_Init",), 0x80A25758:("ObjIceblock_Destroy",), - 0x80A257A0:("func_80A257A0",), - 0x80A257B4:("func_80A257B4",), + 0x80A257A0:("ObjIceBlock_SetupAttemptSpawnCutscene",), + 0x80A257B4:("ObjIceBlock_AttemptSpawnCutscene",), 0x80A25824:("func_80A25824",), 0x80A2586C:("func_80A2586C",), 0x80A25978:("func_80A25978",), @@ -10081,7 +10081,7 @@ 0x80A2C4D0:("func_80A2C4D0",), 0x80A2C5DC:("func_80A2C5DC",), 0x80A2C78C:("EnSyatekiDekunuts_Update",), - 0x80A2C8A0:("func_80A2C8A0",), + 0x80A2C8A0:("EnSyatekiDekunuts_OverrideLimbDraw",), 0x80A2C8E8:("EnSyatekiDekunuts_Draw",), 0x80A2CD10:("ElfMsg3_SetupAction",), 0x80A2CD1C:("func_80A2CD1C",), @@ -10186,8 +10186,8 @@ 0x80A32F48:("func_80A32F48",), 0x80A33098:("func_80A33098",), 0x80A331C4:("EnPr_Update",), - 0x80A3357C:("func_80A3357C",), - 0x80A335B4:("func_80A335B4",), + 0x80A3357C:("EnPr_OverrideLimbDraw",), + 0x80A335B4:("EnPr_PostLimbDraw",), 0x80A336C0:("EnPr_Draw",), 0x80A33B00:("func_80A33B00",), 0x80A33BB4:("func_80A33BB4",), @@ -10238,7 +10238,7 @@ 0x80A36B9C:("EnSyatekiOkuta_Update",), 0x80A36CB0:("func_80A36CB0",), 0x80A370EC:("func_80A370EC",), - 0x80A37294:("func_80A37294",), + 0x80A37294:("EnSyatekiOkuta_OverrideLimbDraw",), 0x80A3735C:("EnSyatekiOkuta_Draw",), 0x80A37ED0:("ObjShutter_Init",), 0x80A37EE0:("ObjShutter_Destroy",), @@ -10845,14 +10845,14 @@ 0x80A675C4:("ObjDriftice_Draw",), 0x80A678B0:("EnLookNuts_Init",), 0x80A67A08:("EnLookNuts_Destroy",), - 0x80A67A34:("func_80A67A34",), + 0x80A67A34:("EnLookNuts_SetupPatrol",), 0x80A67AA8:("func_80A67AA8",), - 0x80A67C48:("func_80A67C48",), - 0x80A67D0C:("func_80A67D0C",), + 0x80A67C48:("EnLookNuts_SetupStandAndWait",), + 0x80A67D0C:("EnLookNuts_StandAndWait",), 0x80A67F30:("func_80A67F30",), 0x80A67FC4:("func_80A67FC4",), - 0x80A68080:("func_80A68080",), - 0x80A680FC:("func_80A680FC",), + 0x80A68080:("EnLookNuts_SetupSendPlayerToSpawn",), + 0x80A680FC:("EnLookNuts_SendPlayerToSpawn",), 0x80A681C4:("EnLookNuts_Update",), 0x80A68540:("EnLookNuts_Draw",), 0x80A687A0:("func_80A687A0",), @@ -10956,8 +10956,8 @@ 0x80A6FFAC:("func_80A6FFAC",), 0x80A70084:("func_80A70084",), 0x80A70134:("EnMm3_Update",), - 0x80A701E0:("func_80A701E0",), - 0x80A702B0:("func_80A702B0",), + 0x80A701E0:("EnMm3_OverrideLimbDraw",), + 0x80A702B0:("EnMm3_PostLimbDraw",), 0x80A702F0:("EnMm3_Draw",), 0x80A706F0:("BgCraceMovebg_Init",), 0x80A7090C:("func_80A7090C",), @@ -11005,8 +11005,8 @@ 0x80A72BA4:("func_80A72BA4",), 0x80A72C04:("func_80A72C04",), 0x80A72CF8:("func_80A72CF8",), - 0x80A72D8C:("func_80A72D8C",), - 0x80A72FAC:("func_80A72FAC",), + 0x80A72D8C:("EnDno_ActorPathing_UpdateActorInfo",), + 0x80A72FAC:("EnDno_ActorPathing_Move",), 0x80A730A0:("func_80A730A0",), 0x80A73244:("func_80A73244",), 0x80A732C8:("func_80A732C8",), @@ -11530,7 +11530,7 @@ 0x80AA67F8:("func_80AA67F8",), 0x80AA695C:("func_80AA695C",), 0x80AA6A04:("DmChar00_Update",), - 0x80AA6A6C:("func_80AA6A6C",), + 0x80AA6A6C:("DmChar00_OverrideLimbDraw",), 0x80AA6B34:("DmChar00_Draw",), 0x80AA81E0:("DmChar01_Init",), 0x80AA8660:("DmChar01_Destroy",), @@ -11605,8 +11605,8 @@ 0x80AAD450:("func_80AAD450",), 0x80AAD4A8:("func_80AAD4A8",), 0x80AAD78C:("DmChar05_Update",), - 0x80AAD964:("func_80AAD964",), - 0x80AAD980:("func_80AAD980",), + 0x80AAD964:("DmChar05_OverrideLimbDraw",), + 0x80AAD980:("DmChar05_PostLimbDraw",), 0x80AAD998:("func_80AAD998",), 0x80AADA90:("func_80AADA90",), 0x80AADB4C:("func_80AADB4C",), @@ -11804,16 +11804,16 @@ 0x80ABAE64:("func_80ABAE64",), 0x80ABB0E0:("EnGuardNuts_Init",), 0x80ABB1E4:("EnGuardNuts_Destroy",), - 0x80ABB210:("func_80ABB210",), - 0x80ABB29C:("func_80ABB29C",), - 0x80ABB2D4:("func_80ABB2D4",), + 0x80ABB210:("EnGuardNuts_ChangeAnim",), + 0x80ABB29C:("EnGuardNuts_SetupWait",), + 0x80ABB2D4:("EnGuardNuts_Wait",), 0x80ABB540:("func_80ABB540",), 0x80ABB590:("func_80ABB590",), - 0x80ABB854:("func_80ABB854",), - 0x80ABB91C:("func_80ABB91C",), - 0x80ABB990:("func_80ABB990",), + 0x80ABB854:("EnGuardNuts_Burrow",), + 0x80ABB91C:("EnGuardNuts_SetupUnburrow",), + 0x80ABB990:("EnGuardNuts_Unburrow",), 0x80ABBACC:("EnGuardNuts_Update",), - 0x80ABBC60:("func_80ABBC60",), + 0x80ABBC60:("EnGuardNuts_OverrideLimbDraw",), 0x80ABBCB8:("EnGuardNuts_Draw",), 0x80ABBFC0:("func_80ABBFC0",), 0x80ABC2E0:("func_80ABC2E0",), @@ -12149,12 +12149,12 @@ 0x80AD1634:("func_80AD1634",), 0x80AD16A8:("func_80AD16A8",), 0x80AD19A0:("func_80AD19A0",), - 0x80AD1A4C:("func_80AD1A4C",), + 0x80AD1A4C:("EnOsn_Idle",), 0x80AD1A5C:("EnOsn_Init",), 0x80AD1C88:("EnOsn_Destroy",), 0x80AD1CC8:("EnOsn_Update",), - 0x80AD1DA8:("func_80AD1DA8",), - 0x80AD1E28:("func_80AD1E28",), + 0x80AD1DA8:("EnOsn_OverrideLimbDraw",), + 0x80AD1E28:("EnOsn_PostLimbDraw",), 0x80AD1F88:("EnOsn_Draw",), 0x80AD2B70:("BgCtowerGear_Splash",), 0x80AD2E84:("BgCtowerGear_Init",), @@ -12208,7 +12208,7 @@ 0x80AD5394:("func_80AD5394",), 0x80AD54C8:("EnTrt2_OverrideLimbDraw",), 0x80AD5584:("EnTrt2_PostLimbDraw",), - 0x80AD566C:("EnTrt2_UnkDraw",), + 0x80AD566C:("EnTrt2_TransformLimbDraw",), 0x80AD56E8:("func_80AD56E8",), 0x80AD5BB0:("ObjTokeiStep_SetSysMatrix",), 0x80AD5BE8:("ObjTokeiStep_AddQuake",), @@ -12384,8 +12384,8 @@ 0x80AE0D78:("func_80AE0D78",), 0x80AE0DDC:("EnTsn_Update",), 0x80AE0F84:("func_80AE0F84",), - 0x80AE0FA8:("func_80AE0FA8",), - 0x80AE1024:("func_80AE1024",), + 0x80AE0FA8:("EnTsn_OverrideLimbDraw",), + 0x80AE1024:("EnTsn_PostLimbDraw",), 0x80AE1080:("EnTsn_Draw",), 0x80AE1650:("func_80AE1650",), 0x80AE16A0:("func_80AE16A0",), @@ -12461,8 +12461,8 @@ 0x80AE5990:("EnFsn_Draw",), 0x80AE6130:("func_80AE6130",), 0x80AE615C:("func_80AE615C",), - 0x80AE61C0:("func_80AE61C0",), - 0x80AE625C:("func_80AE625C",), + 0x80AE61C0:("EnShn_IsFacingPlayer",), + 0x80AE625C:("EnShn_GetPlayer",), 0x80AE626C:("func_80AE626C",), 0x80AE63A8:("func_80AE63A8",), 0x80AE6488:("func_80AE6488",), @@ -12475,9 +12475,9 @@ 0x80AE6B30:("EnShn_Init",), 0x80AE6C4C:("EnShn_Destroy",), 0x80AE6C5C:("EnShn_Update",), - 0x80AE6CF0:("func_80AE6CF0",), - 0x80AE6D40:("func_80AE6D40",), - 0x80AE6D90:("func_80AE6D90",), + 0x80AE6CF0:("EnShn_OverrideLimbDraw",), + 0x80AE6D40:("EnShn_PostLimbDraw",), + 0x80AE6D90:("EnShn_TransformLimbDraw",), 0x80AE6E8C:("EnShn_Draw",), 0x80AE73A0:("EnStopheishi_Init",), 0x80AE74E0:("EnStopheishi_Destroy",), @@ -12776,14 +12776,14 @@ 0x80AFAA44:("EnPm_PostLimbDraw",), 0x80AFABAC:("EnPm_TransformLimbDraw",), 0x80AFACAC:("EnPm_Draw",), - 0x80AFC960:("func_80AFC960",), + 0x80AFC960:("EnGakufu_ProcessNotes",), 0x80AFCA94:("EnGakufu_Init",), 0x80AFCB64:("EnGakufu_Destroy",), - 0x80AFCB94:("func_80AFCB94",), - 0x80AFCBD4:("func_80AFCBD4",), - 0x80AFCC14:("func_80AFCC14",), - 0x80AFCC24:("func_80AFCC24",), - 0x80AFCC58:("func_80AFCC58",), + 0x80AFCB94:("EnGakufu_DisplayOnTimer",), + 0x80AFCBD4:("EnGakufu_WaitForTimer",), + 0x80AFCC14:("EnGakufu_DoNothing",), + 0x80AFCC24:("EnGakufu_IsPlayerInRange",), + 0x80AFCC58:("EnGakufu_GiveReward",), 0x80AFCD44:("func_80AFCD44",), 0x80AFCDC8:("func_80AFCDC8",), 0x80AFCE70:("EnGakufu_Update",), @@ -12819,8 +12819,8 @@ 0x80AFEB0C:("EnTalkGibud_Destroy",), 0x80AFEB38:("EnTalkGibud_SetupIdle",), 0x80AFEB7C:("EnTalkGibud_Idle",), - 0x80AFEC08:("EnTalkGibud_SetupAttemptPlayerStun",), - 0x80AFEC4C:("EnTalkGibud_AttemptStun",), + 0x80AFEC08:("EnTalkGibud_SetupAttemptPlayerFreeze",), + 0x80AFEC4C:("EnTalkGibud_AttemptPlayerFreeze",), 0x80AFED08:("EnTalkGibud_SetupWalkToPlayer",), 0x80AFED7C:("EnTalkGibud_WalkToPlayer",), 0x80AFEFD4:("EnTalkGibud_SetupGrab",), @@ -12857,8 +12857,8 @@ 0x80B00760:("EnTalkGibud_MoveToIdealGrabPositionAndRotation",), 0x80B008BC:("EnTalkGibud_PlayAnimation",), 0x80B008FC:("EnTalkGibud_MoveWithGravity",), - 0x80B0094C:("EnTalkGibud_CheckDamageEffect",), - 0x80B00B8C:("EnTalkGibud_CheckCollision",), + 0x80B0094C:("EnTalkGibud_UpdateDamage",), + 0x80B00B8C:("EnTalkGibud_UpdateCollision",), 0x80B00C94:("EnTalkGibud_MoveGrabbedPlayerAwayFromWall",), 0x80B00D9C:("EnTalkGibud_UpdateEffect",), 0x80B00E48:("EnTalkGibud_Update",), @@ -13267,7 +13267,7 @@ 0x80B23910:("func_80B23910",), 0x80B23934:("func_80B23934",), 0x80B239FC:("EnHanabi_Update",), - 0x80B23A38:("func_80B23A38",), + 0x80B23A38:("EnHanabi_Draw",), 0x80B23D50:("func_80B23D50",), 0x80B23DD0:("func_80B23DD0",), 0x80B23E10:("ObjDowsing_Init",), @@ -13297,8 +13297,8 @@ 0x80B25708:("EnRacedog_Update",), 0x80B2583C:("func_80B2583C",), 0x80B258D8:("func_80B258D8",), - 0x80B25A74:("func_80B25A74",), - 0x80B25A90:("func_80B25A90",), + 0x80B25A74:("EnRacedog_OverrideLimbDraw",), + 0x80B25A90:("EnRacedog_PostLimbDraw",), 0x80B25B14:("EnRacedog_Draw",), 0x80B262A0:("EnKendoJs_Init",), 0x80B264FC:("EnKendoJs_Destroy",), @@ -13330,8 +13330,8 @@ 0x80B279F0:("func_80B279F0",), 0x80B27A90:("func_80B27A90",), 0x80B27ACC:("EnKendoJs_Update",), - 0x80B27B54:("func_80B27B54",), - 0x80B27B8C:("func_80B27B8C",), + 0x80B27B54:("EnKendoJs_OverrideLimbDraw",), + 0x80B27B8C:("EnKendoJs_PostLimbDraw",), 0x80B27BA4:("EnKendoJs_Draw",), 0x80B28080:("BgBotihasira_Init",), 0x80B28124:("BgBotihasira_Destroy",), @@ -13484,9 +13484,9 @@ 0x80B32E74:("EnZoraegg_Update",), 0x80B32F04:("func_80B32F04",), 0x80B331C8:("func_80B331C8",), - 0x80B3336C:("func_80B3336C",), + 0x80B3336C:("EnZoraegg_OverrideLimbDraw",), 0x80B333DC:("func_80B333DC",), - 0x80B33480:("func_80B33480",), + 0x80B33480:("EnZoraegg_PostLimbDraw",), 0x80B33818:("func_80B33818",), 0x80B338C0:("EnZoraegg_Draw",), 0x80B33D30:("EnKbt_Init",), @@ -13501,8 +13501,8 @@ 0x80B34574:("func_80B34574",), 0x80B34598:("func_80B34598",), 0x80B349A4:("EnKbt_Update",), - 0x80B349C8:("func_80B349C8",), - 0x80B34A00:("func_80B34A00",), + 0x80B349C8:("EnKbt_OverrideLimbDraw",), + 0x80B34A00:("EnKbt_PostLimbDraw",), 0x80B34A40:("EnKbt_Draw",), 0x80B34F70:("func_80B34F70",), 0x80B34FB4:("func_80B34FB4",), @@ -13527,8 +13527,8 @@ 0x80B364F8:("EnGg_Init",), 0x80B36660:("EnGg_Destroy",), 0x80B36670:("EnGg_Update",), - 0x80B368B0:("func_80B368B0",), - 0x80B368F0:("func_80B368F0",), + 0x80B368B0:("EnGg_OverrideLimbDraw",), + 0x80B368F0:("EnGg_PostLimbDraw",), 0x80B36A34:("EnGg_Draw",), 0x80B37080:("EnMaruta_Init",), 0x80B37280:("EnMaruta_Destroy",), @@ -14003,9 +14003,9 @@ 0x80B526FC:("EnGk_Init",), 0x80B529B8:("EnGk_Destroy",), 0x80B529E4:("EnGk_Update",), - 0x80B52AD4:("func_80B52AD4",), - 0x80B52AF0:("func_80B52AF0",), - 0x80B52D8C:("func_80B52D8C",), + 0x80B52AD4:("EnGk_OverrideLimbDraw",), + 0x80B52AF0:("EnGk_PostLimbDraw",), + 0x80B52D8C:("EnGk_TransformDraw",), 0x80B52F74:("EnGk_Draw",), 0x80B53840:("func_80B53840",), 0x80B539CC:("func_80B539CC",), @@ -14116,8 +14116,8 @@ 0x80B5CEC8:("func_80B5CEC8",), 0x80B5D114:("func_80B5D114",), 0x80B5D160:("func_80B5D160",), - 0x80B5D37C:("func_80B5D37C",), - 0x80B5D470:("func_80B5D470",), + 0x80B5D37C:("EnOt_ActorPathing_Move",), + 0x80B5D470:("EnOt_ActorPathing_UpdateActorInfo",), 0x80B5D648:("func_80B5D648",), 0x80B5D750:("func_80B5D750",), 0x80B5D8AC:("EnOt_Update",), @@ -14130,24 +14130,24 @@ 0x80B5E1D8:("func_80B5E1D8",), 0x80B5E890:("EnDragon_Init",), 0x80B5EA74:("EnDragon_Destroy",), - 0x80B5EAA0:("func_80B5EAA0",), - 0x80B5EB40:("func_80B5EB40",), - 0x80B5ED90:("func_80B5ED90",), - 0x80B5EDF0:("func_80B5EDF0",), - 0x80B5EE3C:("func_80B5EE3C",), - 0x80B5EF88:("func_80B5EF88",), - 0x80B5EFD0:("func_80B5EFD0",), - 0x80B5F3A4:("func_80B5F3A4",), - 0x80B5F418:("func_80B5F418",), - 0x80B5F508:("func_80B5F508",), - 0x80B5F888:("func_80B5F888",), - 0x80B5F8D8:("func_80B5F8D8",), - 0x80B5FCC0:("func_80B5FCC0",), - 0x80B5FD68:("func_80B5FD68",), - 0x80B60138:("func_80B60138",), + 0x80B5EAA0:("EnDragon_ChangeAnimation",), + 0x80B5EB40:("EnDragon_SpawnBubbles",), + 0x80B5ED90:("EnDragon_RetreatOnceTimerEnds",), + 0x80B5EDF0:("EnDragon_SetupRetreatOrIdle",), + 0x80B5EE3C:("EnDragon_RetreatOrIdle",), + 0x80B5EF88:("EnDragon_SetupExtend",), + 0x80B5EFD0:("EnDragon_Extend",), + 0x80B5F3A4:("EnDragon_CameraSetAtEye",), + 0x80B5F418:("EnDragon_SetupGrab",), + 0x80B5F508:("EnDragon_Grab",), + 0x80B5F888:("EnDragon_SetupAttack",), + 0x80B5F8D8:("EnDragon_Attack",), + 0x80B5FCC0:("EnDragon_SetupDead",), + 0x80B5FD68:("EnDragon_Dead",), + 0x80B60138:("EnDragon_UpdateDamage",), 0x80B6031C:("EnDragon_Update",), - 0x80B6043C:("func_80B6043C",), - 0x80B60494:("func_80B60494",), + 0x80B6043C:("EnDragon_OverrideLimbDraw",), + 0x80B60494:("EnDragon_PostLimbDraw",), 0x80B60564:("EnDragon_Draw",), 0x80B60AD0:("ObjDora_Init",), 0x80B60C70:("ObjDora_Destroy",), @@ -14407,35 +14407,35 @@ 0x80B72E88:("EnRailSkb_OverrideLimbDraw",), 0x80B7302C:("EnRailSkb_PostLimbDraw",), 0x80B731EC:("EnRailSkb_Draw",), - 0x80B73A90:("func_80B73A90",), - 0x80B73AE4:("func_80B73AE4",), - 0x80B73B98:("func_80B73B98",), - 0x80B73C58:("func_80B73C58",), - 0x80B73DF4:("func_80B73DF4",), - 0x80B73E3C:("func_80B73E3C",), - 0x80B73F1C:("func_80B73F1C",), - 0x80B7406C:("func_80B7406C",), - 0x80B7408C:("func_80B7408C",), - 0x80B74134:("func_80B74134",), - 0x80B741F8:("func_80B741F8",), - 0x80B742F8:("func_80B742F8",), - 0x80B74440:("func_80B74440",), - 0x80B74550:("func_80B74550",), - 0x80B747C8:("func_80B747C8",), - 0x80B74840:("func_80B74840",), - 0x80B749D0:("func_80B749D0",), - 0x80B74AD8:("func_80B74AD8",), - 0x80B74B54:("func_80B74B54",), - 0x80B74BC8:("func_80B74BC8",), - 0x80B74E5C:("func_80B74E5C",), - 0x80B750A0:("func_80B750A0",), - 0x80B7517C:("func_80B7517C",), - 0x80B751F8:("func_80B751F8",), + 0x80B73A90:("EnJg_GetShrineGoronToFocusOn",), + 0x80B73AE4:("EnJg_UpdateCollision",), + 0x80B73B98:("EnJg_GetWalkingYRotation",), + 0x80B73C58:("EnJg_ReachedPoint",), + 0x80B73DF4:("EnJg_GetCutsceneForTeachingLullabyIntro",), + 0x80B73E3C:("EnJg_SetupGoronShrineCheer",), + 0x80B73F1C:("EnJg_SetupTalk",), + 0x80B7406C:("EnJg_Idle",), + 0x80B7408C:("EnJg_GoronShrineIdle",), + 0x80B74134:("EnJg_GoronShrineTalk",), + 0x80B741F8:("EnJg_GoronShrineCheer",), + 0x80B742F8:("EnJg_AlternateTalkOrWalkInPlace",), + 0x80B74440:("EnJg_Walk",), + 0x80B74550:("EnJg_Talk",), + 0x80B747C8:("EnJg_SetupWalk",), + 0x80B74840:("EnJg_Freeze",), + 0x80B749D0:("EnJg_FrozenIdle",), + 0x80B74AD8:("EnJg_EndFrozenInteraction",), + 0x80B74B54:("EnJg_TeachLullabyIntro",), + 0x80B74BC8:("EnJg_LullabyIntroCutsceneAction",), + 0x80B74E5C:("EnJg_GetNextTextId",), + 0x80B750A0:("EnJg_GetStartingConversationTextId",), + 0x80B7517C:("EnJg_SpawnBreath",), + 0x80B751F8:("EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer",), 0x80B753A0:("EnJg_Init",), 0x80B75564:("EnJg_Destroy",), 0x80B75590:("EnJg_Update",), - 0x80B75658:("func_80B75658",), - 0x80B75708:("func_80B75708",), + 0x80B75658:("EnJg_OverrideLimbDraw",), + 0x80B75708:("EnJg_PostLimbDraw",), 0x80B757AC:("EnJg_Draw",), 0x80B76030:("func_80B76030",), 0x80B76110:("func_80B76110",), @@ -14457,9 +14457,9 @@ 0x80B76E1C:("EnTruMt_Destroy",), 0x80B76E48:("EnTruMt_Update",), 0x80B76ED4:("func_80B76ED4",), - 0x80B77008:("func_80B77008",), - 0x80B77078:("func_80B77078",), - 0x80B77354:("func_80B77354",), + 0x80B77008:("EnTruMt_OverrideLimbDraw",), + 0x80B77078:("EnTruMt_PostLimbDraw",), + 0x80B77354:("EnTruMt_TransformLimbDraw",), 0x80B773D0:("EnTruMt_Draw",), 0x80B77770:("func_80B77770",), 0x80B77FA4:("func_80B77FA4",), @@ -14517,36 +14517,36 @@ 0x80B7C03C:("ObjUm_Draw",), 0x80B7C890:("EnNeoReeba_Init",), 0x80B7CA08:("EnNeoReeba_Destroy",), - 0x80B7CA34:("func_80B7CA34",), - 0x80B7CA70:("func_80B7CA70",), - 0x80B7CB3C:("func_80B7CB3C",), - 0x80B7CB88:("func_80B7CB88",), - 0x80B7CCE0:("func_80B7CCE0",), - 0x80B7CD28:("func_80B7CD28",), - 0x80B7CE34:("func_80B7CE34",), - 0x80B7CE94:("func_80B7CE94",), - 0x80B7CFA0:("func_80B7CFA0",), - 0x80B7CFFC:("func_80B7CFFC",), - 0x80B7D130:("func_80B7D130",), - 0x80B7D150:("func_80B7D150",), - 0x80B7D254:("func_80B7D254",), - 0x80B7D2E4:("func_80B7D2E4",), - 0x80B7D360:("func_80B7D360",), - 0x80B7D398:("func_80B7D398",), - 0x80B7D3EC:("func_80B7D3EC",), - 0x80B7D47C:("func_80B7D47C",), - 0x80B7D4FC:("func_80B7D4FC",), - 0x80B7D5A4:("func_80B7D5A4",), - 0x80B7D6D0:("func_80B7D6D0",), - 0x80B7D788:("func_80B7D788",), - 0x80B7D9B8:("func_80B7D9B8",), - 0x80B7DC80:("func_80B7DC80",), - 0x80B7DD7C:("func_80B7DD7C",), - 0x80B7DF34:("func_80B7DF34",), - 0x80B7E0BC:("func_80B7E0BC",), - 0x80B7E260:("func_80B7E260",), + 0x80B7CA34:("EnNeoReeba_SetupWaitUnderground",), + 0x80B7CA70:("EnNeoReeba_WaitUnderground",), + 0x80B7CB3C:("EnNeoReeba_SetupChooseAction",), + 0x80B7CB88:("EnNeoReeba_ChooseAction",), + 0x80B7CCE0:("EnNeoReeba_SetupSink",), + 0x80B7CD28:("EnNeoReeba_Sink",), + 0x80B7CE34:("EnNeoReeba_SetupRise",), + 0x80B7CE94:("EnNeoReeba_RiseOutOfGround",), + 0x80B7CFA0:("EnNeoReeba_SetupMove",), + 0x80B7CFFC:("EnNeoReeba_Move",), + 0x80B7D130:("EnNeoReeba_SetupReturnHome",), + 0x80B7D150:("EnNeoReeba_ReturnHome",), + 0x80B7D254:("EnNeoReeba_SetupBounce",), + 0x80B7D2E4:("EnNeoReeba_Bounce",), + 0x80B7D360:("EnNeoReeba_SetupStun",), + 0x80B7D398:("EnNeoReeba_Stunned",), + 0x80B7D3EC:("EnNeoReeba_SetupFrozen",), + 0x80B7D47C:("EnNeoReeba_Frozen",), + 0x80B7D4FC:("EnNeoReeba_SetupDamageAnim",), + 0x80B7D5A4:("EnNeoReeba_DamageAnim",), + 0x80B7D6D0:("EnNeoReeba_SetupDeathEffects",), + 0x80B7D788:("EnNeoReeba_PlayDeathEffects",), + 0x80B7D9B8:("EnNeoReeba_HandleHit",), + 0x80B7DC80:("EnNeoReeba_UpdatePosition",), + 0x80B7DD7C:("EnNeoReeba_DrawFrozenEffects",), + 0x80B7DF34:("EnNeoReeba_DrawEffects",), + 0x80B7E0BC:("EnNeoReeba_SpawnIce",), + 0x80B7E260:("EnNeoReeba_SinkIfStoneMask",), 0x80B7E2C4:("EnNeoReeba_Update",), - 0x80B7E378:("func_80B7E378",), + 0x80B7E378:("EnNeoReeba_OverrideLimbDraw",), 0x80B7E424:("EnNeoReeba_Draw",), 0x80B7E930:("BgMbarChair_Init",), 0x80B7E980:("BgMbarChair_Destroy",), @@ -15118,56 +15118,56 @@ 0x80BA4CB4:("func_80BA4CB4",), 0x80BA4E2C:("EnToto_Update",), 0x80BA4EFC:("EnToto_Draw",), - 0x80BA5400:("func_80BA5400",), + 0x80BA5400:("EnRailgibud_SpawnOtherGibdosAndSetPositionAndRotation",), 0x80BA5620:("EnRailgibud_Init",), 0x80BA577C:("EnRailgibud_Destroy",), - 0x80BA57A8:("func_80BA57A8",), - 0x80BA57F8:("func_80BA57F8",), - 0x80BA59F0:("func_80BA59F0",), - 0x80BA5A34:("func_80BA5A34",), - 0x80BA5AF0:("func_80BA5AF0",), - 0x80BA5B64:("func_80BA5B64",), - 0x80BA5DBC:("func_80BA5DBC",), - 0x80BA5E18:("func_80BA5E18",), - 0x80BA6054:("func_80BA6054",), - 0x80BA60B0:("func_80BA60B0",), - 0x80BA6158:("func_80BA6158",), - 0x80BA61A0:("func_80BA61A0",), - 0x80BA6284:("func_80BA6284",), - 0x80BA62D4:("func_80BA62D4",), - 0x80BA6440:("func_80BA6440",), - 0x80BA64AC:("func_80BA64AC",), - 0x80BA6584:("func_80BA6584",), - 0x80BA6604:("func_80BA6604",), - 0x80BA6664:("func_80BA6664",), - 0x80BA66C8:("func_80BA66C8",), - 0x80BA6800:("func_80BA6800",), - 0x80BA6974:("func_80BA6974",), - 0x80BA6B30:("func_80BA6B30",), - 0x80BA6B9C:("func_80BA6B9C",), - 0x80BA6D10:("func_80BA6D10",), - 0x80BA6DAC:("func_80BA6DAC",), - 0x80BA6DF8:("func_80BA6DF8",), - 0x80BA7088:("func_80BA7088",), - 0x80BA71E4:("func_80BA71E4",), - 0x80BA7234:("func_80BA7234",), - 0x80BA7388:("func_80BA7388",), - 0x80BA7434:("func_80BA7434",), - 0x80BA7578:("func_80BA7578",), - 0x80BA76C4:("func_80BA76C4",), + 0x80BA57A8:("EnRailgibud_SetupWalkInCircles",), + 0x80BA57F8:("EnRailgibud_WalkInCircles",), + 0x80BA59F0:("EnRailgibud_SetupAttemptPlayerFreeze",), + 0x80BA5A34:("EnRailgibud_AttemptPlayerFreeze",), + 0x80BA5AF0:("EnRailgibud_SetupWalkToPlayer",), + 0x80BA5B64:("EnRailgibud_WalkToPlayer",), + 0x80BA5DBC:("EnRailgibud_SetupGrab",), + 0x80BA5E18:("EnRailgibud_Grab",), + 0x80BA6054:("EnRailgibud_SetupGrabFail",), + 0x80BA60B0:("EnRailgibud_GrabFail",), + 0x80BA6158:("EnRailgibud_SetupTurnAwayAndShakeHead",), + 0x80BA61A0:("EnRailgibud_TurnAwayAndShakeHead",), + 0x80BA6284:("EnRailgibud_SetupWalkToHome",), + 0x80BA62D4:("EnRailgibud_WalkToHome",), + 0x80BA6440:("EnRailgibud_SetupDamage",), + 0x80BA64AC:("EnRailgibud_Damage",), + 0x80BA6584:("EnRailgibud_SetupStunned",), + 0x80BA6604:("EnRailgibud_Stunned",), + 0x80BA6664:("EnRailgibud_SetupDead",), + 0x80BA66C8:("EnRailgibud_Dead",), + 0x80BA6800:("EnRailgibud_SpawnEffectsForSinkingIntoTheGround",), + 0x80BA6974:("EnRailgibud_SpawnDust",), + 0x80BA6B30:("EnRailgibud_UpdateWalkForwardState",), + 0x80BA6B9C:("EnRailgibud_TurnTowardsPlayer",), + 0x80BA6D10:("EnRailgibud_PlayerInRangeWithCorrectState",), + 0x80BA6DAC:("EnRailgibud_PlayerOutOfRange",), + 0x80BA6DF8:("EnRailgibud_UpdateDamage",), + 0x80BA7088:("EnRailgibud_MoveToIdealGrabPositionAndRotation",), + 0x80BA71E4:("EnRailgibud_MoveWithGravity",), + 0x80BA7234:("EnRailgibud_MoveGrabbedPlayerAwayFromWall",), + 0x80BA7388:("EnRailgibud_UpdateEffect",), + 0x80BA7434:("EnRailgibud_CheckForGibdoMask",), + 0x80BA7578:("EnRailgibud_CheckIfTalkingToPlayer",), + 0x80BA76C4:("EnRailgibud_UpdateCollision",), 0x80BA77A0:("EnRailgibud_Update",), - 0x80BA7878:("func_80BA7878",), - 0x80BA789C:("func_80BA789C",), - 0x80BA78F8:("func_80BA78F8",), + 0x80BA7878:("EnRailgibud_MainGibdo_DeadUpdate",), + 0x80BA789C:("EnRailgibud_OverrideLimbDraw",), + 0x80BA78F8:("EnRailgibud_PostLimbDraw",), 0x80BA79D4:("EnRailgibud_Draw",), - 0x80BA7B6C:("func_80BA7B6C",), - 0x80BA7C78:("func_80BA7C78",), - 0x80BA7CF0:("func_80BA7CF0",), - 0x80BA7D04:("func_80BA7D04",), - 0x80BA7D14:("func_80BA7D14",), - 0x80BA7D30:("func_80BA7D30",), - 0x80BA7DC8:("func_80BA7DC8",), - 0x80BA8050:("func_80BA8050",), + 0x80BA7B6C:("EnRailgibud_InitCutsceneGibdo",), + 0x80BA7C78:("EnRailgibud_InitActorActionCommand",), + 0x80BA7CF0:("EnRailgibud_SetupDoNothing",), + 0x80BA7D04:("EnRailgibud_DoNothing",), + 0x80BA7D14:("EnRailgibud_SetupSinkIntoGround",), + 0x80BA7D30:("EnRailgibud_SinkIntoGround",), + 0x80BA7DC8:("EnRailgibud_PerformCutsceneActions",), + 0x80BA8050:("EnRailgibud_Cutscene_Update",), 0x80BA8820:("func_80BA8820",), 0x80BA886C:("func_80BA886C",), 0x80BA8C4C:("func_80BA8C4C",), @@ -15192,9 +15192,9 @@ 0x80BA9E6C:("EnBaba_Init",), 0x80BA9F24:("EnBaba_Destroy",), 0x80BA9F50:("EnBaba_Update",), - 0x80BA9FB0:("func_80BA9FB0",), - 0x80BAA198:("func_80BAA198",), - 0x80BAA20C:("func_80BAA20C",), + 0x80BA9FB0:("EnBaba_OverrideLimbDraw",), + 0x80BAA198:("EnBaba_PostLimbDraw",), + 0x80BAA20C:("EnBaba_TransformLimbDraw",), 0x80BAA220:("EnBaba_Draw",), 0x80BAA6D0:("EnSuttari_UpdateCollider",), 0x80BAA848:("EnSuttari_GetActorById",), @@ -15211,7 +15211,7 @@ 0x80BAB434:("func_80BAB434",), 0x80BAB490:("EnSuttari_GetPaths",), 0x80BAB4F0:("func_80BAB4F0",), - 0x80BAB698:("func_80BAB698",), + 0x80BAB698:("EnSuttari_GetDistSqAndOrient",), 0x80BAB758:("func_80BAB758",), 0x80BAB8F4:("func_80BAB8F4",), 0x80BABA90:("func_80BABA90",), @@ -15274,23 +15274,23 @@ 0x80BB03E8:("EnZod_Draw",), 0x80BB08E0:("EnKujiya_Init",), 0x80BB0998:("EnKujiya_Destroy",), - 0x80BB09A8:("func_80BB09A8",), - 0x80BB09BC:("func_80BB09BC",), - 0x80BB0B28:("func_80BB0B28",), - 0x80BB0BF8:("func_80BB0BF8",), - 0x80BB0E44:("func_80BB0E44",), - 0x80BB0E58:("func_80BB0E58",), - 0x80BB0F24:("func_80BB0F24",), - 0x80BB0F38:("func_80BB0F38",), - 0x80BB0F94:("func_80BB0F94",), - 0x80BB0FA8:("func_80BB0FA8",), - 0x80BB0FF8:("func_80BB0FF8",), - 0x80BB1088:("func_80BB1088",), - 0x80BB10F8:("func_80BB10F8",), - 0x80BB1168:("func_80BB1168",), - 0x80BB1180:("func_80BB1180",), - 0x80BB1250:("func_80BB1250",), - 0x80BB1268:("func_80BB1268",), + 0x80BB09A8:("EnKujiya_SetupWait",), + 0x80BB09BC:("EnKujiya_Wait",), + 0x80BB0B28:("EnKujiya_HandlePlayerChoice",), + 0x80BB0BF8:("EnKujiya_ChooseNextDialogue",), + 0x80BB0E44:("EnKujiya_SetupTalk",), + 0x80BB0E58:("EnKujiya_Talk",), + 0x80BB0F24:("EnKujiya_SetupGivePrize",), + 0x80BB0F38:("EnKujiya_GivePrize",), + 0x80BB0F94:("EnKujiya_SetupFinishGivePrize",), + 0x80BB0FA8:("EnKujiya_FinishGivePrize",), + 0x80BB0FF8:("EnKujiya_CheckBoughtTicket",), + 0x80BB1088:("EnKujiya_SetBoughtTicket",), + 0x80BB10F8:("EnKujiya_UnsetBoughtTicket",), + 0x80BB1168:("EnKujiya_SetupTurnToOpen",), + 0x80BB1180:("EnKujiya_TurnToOpen",), + 0x80BB1250:("EnKujiya_SetupTurnToClosed",), + 0x80BB1268:("EnKujiya_TurnToClosed",), 0x80BB1338:("EnKujiya_Update",), 0x80BB135C:("EnKujiya_Draw",), 0x80BB16D0:("func_80BB16D0",), @@ -15375,15 +15375,15 @@ 0x80BB98E0:("ObjChan_Init",), 0x80BB99F0:("ObjChan_Destroy",), 0x80BB9A1C:("func_80BB9A1C",), - 0x80BB9B40:("func_80BB9B40",), - 0x80BB9C08:("func_80BB9C08",), - 0x80BB9F24:("func_80BB9F24",), - 0x80BBA2FC:("func_80BBA2FC",), - 0x80BBA314:("func_80BBA314",), - 0x80BBA488:("func_80BBA488",), + 0x80BB9B40:("ObjChan_CalculatePotPosition",), + 0x80BB9C08:("ObjChan_InitChandelier",), + 0x80BB9F24:("ObjChan_ChandelierAction",), + 0x80BBA2FC:("ObjChan_InitPot",), + 0x80BBA314:("ObjChan_PotAction",), + 0x80BBA488:("ObjChan_CreateSmashParticles",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), - 0x80BBA894:("func_80BBA894",), + 0x80BBA894:("ObjChan_DrawPot",), 0x80BBA930:("func_80BBA930",), 0x80BBACA0:("EnZos_Init",), 0x80BBAE60:("EnZos_Destroy",), @@ -15503,9 +15503,9 @@ 0x80BC2388:("EnJa_Init",), 0x80BC2498:("EnJa_Destroy",), 0x80BC24C4:("EnJa_Update",), - 0x80BC25E0:("func_80BC25E0",), - 0x80BC2620:("func_80BC2620",), - 0x80BC2B30:("func_80BC2B30",), + 0x80BC25E0:("EnJa_OverrideLimbDraw",), + 0x80BC2620:("EnJa_PostLimbDraw",), + 0x80BC2B30:("EnJa_TransformLimbDraw",), 0x80BC2CE4:("EnJa_Draw",), 0x80BC2EA4:("func_80BC2EA4",), 0x80BC3154:("func_80BC3154",), @@ -15531,14 +15531,14 @@ 0x80BC457C:("func_80BC457C",), 0x80BC458C:("BgF40Block_Update",), 0x80BC45CC:("BgF40Block_Draw",), - 0x80BC47B0:("func_80BC47B0",), + 0x80BC47B0:("BgF40Switch_CheckAll",), 0x80BC4A3C:("BgF40Switch_Init",), 0x80BC4AEC:("BgF40Switch_Destroy",), - 0x80BC4B20:("func_80BC4B20",), - 0x80BC4B94:("func_80BC4B94",), - 0x80BC4BB8:("func_80BC4BB8",), - 0x80BC4C68:("func_80BC4C68",), - 0x80BC4D30:("func_80BC4D30",), + 0x80BC4B20:("BgF40Switch_Unpress",), + 0x80BC4B94:("BgF40Switch_IdlePressed",), + 0x80BC4BB8:("BgF40Switch_Press",), + 0x80BC4C68:("BgF40Switch_WaitToPress",), + 0x80BC4D30:("BgF40Switch_IdleUnpressed",), 0x80BC4D54:("BgF40Switch_Update",), 0x80BC4D90:("BgF40Switch_Draw",), 0x80BC4F30:("EnPoComposer_Init",), @@ -15730,8 +15730,8 @@ 0x80BD1F1C:("func_80BD1F1C",), 0x80BD1FC8:("func_80BD1FC8",), 0x80BD20B4:("EnZov_Update",), - 0x80BD2380:("func_80BD2380",), - 0x80BD2404:("func_80BD2404",), + 0x80BD2380:("EnZov_OverrideLimbDraw",), + 0x80BD2404:("EnZov_PostLimbDraw",), 0x80BD24B4:("EnZov_Draw",), 0x80BD2A30:("func_80BD2A30",), 0x80BD2AE0:("func_80BD2AE0",), @@ -16029,9 +16029,9 @@ 0x80BDF75C:("EnAl_Init",), 0x80BDF840:("EnAl_Destroy",), 0x80BDF86C:("EnAl_Update",), - 0x80BDF914:("func_80BDF914",), - 0x80BDF950:("func_80BDF950",), - 0x80BDFA34:("func_80BDFA34",), + 0x80BDF914:("EnAl_OverrideLimbDraw",), + 0x80BDF950:("EnAl_PostLimbDraw",), + 0x80BDFA34:("EnAl_TransformLimbDraw",), 0x80BDFB30:("EnAl_Draw",), 0x80BE04E0:("func_80BE04E0",), 0x80BE0590:("func_80BE0590",), @@ -16057,9 +16057,9 @@ 0x80BE1424:("EnTab_Init",), 0x80BE1524:("EnTab_Destroy",), 0x80BE1550:("EnTab_Update",), - 0x80BE1648:("func_80BE1648",), - 0x80BE16B4:("func_80BE16B4",), - 0x80BE1704:("func_80BE1704",), + 0x80BE1648:("EnTab_OverrideLimbDraw",), + 0x80BE16B4:("EnTab_PostLimbDraw",), + 0x80BE1704:("EnTab_TransformDraw",), 0x80BE1810:("EnTab_Draw",), 0x80BE1C80:("func_80BE1C80",), 0x80BE1CEC:("EnNimotsu_Init",), @@ -16094,10 +16094,10 @@ 0x80BE393C:("EnRuppecrow_Draw",), 0x80BE3B80:("EnTanron4_Init",), 0x80BE3DB0:("EnTanron4_Destroy",), - 0x80BE3DC0:("func_80BE3DC0",), - 0x80BE3DFC:("func_80BE3DFC",), - 0x80BE4268:("func_80BE4268",), - 0x80BE42A4:("func_80BE42A4",), + 0x80BE3DC0:("EnTanron4_SetupFlyNearHome",), + 0x80BE3DFC:("EnTanron4_FlyNearHome",), + 0x80BE4268:("EnTanron4_SetupFlyNearActor",), + 0x80BE42A4:("EnTanron4_FlyNearActor",), 0x80BE4734:("EnTanron4_Update",), 0x80BE4804:("EnTanron4_Draw",), 0x80BE4930:("func_80BE4930",), @@ -16161,23 +16161,23 @@ 0x80BE8D94:("EnBaisen_Draw",), 0x80BE8F20:("EnHeishi_Init",), 0x80BE9090:("EnHeishi_Destroy",), - 0x80BE90BC:("func_80BE90BC",), - 0x80BE9148:("func_80BE9148",), - 0x80BE91DC:("func_80BE91DC",), - 0x80BE9214:("func_80BE9214",), + 0x80BE90BC:("EnHeishi_ChangeAnimation",), + 0x80BE9148:("EnHeishi_SetHeadRotation",), + 0x80BE91DC:("EnHeishi_SetupIdle",), + 0x80BE9214:("EnHeishi_Idle",), 0x80BE9224:("EnHeishi_Update",), - 0x80BE9380:("func_80BE9380",), + 0x80BE9380:("EnHeishi_OverrideLimbDraw",), 0x80BE93D8:("EnHeishi_Draw",), 0x80BE9510:("EnDemoheishi_Init",), 0x80BE95C0:("EnDemoheishi_Destroy",), - 0x80BE95EC:("func_80BE95EC",), - 0x80BE9678:("func_80BE9678",), - 0x80BE970C:("func_80BE970C",), - 0x80BE975C:("func_80BE975C",), - 0x80BE97F0:("func_80BE97F0",), - 0x80BE980C:("func_80BE980C",), + 0x80BE95EC:("EnDemoheishi_ChangeAnimation",), + 0x80BE9678:("EnDemoheishi_SetHeadRotation",), + 0x80BE970C:("EnDemoheishi_SetupIdle",), + 0x80BE975C:("EnDemoheishi_Idle",), + 0x80BE97F0:("EnDemoheishi_SetupTalk",), + 0x80BE980C:("EnDemoheishi_Talk",), 0x80BE9864:("EnDemoheishi_Update",), - 0x80BE9974:("func_80BE9974",), + 0x80BE9974:("EnDemoheishi_OverrideLimbDraw",), 0x80BE99CC:("EnDemoheishi_Draw",), 0x80BE9B20:("EnDt_Init",), 0x80BE9C48:("EnDt_Destroy",), @@ -16317,7 +16317,7 @@ 0x80BF2E04:("EnIg_Update",), 0x80BF2EDC:("EnIg_OverrideLimbDraw",), 0x80BF2EFC:("EnIg_PostLimbDraw",), - 0x80BF302C:("EnIg_UnkDraw",), + 0x80BF302C:("EnIg_TransformLimbDraw",), 0x80BF312C:("EnIg_Draw",), 0x80BF3920:("func_80BF3920",), 0x80BF3C64:("func_80BF3C64",), @@ -16379,24 +16379,24 @@ 0x80BFA100:("EnYb_Init",), 0x80BFA2D0:("EnYb_Destroy",), 0x80BFA2FC:("func_80BFA2FC",), - 0x80BFA350:("func_80BFA350",), - 0x80BFA444:("func_80BFA444",), - 0x80BFA5CC:("func_80BFA5CC",), - 0x80BFA634:("func_80BFA634",), - 0x80BFA67C:("func_80BFA67C",), - 0x80BFA6E0:("func_80BFA6E0",), - 0x80BFA710:("func_80BFA710",), - 0x80BFA730:("func_80BFA730",), - 0x80BFA868:("func_80BFA868",), - 0x80BFA91C:("func_80BFA91C",), - 0x80BFA9D4:("func_80BFA9D4",), - 0x80BFAB4C:("func_80BFAB4C",), - 0x80BFABF0:("func_80BFABF0",), - 0x80BFAC88:("func_80BFAC88",), - 0x80BFAE80:("func_80BFAE80",), + 0x80BFA350:("EnYb_ActorShadowFunc",), + 0x80BFA444:("EnYb_SetAnimation",), + 0x80BFA5CC:("EnYb_CanTalk",), + 0x80BFA634:("EnYb_UpdateAnimation",), + 0x80BFA67C:("EnYb_FinishTeachingCutscene",), + 0x80BFA6E0:("EnYb_ChangeCutscene",), + 0x80BFA710:("EnYb_EnableProximityMusic",), + 0x80BFA730:("EnYb_Disappear",), + 0x80BFA868:("EnYb_SetupLeaving",), + 0x80BFA91C:("EnYb_ReceiveMask",), + 0x80BFA9D4:("EnYb_Talk",), + 0x80BFAB4C:("EnYb_TeachingDanceFinish",), + 0x80BFABF0:("EnYb_TeachingDance",), + 0x80BFAC88:("EnYb_Idle",), + 0x80BFAE80:("EnYb_WaitForMidnight",), 0x80BFAEFC:("EnYb_Update",), - 0x80BFB074:("func_80BFB074",), - 0x80BFB0E0:("func_80BFB0E0",), + 0x80BFB074:("EnYb_PostLimbDrawOpa",), + 0x80BFB0E0:("EnYb_PostLimbDrawXlu",), 0x80BFB14C:("EnYb_Draw",), 0x80BFB480:("EnRz_Init",), 0x80BFB780:("func_80BFB780",), @@ -16530,11 +16530,11 @@ 0x80C04354:("func_80C04354",), 0x80C043C8:("func_80C043C8",), 0x80C0443C:("EnBombers_Update",), - 0x80C045B4:("func_80C045B4",), + 0x80C045B4:("EnBombers_OverrideLimbDraw",), 0x80C04614:("EnBombers_Draw",), 0x80C04930:("EnBombers2_Init",), 0x80C04A80:("EnBombers2_Destroy",), - 0x80C04AAC:("func_80C04AAC",), + 0x80C04AAC:("EnBombers2_ChangeAnim",), 0x80C04B40:("func_80C04B40",), 0x80C04BA0:("func_80C04BA0",), 0x80C04D00:("func_80C04D00",), @@ -16811,8 +16811,8 @@ 0x80C14D14:("func_80C14D14",), 0x80C14D58:("func_80C14D58",), 0x80C14E08:("EnJgameTsn_Update",), - 0x80C14E64:("func_80C14E64",), - 0x80C14EE4:("func_80C14EE4",), + 0x80C14E64:("EnJgamesTsn_OverrideLimbDraw",), + 0x80C14EE4:("EnJgamesTsn_PostLimbDraw",), 0x80C14F1C:("EnJgameTsn_Draw",), 0x80C152F0:("ObjJgameLight_Init",), 0x80C1542C:("ObjJgameLight_Destroy",), @@ -16974,14 +16974,14 @@ 0x80C1E108:("DmNb_Update",), 0x80C1E168:("DmNb_TransformLimbDraw",), 0x80C1E17C:("DmNb_Draw",), - 0x80C1E290:("func_80C1E290",), - 0x80C1E2D4:("func_80C1E2D4",), - 0x80C1E3DC:("func_80C1E3DC",), + 0x80C1E290:("EnDrs_CollisionUpdate",), + 0x80C1E2D4:("EnDrs_Setup",), + 0x80C1E3DC:("EnDrs_Idle",), 0x80C1E3EC:("EnDrs_Init",), 0x80C1E424:("EnDrs_Destroy",), 0x80C1E450:("EnDrs_Update",), - 0x80C1E4B0:("func_80C1E4B0",), - 0x80C1E568:("func_80C1E568",), + 0x80C1E4B0:("EnDrs_PostLimbDraw",), + 0x80C1E568:("EnDrs_Draw",), 0x80C1E690:("EnEndingHero_Init",), 0x80C1E738:("EnEndingHero_Destroy",), 0x80C1E748:("func_80C1E748",), @@ -17112,8 +17112,8 @@ 0x80C24BE0:("DmGm_Init",), 0x80C24C34:("DmGm_Destroy",), 0x80C24C44:("DmGm_Update",), - 0x80C24CD0:("func_80C24CD0",), - 0x80C24E4C:("func_80C24E4C",), + 0x80C24CD0:("DmGm_PostLimbDraw",), + 0x80C24E4C:("DmGm_TransformLimbDraw",), 0x80C25000:("func_80C25000",), 0x80C25360:("func_80C25360",), 0x80C253D0:("func_80C253D0",), diff --git a/tools/disasm/mips_isa.py b/tools/disasm/mips_isa.py index 44cddacd7..337bbd021 100644 --- a/tools/disasm/mips_isa.py +++ b/tools/disasm/mips_isa.py @@ -286,15 +286,26 @@ mips_cop0_names = [ "TagLo" , "TagHi" , "ErrorEPC" , "Reserved31", ] -mips_fpr_names = [ +numeric_fpr_names = [ "$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", "$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", "$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", - "$31", + "$31", # Floating-point control/status register ] +o32_fpr_names = [ + "$fv0", "$fv0f", "$fv1", "$fv1f", + "$ft0", "$ft0f", "$ft1", "$ft1f", "$ft2", "$ft2f", "$ft3", "$ft3f", + "$fa0", "$fa0f", "$fa1", "$fa1f", + "$ft4", "$ft4f", "$ft5", "$ft5f", + "$fs0", "$fs0f", "$fs1", "$fs1f", "$fs2", "$fs2f", "$fs3", "$fs3f", "$fs4", "$fs4f", "$fs5", + "$31", # Floating-point control/status register +] + +mips_fpr_names = numeric_fpr_names + # Instruction field fetching def sign_extend_16(value): diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1aa72e4c9..f9cc84ab4 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -35,7 +35,9 @@ 0x80096CD0:("sGfxPrintUnkTLUT","u16","[16]",0x20), 0x80096CF0:("sGfxPrintUnkData","u8","[8]",0x8), 0x80096CF8:("sGfxPrintFontData","u8","[0x800]",0x800), - 0x80097500:("D_80097500","UNK_TYPE4","",0x4), + 0x80097500:("sInitFuncs","void*","",0x4), + 0x80097504:("sNew","char","[4]",0x4), + 0x80097508:("D_80097508","[24]","",0x18), 0x80097520:("qNaN0x3FFFFF","f32","",0x4), 0x80097524:("qNaN0x10000","f32","",0x4), 0x80097528:("sNaN0x3FFFFF","f32","",0x4), @@ -443,7 +445,7 @@ 0x801AEE38:("D_801AEE38","struct_801AEE38","[14]",0x150), 0x801AEF88:("D_801AEF88","UNK_TYPE1","",0x1), 0x801AEFA0:("D_801AEFA0","UNK_TYPE1","",0x1), - 0x801AEFA8:("D_801AEFA8","UNK_TYPE1","",0x1), + 0x801AEFA8:("sElectricSparkTextures","UNK_TYPE1","",0x1), 0x801AEFB8:("D_801AEFB8","UNK_TYPE1","",0x1), 0x801AEFBC:("D_801AEFBC","UNK_TYPE1","",0x1), 0x801AEFC0:("D_801AEFC0","UNK_TYPE1","",0x1), @@ -907,7 +909,7 @@ 0x801BB124:("D_801BB124","UNK_TYPE2","",0x2), 0x801BB128:("D_801BB128","UNK_TYPE2","",0x2), 0x801BB12C:("D_801BB12C","UNK_TYPE1","",0x1), - 0x801BB130:("D_801BB130","UNK_TYPE1","",0x1), + 0x801BB130:("sCutsceneStoredPlayerForm","UNK_TYPE1","",0x1), 0x801BB134:("sCsStateHandlers1","cutscene_update_func","[5]",0x14), 0x801BB148:("sCsStateHandlers2","cutscene_update_func","[5]",0x14), 0x801BB15C:("D_801BB15C","UNK_TYPE2","",0x2), @@ -917,9 +919,9 @@ 0x801BC240:("D_801BC240","Gfx","[9]",0x48), 0x801BC288:("D_801BC288","Gfx","[3]",0x18), 0x801BC2A0:("D_801BC2A0","UNK_TYPE1","",0x1), - 0x801BC3F0:("D_801BC3F0","UNK_TYPE1","",0x1), - 0x801BC400:("D_801BC400","UNK_TYPE1","",0x1), - 0x801BC410:("D_801BC410","s32",[],0x10), + 0x801BC3F0:("gEnHyBodyParts","UNK_TYPE1","",0x1), + 0x801BC400:("gEnHyBodyPartsIndex","UNK_TYPE1","",0x1), + 0x801BC410:("gEnHyShadowSize","s32",[],0x10), 0x801BC420:("sReactionTextIds","u16","[]",0x140A), 0x801BD830:("actorCutscenesGlobalCutscenes","ActorCutscene","[8]",0x80), 0x801BD8B0:("actorCutsceneCurrent","s16","",0x2), @@ -932,7 +934,8 @@ 0x801BD8C4:("actorCutsceneReturnCamera","s16","",0x2), 0x801BD8C6:("D_801BD8C6","s16","",0x2), 0x801BD8D0:("sFireObjCollisionInit","ColliderCylinderInit","",0x2c), - 0x801BD8FC:("sFireObjLightParams","FireObjLightParams","[2]",0x10), + 0x801BD8FC:("sFireObjColors","FireObjColors","[1]",0x08), + 0x801BD904:("sFireObjLightParams","FireObjLightParams","[1]",0x08), 0x801BD910:("gGameStateOverlayTable","GameStateOverlay","[7]",0x150), 0x801BDA60:("graphNumGameStates","UNK_TYPE4","",0x4), 0x801BDA70:("D_801BDA70","UNK_TYPE2","",0x2), @@ -957,8 +960,8 @@ 0x801BDAF0:("D_801BDAF0","UNK_TYPE4","",0x4), 0x801BDAF8:("D_801BDAF8","UNK_TYPE4","",0x4), 0x801BDB00:("D_801BDB00","UNK_TYPE1","",0x1), - 0x801BDB08:("D_801BDB08","UNK_TYPE1","",0x1), - 0x801BDB18:("D_801BDB18","UNK_TYPE1","",0x1), + 0x801BDB08:("sKaleidoSetupEyeX","UNK_TYPE1","",0x1), + 0x801BDB18:("sKaleidoSetupEyeZ","UNK_TYPE1","",0x1), 0x801BDB30:("kanfontOrdering","u8","[92]",0x5c), 0x801BDB90:("D_801BDB90","f32","",0x4), 0x801BDB94:("D_801BDB94","UNK_TYPE4","",0x4), @@ -1965,33 +1968,27 @@ 0x801C5EB0:("D_801C5EB0","UNK_TYPE4","",0x4), 0x801C5EC4:("D_801C5EC4","UNK_TYPE2","",0x2), 0x801C5F44:("D_801C5F44","UNK_TYPE4","",0x4), - 0x801C5FC0:("D_801C5FC0","UNK_TYPE4","",0x4), - 0x801C5FC4:("D_801C5FC4","UNK_TYPE4","",0x4), - 0x801C5FC8:("D_801C5FC8","UNK_TYPE4","",0x4), - 0x801C5FCC:("D_801C5FCC","UNK_TYPE4","",0x4), - 0x801C5FD0:("D_801C5FD0","UNK_TYPE4","",0x4), + 0x801C5FC0:("D_801C5FC0","u32","[452]",0x710), 0x801C66D0:("D_801C66D0","UNK_TYPE2","",0x2), 0x801C6798:("D_801C6798","UNK_TYPE4","",0x4), 0x801C67B0:("D_801C67B0","UNK_TYPE1","",0x1), - 0x801C67C8:("D_801C67C8","UNK_TYPE4","",0x4), - 0x801C67CC:("D_801C67CC","UNK_TYPE4","",0x4), + 0x801C67C8:("D_801C67C8","s32","[8]",0x20), 0x801C67E8:("D_801C67E8","UNK_TYPE4","",0x4), - 0x801C67F0:("D_801C67F0","UNK_TYPE4","",0x4), - 0x801C67F4:("D_801C67F4","UNK_TYPE4","",0x4), + 0x801C67F0:("D_801C67F0","s32","[8]",0x20), 0x801C6818:("D_801C6818","UNK_TYPE1","",0x1), 0x801C6838:("D_801C6838","UNK_TYPE4","",0x4), 0x801C6840:("D_801C6840","UNK_TYPE1","",0x1), 0x801C6850:("D_801C6850","UNK_TYPE1","",0x1), 0x801C6870:("D_801C6870","UNK_TYPE1","",0x1), 0x801C6890:("D_801C6890","UNK_TYPE1","",0x1), - 0x801C6898:("D_801C6898","SaveInfo","",0x28), - 0x801C68C0:("D_801C68C0","SaveContext_struct2","",0x22), - 0x801C68E4:("gSaveDefaultInventory","Inventory","",0x88), - 0x801C696C:("gSaveDefaultChecksum","u16","",0x2), - 0x801C6970:("D_801C6970","SaveInfo","",0x28), - 0x801C6998:("D_801C6998","SaveContext_struct2","",0x22), - 0x801C69BC:("D_801C69BC","Inventory","",0x88), - 0x801C6A44:("D_801C6A44","u16","",0x2), + 0x801C6898:("sSaveDefaultPlayerData","SavePlayerData","",0x28), + 0x801C68C0:("sSaveDefaultItemEquips","ItemEquips","",0x22), + 0x801C68E4:("sSaveDefaultInventory","Inventory","",0x88), + 0x801C696C:("sSaveDefaultChecksum","u16","",0x2), + 0x801C6970:("sSaveDebugPlayerData","SaveInfo","",0x28), + 0x801C6998:("sSaveDebugItemEquips","ItemEquips","",0x22), + 0x801C69BC:("sSaveDebugInventory","Inventory","",0x88), + 0x801C6A44:("sSaveDebugChecksum","u16","",0x2), 0x801C6A48:("D_801C6A48","UNK_TYPE1","",0x1), 0x801C6A50:("D_801C6A50","UNK_TYPE1","",0x1), 0x801C6A58:("D_801C6A58","UNK_TYPE1","",0x1), @@ -2162,7 +2159,7 @@ 0x801D0D58:("D_801D0D58","UNK_TYPE2","",0x2), 0x801D0D5C:("D_801D0D5C","UNK_TYPE2","",0x2), 0x801D0D60:("D_801D0D60","Input*","",0x4), - 0x801D0D64:("D_801D0D64","UNK_TYPE2","",0x2), + 0x801D0D64:("D_801D0D64","s16","[10]",0x14), 0x801D0D7A:("D_801D0D7A","UNK_TYPE1","",0x1), 0x801D0D80:("D_801D0D80","UNK_TYPE1","",0x1), 0x801D11F4:("D_801D11F4","UNK_TYPE1","",0x1), @@ -2268,7 +2265,7 @@ 0x801D5FD4:("D_801D5FD4","UNK_TYPE1","",0x1), 0x801D5FE0:("D_801D5FE0","UNK_PTR","",0x4), 0x801D5FE4:("D_801D5FE4","UNK_TYPE1","",0x1), - 0x801D5FE8:("D_801D5FE8","UNK_TYPE4","",0x4), + 0x801D5FE8:("gAudioContextInitalized","UNK_TYPE4","",0x4), 0x801D5FEC:("D_801D5FEC","UNK_TYPE4","",0x4), 0x801D5FF0:("D_801D5FF0","UNK_TYPE4","",0x4), 0x801D5FF4:("D_801D5FF4","UNK_TYPE4","",0x4), @@ -2287,122 +2284,116 @@ 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), 0x801D6600:("D_801D6600","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), - 0x801D6610:("D_801D6610","UNK_TYPE1","",0x1), - 0x801D662C:("D_801D662C","UNK_TYPE1","",0x1), - 0x801D6648:("D_801D6648","UNK_TYPE1","",0x1), - 0x801D664C:("D_801D664C","UNK_TYPE1","",0x1), - 0x801D6650:("D_801D6650","UNK_TYPE1","",0x1), - 0x801D6654:("D_801D6654","UNK_TYPE4","",0x4), - 0x801D6658:("D_801D6658","UNK_TYPE1","",0x1), - 0x801D665C:("D_801D665C","UNK_TYPE1","",0x1), - 0x801D6660:("D_801D6660","UNK_TYPE1","",0x1), - 0x801D666C:("D_801D666C","UNK_TYPE1","",0x1), - 0x801D6680:("D_801D6680","UNK_TYPE1","",0x1), - 0x801D6684:("D_801D6684","UNK_TYPE1","",0x1), - 0x801D6694:("D_801D6694","UNK_TYPE4","",0x4), - 0x801D6698:("D_801D6698","UNK_TYPE1","",0x1), - 0x801D669E:("D_801D669E","UNK_TYPE1","",0x1), - 0x801D669F:("D_801D669F","UNK_TYPE1","",0x1), - 0x801D66A0:("D_801D66A0","UNK_TYPE1","",0x1), - 0x801D66A4:("D_801D66A4","UNK_TYPE2","",0x2), - 0x801D66A8:("D_801D66A8","UNK_TYPE1","",0x1), - 0x801D66AC:("D_801D66AC","UNK_TYPE1","",0x1), - 0x801D66B0:("D_801D66B0","UNK_TYPE1","",0x1), - 0x801D66B4:("D_801D66B4","UNK_TYPE1","",0x1), - 0x801D66B8:("D_801D66B8","UNK_TYPE1","",0x1), - 0x801D66BC:("D_801D66BC","UNK_TYPE1","",0x1), - 0x801D66C0:("D_801D66C0","UNK_TYPE1","",0x1), - 0x801D66C4:("D_801D66C4","f32","",0x4), - 0x801D66C8:("D_801D66C8","UNK_TYPE1","",0x1), - 0x801D66CC:("D_801D66CC","UNK_TYPE2","",0x2), - 0x801D66D0:("D_801D66D0","UNK_TYPE1","",0x1), - 0x801D66D4:("D_801D66D4","UNK_TYPE1","",0x1), - 0x801D66D8:("D_801D66D8","UNK_TYPE4","",0x4), - 0x801D66DC:("D_801D66DC","UNK_TYPE4","",0x4), - 0x801D66E0:("D_801D66E0","UNK_TYPE1","",0x1), - 0x801D66E4:("D_801D66E4","UNK_TYPE1","",0x1), - 0x801D66E8:("D_801D66E8","UNK_TYPE1","",0x1), - 0x801D66EC:("D_801D66EC","UNK_TYPE1","",0x1), - 0x801D66F0:("D_801D66F0","UNK_TYPE1","",0x1), - 0x801D66F4:("D_801D66F4","UNK_TYPE4","",0x4), - 0x801D66F8:("D_801D66F8","UNK_TYPE4","",0x4), - 0x801D66FC:("D_801D66FC","UNK_TYPE1","",0x1), - 0x801D6700:("D_801D6700","UNK_TYPE1","",0x1), - 0x801D6780:("D_801D6780","UNK_TYPE1","",0x1), - 0x801D6794:("D_801D6794","UNK_TYPE1","",0x1), - 0x801D6FB4:("D_801D6FB4","UNK_TYPE1","",0x1), - 0x801D6FB8:("D_801D6FB8","UNK_TYPE1","",0x1), - 0x801D6FBC:("D_801D6FBC","UNK_TYPE1","",0x1), - 0x801D6FC0:("D_801D6FC0","UNK_TYPE1","",0x1), - 0x801D6FC4:("D_801D6FC4","UNK_TYPE1","",0x1), - 0x801D6FC8:("D_801D6FC8","UNK_TYPE1","",0x1), - 0x801D6FCC:("D_801D6FCC","f32","",0x4), - 0x801D6FD0:("D_801D6FD0","UNK_TYPE1","",0x1), - 0x801D6FD4:("D_801D6FD4","UNK_TYPE1","",0x1), - 0x801D6FD8:("D_801D6FD8","UNK_TYPE1","",0x1), - 0x801D6FDC:("D_801D6FDC","UNK_TYPE1","",0x1), - 0x801D6FE0:("D_801D6FE0","UNK_TYPE1","",0x1), + 0x801D6610:("gChannelsPerBank","UNK_TYPE1","",0x1), + 0x801D662C:("gUsedChannelsPerBank","UNK_TYPE1","",0x1), + 0x801D6648:("sGiantsMaskFreq","UNK_TYPE1","",0x1), + 0x801D664C:("sGiantsMaskReverbAdd","UNK_TYPE1","",0x1), + 0x801D6650:("sWaterWheelVolume","UNK_TYPE1","",0x1), + 0x801D6654:("gSfxVolume","UNK_TYPE4","",0x4), + 0x801D6658:("sSfxTimer","UNK_TYPE1","",0x1), + 0x801D665C:("sSfxTimerLerpRange2","UNK_TYPE1","",0x1), + 0x801D6660:("sSfxTimerLerpRange1","s8","",0x1), + 0x801D6664:("D_801D6664","f32","[2]",0x8), + 0x801D666C:("sAudioIncreasingTranspose","UNK_TYPE1","",0x1), + 0x801D6680:("sPrevChargeLevel","UNK_TYPE1","",0x1), + 0x801D6684:("sChargeLevelsSfxFreq","UNK_TYPE1","",0x1), + 0x801D6694:("sCurChargeLevelSfxFreq","UNK_TYPE4","",0x4), + 0x801D6698:("sGanonsTowerLevelsVol","u8","[8]",0x8), + 0x801D66A0:("sEnterGanonsTowerTimer","UNK_TYPE1","",0x1), + 0x801D66A4:("sSfxVolumeDuration","UNK_TYPE2","",0x2), + 0x801D66A8:("sAudioFileSelectSetting","UNK_TYPE1","",0x1), + 0x801D66AC:("sAudioIsWindowOpen","UNK_TYPE1","",0x1), + 0x801D66B0:("sAudioCutsceneFlag","UNK_TYPE1","",0x1), + 0x801D66B4:("sSpecReverb","UNK_TYPE1","",0x1), + 0x801D66B8:("sAudioEnvReverb","UNK_TYPE1","",0x1), + 0x801D66BC:("sAudioCodeReverb","UNK_TYPE1","",0x1), + 0x801D66C0:("sPrevSeqMode","UNK_TYPE1","",0x1), + 0x801D66C4:("sAudioEnemyDist","f32","",0x4), + 0x801D66C8:("sAudioEnemyVol","UNK_TYPE1","",0x1), + 0x801D66CC:("sPrevMainBgmSeqId","UNK_TYPE2","",0x2), + 0x801D66D0:("sBgmPlayerIOPort7","UNK_TYPE1","",0x1), + 0x801D66D4:("sSceneSeqId2","UNK_TYPE1","",0x1), + 0x801D66D8:("sNumFramesStill","UNK_TYPE4","",0x4), + 0x801D66DC:("sNumFramesMoving","UNK_TYPE4","",0x4), + 0x801D66E0:("sAudioBaseFilter","UNK_TYPE1","",0x1), + 0x801D66E4:("sAudioExtraFilter","UNK_TYPE1","",0x1), + 0x801D66E8:("sAudioBaseFilter2","UNK_TYPE1","",0x1), + 0x801D66EC:("sAudioExtraFilter2","UNK_TYPE1","",0x1), + 0x801D66F0:("gUnderwaterSfxReverbAdd","UNK_TYPE1","",0x1), + 0x801D66F4:("sRiverSoundBgmPos","UNK_TYPE4","",0x4), + 0x801D66F8:("sRiverSoundXZDistToPlayer","UNK_TYPE4","",0x4), + 0x801D66FC:("sObjSoundMainBgmSeqId","UNK_TYPE1","",0x1), + 0x801D6700:("sSeqFlags","UNK_TYPE1","",0x1), + 0x801D6780:("sSpecReverbs","UNK_TYPE1","",0x1), + 0x801D6794:("sNatureAmbienceData","UNK_TYPE1","",0x1), + 0x801D6FB4:("sIsOcarinaInputEnabled","UNK_TYPE1","",0x1), + 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), + 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D6FC0:("sPrevOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D6FC4:("sCurOcarinaButtonIndex","UNK_TYPE1","",0x1), + 0x801D6FC8:("sMusicStaffPrevPitch","UNK_TYPE1","",0x1), + 0x801D6FCC:("sCurOcarinaBendFreq","f32","",0x4), + 0x801D6FD0:("sDefaultOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D6FD4:("sCurOcarinaBendIndex","UNK_TYPE1","",0x1), + 0x801D6FD8:("sCurOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D6FDC:("sCurOcarinaVibrato","UNK_TYPE1","",0x1), + 0x801D6FE0:("sPlaybackState","UNK_TYPE1","",0x1), 0x801D6FE4:("D_801D6FE4","UNK_TYPE1","",0x1), 0x801D6FE8:("D_801D6FE8","UNK_TYPE1","",0x1), - 0x801D6FEC:("D_801D6FEC","UNK_TYPE4","",0x4), - 0x801D6FF0:("D_801D6FF0","UNK_TYPE4","",0x4), - 0x801D6FF4:("D_801D6FF4","UNK_TYPE2","",0x2), - 0x801D6FF8:("D_801D6FF8","UNK_TYPE2","",0x2), - 0x801D6FFC:("D_801D6FFC","UNK_TYPE4","",0x4), - 0x801D7000:("D_801D7000","UNK_TYPE1","",0x1), - 0x801D7004:("D_801D7004","UNK_TYPE1","",0x1), - 0x801D7008:("D_801D7008","UNK_TYPE1","",0x1), - 0x801D700C:("D_801D700C","UNK_TYPE1","",0x1), - 0x801D7010:("D_801D7010","f32","",0x4), - 0x801D7014:("D_801D7014","f32","",0x4), - 0x801D7018:("D_801D7018","UNK_TYPE4","",0x4), - 0x801D701C:("D_801D701C","UNK_TYPE4","",0x4), - 0x801D701E:("D_801D701E","UNK_TYPE1","",0x1), - 0x801D701F:("D_801D701F","UNK_TYPE1","",0x1), - 0x801D7020:("D_801D7020","UNK_TYPE1","",0x1), - 0x801D7028:("D_801D7028","UNK_TYPE1","",0x1), - 0x801D702C:("D_801D702C","UNK_TYPE1","",0x1), - 0x801D7030:("D_801D7030","UNK_TYPE1","",0x1), - 0x801D7038:("D_801D7038","UNK_TYPE1","",0x1), - 0x801D703C:("D_801D703C","UNK_TYPE1","",0x1), - 0x801D7040:("D_801D7040","UNK_TYPE1","",0x1), - 0x801D7044:("D_801D7044","UNK_TYPE1","",0x1), - 0x801D7E04:("D_801D7E04","UNK_TYPE4","",0x4), - 0x801D7EA4:("D_801D7EA4","UNK_TYPE1","",0x1), - 0x801D7F44:("D_801D7F44","UNK_TYPE1","",0x1), - 0x801D84E4:("D_801D84E4","UNK_TYPE1","",0x1), - 0x801D84F0:("D_801D84F0","UNK_PTR","",0x4), - 0x801D84F4:("D_801D84F4","UNK_TYPE1","",0x1), - 0x801D8508:("D_801D8508","UNK_TYPE1","",0x1), - 0x801D850C:("D_801D850C","UNK_TYPE1","",0x1), - 0x801D8510:("D_801D8510","UNK_TYPE4","",0x4), - 0x801D8514:("D_801D8514","UNK_TYPE1","",0x1), - 0x801D8518:("D_801D8518","UNK_TYPE1","",0x1), - 0x801D851C:("D_801D851C","UNK_TYPE1","",0x1), - 0x801D8520:("D_801D8520","UNK_TYPE1","",0x1), - 0x801D8524:("D_801D8524","UNK_TYPE1","",0x1), - 0x801D8528:("D_801D8528","UNK_TYPE1","",0x1), - 0x801D852C:("D_801D852C","UNK_TYPE1","",0x1), + 0x801D6FEC:("sOcarinaFlags","UNK_TYPE4","",0x4), + 0x801D6FF0:("sPlaybackNoteTimer","UNK_TYPE4","",0x4), + 0x801D6FF4:("sPlaybackNotePos","UNK_TYPE2","",0x2), + 0x801D6FF8:("sPlaybackStaffPos","UNK_TYPE2","",0x2), + 0x801D6FFC:("sPrevOcarinaSongFlags","UNK_TYPE4","",0x4), + 0x801D7000:("sPlaybackNoteValue","UNK_TYPE1","",0x1), + 0x801D7004:("sNotePlaybackVolume","UNK_TYPE1","",0x1), + 0x801D7008:("sNotePlaybackVibrato","UNK_TYPE1","",0x1), + 0x801D700C:("sNotePlaybackBend","UNK_TYPE1","",0x1), + 0x801D7010:("sNormalizedNotePlaybackTone","f32","",0x4), + 0x801D7014:("sNormalizedNotePlaybackVolume","f32","",0x4), + 0x801D7018:("sOcarinaPlaybackTaskStart","UNK_TYPE4","",0x4), + 0x801D701C:("sOcarinaWallCounter","UNK_TYPE4","",0x4), + 0x801D7020:("sCurOcarinaSong","u8","[8]",0x8), + 0x801D7028:("sOcarinaSongAppendPos","UNK_TYPE1","",0x1), + 0x801D702C:("sOcarinaSongStartingPos","UNK_TYPE1","",0x1), + 0x801D7030:("sButtonToPitchMap","UNK_TYPE1","",0x1), + 0x801D7038:("sOcarinaMemoryGameAppendPos","UNK_TYPE1","",0x1), + 0x801D703C:("sOcaMemoryGameEndPos","UNK_TYPE1","",0x1), + 0x801D7040:("sOcaMemoryGameNumNotes","UNK_TYPE1","",0x1), + 0x801D7044:("sOcarinaSongNotes","OcarinaNote","[24][20]",0xF00), + 0x801D7F44:("sOoTOcarinaSongNotes","OcarinaNote","[9][20]",0x5A0), + 0x801D84E4:("sOoTOcarinaSongsNumNotes","UNK_TYPE1","",0x1), + 0x801D84F0:("sPlaybackSong","UNK_PTR","",0x4), + 0x801D84F4:("sFrogsSongNotes","u8","[14]",0xE), + 0x801D8504:("gFrogsSongPtr","u8*","",0x4), + 0x801D8508:("sRecordingState","UNK_TYPE1","",0x1), + 0x801D850C:("sRecordSongPos","UNK_TYPE1","",0x1), + 0x801D8510:("sOcarinaRecordTaskStart","UNK_TYPE4","",0x4), + 0x801D8514:("sRecordOcarinaPitch","UNK_TYPE1","",0x1), + 0x801D8518:("sRecordOcarinaVolume","UNK_TYPE1","",0x1), + 0x801D851C:("sRecordOcarinaVibrato","UNK_TYPE1","",0x1), + 0x801D8520:("sRecordOcarinaBendIndex","UNK_TYPE1","",0x1), + 0x801D8524:("sRecordOcarinaButtonIndex","UNK_TYPE1","",0x1), + 0x801D8528:("sPlayedOcarinaSongIndexPlusOne","UNK_TYPE1","",0x1), + 0x801D852C:("sMusicStaffNumNotesPerTest","UNK_TYPE1","",0x1), 0x801D8530:("D_801D8530","UNK_TYPE1","",0x1), 0x801D8534:("D_801D8534","UNK_TYPE4","",0x4), - 0x801D8538:("D_801D8538","UNK_TYPE1","",0x1), - 0x801D853C:("D_801D853C","UNK_TYPE1","",0x1), - 0x801D853E:("D_801D853E","UNK_TYPE2","",0x2), - 0x801D8544:("D_801D8544","UNK_TYPE1","",0x1), - 0x801D889C:("D_801D889C","UNK_PTR","",0x4), - 0x801D88A0:("D_801D88A0","UNK_PTR","",0x4), - 0x801D88A4:("D_801D88A4","UNK_PTR","",0x4), - 0x801D88A8:("D_801D88A8","UNK_TYPE1","",0x1), - 0x801D88B8:("D_801D88B8","UNK_TYPE1","",0x1), - 0x801D8A48:("D_801D8A48","UNK_TYPE1","",0x1), - 0x801D8B20:("D_801D8B20","UNK_TYPE1","",0x1), - 0x801D8B24:("D_801D8B24","UNK_PTR","",0x4), - 0x801D8B28:("D_801D8B28","UNK_TYPE2","",0x2), - 0x801D8B2C:("D_801D8B2C","UNK_TYPE1","",0x1), + 0x801D8538:("sIsOcarinaNoteChanged","UNK_TYPE1","",0x1), + 0x801D853C:("sScarecrowsLongSongNotes","OcarinaNote","[108]",0x360), + 0x801D889C:("gScarecrowLongSongPtr","UNK_PTR","",0x4), + 0x801D88A0:("gScarecrowSpawnSongPtr","UNK_PTR","",0x4), + 0x801D88A4:("sTerminaWallSongPtr","UNK_PTR","",0x4), + 0x801D88A8:("sPitchToButtonMap","UNK_TYPE1","",0x1), + 0x801D88B8:("sCustomSequenceScript","UNK_TYPE1","",0x1), + 0x801D8A48:("gOcarinaSongButtons","UNK_TYPE1","",0x1), + 0x801D8B20:("sScarecrowAfterCreditsState","UNK_TYPE1","",0x1), + 0x801D8B24:("sScarecrowAfterCreditsIntrumentId","UNK_PTR","",0x4), + 0x801D8B28:("sScarecrowAfterCreditsTimer","UNK_TYPE2","",0x2), + 0x801D8B2C:("sRequestCustomSequence","UNK_TYPE1","",0x1), 0x801D8B30:("D_801D8B30","UNK_TYPE1","",0x1), - 0x801D8BB0:("D_801D8BB0","UNK_TYPE1","",0x1), - 0x801D8BD0:("D_801D8BD0","UNK_TYPE2","",0x2), - 0x801D8BD4:("D_801D8BD4","UNK_TYPE4","",0x4), + 0x801D8BB0:("sBigBellsVolume","UNK_TYPE1","",0x1), + 0x801D8BD0:("sBgmPlayers","UNK_TYPE2","",0x2), + 0x801D8BD4:("sSfxOriginalPos","UNK_TYPE4","",0x4), 0x801D8BE0:("D_801D8BE0","UNK_TYPE1","",0x1), 0x801D8E3C:("D_801D8E3C","UNK_TYPE1","",0x1), 0x801D8E40:("D_801D8E40","UNK_TYPE4","",0x4), @@ -2449,7 +2440,7 @@ 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), 0x801DB930:("D_801DB930","UNK_PTR","",0x4), - 0x801DB958:("D_801DB958","AudioSpec","[21]",0x498), + 0x801DB958:("gAudioSpecs","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), 0x801DBE68:("D_801DBE68","f32","",0x4), @@ -3774,16 +3765,16 @@ 0x801E07C4:("jtbl_801E07C4","UNK_PTR","",0x4), 0x801E0948:("jtbl_801E0948","UNK_PTR","",0x4), 0x801E0A08:("jtbl_801E0A08","UNK_PTR","",0x4), - 0x801E0BD0:("D_801E0BD0","UNK_TYPE1","",0x1), - 0x801E0BFC:("D_801E0BFC","UNK_TYPE1","",0x1), - 0x801E0C14:("D_801E0C14","char","[]",0x1), - 0x801E0C38:("D_801E0C38","char","[]",0x1), - 0x801E0C64:("D_801E0C64","char","[]",0x1), - 0x801E0C6C:("D_801E0C6C","char","[]",0x1), - 0x801E0C74:("D_801E0C74","char","[]",0x1), - 0x801E0C7C:("D_801E0C7C","char","[]",0x1), - 0x801E0CA4:("D_801E0CA4","char","[]",0x1), - 0x801E0CD0:("D_801E0CD0","char","[]",0x1), + 0x801E0BD0:("gAudioEnvironmentalSfx","UNK_TYPE1","",0x1), + 0x801E0BFC:("sIsOcarinaSongReserved","UNK_TYPE1","",0x1), + 0x801E0C14:("sAudioOcarinaUnusedText0","char","[]",0x1), + 0x801E0C38:("sAudioOcarinaUnusedText1","char","[]",0x1), + 0x801E0C64:("sAudioOcarinaUnusedText2","char","[]",0x1), + 0x801E0C6C:("sAudioOcarinaUnusedText3","char","[]",0x1), + 0x801E0C74:("sAudioOcarinaUnusedText4","char","[]",0x1), + 0x801E0C7C:("sAudioOcarinaUnusedText5","char","[]",0x1), + 0x801E0CA4:("sAudioOcarinaUnusedText6","char","[]",0x1), + 0x801E0CD0:("sAudioOcarinaUnusedText7","char","[]",0x1), 0x801E0CEC:("D_801E0CEC","f32","",0x4), 0x801E0CF0:("D_801E0CF0","f32","",0x4), 0x801E0CF4:("D_801E0CF4","f32","",0x4), @@ -3967,12 +3958,10 @@ 0x801F3F80:("D_801F3F80","UNK_TYPE1","",0x1), 0x801F3F83:("D_801F3F83","UNK_TYPE1","",0x1), 0x801F48C8:("D_801F48C8","UNK_TYPE1","",0x1), - 0x801F4D40:("D_801F4D40","UNK_TYPE1","",0x1), - 0x801F4D42:("D_801F4D42","UNK_TYPE2","",0x2), - 0x801F4D48:("D_801F4D48","UNK_TYPE1","",0x1), - 0x801F4DC8:("D_801F4DC8","UNK_TYPE1","",0x1), - 0x801F4DCA:("D_801F4DCA","UNK_TYPE1","",0x1), - 0x801F4DCC:("D_801F4DCC","UNK_TYPE2","[8]",0x10), + 0x801F4D40:("seqId","u16","",0x2), + 0x801F4D42:("sCutsceneQuakeIndex","UNK_TYPE2","",0x2), + 0x801F4D48:("sCutsceneCameraInfo","UNK_TYPE","",0x80), + 0x801F4DC8:("D_801F4DC8","u16","[10]",0x14), 0x801F4DDC:("D_801F4DDC","UNK_TYPE1","",0x1), 0x801F4DE0:("D_801F4DE0","UNK_TYPE1","",0x1), 0x801F4DE2:("D_801F4DE2","UNK_TYPE2","",0x2), @@ -4062,7 +4051,8 @@ 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), 0x801F5AB0:("sAnimQueueFlags","UNK_TYPE1","",0x1), 0x801F5AB4:("sDisableAnimQueueFlags","UNK_TYPE1","",0x1), - 0x801F5AC0:("D_801F5AC0","UNK_TYPE1","",0x1), + 0x801F5AC0:("gSkinLimbMatrices","MtxF","[60]",0xF00), + 0x801F69C0:("D_801F69C0","UNK_TYPE1","",0x10), 0x801F69D0:("D_801F69D0","UNK_TYPE1","",0x1), 0x801F6A10:("D_801F6A10","UNK_TYPE1","",0x1), 0x801F6AD4:("D_801F6AD4","UNK_TYPE1","",0x1), @@ -4086,10 +4076,10 @@ 0x801F6B1E:("D_801F6B1E","UNK_TYPE1","",0x1), 0x801F6B20:("D_801F6B20","UNK_TYPE1","",0x1), 0x801F6B22:("D_801F6B22","UNK_TYPE1","",0x1), - 0x801F6B30:("D_801F6B30","UNK_TYPE1","",0x1), - 0x801F6B34:("D_801F6B34","UNK_TYPE1","",0x1), - 0x801F6B38:("D_801F6B38","UNK_TYPE1","",0x1), - 0x801F6B3C:("D_801F6B3C","UNK_TYPE1","",0x1), + 0x801F6B30:("sPlayerCallInitFunc","UNK_TYPE1","",0x1), + 0x801F6B34:("sPlayerCallDestroyFunc","UNK_TYPE1","",0x1), + 0x801F6B38:("sPlayerCallUpdateFunc","UNK_TYPE1","",0x1), + 0x801F6B3C:("sPlayerCallDrawFunc","UNK_TYPE1","",0x1), 0x801F6B40:("gShrinkWindowContext","ShrinkWindowContext","",0x4), 0x801F6B44:("gShrinkWindowContextPtr","ShrinkWindowContext*","",0x4), 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), @@ -4280,87 +4270,83 @@ 0x801FD158:("D_801FD158","UNK_TYPE1","",0x1), 0x801FD198:("D_801FD198","UNK_TYPE1","",0x1), 0x801FD1E0:("D_801FD1E0","UNK_TYPE1","",0x1), - 0x801FD1F0:("D_801FD1F0","UNK_TYPE1","",0x1), - 0x801FD250:("D_801FD250","UNK_TYPE1","",0x1), - 0x801FD254:("D_801FD254","UNK_TYPE1","",0x1), - 0x801FD258:("D_801FD258","UNK_TYPE1","",0x1), - 0x801FD25C:("D_801FD25C","UNK_TYPE1","",0x1), - 0x801FD260:("D_801FD260","UNK_TYPE1","",0x1), - 0x801FD264:("D_801FD264","UNK_TYPE1","",0x1), - 0x801FD268:("D_801FD268","UNK_TYPE1","",0x1), - 0x801FD278:("D_801FD278","UNK_TYPE1","",0x1), - 0x801FD288:("D_801FD288","UNK_TYPE1","",0x1), - 0x801FD28C:("D_801FD28C","UNK_TYPE1","",0x1), - 0x801FD28D:("D_801FD28D","UNK_TYPE1","",0x1), - 0x801FD28E:("D_801FD28E","UNK_TYPE1","",0x1), - 0x801FD28F:("D_801FD28F","UNK_TYPE1","",0x1), - 0x801FD290:("D_801FD290","UNK_TYPE1","",0x1), - 0x801FD291:("D_801FD291","UNK_TYPE1","",0x1), - 0x801FD294:("D_801FD294","UNK_TYPE1","",0x1), - 0x801FD298:("D_801FD298","UNK_TYPE1","",0x1), - 0x801FD29C:("D_801FD29C","UNK_TYPE1","",0x1), - 0x801FD2A0:("D_801FD2A0","UNK_TYPE1","",0x1), - 0x801FD2A8:("D_801FD2A8","UNK_TYPE1","",0x1), + 0x801FD1F0:("sSfxSettings","UNK_TYPE1","",0x1), + 0x801FD250:("sSfxSettingsFlags","UNK_TYPE1","",0x1), + 0x801FD254:("sTwoSemitonesLoweredFreq","UNK_TYPE1","",0x1), + 0x801FD258:("sSfxIncreasedReverb","UNK_TYPE1","",0x1), + 0x801FD25C:("sSfxSyncedVolume","UNK_TYPE1","",0x1), + 0x801FD260:("sSfxSyncedVolumeForMetalEffects","UNK_TYPE1","",0x1), + 0x801FD264:("sSfxSyncedFreq","UNK_TYPE1","",0x1), + 0x801FD268:("sRiverFreqScaleLerp","UNK_TYPE1","",0x1), + 0x801FD278:("sWaterfallFreqScaleLerp","UNK_TYPE1","",0x1), + 0x801FD288:("sSfxAdjustedFreq","UNK_TYPE1","",0x1), + 0x801FD28C:("sSfxCustomReverb","UNK_TYPE1","",0x1), + 0x801FD28D:("sRiverSoundMainBgmVol","UNK_TYPE1","",0x1), + 0x801FD28E:("sRiverSoundMainBgmCurrentVol","UNK_TYPE1","",0x1), + 0x801FD28F:("sRiverSoundMainBgmLower","UNK_TYPE1","",0x1), + 0x801FD290:("sRiverSoundMainBgmRestore","UNK_TYPE1","",0x1), + 0x801FD291:("sGanonsTowerVol","UNK_TYPE1","",0x1), + 0x801FD294:("sSfxVolumeCur","UNK_TYPE1","",0x1), + 0x801FD298:("sSfxVolumeTarget","UNK_TYPE1","",0x1), + 0x801FD29C:("sSfxVolumeRate","UNK_TYPE1","",0x1), + 0x801FD2A0:("sSceneSeqId1","UNK_TYPE1","",0x1), + 0x801FD2A8:("sSfxChannelState","UNK_TYPE1","",0x1), 0x801FD3A8:("D_801FD3A8","UNK_TYPE1","",0x1), 0x801FD3A9:("D_801FD3A9","UNK_TYPE1","",0x1), - 0x801FD3AA:("D_801FD3AA","UNK_TYPE1","",0x1), - 0x801FD3AB:("D_801FD3AB","UNK_TYPE1","",0x1), - 0x801FD3AC:("D_801FD3AC","UNK_TYPE1","",0x1), - 0x801FD3AE:("D_801FD3AE","UNK_TYPE1","",0x1), - 0x801FD3AF:("D_801FD3AF","UNK_TYPE1","",0x1), - 0x801FD3B0:("D_801FD3B0","UNK_TYPE1","",0x1), - 0x801FD3B4:("D_801FD3B4","UNK_TYPE1","",0x1), - 0x801FD3B7:("D_801FD3B7","UNK_TYPE1","",0x1), - 0x801FD3B8:("D_801FD3B8","UNK_TYPE1","",0x1), - 0x801FD3D8:("D_801FD3D8","UNK_TYPE1","",0x1), - 0x801FD3D9:("D_801FD3D9","UNK_TYPE1","",0x1), - 0x801FD3DA:("D_801FD3DA","UNK_TYPE1","",0x1), - 0x801FD3E0:("D_801FD3E0","UNK_TYPE1","",0x1), - 0x801FD3EC:("D_801FD3EC","UNK_TYPE1","",0x1), - 0x801FD3F0:("D_801FD3F0","UNK_TYPE1","",0x1), - 0x801FD3FC:("D_801FD3FC","UNK_TYPE1","",0x1), - 0x801FD400:("D_801FD400","UNK_TYPE1","",0x1), - 0x801FD404:("D_801FD404","UNK_TYPE1","",0x1), - 0x801FD408:("D_801FD408","UNK_TYPE1","",0x1), - 0x801FD40C:("D_801FD40C","UNK_TYPE1","",0x1), - 0x801FD410:("D_801FD410","UNK_TYPE1","",0x1), - 0x801FD420:("D_801FD420","UNK_TYPE1","",0x1), - 0x801FD42C:("D_801FD42C","UNK_TYPE1","",0x1), - 0x801FD430:("D_801FD430","UNK_TYPE1","",0x1), - 0x801FD431:("D_801FD431","UNK_TYPE1","",0x1), + 0x801FD3AA:("sRiverSoundBgmTimer","UNK_TYPE1","",0x1), + 0x801FD3AB:("sFanfareState","UNK_TYPE1","",0x1), + 0x801FD3AC:("sFanfareSeqId","UNK_TYPE1","",0x1), + 0x801FD3AE:("sMuteOnlySfxAndNatureSeq","UNK_TYPE1","",0x1), + 0x801FD3AF:("sAllPlayersMutedExceptOcaAndSys","UNK_TYPE1","",0x1), + 0x801FD3B0:("sAudioPauseState","UNK_TYPE1","",0x1), + 0x801FD3B4:("sSpatialSeqIsActive","u8","[4]",0x4), + 0x801FD3B8:("sSequenceFilter","UNK_TYPE1","",0x1), + 0x801FD3D8:("sIsFinalHoursOrSoaring","UNK_TYPE1","",0x1), + 0x801FD3D9:("sObjSoundFanfareSeqId","UNK_TYPE1","",0x1), + 0x801FD3DA:("sObjSoundFanfareRequested","UNK_TYPE1","",0x1), + 0x801FD3E0:("sObjSoundFanfarePos","UNK_TYPE1","",0x1), + 0x801FD3EC:("sObjSoundPlayerIndex","UNK_TYPE1","",0x1), + 0x801FD3F0:("sObjSoundPos","UNK_TYPE1","",0x1), + 0x801FD3FC:("sObjSoundFlags","UNK_TYPE1","",0x1), + 0x801FD400:("sObjSoundMinDist","UNK_TYPE1","",0x1), + 0x801FD404:("sObjSoundMaxDist","UNK_TYPE1","",0x1), + 0x801FD408:("sObjSoundMaxVol","UNK_TYPE1","",0x1), + 0x801FD40C:("sObjSoundMinVol","UNK_TYPE1","",0x1), + 0x801FD410:("sSpatialSeqNoFilterPos","UNK_TYPE1","",0x1), + 0x801FD420:("sSpatialSeqFilterPos","UNK_TYPE1","",0x1), + 0x801FD42C:("sSpatialSeqMaxDist","UNK_TYPE1","",0x1), + 0x801FD430:("sSpatialSeqSeqId","UNK_TYPE1","",0x1), + 0x801FD431:("sSpatialSeqFlags","UNK_TYPE1","",0x1), 0x801FD432:("D_801FD432","UNK_TYPE1","",0x1), - 0x801FD433:("D_801FD433","UNK_TYPE1","",0x1), + 0x801FD433:("sSpatialSubBgmFadeTimer","UNK_TYPE1","",0x1), 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), - 0x801FD435:("D_801FD435","UNK_TYPE1","",0x1), - 0x801FD436:("D_801FD436","UNK_TYPE1","",0x1), + 0x801FD435:("sSpatialSeqPlayerIndex","UNK_TYPE1","",0x1), + 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), - 0x801FD43A:("D_801FD43A","UNK_TYPE1","",0x1), - 0x801FD43B:("D_801FD43B","UNK_TYPE1","",0x1), - 0x801FD43E:("D_801FD43E","UNK_TYPE1","",0x1), - 0x801FD442:("D_801FD442","UNK_TYPE1","",0x1), - 0x801FD448:("D_801FD448","UNK_TYPE1","",0x1), - 0x801FD44C:("D_801FD44C","UNK_TYPE1","",0x1), - 0x801FD44D:("D_801FD44D","UNK_TYPE1","",0x1), - 0x801FD450:("D_801FD450","UNK_TYPE1","",0x1), - 0x801FD454:("D_801FD454","UNK_TYPE1","",0x1), - 0x801FD458:("D_801FD458","UNK_TYPE1","",0x1), - 0x801FD45C:("D_801FD45C","UNK_TYPE1","",0x1), - 0x801FD460:("D_801FD460","UNK_TYPE1","",0x1), - 0x801FD461:("D_801FD461","UNK_TYPE1","",0x1), - 0x801FD462:("D_801FD462","UNK_TYPE1","",0x1), - 0x801FD463:("D_801FD463","UNK_TYPE1","",0x1), - 0x801FD464:("D_801FD464","UNK_TYPE1","",0x1), - 0x801FD468:("D_801FD468","UNK_TYPE1","",0x1), - 0x801FD46C:("D_801FD46C","UNK_TYPE1","",0x1), - 0x801FD470:("D_801FD470","UNK_TYPE1","",0x1), - 0x801FD4A0:("D_801FD4A0","UNK_TYPE1","",0x1), - 0x801FD4D0:("D_801FD4D0","UNK_TYPE1","",0x1), - 0x801FD500:("D_801FD500","UNK_TYPE1","",0x1), + 0x801FD43A:("sPlayingStaff","OcarinaStaff","",0x3), + 0x801FD43E:("sPlaybackStaff","OcarinaStaff","",0x3), + 0x801FD442:("sRecordingStaff","OcarinaStaff","",0x3), + 0x801FD448:("sOcarinaUpdateTaskCurrent","UNK_TYPE1","",0x1), + 0x801FD44C:("sOcarinaInputStickRel","OcarinaControlStick","",0x2), + 0x801FD450:("sOcarinaInputButtonCur","UNK_TYPE1","",0x1), + 0x801FD454:("sOcarinaInputButtonStart","UNK_TYPE1","",0x1), + 0x801FD458:("sOcarinaInputButtonPrev","UNK_TYPE1","",0x1), + 0x801FD45C:("sOcaInputBtnPress","UNK_TYPE1","",0x1), + 0x801FD460:("sOcarinaResetDelay","UNK_TYPE1","",0x1), + 0x801FD461:("sOcarinaResetUnused","UNK_TYPE1","",0x1), + 0x801FD462:("sOcarinaHasStartedSong","UNK_TYPE1","",0x1), + 0x801FD463:("sFirstOcarinaSongIndex","UNK_TYPE1","",0x1), + 0x801FD464:("sLastOcarinaSongIndex","UNK_TYPE1","",0x1), + 0x801FD468:("sOcarinaAvailSongs","UNK_TYPE1","",0x1), + 0x801FD46C:("sOcarinaStaffPlayingPos","UNK_TYPE1","",0x1), + 0x801FD470:("sMusicStaffPos","UNK_TYPE1","",0x1), + 0x801FD4A0:("sMusicStaffCurHeldLength","UNK_TYPE1","",0x1), + 0x801FD4D0:("sMusicStaffExpectedLength","UNK_TYPE1","",0x1), + 0x801FD500:("sMusicStaffExpectedPitch","UNK_TYPE1","",0x1), 0x801FD518:("D_801FD518","UNK_TYPE1","",0x1), - 0x801FD530:("D_801FD530","UNK_TYPE1","",0x1), - 0x801FD533:("D_801FD533","UNK_TYPE1","",0x1), - 0x801FD590:("D_801FD590","UNK_TYPE1","",0x1), - 0x801FD598:("D_801FD598","UNK_TYPE1","",0x1), + 0x801FD530:("D_801FD530","u32","[24]",0x60), + 0x801FD590:("sRecordingSongNote","UNK_TYPE1","",0x1), + 0x801FD598:("sCustomSequencePc","UNK_TYPE1","",0x1), 0x801FD5A0:("D_801FD5A0","UNK_TYPE1","",0x1), 0x801FD5A4:("D_801FD5A4","UNK_TYPE1","",0x1), 0x801FD5B8:("D_801FD5B8","UNK_TYPE1","",0x1), @@ -5611,13 +5597,11 @@ 0x80867784:("D_80867784","UNK_TYPE1","",0x1), 0x8086778C:("D_8086778C","UNK_PTR","",0x4), 0x8086780C:("En_Door_InitVars","UNK_TYPE1","",0x1), - 0x8086782C:("D_8086782C","UNK_TYPE2","",0x2), - 0x80867886:("D_80867886","UNK_TYPE1","",0x1), - 0x8086788A:("D_8086788A","UNK_TYPE2","",0x2), - 0x80867954:("D_80867954","UNK_TYPE1","",0x1), - 0x80867964:("D_80867964","UNK_TYPE1","",0x1), - 0x8086798C:("D_8086798C","UNK_TYPE1","",0x1), - 0x80867998:("D_80867998","UNK_TYPE1","",0x1), + 0x8086782C:("sObjInfo","UNK_TYPE2","",0x126), + 0x80867954:("sInitChain","UNK_TYPE1","",0x1), + 0x80867964:("sAnimations","AnimationHeader","[10]",0x28), + 0x8086798C:("sAnimOpenFrames","u8","[10]",0x10), + 0x80867998:("sAnimCloseFrames","u8","[10]",0x10), 0x808679A4:("D_808679A4","UNK_TYPE1","",0x1), 0x80867A20:("D_80867A20","f32","",0x4), 0x80867BC0:("D_80867BC0","UNK_TYPE1","",0x1), @@ -5800,10 +5784,7 @@ 0x808763AC:("D_808763AC","UNK_TYPE1","",0x1), 0x808763B4:("D_808763B4","UNK_TYPE1","",0x1), 0x808763C0:("D_808763C0","UNK_TYPE1","",0x1), - 0x808763D4:("D_808763D4","UNK_TYPE1","",0x1), - 0x808763D6:("D_808763D6","UNK_TYPE1","",0x1), - 0x808763E6:("D_808763E6","UNK_TYPE1","",0x1), - 0x808763E7:("D_808763E7","UNK_TYPE1","",0x1), + 0x808763D4:("D_808763D4","s8","[25]",0x25), 0x808763F0:("D_808763F0","f32","",0x4), 0x808763F4:("D_808763F4","f32","",0x4), 0x808763F8:("D_808763F8","f32","",0x4), @@ -5895,19 +5876,18 @@ 0x8087B538:("D_8087B538","f32","",0x4), 0x80888EC0:("D_80888EC0","UNK_TYPE1","",0x1), 0x80888EE4:("D_80888EE4","UNK_TYPE1","",0x1), - 0x80888F08:("D_80888F08","UNK_TYPE1","",0x1), + 0x80888F08:("sAnimationHeaders","AnimationHeader*","[5]",0x14), 0x80888F1C:("D_80888F1C","UNK_TYPE1","",0x1), 0x80888F34:("D_80888F34","UNK_TYPE4","",0x4), - 0x80888F40:("D_80888F40","UNK_TYPE1","",0x1), + 0x80888F40:("sSkeletonHeaders","UNK_TYPE1","",0x1), 0x80888F54:("En_Horse_InitVars","UNK_TYPE1","",0x1), - 0x80888F74:("D_80888F74","UNK_TYPE1","",0x1), - 0x80888FA0:("D_80888FA0","UNK_TYPE1","",0x1), + 0x80888F74:("sCylinderInit1","UNK_TYPE1","",0x1), + 0x80888FA0:("sCylinderInit2","UNK_TYPE1","",0x1), 0x80888FCC:("D_80888FCC","UNK_TYPE1","",0x1), - 0x80888FF0:("D_80888FF0","UNK_TYPE1","",0x1), - 0x80888FFC:("D_80888FFC","UNK_PTR","",0x4), - 0x80889000:("D_80889000","UNK_TYPE1","",0x1), + 0x80888FF0:("sJntSphInit","UNK_TYPE1","",0x10), + 0x80889000:("sColChkInfoInit","UNK_TYPE1","",0x1), 0x80889008:("D_80889008","UNK_TYPE1","",0x1), - 0x80889010:("D_80889010","UNK_TYPE1","",0x1), + 0x80889010:("sInitChain","UNK_TYPE1","",0x1), 0x80889018:("D_80889018","UNK_TYPE1","",0x1), 0x80889030:("D_80889030","UNK_TYPE1","",0x1), 0x80889048:("D_80889048","UNK_TYPE1","",0x1), @@ -5922,7 +5902,7 @@ 0x8088911C:("D_8088911C","UNK_TYPE1","",0x1), 0x80889148:("D_80889148","UNK_TYPE4","",0x4), 0x80889154:("D_80889154","UNK_TYPE4","",0x4), - 0x80889160:("D_80889160","UNK_PTR","",0x4), + 0x80889160:("sActionFuncs","UNK_PTR","",0x4), 0x808891C8:("D_808891C8","UNK_TYPE4","",0x4), 0x808891D4:("D_808891D4","UNK_TYPE4","",0x4), 0x808891E0:("D_808891E0","UNK_TYPE4","",0x4), @@ -7987,15 +7967,14 @@ 0x8092024C:("D_8092024C","UNK_TYPE1","",0x1), 0x80920268:("D_80920268","UNK_TYPE1","",0x1), 0x80920290:("jtbl_80920290","UNK_PTR","",0x4), - 0x80920DF0:("arrowFireTexture1","u8","[2048]",0x800), - 0x809215F0:("arrowFireTexture2","u8","[2048]",0x800), - 0x80921DF0:("arrowFireVertices","F3DVertex","[43]",0x2b0), - 0x80921FF0:("D_80921FF0","UNK_TYPE1","",0x1), - 0x809220A0:("D_809220A0","Gfx","[22]",0xb0), - 0x80922150:("D_80922150","Gfx","[24]",0xc0), + 0x80920DF0:("gFireArrowTex","u8","[2048]",0x800), + 0x809215F0:("gFireArrowMaskTex","u8","[2048]",0x800), + 0x80921DF0:("gFireArrowVtx","F3DVertex","[43]",0x2b0), + 0x809220A0:("gIceArrowMaterialDL","Gfx","[22]",0xb0), + 0x80922150:("gIceArrowModelDL","Gfx","[24]",0xc0), 0x80922210:("Arrow_Fire_InitVars","ActorInit","",0x20), - 0x80922230:("D_80922230","UNK_TYPE1","",0x1), - 0x80922280:("fireArrowActorInitVars","ActorInitVar","[1]",0x4), + 0x80922230:("sQuadInit","UNK_TYPE1","",0x1), + 0x80922280:("sInitChain","ActorInitVar","[1]",0x4), 0x80922284:("D_80922284","Vec3f","",0xc), 0x80922290:("D_80922290","Vec3f","",0xc), 0x8092229C:("D_8092229C","Vec3f","",0xc), @@ -8036,7 +8015,7 @@ 0x80925F10:("D_80925F10","UNK_TYPE1","",0x1), 0x80925FC0:("D_80925FC0","UNK_TYPE1","",0x1), 0x80926080:("Arrow_Light_InitVars","UNK_TYPE1","",0x1), - 0x809260A0:("D_809260A0","UNK_TYPE1","",0x1), + 0x809260A0:("sInitChain","UNK_TYPE1","",0x1), 0x809260B0:("D_809260B0","char","[]",0x1), 0x809260B8:("D_809260B8","f32","",0x4), 0x809260BC:("D_809260BC","f32","",0x4), @@ -9000,8 +8979,8 @@ 0x80979150:("D_80979150","f32","",0x4), 0x80979560:("Effect_Ss_D_Fire_InitVars","UNK_TYPE1","",0x1), 0x80979568:("D_80979568","UNK_TYPE1","",0x1), - 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x1), - 0x80979AB8:("D_80979AB8","UNK_TYPE1","",0x1), + 0x80979AB0:("Effect_Ss_Bubble_InitVars","UNK_TYPE1","",0x8), + 0x80979AB8:("D_80979AB8","f32","[3]",0xC), 0x80979AD0:("D_80979AD0","f32","",0x4), 0x80979AD4:("D_80979AD4","f32","",0x4), 0x80979FF0:("Effect_Ss_G_Ripple_InitVars","UNK_TYPE1","",0x1), @@ -10312,17 +10291,17 @@ 0x809E8F14:("D_809E8F14","UNK_TYPE1","",0x1), 0x809E8F24:("D_809E8F24","UNK_TYPE1","",0x1), 0x809E8FD8:("D_809E8FD8","UNK_TYPE1","",0x1), - 0x809E8FE8:("D_809E8FE8","UNK_TYPE4","",0x4), - 0x809E90FC:("D_809E90FC","UNK_TYPE1","",0x1), - 0x809E9100:("D_809E9100","UNK_TYPE1","",0x1), + 0x809E8FE8:("sGyorgInitialPos","Vec3f","",0xC), + 0x809E8FF4:("D_809E8FF4","f32","",0x1), + 0x809E90FC:("sGyorgDustPrimColor","UNK_TYPE1","",0x1), + 0x809E9100:("sGyorgDustEnvColor","UNK_TYPE1","",0x1), 0x809E9104:("D_809E9104","UNK_TYPE1","",0x1), - 0x809E9128:("D_809E9128","UNK_TYPE1","",0x1), - 0x809E9136:("D_809E9136","UNK_TYPE1","",0x1), + 0x809E9128:("sGyorgSphElementIndices","s8","[30]",0x1E), 0x809E9148:("D_809E9148","UNK_TYPE1","",0x1), - 0x809E9154:("D_809E9154","UNK_TYPE1","",0x1), + 0x809E9154:("D_809E9154","Vec3f","[7]",0x54), 0x809E91A8:("D_809E91A8","UNK_TYPE1","",0x1), 0x809E91B4:("D_809E91B4","f32","",0x4), - 0x809E91C0:("D_809E91C0","UNK_TYPE4","",0x4), + 0x809E91C0:("sGyorgSeaweedDLs","UNK_TYPE4","",0x4), 0x809E91E0:("D_809E91E0","f32","",0x4), 0x809E91E4:("D_809E91E4","f32","",0x4), 0x809E91E8:("D_809E91E8","f32","",0x4), @@ -10385,13 +10364,11 @@ 0x809E9841:("D_809E9841","UNK_TYPE1","",0x1), 0x809E9842:("D_809E9842","UNK_TYPE1","",0x1), 0x809E9848:("D_809E9848","UNK_TYPE1","",0x1), - 0x809E9858:("D_809E9858","UNK_TYPE1","",0x1), - 0x809E989C:("D_809E989C","UNK_TYPE1","",0x1), - 0x809E98E0:("D_809E98E0","UNK_TYPE1","",0x1), - 0x809EC030:("D_809EC030","UNK_TYPE4","",0x4), - 0x809EC034:("D_809EC034","UNK_TYPE4","",0x4), - 0x809EC038:("D_809EC038","UNK_TYPE4","",0x4), - 0x809EC03C:("D_809EC03C","UNK_TYPE4","",0x4), + 0x809E9858:("sGyorgEffects","UNK_TYPE1","[150]",0x27D8), + 0x809EC030:("sGyorgBossInstance","UNK_TYPE4","",0x4), + 0x809EC034:("sRandSeed0","UNK_TYPE4","",0x4), + 0x809EC038:("sRandSeed1","UNK_TYPE4","",0x4), + 0x809EC03C:("sRandSeed2","UNK_TYPE4","",0x4), 0x809EE150:("D_809EE150","UNK_TYPE1","",0x1), 0x809EE170:("Boss_04_InitVars","UNK_TYPE1","",0x1), 0x809EE190:("D_809EE190","UNK_TYPE1","",0x1), @@ -13475,10 +13452,9 @@ 0x80AF34F4:("D_80AF34F4","f32","",0x4), 0x80AF34F8:("D_80AF34F8","f32","",0x4), 0x80AF38B0:("D_80AF38B0","UNK_TYPE1","",0x1), - 0x80AF38F0:("D_80AF38F0","f32","",0x4), - 0x80AF38F4:("D_80AF38F4","f32","",0x4), - 0x80AF38F8:("D_80AF38F8","f32","",0x4), - 0x80AF3900:("D_80AF3900","UNK_TYPE1","",0x1), + 0x80AF38F0:("D_80AF38F0","Vec3f","",0xC), + 0x80AF38FC:("D_80AF38FC","UNK_TYPE4","",0x4), + 0x80AF3900:("D_80AF3900","Vec3f","",0xC), 0x80AF3E80:("Obj_Lightblock_InitVars","UNK_TYPE1","",0x1), 0x80AF3EA0:("D_80AF3EA0","UNK_TYPE1","",0x1), 0x80AF3ECC:("D_80AF3ECC","UNK_TYPE1","",0x1), @@ -14052,25 +14028,18 @@ 0x80B245CC:("D_80B245CC","UNK_TYPE4","",0x4), 0x80B245D0:("D_80B245D0","f32","",0x4), 0x80B25D20:("En_Racedog_InitVars","UNK_TYPE1","",0x1), - 0x80B25D40:("D_80B25D40","UNK_TYPE2","",0x2), - 0x80B25D44:("D_80B25D44","UNK_TYPE2","",0x2), - 0x80B25D48:("D_80B25D48","UNK_TYPE2","",0x2), - 0x80B25D4C:("D_80B25D4C","UNK_TYPE2","",0x2), - 0x80B25D50:("D_80B25D50","f32","",0x4), - 0x80B25D54:("D_80B25D54","f32","",0x4), - 0x80B25D88:("D_80B25D88","UNK_TYPE1","",0x1), - 0x80B25D90:("D_80B25D90","UNK_TYPE1","",0x1), - 0x80B25D94:("D_80B25D94","UNK_TYPE1","",0x1), - 0x80B25D96:("D_80B25D96","UNK_TYPE1","",0x1), - 0x80B25E68:("D_80B25E68","UNK_TYPE4","",0x4), - 0x80B25E72:("D_80B25E72","UNK_TYPE2","",0x2), - 0x80B25E78:("D_80B25E78","UNK_TYPE1","",0x1), - 0x80B25E98:("D_80B25E98","UNK_TYPE1","",0x1), - 0x80B25EC4:("D_80B25EC4","UNK_TYPE1","",0x1), - 0x80B25ED0:("D_80B25ED0","UNK_TYPE1","",0x1), - 0x80B25EF0:("D_80B25EF0","UNK_PTR","",0x4), - 0x80B25EF4:("D_80B25EF4","UNK_TYPE1","",0x1), - 0x80B25F14:("D_80B25F14","UNK_TYPE1","",0x1), + 0x80B25D40:("D_80B25D40","s16","",0x2), + 0x80B25D44:("D_80B25D44","s16","",0x2), + 0x80B25D48:("D_80B25D48","s16","",0x2), + 0x80B25D4C:("D_80B25D4C","s16","",0x2), + 0x80B25D50:("D_80B25D50","f32","",0x38), + 0x80B25D88:("D_80B25D88","UNK_TYPE1","",0xE0), + 0x80B25E68:("D_80B25E68","UNK_TYPE1","",0x10), + 0x80B25E78:("D_80B25E78","f32","",0x20), + 0x80B25E98:("D_80B25E98","UNK_TYPE1","",0x2C), + 0x80B25EC4:("D_80B25EC4","UNK_TYPE1","",0xC), + 0x80B25ED0:("D_80B25ED0","UNK_TYPE1","",0x20), + 0x80B25EF0:("D_80B25EF0","UNK_TYPE1","",0x100), 0x80B25FF0:("D_80B25FF0","UNK_TYPE1","",0x1), 0x80B25FF4:("D_80B25FF4","UNK_TYPE4","",0x4), 0x80B26000:("D_80B26000","UNK_TYPE4","",0x4), @@ -14202,10 +14171,7 @@ 0x80B311D8:("D_80B311D8","UNK_TYPE1","",0x1), 0x80B31340:("D_80B31340","UNK_TYPE1","",0x1), 0x80B31350:("D_80B31350","UNK_TYPE1","",0x1), - 0x80B313A0:("D_80B313A0","UNK_TYPE1","",0x18), - 0x80B313B8:("D_80B313B8","UNK_TYPE1","",0x18), - 0x80B313D0:("D_80B313D0","UNK_TYPE1","",0x18), - 0x80B313E8:("D_80B313E8","UNK_TYPE1","",0x18), + 0x80B313A0:("D_80B313A0","ObjSpidertentStruct2","[4]",0x60), 0x80B31400:("D_80B31400","UNK_TYPE1","",0x1), 0x80B3140C:("D_80B3140C","UNK_TYPE1","",0x1), 0x80B31418:("D_80B31418","UNK_TYPE1","",0x1), @@ -14817,15 +14783,10 @@ 0x80B60754:("D_80B60754","UNK_TYPE1","",0x1), 0x80B60758:("D_80B60758","UNK_TYPE1","",0x1), 0x80B60764:("D_80B60764","UNK_TYPE1","",0x1), - 0x80B60770:("D_80B60770","f32","",0x4), - 0x80B60774:("D_80B60774","f32","",0x4), - 0x80B60778:("D_80B60778","f32","",0x4), - 0x80B6077C:("D_80B6077C","UNK_TYPE1","",0x1), - 0x80B60780:("D_80B60780","f32","",0x4), - 0x80B60788:("D_80B60788","UNK_TYPE1","",0x1), - 0x80B60790:("D_80B60790","f32","",0x4), - 0x80B607E8:("D_80B607E8","UNK_TYPE1","",0x1), - 0x80B607F0:("D_80B607F0","f32","",0x4), + 0x80B60770:("D_80B60770","Vec3f","",0xC), + 0x80B6077C:("D_80B6077C","Vec3f","",0xC), + 0x80B60788:("D_80B60788","Vec3f","[8]",0x60), + 0x80B607E8:("D_80B607E8","Vec3f","[8]",0x60), 0x80B60848:("D_80B60848","UNK_TYPE1","",0x1), 0x80B60858:("D_80B60858","UNK_TYPE1","",0x1), 0x80B60878:("D_80B60878","UNK_TYPE4","",0x4), @@ -15676,9 +15637,7 @@ 0x80BB821C:("D_80BB821C","f32","",0x4), 0x80BB8450:("D_80BB8450","UNK_TYPE4","",0x4), 0x80BB8454:("D_80BB8454","f32","",0x4), - 0x80BB8458:("D_80BB8458","UNK_TYPE4","",0x4), - 0x80BB845C:("D_80BB845C","UNK_TYPE4","",0x4), - 0x80BB8460:("D_80BB8460","UNK_TYPE4","",0x4), + 0x80BB8458:("D_80BB8458","EnTanron2*","[82]",0x148), 0x80BB9720:("D_80BB9720","UNK_TYPE4","",0x4), 0x80BB972C:("D_80BB972C","UNK_TYPE4","",0x4), 0x80BB9730:("En_Tanron3_InitVars","UNK_TYPE1","",0x1), @@ -15696,10 +15655,10 @@ 0x80BB97D0:("D_80BB97D0","f32","",0x4), 0x80BB97D4:("D_80BB97D4","f32","",0x4), 0x80BBAB10:("Obj_Chan_InitVars","UNK_TYPE1","",0x1), - 0x80BBAB30:("D_80BBAB30","UNK_TYPE1","",0x1), - 0x80BBAB5C:("D_80BBAB5C","UNK_TYPE1","",0x1), - 0x80BBAB60:("D_80BBAB60","UNK_TYPE4","",0x4), - 0x80BBAB78:("D_80BBAB78","f32","",0x4), + 0x80BBAB30:("sObjChanCylinderInit","UNK_TYPE1","",0x1), + 0x80BBAB5C:("sObjChanInitChain","UNK_TYPE1","",0x1), + 0x80BBAB60:("sObjChanFlameSize","UNK_TYPE4","",0x4), + 0x80BBAB78:("sObjChanFlameYOffset","f32","",0x4), 0x80BBAB80:("D_80BBAB80","f32","",0x4), 0x80BBAB84:("D_80BBAB84","f32","",0x4), 0x80BBAB88:("D_80BBAB88","f32","",0x4), @@ -15710,7 +15669,7 @@ 0x80BBAB9C:("D_80BBAB9C","f32","",0x4), 0x80BBABA0:("D_80BBABA0","f32","",0x4), 0x80BBABA4:("D_80BBABA4","f32","",0x4), - 0x80BBAC90:("D_80BBAC90","UNK_TYPE1","",0x1), + 0x80BBAC90:("sObjChanLoaded","UNK_TYPE1","",0x1), 0x80BBC6D0:("En_Zos_InitVars","UNK_TYPE1","",0x1), 0x80BBC6F0:("D_80BBC6F0","UNK_TYPE1","",0x1), 0x80BBC71C:("D_80BBC71C","UNK_TYPE1","",0x1), @@ -15776,8 +15735,8 @@ 0x80BC4668:("D_80BC4668","UNK_TYPE1","",0x1), 0x80BC4680:("jtbl_80BC4680","UNK_PTR","",0x4), 0x80BC4DD0:("Bg_F40_Switch_InitVars","UNK_TYPE1","",0x1), - 0x80BC4DF0:("D_80BC4DF0","UNK_TYPE4","",0x4), - 0x80BC4DF4:("D_80BC4DF4","UNK_TYPE4","",0x4), + 0x80BC4DF0:("sBgF40SwitchGlobalsInitialized","s32","",0x4), + 0x80BC4DF4:("sBgF40SwitchGlobalFlags","BgF40SwitchGlobalFlags","",0x10), 0x80BC4E04:("D_80BC4E04","UNK_TYPE1","",0x1), 0x80BC4E20:("D_80BC4E20","f32","",0x4), 0x80BC4E24:("D_80BC4E24","f32","",0x4), @@ -15786,7 +15745,7 @@ 0x80BC4E30:("D_80BC4E30","f32","",0x4), 0x80BC4E34:("D_80BC4E34","f32","",0x4), 0x80BC4E38:("D_80BC4E38","f32","",0x4), - 0x80BC4F20:("D_80BC4F20","UNK_TYPE1","",0x1), + 0x80BC4F20:("sBgF40SwitchLastUpdateFrame","u32","",0x4), 0x80BC6760:("En_Po_Composer_InitVars","UNK_TYPE1","",0x1), 0x80BC6780:("D_80BC6780","UNK_TYPE1","",0x1), 0x80BC67AC:("D_80BC67AC","UNK_TYPE1","",0x1), @@ -16042,9 +16001,7 @@ 0x80BDDCF0:("D_80BDDCF0","UNK_TYPE1","",0x1), 0x80BDDD1C:("D_80BDDD1C","UNK_TYPE4","",0x4), 0x80BDDD28:("D_80BDDD28","UNK_TYPE4","",0x4), - 0x80BDDD34:("D_80BDDD34","f32","",0x4), - 0x80BDDD38:("D_80BDDD38","f32","",0x4), - 0x80BDDD3C:("D_80BDDD3C","f32","",0x4), + 0x80BDDD34:("D_80BDDD34","Vec3f","",0xC), 0x80BDDD40:("D_80BDDD40","UNK_TYPE1","",0x1), 0x80BDDD4C:("D_80BDDD4C","UNK_TYPE1","",0x1), 0x80BDDD58:("D_80BDDD58","UNK_TYPE4","",0x4), @@ -16154,9 +16111,9 @@ 0x80BE6150:("En_Tanron6_InitVars","UNK_TYPE1","",0x1), 0x80BE6170:("D_80BE6170","UNK_TYPE1","",0x1), 0x80BE78D0:("En_Daiku2_InitVars","UNK_TYPE1","",0x1), - 0x80BE78F0:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE78F0:("sTextIds","s16","",0x1), 0x80BE7900:("D_80BE7900","UNK_TYPE1","",0x1), - 0x80BE792C:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE792C:("sAnimations","AnimationHeader*","",0x1), 0x80BE7958:("D_80BE7958","UNK_TYPE1","",0x1), 0x80BE7970:("D_80BE7970","f32","",0x4), 0x80BE7974:("D_80BE7974","f32","",0x4), @@ -16174,14 +16131,14 @@ 0x80BE8E4C:("D_80BE8E4C","UNK_TYPE1","",0x1), 0x80BE8E58:("D_80BE8E58","UNK_TYPE1","",0x1), 0x80BE9430:("En_Heishi_InitVars","UNK_TYPE1","",0x1), - 0x80BE9450:("D_80BE9450","UNK_TYPE1","",0x1), - 0x80BE947C:("D_80BE947C","UNK_TYPE1","",0x1), - 0x80BE9490:("D_80BE9490","UNK_TYPE1","",0x1), + 0x80BE9450:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80BE947C:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE9490:("sAnimModes","UNK_TYPE1","",0x1), 0x80BE9A30:("En_Demo_heishi_InitVars","UNK_TYPE1","",0x1), - 0x80BE9A50:("D_80BE9A50","UNK_TYPE1","",0x1), - 0x80BE9A7C:("D_80BE9A7C","UNK_TYPE1","",0x1), - 0x80BE9A80:("D_80BE9A80","UNK_TYPE1","",0x1), - 0x80BE9A94:("D_80BE9A94","UNK_TYPE1","",0x1), + 0x80BE9A50:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80BE9A7C:("sTextIds","UNK_TYPE1","",0x1), + 0x80BE9A80:("sAnimations","UNK_TYPE1","",0x1), + 0x80BE9A94:("sAnimModes","UNK_TYPE1","",0x1), 0x80BEB1B0:("En_Dt_InitVars","UNK_TYPE1","",0x1), 0x80BEB1D0:("D_80BEB1D0","UNK_TYPE1","",0x1), 0x80BEB208:("D_80BEB208","UNK_TYPE1","",0x1), @@ -16423,13 +16380,13 @@ 0x80C0482C:("D_80C0482C","UNK_TYPE1","",0x1), 0x80C04838:("D_80C04838","UNK_TYPE1","",0x1), 0x80C05880:("En_Bombers2_InitVars","UNK_TYPE1","",0x1), - 0x80C058A0:("D_80C058A0","UNK_TYPE1","",0x1), - 0x80C058B0:("D_80C058B0","UNK_TYPE1","",0x1), - 0x80C058DC:("D_80C058DC","UNK_TYPE1","",0x1), - 0x80C058F8:("D_80C058F8","UNK_TYPE1","",0x1), - 0x80C05900:("D_80C05900","UNK_TYPE1","",0x1), - 0x80C05910:("D_80C05910","UNK_PTR","",0x4), - 0x80C05914:("D_80C05914","UNK_TYPE1","",0x1), + 0x80C058A0:("sTextIds","u16","",0x1), + 0x80C058B0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80C058DC:("sAnimations","AnimationHeader*","",0x1), + 0x80C058F8:("sAnimModes","u8","",0x1), + 0x80C05900:("sSetPrimColorDL","UNK_TYPE1","",0x1), + 0x80C05910:("sSetPrimColorDlPtr","Gfx*","",0x4), + 0x80C05914:("sEyeTextures","void*","",0x1), 0x80C05920:("D_80C05920","UNK_TYPE4","",0x4), 0x80C05930:("jtbl_80C05930","UNK_PTR","",0x4), 0x80C06440:("En_Bombal_InitVars","UNK_TYPE1","",0x1), diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index eb2f1ac4b..2676d13ee 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -13,6 +13,7 @@ SQ = "int" CLAMP = "int" CLOCK_TIME = "int" CURRENT_DAY = "int" +CHECK_NEWF = "int" NULL = "int" [decompme.compilers] diff --git a/tools/reloc_spec_check.sh b/tools/reloc_spec_check.sh new file mode 100755 index 000000000..434a49ec3 --- /dev/null +++ b/tools/reloc_spec_check.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +# This script checks for overlay's relocs to be correctly used on the spec file depending on the overlay's NON_MATCHING/NON_EQUIVALENT +# and minimize possible broken NON_MATCHING builds. +# The script performs the following checks: +# - The extracted reloc isn't being used on the spec if the overlay has no other GLOBAL_ASM left (it has been matched). +# - Warn if an overlay is using both NON_MATCHING and NON_EQUIVALENT. +# - Warn if an overlay has NON_MATCHING ifdefs but some functions are still unattempted. +# - Both relocs (generated and extracted) are used on the spec on NON_MATCHING overlays. +# - The generated reloc isn't being used on NON_EQUIVALENT overlays. +# If any of those checks fails for any overlay, the script will print a warning and exit with a non-zero exit code. + +BOLD="$(tput bold)" +RED="$(tput setaf 1)" +PURPLE="$(tput setaf 5)" +WHITE="$(tput setaf 7)" +BLINK="$(tput blink)" +RST="$(tput sgr0)" + +# Run the script from the root of the project +DIR="$(dirname "$(readlink -f "$0")")" +cd "$DIR/.." + +EXIT_CODE=0 + +OVERLAYS_SUBFOLDERS="$(find src/overlays/*/* -type d)" + +while read OVL_FOLDER; do + # C files which are part of the current overlay + FILES_OF_OVERLAY="$(find "$OVL_FOLDER" -name '*.c')" + # List of files (of the current overlay) which doesn't contain GLOBAL_ASM + FILES_WITHOUT_PRAGMA="$(grep -L '#pragma GLOBAL_ASM' ${FILES_OF_OVERLAY})" + + if [ "$FILES_OF_OVERLAY" == "$FILES_WITHOUT_PRAGMA" ]; then + # This overlay is fully matched, so it should not be using the extracted reloc (use the generated one instead) + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" != "" ]; then + echo "${BOLD} Matching overlay using extracted reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Don't forget to change the extracted reloc to the generated one on the spec, otherwise the matched overlay won't be shiftable" + EXIT_CODE=1 + fi + else + # Overlay not fully matched + + # Search for files with NON_MATCHING and NON_EQUIVALENT + FILES_WITH_NON_MATCHING="$(grep -Fl '#ifdef NON_MATCHING' ${FILES_OF_OVERLAY})" + FILES_WITH_NON_EQUIVALENT="$(grep -Fl '#ifdef NON_EQUIVALENT' ${FILES_OF_OVERLAY})" + + if [ "$FILES_WITH_NON_MATCHING" != "" ] && [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # An overlay can't have both NON_MATCHINGs and NON_EQUIVALENTs, because relocs wouldn't be generated correctly + + echo "${BOLD} Overlay with both NON_MATCHINGs and NON_EQUIVALENTs found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays can't have both NON_MATCHING and NON_EQUIVALENT because it breaks NON_MATCHING builds" + echo " As an alternative you could mark NON_MATCHING functions as NON_EQUIVALENT and add a comment mentioning it is actually equivalent" + EXIT_CODE=1 + + elif [ "$FILES_WITH_NON_MATCHING" != "" ]; then + # Overlay only contains NON_MATCHINGs + + # Get the count of NON_MATCHING and GLOBAL_ASM of the current overlay + NON_MATCHINGS_COUNT_OF_OVERLAY="$(grep -F '#ifdef NON_MATCHING' ${FILES_WITH_NON_MATCHING} | wc -l)" + PRAGMAS_COUNT_OF_OVERLAY="$(grep -F '#pragma GLOBAL_ASM' ${FILES_WITH_NON_MATCHING} | wc -l)" + + if [ "$NON_MATCHINGS_COUNT_OF_OVERLAY" != "$PRAGMAS_COUNT_OF_OVERLAY" ]; then + # If an overlay uses NON_MATCHING, then every function should be either matching or marked as NON_MATCHING + + echo "${BOLD} Found an overlay with a differing number of NON_MATCHINGs and #pragma GLOBAL_ASM: ${RED} ${OVL_FOLDER} ${RST}" + echo " To use a NON_MATCHING check on an overlay, every function that does not match should verified to be equivalent" + echo " But the amount of NON_MATCHING ifdefs and GLOBAL_ASM does no match, which may suggest not every function of this overlay may have been attempted" + EXIT_CODE=1 + fi + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the extracted reloc of this overlay + OVL_WITH_EXTRACTED_RELOC="$(grep -F "$OVL_NAME".reloc spec)" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_EXTRACTED_RELOC" == "" ] || [ "$OVL_WITH_GENERATED_RELOC" == "" ]; then + # Overlays with NON_MATCHINGs should have both relocs on the spec + + echo "${BOLD} NON_MATCHING overlay missing either extracted or generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_MATCHING ifdefs must also add a NON_MATCHING ifdef on the spec to allow using the generated reloc on NON_MATCHING builds" + EXIT_CODE=1 + fi + elif [ "$FILES_WITH_NON_EQUIVALENT" != "" ]; then + # Overlay only contains NON_EQUIVALENTs + + OVL_NAME="$(cut -d '/' -f 4 <<< ${OVL_FOLDER})" + + # Parse the spec, searching for the generated reloc of this overlay + OVL_WITH_GENERATED_RELOC="$(grep -F "$OVL_NAME"_reloc spec)" + + if [ "$OVL_WITH_GENERATED_RELOC" != "" ]; then + # Overlays with NON_EQUIVALENTs should not use a generated reloc + + echo "${BOLD} NON_EQUIVALENT overlay with generated reloc on spec found: ${RED} ${OVL_FOLDER} ${RST}" + echo " Overlays with NON_EQUIVALENT ifdefs can't use generated relocs" + EXIT_CODE=1 + fi + fi + fi +done <<< ${OVERLAYS_SUBFOLDERS} + +exit $EXIT_CODE diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index 3685e3fa9..6c5c92e16 100644 --- a/tools/sizes/boot_functions.csv +++ b/tools/sizes/boot_functions.csv @@ -9,8 +9,8 @@ asm/non_matchings/boot/idle/Idle_InitVideo.s,Idle_InitVideo,0x8008038C,0x62 asm/non_matchings/boot/idle/Idle_ThreadEntry.s,Idle_ThreadEntry,0x80080514,0x33 asm/non_matchings/boot/viconfig/ViConfig_UpdateVi.s,ViConfig_UpdateVi,0x800805E0,0x5A asm/non_matchings/boot/viconfig/ViConfig_UpdateBlack.s,ViConfig_UpdateBlack,0x80080748,0x12 -asm/non_matchings/boot/z_std_dma/DmaMgr_DMARomToRam.s,DmaMgr_DMARomToRam,0x80080790,0x51 -asm/non_matchings/boot/z_std_dma/DmaMgr_DmaCallback0.s,DmaMgr_DmaCallback0,0x800808D4,0x8 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaRomToRam.s,DmaMgr_DmaRomToRam,0x80080790,0x51 +asm/non_matchings/boot/z_std_dma/DmaMgr_DmaHandler.s,DmaMgr_DmaHandler,0x800808D4,0x8 asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaEntry.s,DmaMgr_FindDmaEntry,0x800808F4,0x17 asm/non_matchings/boot/z_std_dma/DmaMgr_TranslateVromToRom.s,DmaMgr_TranslateVromToRom,0x80080950,0x1B asm/non_matchings/boot/z_std_dma/DmaMgr_FindDmaIndex.s,DmaMgr_FindDmaIndex,0x800809BC,0xE @@ -155,14 +155,14 @@ asm/non_matchings/boot/mtxuty-cvt/MtxConv_L2F.s,MtxConv_L2F,0x80086258,0xA asm/non_matchings/boot/assert/__assert.s,__assert,0x80086280,0xD asm/non_matchings/boot/assert/func_800862B4.s,func_800862B4,0x800862B4,0xB asm/non_matchings/boot/boot_800862E0/SystemArena_MallocMin1.s,SystemArena_MallocMin1,0x800862E0,0xC -asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNull.s,SystemArena_FreeNull,0x80086310,0xB -asm/non_matchings/boot/boot_800862E0/func_8008633C.s,func_8008633C,0x8008633C,0x1C -asm/non_matchings/boot/boot_800862E0/func_800863AC.s,func_800863AC,0x800863AC,0x1C -asm/non_matchings/boot/boot_800862E0/func_8008641C.s,func_8008641C,0x8008641C,0x34 -asm/non_matchings/boot/boot_800862E0/func_800864EC.s,func_800864EC,0x800864EC,0x27 -asm/non_matchings/boot/boot_800862E0/func_80086588.s,func_80086588,0x80086588,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_FreeNullCheck.s,SystemArena_FreeNullCheck,0x80086310,0xB +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc.s,SystemArena_RunBlockFunc,0x8008633C,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1.s,SystemArena_RunBlockFunc1,0x800863AC,0x1C +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc8.s,SystemArena_RunBlockFunc8,0x8008641C,0x34 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunBlockFunc1Reverse.s,SystemArena_RunBlockFunc1Reverse,0x800864EC,0x27 +asm/non_matchings/boot/boot_800862E0/SystemArena_RunInits.s,SystemArena_RunInits,0x80086588,0x1C asm/non_matchings/boot/boot_800862E0/SystemArena_Init.s,SystemArena_Init,0x800865F8,0xA -asm/non_matchings/boot/padsetup/func_80086620.s,func_80086620,0x80086620,0x50 +asm/non_matchings/boot/padsetup/PadSetup_Init.s,PadSetup_Init,0x80086620,0x50 asm/non_matchings/boot/boot_80086760/func_80086760.s,func_80086760,0x80086760,0xD asm/non_matchings/boot/boot_80086760/func_80086794.s,func_80086794,0x80086794,0x8 asm/non_matchings/boot/boot_80086760/func_800867B4.s,func_800867B4,0x800867B4,0x8 diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index edea6d621..04d7cb4fd 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -381,7 +381,7 @@ asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShie asm/non_matchings/code/z_actor/Actor_SetColorFilter.s,Actor_SetColorFilter,0x800BCB70,0x21 asm/non_matchings/code/z_actor/func_800BCBF4.s,func_800BCBF4,0x800BCBF4,0x1D asm/non_matchings/code/z_actor/func_800BCC68.s,func_800BCC68,0x800BCC68,0x1D -asm/non_matchings/code/z_actor/func_800BCCDC.s,func_800BCCDC,0x800BCCDC,0x176 +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 @@ -391,7 +391,7 @@ asm/non_matchings/code/z_actor/func_800BD9A0.s,func_800BD9A0,0x800BD9A0,0x10 asm/non_matchings/code/z_actor/func_800BD9E0.s,func_800BD9E0,0x800BD9E0,0x30 asm/non_matchings/code/z_actor/func_800BDAA0.s,func_800BDAA0,0x800BDAA0,0x33 asm/non_matchings/code/z_actor/func_800BDB6C.s,func_800BDB6C,0x800BDB6C,0x3C -asm/non_matchings/code/z_actor/Actor_ChangeAnimation.s,Actor_ChangeAnimation,0x800BDC5C,0x26 +asm/non_matchings/code/z_actor/Actor_ChangeAnimationByInfo.s,Actor_ChangeAnimationByInfo,0x800BDC5C,0x26 asm/non_matchings/code/z_actor/func_800BDCF4.s,func_800BDCF4,0x800BDCF4,0xAF asm/non_matchings/code/z_actor/Actor_Noop.s,Actor_Noop,0x800BDFB0,0x4 asm/non_matchings/code/z_actor/Gfx_DrawDListOpa.s,Gfx_DrawDListOpa,0x800BDFC0,0x1F @@ -407,7 +407,7 @@ asm/non_matchings/code/z_actor/func_800BE504.s,func_800BE504,0x800BE504,0x19 asm/non_matchings/code/z_actor/func_800BE568.s,func_800BE568,0x800BE568,0x19 asm/non_matchings/code/z_actor/func_800BE5CC.s,func_800BE5CC,0x800BE5CC,0x1C asm/non_matchings/code/z_actor/func_800BE63C.s,func_800BE63C,0x800BE63C,0x11 -asm/non_matchings/code/z_actor/func_800BE680.s,func_800BE680,0x800BE680,0x453 +asm/non_matchings/code/z_actor/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_FaultAddrConv.s,ActorOverlayTable_FaultAddrConv,0x800BFA78,0x1C @@ -786,13 +786,13 @@ asm/non_matchings/code/z_camera/Camera_ChangeMode.s,Camera_ChangeMode,0x800DF840 asm/non_matchings/code/z_camera/func_800DF86C.s,func_800DF86C,0x800DF86C,0x20 asm/non_matchings/code/z_camera/func_800DF8EC.s,func_800DF8EC,0x800DF8EC,0x77 asm/non_matchings/code/z_camera/func_800DFAC8.s,func_800DFAC8,0x800DFAC8,0x13 -asm/non_matchings/code/z_camera/func_800DFB14.s,func_800DFB14,0x800DFB14,0x42 +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/func_800DFC68.s,func_800DFC68,0x800DFC68,0xA +asm/non_matchings/code/z_camera/Camera_GetInputDirYaw.s,Camera_GetInputDirYaw,0x800DFC68,0xA asm/non_matchings/code/z_camera/func_800DFC90.s,func_800DFC90,0x800DFC90,0x9 -asm/non_matchings/code/z_camera/func_800DFCB4.s,func_800DFCB4,0x800DFCB4,0xA -asm/non_matchings/code/z_camera/func_800DFCDC.s,func_800DFCDC,0x800DFCDC,0xA +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/func_800DFD04.s,func_800DFD04,0x800DFD04,0x1D asm/non_matchings/code/z_camera/func_800DFD78.s,func_800DFD78,0x800DFD78,0x5E asm/non_matchings/code/z_camera/func_800DFEF0.s,func_800DFEF0,0x800DFEF0,0xA @@ -804,13 +804,13 @@ asm/non_matchings/code/z_camera/Camera_ClearFlags.s,Camera_ClearFlags,0x800DFF84 asm/non_matchings/code/z_camera/func_800DFFAC.s,func_800DFFAC,0x800DFFAC,0x34 asm/non_matchings/code/z_camera/func_800E007C.s,func_800E007C,0x800E007C,0x4C asm/non_matchings/code/z_camera/func_800E01AC.s,func_800E01AC,0x800E01AC,0x3 -asm/non_matchings/code/z_camera/func_800E01B8.s,func_800E01B8,0x800E01B8,0x9 +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/func_800E0238.s,func_800E0238,0x800E0238,0x1D -asm/non_matchings/code/z_camera/func_800E02AC.s,func_800E02AC,0x800E02AC,0x17 -asm/non_matchings/code/z_camera/func_800E0308.s,func_800E0308,0x800E0308,0x5 -asm/non_matchings/code/z_camera/func_800E031C.s,func_800E031C,0x800E031C,0xB +asm/non_matchings/code/z_camera/Camera_SetToTrackActor.s,Camera_SetToTrackActor,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 asm/non_matchings/code/z_collision_btltbls/DamageTable_Get.s,DamageTable_Get,0x800E03A0,0xB asm/non_matchings/code/z_collision_btltbls/DamageTable_Clear.s,DamageTable_Clear,0x800E03CC,0xD @@ -1034,7 +1034,7 @@ asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,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_display/func_800E9470.s,func_800E9470,0x800E9470,0x6 +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 asm/non_matchings/code/z_debug_display/func_800E95F4.s,func_800E95F4,0x800E95F4,0x79 @@ -1048,36 +1048,36 @@ asm/non_matchings/code/z_debug_mode/func_800E9DBC.s,func_800E9DBC,0x800E9DBC,0x3 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/func_800EA0D4.s,func_800EA0D4,0x800EA0D4,0x6 -asm/non_matchings/code/z_demo/func_800EA0EC.s,func_800EA0EC,0x800EA0EC,0x9 -asm/non_matchings/code/z_demo/Cutscene_StepCutscene1.s,Cutscene_StepCutscene1,0x800EA110,0x13 -asm/non_matchings/code/z_demo/Cutscene_StepCutscene2.s,Cutscene_StepCutscene2,0x800EA15C,0x2D -asm/non_matchings/code/z_demo/Cutscene_Nop800EA210.s,Cutscene_Nop800EA210,0x800EA210,0x4 +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/func_800EA324.s,func_800EA324,0x800EA324,0x222 -asm/non_matchings/code/z_demo/func_800EABAC.s,func_800EABAC,0x800EABAC,0x17 -asm/non_matchings/code/z_demo/func_800EAC08.s,func_800EAC08,0x800EAC08,0xF -asm/non_matchings/code/z_demo/func_800EAC44.s,func_800EAC44,0x800EAC44,0x14 -asm/non_matchings/code/z_demo/func_800EAC94.s,func_800EAC94,0x800EAC94,0x20 -asm/non_matchings/code/z_demo/func_800EAD14.s,func_800EAD14,0x800EAD14,0xD +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/func_800EAECC.s,func_800EAECC,0x800EAECC,0x15 -asm/non_matchings/code/z_demo/func_800EAF20.s,func_800EAF20,0x800EAF20,0x30 -asm/non_matchings/code/z_demo/func_800EAFE0.s,func_800EAFE0,0x800EAFE0,0x7F -asm/non_matchings/code/z_demo/func_800EB1DC.s,func_800EB1DC,0x800EB1DC,0x62 -asm/non_matchings/code/z_demo/func_800EB364.s,func_800EB364,0x800EB364,0x54 -asm/non_matchings/code/z_demo/func_800EB4B4.s,func_800EB4B4,0x800EB4B4,0x91 -asm/non_matchings/code/z_demo/func_800EB6F8.s,func_800EB6F8,0x800EB6F8,0x11C -asm/non_matchings/code/z_demo/func_800EBB68.s,func_800EBB68,0x800EBB68,0x5A -asm/non_matchings/code/z_demo/func_800EBCD0.s,func_800EBCD0,0x800EBCD0,0x24 -asm/non_matchings/code/z_demo/func_800EBD60.s,func_800EBD60,0x800EBD60,0x246 -asm/non_matchings/code/z_demo/func_800EC678.s,func_800EC678,0x800EC678,0x17 -asm/non_matchings/code/z_demo/func_800EC6D4.s,func_800EC6D4,0x800EC6D4,0x94 -asm/non_matchings/code/z_demo/func_800EC924.s,func_800EC924,0x800EC924,0x116 +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_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 @@ -1085,17 +1085,17 @@ 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/nop_800EDDB0.s,nop_800EDDB0,0x800EDDB0,0x3 +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/func_800EDDCC.s,func_800EDDCC,0x800EDDCC,0x1A -asm/non_matchings/code/z_demo/func_800EDE34.s,func_800EDE34,0x800EDE34,0x3C -asm/non_matchings/code/z_demo/func_800EDF24.s,func_800EDF24,0x800EDF24,0x15 -asm/non_matchings/code/z_demo/func_800EDF78.s,func_800EDF78,0x800EDF78,0x55 -asm/non_matchings/code/z_demo/func_800EE0CC.s,func_800EE0CC,0x800EE0CC,0x43 -asm/non_matchings/code/z_demo/func_800EE1D8.s,func_800EE1D8,0x800EE1D8,0xA -asm/non_matchings/code/z_demo/func_800EE200.s,func_800EE200,0x800EE200,0x27 -asm/non_matchings/code/z_demo/func_800EE29C.s,func_800EE29C,0x800EE29C,0x16 -asm/non_matchings/code/z_demo/func_800EE2F4.s,func_800EE2F4,0x800EE2F4,0xB +asm/non_matchings/code/z_demo/Cutscene_LoadCutsceneData.s,Cutscene_LoadCutsceneData,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_GetSceneSetupIndex.s,Cutscene_GetSceneSetupIndex,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_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/func_800EE364.s,func_800EE364,0x800EE364,0x27 asm/non_matchings/code/z_draw/func_800EE400.s,func_800EE400,0x800EE400,0x7F @@ -1213,7 +1213,7 @@ asm/non_matchings/code/z_jpeg/Jpeg_GetUnalignedU16.s,Jpeg_GetUnalignedU16,0x800F asm/non_matchings/code/z_jpeg/Jpeg_ParseMarkers.s,Jpeg_ParseMarkers,0x800F4540,0x73 asm/non_matchings/code/z_jpeg/Jpeg_Decode.s,Jpeg_Decode,0x800F470C,0xC1 asm/non_matchings/code/z_kaleido_setup/func_800F4A10.s,func_800F4A10,0x800F4A10,0x7F -asm/non_matchings/code/z_kaleido_setup/func_800F4C0C.s,func_800F4C0C,0x800F4C0C,0x85 +asm/non_matchings/code/z_kaleido_setup/KaleidoSetup_Update.s,KaleidoSetup_Update,0x800F4C0C,0x85 asm/non_matchings/code/z_kaleido_setup/func_800F4E20.s,func_800F4E20,0x800F4E20,0x42 asm/non_matchings/code/z_kaleido_setup/func_800F4F28.s,func_800F4F28,0x800F4F28,0x6 asm/non_matchings/code/z_kanfont/Font_LoadChar.s,Font_LoadChar,0x800F4F40,0x5 @@ -1224,7 +1224,7 @@ 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/func_800F5954.s,func_800F5954,0x800F5954,0x4E -asm/non_matchings/code/z_kankyo/func_800F5A8C.s,func_800F5A8C,0x800F5A8C,0x21 +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/func_800F6834.s,func_800F6834,0x800F6834,0x46 @@ -1252,7 +1252,7 @@ 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 asm/non_matchings/code/z_kankyo/func_800FB010.s,func_800FB010,0x800FB010,0xC4 -asm/non_matchings/code/z_kankyo/func_800FB320.s,func_800FB320,0x800FB320,0x1A +asm/non_matchings/code/z_kankyo/Environment_AddLightningBolts.s,Environment_AddLightningBolts,0x800FB320,0x1A 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 @@ -2122,23 +2122,23 @@ asm/non_matchings/code/z_skelanime/SkelAnime_UpdateTranslation.s,SkelAnime_Updat asm/non_matchings/code/z_skelanime/Animation_OnFrame.s,Animation_OnFrame,0x801378B8,0xA asm/non_matchings/code/z_skelanime/SkelAnime_Free.s,SkelAnime_Free,0x801378E0,0x13 asm/non_matchings/code/z_skelanime/SkelAnime_CopyFrameTable.s,SkelAnime_CopyFrameTable,0x8013792C,0x11 -asm/non_matchings/code/z_skin/func_80137970.s,func_80137970,0x80137970,0x71 -asm/non_matchings/code/z_skin/func_80137B34.s,func_80137B34,0x80137B34,0xE2 -asm/non_matchings/code/z_skin/func_80137EBC.s,func_80137EBC,0x80137EBC,0x27 -asm/non_matchings/code/z_skin/func_80137F58.s,func_80137F58,0x80137F58,0x3E -asm/non_matchings/code/z_skin/func_80138050.s,func_80138050,0x80138050,0x76 +asm/non_matchings/code/z_skin/Skin_UpdateVertices.s,Skin_UpdateVertices,0x80137970,0x71 +asm/non_matchings/code/z_skin/Skin_ApplyLimbModifications.s,Skin_ApplyLimbModifications,0x80137B34,0xE2 +asm/non_matchings/code/z_skin/Skin_DrawAnimatedLimb.s,Skin_DrawAnimatedLimb,0x80137EBC,0x27 +asm/non_matchings/code/z_skin/Skin_DrawLimb.s,Skin_DrawLimb,0x80137F58,0x3E +asm/non_matchings/code/z_skin/Skin_DrawImpl.s,Skin_DrawImpl,0x80138050,0x76 asm/non_matchings/code/z_skin/func_80138228.s,func_80138228,0x80138228,0xC asm/non_matchings/code/z_skin/func_80138258.s,func_80138258,0x80138258,0xD asm/non_matchings/code/z_skin/func_8013828C.s,func_8013828C,0x8013828C,0xE asm/non_matchings/code/z_skin/func_801382C4.s,func_801382C4,0x801382C4,0xF -asm/non_matchings/code/z_skin/func_80138300.s,func_80138300,0x80138300,0x17 -asm/non_matchings/code/z_skin/func_8013835C.s,func_8013835C,0x8013835C,0x2D -asm/non_matchings/code/z_skin_awb/func_80138410.s,func_80138410,0x80138410,0x5 -asm/non_matchings/code/z_skin_awb/func_80138424.s,func_80138424,0x80138424,0x5E -asm/non_matchings/code/z_skin_awb/func_8013859C.s,func_8013859C,0x8013859C,0x59 -asm/non_matchings/code/z_skin_awb/func_80138700.s,func_80138700,0x80138700,0x35 +asm/non_matchings/code/z_skin/Skin_GetLimbPos.s,Skin_GetLimbPos,0x80138300,0x17 +asm/non_matchings/code/z_skin/Skin_GetVertexPos.s,Skin_GetVertexPos,0x8013835C,0x2D +asm/non_matchings/code/z_skin_awb/Skin_Setup.s,Skin_Setup,0x80138410,0x5 +asm/non_matchings/code/z_skin_awb/Skin_InitAnimatedLimb.s,Skin_InitAnimatedLimb,0x80138424,0x5E +asm/non_matchings/code/z_skin_awb/Skin_Init.s,Skin_Init,0x8013859C,0x59 +asm/non_matchings/code/z_skin_awb/Skin_Free.s,Skin_Free,0x80138700,0x35 asm/non_matchings/code/z_skin_awb/func_801387D4.s,func_801387D4,0x801387D4,0x44 -asm/non_matchings/code/z_skin_awb/func_801388E4.s,func_801388E4,0x801388E4,0xAF +asm/non_matchings/code/z_skin_awb/Skin_ApplyAnimTransformations.s,Skin_ApplyAnimTransformations,0x801388E4,0xAF asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZW.s,SkinMatrix_Vec3fMtxFMultXYZW,0x80138BA0,0x3A asm/non_matchings/code/z_skin_matrix/SkinMatrix_Vec3fMtxFMultXYZ.s,SkinMatrix_Vec3fMtxFMultXYZ,0x80138C88,0x2C asm/non_matchings/code/z_skin_matrix/SkinMatrix_MtxFMtxFMult.s,SkinMatrix_MtxFMtxFMult,0x80138D38,0xD7 @@ -2174,49 +2174,49 @@ asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlexLimb.s,SubS_DrawTransformFl asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0x8013AB00,0x9B asm/non_matchings/code/z_sub_s/func_8013AD6C.s,func_8013AD6C,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/func_8013AD9C.s,func_8013AD9C,0x8013AD9C,0x4E -asm/non_matchings/code/z_sub_s/func_8013AED4.s,func_8013AED4,0x8013AED4,0xB +asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF -asm/non_matchings/code/z_sub_s/func_8013BB34.s,func_8013BB34,0x8013BB34,0x12 +asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C -asm/non_matchings/code/z_sub_s/func_8013BC6C.s,func_8013BC6C,0x8013BC6C,0x35 -asm/non_matchings/code/z_sub_s/func_8013BD40.s,func_8013BD40,0x8013BD40,0x67 -asm/non_matchings/code/z_sub_s/func_8013BEDC.s,func_8013BEDC,0x8013BEDC,0x63 +asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 +asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 +asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 -asm/non_matchings/code/z_sub_s/func_8013C8B8.s,func_8013C8B8,0x8013C8B8,0x2B +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/func_8013CC2C.s,func_8013CC2C,0x8013CC2C,0x4E asm/non_matchings/code/z_sub_s/func_8013CD64.s,func_8013CD64,0x8013CD64,0x68 asm/non_matchings/code/z_sub_s/func_8013CF04.s,func_8013CF04,0x8013CF04,0x77 asm/non_matchings/code/z_sub_s/func_8013D0E0.s,func_8013D0E0,0x8013D0E0,0x80 asm/non_matchings/code/z_sub_s/func_8013D2E0.s,func_8013D2E0,0x8013D2E0,0xC2 -asm/non_matchings/code/z_sub_s/func_8013D5E8.s,func_8013D5E8,0x8013D5E8,0x18 -asm/non_matchings/code/z_sub_s/func_8013D648.s,func_8013D648,0x8013D648,0x11 -asm/non_matchings/code/z_sub_s/func_8013D68C.s,func_8013D68C,0x8013D68C,0x25 -asm/non_matchings/code/z_sub_s/func_8013D720.s,func_8013D720,0x8013D720,0x12 -asm/non_matchings/code/z_sub_s/func_8013D768.s,func_8013D768,0x8013D768,0x35 -asm/non_matchings/code/z_sub_s/func_8013D83C.s,func_8013D83C,0x8013D83C,0x28 -asm/non_matchings/code/z_sub_s/func_8013D8DC.s,func_8013D8DC,0x8013D8DC,0x12 -asm/non_matchings/code/z_sub_s/func_8013D924.s,func_8013D924,0x8013D924,0xF +asm/non_matchings/code/z_sub_s/SubS_AngleDiffLessEqual.s,SubS_AngleDiffLessEqual,0x8013D5E8,0x18 +asm/non_matchings/code/z_sub_s/SubS_GetPathByIndex.s,SubS_GetPathByIndex,0x8013D648,0x11 +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPath.s,SubS_CopyPointFromPath,0x8013D68C,0x25 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPoints.s,SubS_GetDistSqAndOrientPoints,0x8013D720,0x12 +asm/non_matchings/code/z_sub_s/SubS_MoveActorToPoint.s,SubS_MoveActorToPoint,0x8013D768,0x35 +asm/non_matchings/code/z_sub_s/SubS_GetDistSqAndOrientPath.s,SubS_GetDistSqAndOrientPath,0x8013D83C,0x28 +asm/non_matchings/code/z_sub_s/SubS_IsObjectLoaded.s,SubS_IsObjectLoaded,0x8013D8DC,0x12 +asm/non_matchings/code/z_sub_s/SubS_GetObjectIndex.s,SubS_GetObjectIndex,0x8013D924,0xF asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A -asm/non_matchings/code/z_sub_s/func_8013D9C8.s,func_8013D9C8,0x8013D9C8,0x72 -asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C -asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 -asm/non_matchings/code/z_sub_s/func_8013DCE0.s,func_8013DCE0,0x8013DCE0,0x49 -asm/non_matchings/code/z_sub_s/func_8013DE04.s,func_8013DE04,0x8013DE04,0x4E -asm/non_matchings/code/z_sub_s/func_8013DF3C.s,func_8013DF3C,0x8013DF3C,0x46 -asm/non_matchings/code/z_sub_s/func_8013E054.s,func_8013E054,0x8013E054,0xA -asm/non_matchings/code/z_sub_s/func_8013E07C.s,func_8013E07C,0x8013E07C,0xA -asm/non_matchings/code/z_sub_s/func_8013E0A4.s,func_8013E0A4,0x8013E0A4,0x49 -asm/non_matchings/code/z_sub_s/func_8013E1C8.s,func_8013E1C8,0x8013E1C8,0x43 -asm/non_matchings/code/z_sub_s/func_8013E2D4.s,func_8013E2D4,0x8013E2D4,0x39 -asm/non_matchings/code/z_sub_s/func_8013E3B8.s,func_8013E3B8,0x8013E3B8,0x3E +asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 +asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C +asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 +asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithGravity.s,SubS_ActorPathing_MoveWithGravity,0x8013E054,0xA +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_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E asm/non_matchings/code/z_sub_s/func_8013E4B0.s,func_8013E4B0,0x8013E4B0,0x47 asm/non_matchings/code/z_sub_s/func_8013E5CC.s,func_8013E5CC,0x8013E5CC,0x1D asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x8013E640,0x42 @@ -2301,30 +2301,30 @@ asm/non_matchings/code/z_vr_box_draw/func_801435A0.s,func_801435A0,0x801435A0,0x asm/non_matchings/code/z_vr_box_draw/func_80143624.s,func_80143624,0x80143624,0x11 asm/non_matchings/code/z_vr_box_draw/func_80143668.s,func_80143668,0x80143668,0xE7 asm/non_matchings/code/z_vr_box_draw/func_80143A04.s,func_80143A04,0x80143A04,0x3 -asm/non_matchings/code/z_sram_NES/func_80143A10.s,func_80143A10,0x80143A10,0x11 -asm/non_matchings/code/z_sram_NES/func_80143A54.s,func_80143A54,0x80143A54,0x1C -asm/non_matchings/code/z_sram_NES/func_80143AC4.s,func_80143AC4,0x80143AC4,0x12 -asm/non_matchings/code/z_sram_NES/func_80143B0C.s,func_80143B0C,0x80143B0C,0x29A +asm/non_matchings/code/z_sram_NES/Sram_ActivateOwl.s,Sram_ActivateOwl,0x80143A10,0x11 +asm/non_matchings/code/z_sram_NES/Sram_ClearHighscores.s,Sram_ClearHighscores,0x80143A54,0x1C +asm/non_matchings/code/z_sram_NES/Sram_ClearFlagsAtDawnOfTheFirstDay.s,Sram_ClearFlagsAtDawnOfTheFirstDay,0x80143AC4,0x12 +asm/non_matchings/code/z_sram_NES/Sram_SaveEndOfCycle.s,Sram_SaveEndOfCycle,0x80143B0C,0x29A asm/non_matchings/code/z_sram_NES/Sram_IncrementDay.s,Sram_IncrementDay,0x80144574,0x1C asm/non_matchings/code/z_sram_NES/Sram_CalcChecksum.s,Sram_CalcChecksum,0x801445E4,0x11 -asm/non_matchings/code/z_sram_NES/func_80144628.s,func_80144628,0x80144628,0x17 +asm/non_matchings/code/z_sram_NES/Sram_ResetSave.s,Sram_ResetSave,0x80144628,0x17 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/func_80144E78.s,func_80144E78,0x80144E78,0x17D +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 asm/non_matchings/code/z_sram_NES/func_801457CC.s,func_801457CC,0x801457CC,0x36D asm/non_matchings/code/z_sram_NES/func_80146580.s,func_80146580,0x80146580,0x2A asm/non_matchings/code/z_sram_NES/func_80146628.s,func_80146628,0x80146628,0x11E -asm/non_matchings/code/z_sram_NES/func_80146AA0.s,func_80146AA0,0x80146AA0,0xD6 +asm/non_matchings/code/z_sram_NES/Sram_InitSave.s,Sram_InitSave,0x80146AA0,0xD6 asm/non_matchings/code/z_sram_NES/func_80146DF8.s,func_80146DF8,0x80146DF8,0x12 -asm/non_matchings/code/z_sram_NES/func_80146E40.s,func_80146E40,0x80146E40,0xC +asm/non_matchings/code/z_sram_NES/Sram_InitSram.s,Sram_InitSram,0x80146E40,0xC asm/non_matchings/code/z_sram_NES/Sram_Alloc.s,Sram_Alloc,0x80146E70,0x13 asm/non_matchings/code/z_sram_NES/func_80146EBC.s,func_80146EBC,0x80146EBC,0xB -asm/non_matchings/code/z_sram_NES/func_80146EE8.s,func_80146EE8,0x80146EE8,0x1D -asm/non_matchings/code/z_sram_NES/func_80146F5C.s,func_80146F5C,0x80146F5C,0x2B +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialEnterClockTown.s,Sram_SaveSpecialEnterClockTown,0x80146EE8,0x1D +asm/non_matchings/code/z_sram_NES/Sram_SaveSpecialNewDay.s,Sram_SaveSpecialNewDay,0x80146F5C,0x2B asm/non_matchings/code/z_sram_NES/func_80147008.s,func_80147008,0x80147008,0x6 asm/non_matchings/code/z_sram_NES/func_80147020.s,func_80147020,0x80147020,0x12 asm/non_matchings/code/z_sram_NES/func_80147068.s,func_80147068,0x80147068,0x34 @@ -2336,8 +2336,8 @@ asm/non_matchings/code/z_sram_NES/func_80147414.s,func_80147414,0x80147414,0x3E asm/non_matchings/code/z_sram_NES/Sram_nop8014750C.s,Sram_nop8014750C,0x8014750C,0x5 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/func_80147624.s,func_80147624,0x80147624,0x44 -asm/non_matchings/code/z_message/func_80147734.s,func_80147734,0x80147734,0x20 +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/func_80147818.s,func_80147818,0x80147818,0x1C0 asm/non_matchings/code/z_message/func_80147F18.s,func_80147F18,0x80147F18,0x190 @@ -2351,12 +2351,12 @@ asm/non_matchings/code/z_message/func_80149454.s,func_80149454,0x80149454,0x9D asm/non_matchings/code/z_message/func_801496C8.s,func_801496C8,0x801496C8,0xA5 asm/non_matchings/code/z_message/func_8014995C.s,func_8014995C,0x8014995C,0xAF asm/non_matchings/code/z_message/func_80149C18.s,func_80149C18,0x80149C18,0xA9 -asm/non_matchings/code/z_message/func_80149EBC.s,func_80149EBC,0x80149EBC,0x2E +asm/non_matchings/code/z_message/Message_FindMessage.s,Message_FindMessage,0x80149EBC,0x2E asm/non_matchings/code/z_message/func_80149F74.s,func_80149F74,0x80149F74,0x2D7 asm/non_matchings/code/z_message/func_8014AAD0.s,func_8014AAD0,0x8014AAD0,0xBB asm/non_matchings/code/z_message/func_8014ADBC.s,func_8014ADBC,0x8014ADBC,0x654 asm/non_matchings/code/z_message/func_8014C70C.s,func_8014C70C,0x8014C70C,0x142 -asm/non_matchings/code/z_message/func_8014CC14.s,func_8014CC14,0x8014CC14,0x28 +asm/non_matchings/code/z_message/Message_LoadChar.s,Message_LoadChar,0x8014CC14,0x28 asm/non_matchings/code/z_message/func_8014CCB4.s,func_8014CCB4,0x8014CCB4,0x4F asm/non_matchings/code/z_message/func_8014CDF0.s,func_8014CDF0,0x8014CDF0,0x7B asm/non_matchings/code/z_message/func_8014CFDC.s,func_8014CFDC,0x8014CFDC,0xCA @@ -2366,7 +2366,7 @@ asm/non_matchings/code/z_message/func_8014D7B4.s,func_8014D7B4,0x8014D7B4,0xCB4 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/func_801518B0.s,func_801518B0,0x801518B0,0x22 +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/func_80151A68.s,func_80151A68,0x80151A68,0x53 asm/non_matchings/code/z_message/func_80151BB4.s,func_80151BB4,0x80151BB4,0x3A @@ -2388,24 +2388,24 @@ 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/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/func_801588D0.s,func_801588D0,0x801588D0,0x2E -asm/non_matchings/code/z_message_nes/func_80158988.s,func_80158988,0x80158988,0x27 -asm/non_matchings/code/z_message_nes/func_80158A24.s,func_80158A24,0x80158A24,0x78 -asm/non_matchings/code/z_message_nes/func_80158C04.s,func_80158C04,0x80158C04,0x65 -asm/non_matchings/code/z_message_nes/func_80158D98.s,func_80158D98,0x80158D98,0x86 -asm/non_matchings/code/z_message_nes/func_80158FB0.s,func_80158FB0,0x80158FB0,0xAF -asm/non_matchings/code/z_message_nes/func_8015926C.s,func_8015926C,0x8015926C,0x73 +asm/non_matchings/code/z_message_nes/Message_FindMessageNES.s,Message_FindMessageNES,0x801588D0,0x2E +asm/non_matchings/code/z_message_nes/Message_LoadCharNES.s,Message_LoadCharNES,0x80158988,0x27 +asm/non_matchings/code/z_message_nes/Message_LoadPluralRupeesNES.s,Message_LoadPluralRupeesNES,0x80158A24,0x78 +asm/non_matchings/code/z_message_nes/Message_LoadLocalizedRupeesNES.s,Message_LoadLocalizedRupeesNES,0x80158C04,0x65 +asm/non_matchings/code/z_message_nes/Message_LoadRupeesNES.s,Message_LoadRupeesNES,0x80158D98,0x86 +asm/non_matchings/code/z_message_nes/Message_LoadTimeNES.s,Message_LoadTimeNES,0x80158FB0,0xAF +asm/non_matchings/code/z_message_nes/Message_LoadAreaTextNES.s,Message_LoadAreaTextNES,0x8015926C,0x73 asm/non_matchings/code/z_message_nes/func_80159438.s,func_80159438,0x80159438,0x8D asm/non_matchings/code/z_message_nes/func_8015966C.s,func_8015966C,0x8015966C,0x6CB asm/non_matchings/code/z_message_nes/func_8015B198.s,func_8015B198,0x8015B198,0xD6E -asm/non_matchings/code/z_message_staff/func_8015E750.s,func_8015E750,0x8015E750,0x27 +asm/non_matchings/code/z_message_staff/Message_FindCreditsMessage.s,Message_FindCreditsMessage,0x8015E750,0x27 asm/non_matchings/code/z_message_staff/func_8015E7EC.s,func_8015E7EC,0x8015E7EC,0x42F asm/non_matchings/code/z_message_staff/func_8015F8A8.s,func_8015F8A8,0x8015F8A8,0x47A -asm/non_matchings/code/z_player_call/func_80160A90.s,func_80160A90,0x80160A90,0x1A -asm/non_matchings/code/z_player_call/func_80160AF8.s,func_80160AF8,0x80160AF8,0x12 -asm/non_matchings/code/z_player_call/func_80160B40.s,func_80160B40,0x80160B40,0x10 -asm/non_matchings/code/z_player_call/func_80160B80.s,func_80160B80,0x80160B80,0x10 -asm/non_matchings/code/z_player_call/func_80160BC0.s,func_80160BC0,0x80160BC0,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_InitFuncPtrs.s,PlayerCall_InitFuncPtrs,0x80160A90,0x1A +asm/non_matchings/code/z_player_call/PlayerCall_Init.s,PlayerCall_Init,0x80160AF8,0x12 +asm/non_matchings/code/z_player_call/PlayerCall_Destroy.s,PlayerCall_Destroy,0x80160B40,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_Update.s,PlayerCall_Update,0x80160B80,0x10 +asm/non_matchings/code/z_player_call/PlayerCall_Draw.s,PlayerCall_Draw,0x80160BC0,0x10 asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxTarget.s,ShrinkWindow_SetLetterboxTarget,0x80160C00,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxTarget.s,ShrinkWindow_GetLetterboxTarget,0x80160C14,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxMagnitude.s,ShrinkWindow_SetLetterboxMagnitude,0x80160C28,0x5 @@ -2512,7 +2512,7 @@ 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_Update.s,Play_Update,0x80168F64,0x5A -asm/non_matchings/code/z_play/func_801690CC.s,func_801690CC,0x801690CC,0xD +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 @@ -2520,28 +2520,28 @@ 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/func_80169474.s,func_80169474,0x80169474,0x1A -asm/non_matchings/code/z_play/func_801694DC.s,func_801694DC,0x801694DC,0x2A -asm/non_matchings/code/z_play/Play_GetActiveCameraIndex.s,Play_GetActiveCameraIndex,0x80169584,0x3 -asm/non_matchings/code/z_play/func_80169590.s,func_80169590,0x80169590,0x1C -asm/non_matchings/code/z_play/func_80169600.s,func_80169600,0x80169600,0x1A -asm/non_matchings/code/z_play/func_80169668.s,func_80169668,0x80169668,0x1B +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 +asm/non_matchings/code/z_play/Play_CameraChangeStatus.s,Play_CameraChangeStatus,0x80169590,0x1C +asm/non_matchings/code/z_play/Play_ClearCamera.s,Play_ClearCamera,0x80169600,0x1A +asm/non_matchings/code/z_play/Play_ClearAllSubCameras.s,Play_ClearAllSubCameras,0x80169668,0x1B asm/non_matchings/code/z_play/Play_GetCamera.s,Play_GetCamera,0x801696D4,0xE asm/non_matchings/code/z_play/Play_CameraSetAtEye.s,Play_CameraSetAtEye,0x8016970C,0x44 -asm/non_matchings/code/z_play/func_8016981C.s,func_8016981C,0x8016981C,0x49 -asm/non_matchings/code/z_play/func_80169940.s,func_80169940,0x80169940,0x12 -asm/non_matchings/code/z_play/func_80169988.s,func_80169988,0x80169988,0x13 -asm/non_matchings/code/z_play/func_801699D4.s,func_801699D4,0x801699D4,0x1F +asm/non_matchings/code/z_play/Play_CameraSetAtEyeUp.s,Play_CameraSetAtEyeUp,0x8016981C,0x49 +asm/non_matchings/code/z_play/Play_CameraSetFov.s,Play_CameraSetFov,0x80169940,0x12 +asm/non_matchings/code/z_play/Play_CameraSetRoll.s,Play_CameraSetRoll,0x80169988,0x13 +asm/non_matchings/code/z_play/Play_CopyCamera.s,Play_CopyCamera,0x801699D4,0x1F asm/non_matchings/code/z_play/func_80169A50.s,func_80169A50,0x80169A50,0x1C -asm/non_matchings/code/z_play/func_80169AC0.s,func_80169AC0,0x80169AC0,0xF +asm/non_matchings/code/z_play/Play_CameraChangeSetting.s,Play_CameraChangeSetting,0x80169AC0,0xF asm/non_matchings/code/z_play/func_80169AFC.s,func_80169AFC,0x80169AFC,0x32 -asm/non_matchings/code/z_play/func_80169BC4.s,func_80169BC4,0x80169BC4,0xD +asm/non_matchings/code/z_play/Play_CameraGetUID.s,Play_CameraGetUID,0x80169BC4,0xD asm/non_matchings/code/z_play/func_80169BF8.s,func_80169BF8,0x80169BF8,0x1B -asm/non_matchings/code/z_play/func_80169C64.s,func_80169C64,0x80169C64,0x8 -asm/non_matchings/code/z_play/func_80169C84.s,func_80169C84,0x80169C84,0xE -asm/non_matchings/code/z_play/convert_scene_number_among_shared_scenes.s,convert_scene_number_among_shared_scenes,0x80169CBC,0x21 -asm/non_matchings/code/z_play/func_80169D40.s,func_80169D40,0x80169D40,0x23 -asm/non_matchings/code/z_play/func_80169DCC.s,func_80169DCC,0x80169DCC,0x28 -asm/non_matchings/code/z_play/func_80169E6C.s,func_80169E6C,0x80169E6C,0x18 +asm/non_matchings/code/z_play/Play_GetCsCamDataSetting.s,Play_GetCsCamDataSetting,0x80169C64,0x8 +asm/non_matchings/code/z_play/Play_GetCsCamDataVec3s.s,Play_GetCsCamDataVec3s,0x80169C84,0xE +asm/non_matchings/code/z_play/Play_GetOriginalSceneNumber.s,Play_GetOriginalSceneNumber,0x80169CBC,0x21 +asm/non_matchings/code/z_play/Play_SaveCycleSceneFlags.s,Play_SaveCycleSceneFlags,0x80169D40,0x23 +asm/non_matchings/code/z_play/Play_SetRespawnData.s,Play_SetRespawnData,0x80169DCC,0x28 +asm/non_matchings/code/z_play/Play_SetupRespawnPoint.s,Play_SetupRespawnPoint,0x80169E6C,0x18 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 @@ -2549,7 +2549,7 @@ 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/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/func_8016A0AC.s,func_8016A0AC,0x8016A0AC,0x2F +asm/non_matchings/code/z_play/Play_IsUnderwater.s,Play_IsUnderwater,0x8016A0AC,0x2F asm/non_matchings/code/z_play/func_8016A168.s,func_8016A168,0x8016A168,0x4 asm/non_matchings/code/z_play/func_8016A178.s,func_8016A178,0x8016A178,0x3C asm/non_matchings/code/z_play/func_8016A268.s,func_8016A268,0x8016A268,0x18 @@ -2834,7 +2834,7 @@ asm/non_matchings/code/sys_math3d/func_8017CFA4.s,func_8017CFA4,0x8017CFA4,0x1F asm/non_matchings/code/sys_math3d/Math3D_TriChkLineSegParaZIntersect.s,Math3D_TriChkLineSegParaZIntersect,0x8017D020,0x63 asm/non_matchings/code/sys_math3d/func_8017D1AC.s,func_8017D1AC,0x8017D1AC,0x1D asm/non_matchings/code/sys_math3d/func_8017D220.s,func_8017D220,0x8017D220,0x37 -asm/non_matchings/code/sys_math3d/func_8017D2FC.s,func_8017D2FC,0x8017D2FC,0x42 +asm/non_matchings/code/sys_math3d/Math3D_LineSegVsPlane.s,Math3D_LineSegVsPlane,0x8017D2FC,0x42 asm/non_matchings/code/sys_math3d/func_8017D404.s,func_8017D404,0x8017D404,0x59 asm/non_matchings/code/sys_math3d/Math3D_TriSetCoords.s,Math3D_TriSetCoords,0x8017D568,0x2C asm/non_matchings/code/sys_math3d/Math3D_IsPointInSphere.s,Math3D_IsPointInSphere,0x8017D618,0x14 @@ -3064,140 +3064,138 @@ asm/non_matchings/code/audio_synthesis/func_8018A768.s,func_8018A768,0x8018A768, asm/non_matchings/code/audio_synthesis/func_8018A808.s,func_8018A808,0x8018A808,0x12F asm/non_matchings/code/audio_synthesis/func_8018ACC4.s,func_8018ACC4,0x8018ACC4,0x5C asm/non_matchings/code/audio_synthesis/func_8018AE34.s,func_8018AE34,0x8018AE34,0xAF -asm/non_matchings/code/audio_heap/func_8018B0F0.s,func_8018B0F0,0x8018B0F0,0x7 -asm/non_matchings/code/audio_heap/func_8018B10C.s,func_8018B10C,0x8018B10C,0x51 -asm/non_matchings/code/audio_heap/func_8018B250.s,func_8018B250,0x8018B250,0x32 -asm/non_matchings/code/audio_heap/func_8018B318.s,func_8018B318,0x8018B318,0x39 -asm/non_matchings/code/audio_heap/func_8018B3FC.s,func_8018B3FC,0x8018B3FC,0x1E -asm/non_matchings/code/audio_heap/func_8018B474.s,func_8018B474,0x8018B474,0x21 -asm/non_matchings/code/audio_heap/func_8018B4F8.s,func_8018B4F8,0x8018B4F8,0xA -asm/non_matchings/code/audio_heap/func_8018B520.s,func_8018B520,0x8018B520,0x16 -asm/non_matchings/code/audio_heap/func_8018B578.s,func_8018B578,0x8018B578,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_ResetLoadStatus.s,AudioHeap_ResetLoadStatus,0x8018B250,0x32 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s,AudioHeap_DiscardFont,0x8018B318,0x39 +asm/non_matchings/code/audio_heap/AudioHeap_ReleaseNotesForFont.s,AudioHeap_ReleaseNotesForFont,0x8018B3FC,0x1E +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSequence.s,AudioHeap_DiscardSequence,0x8018B474,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_WritebackDCache.s,AudioHeap_WritebackDCache,0x8018B4F8,0xA +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroedAttemptExternal.s,AudioHeap_AllocZeroedAttemptExternal,0x8018B520,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocAttemptExternal.s,AudioHeap_AllocAttemptExternal,0x8018B578,0x16 asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemory.s,AudioHeap_AllocDmaMemory,0x8018B5D0,0xE -asm/non_matchings/code/audio_heap/func_8018B608.s,func_8018B608,0x8018B608,0xE -asm/non_matchings/code/audio_heap/func_8018B640.s,func_8018B640,0x8018B640,0x17 -asm/non_matchings/code/audio_heap/func_8018B69C.s,func_8018B69C,0x8018B69C,0x13 -asm/non_matchings/code/audio_heap/func_8018B6E8.s,func_8018B6E8,0x8018B6E8,0x16 -asm/non_matchings/code/audio_heap/func_8018B740.s,func_8018B740,0x8018B740,0xA -asm/non_matchings/code/audio_heap/func_8018B768.s,func_8018B768,0x8018B768,0x5 -asm/non_matchings/code/audio_heap/func_8018B77C.s,func_8018B77C,0x8018B77C,0xC -asm/non_matchings/code/audio_heap/func_8018B7AC.s,func_8018B7AC,0x8018B7AC,0x4 -asm/non_matchings/code/audio_heap/func_8018B7BC.s,func_8018B7BC,0x8018B7BC,0x50 -asm/non_matchings/code/audio_heap/func_8018B8FC.s,func_8018B8FC,0x8018B8FC,0x18 -asm/non_matchings/code/audio_heap/func_8018B95C.s,func_8018B95C,0x8018B95C,0x21 -asm/non_matchings/code/audio_heap/func_8018B9E0.s,func_8018B9E0,0x8018B9E0,0x21 -asm/non_matchings/code/audio_heap/func_8018BA64.s,func_8018BA64,0x8018BA64,0x31 -asm/non_matchings/code/audio_heap/func_8018BB28.s,func_8018BB28,0x8018BB28,0x31 -asm/non_matchings/code/audio_heap/func_8018BBEC.s,func_8018BBEC,0x8018BBEC,0x1E5 -asm/non_matchings/code/audio_heap/func_8018C380.s,func_8018C380,0x8018C380,0x16 -asm/non_matchings/code/audio_heap/func_8018C3D8.s,func_8018C3D8,0x8018C3D8,0x43 +asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemoryZeroed.s,AudioHeap_AllocDmaMemoryZeroed,0x8018B608,0xE +asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17 +asm/non_matchings/code/audio_heap/AudioHeap_TestAlloc.s,AudioHeap_TestAlloc,0x8018B69C,0x13 +asm/non_matchings/code/audio_heap/Audio_Alloc.s,Audio_Alloc,0x8018B6E8,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s,AudioHeap_AllocPoolInit,0x8018B740,0xA +asm/non_matchings/code/audio_heap/AudioHeap_ClearPersistentCache.s,AudioHeap_ClearPersistentCache,0x8018B768,0x5 +asm/non_matchings/code/audio_heap/AudioHeap_ClearTemporaryCache.s,AudioHeap_ClearTemporaryCache,0x8018B77C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ResetPool.s,AudioHeap_ResetPool,0x8018B7AC,0x4 +asm/non_matchings/code/audio_heap/AudioHeap_PopCache.s,AudioHeap_PopCache,0x8018B7BC,0x50 +asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18 +asm/non_matchings/code/audio_heap/AudioHeap_InitSessionPool.s,AudioHeap_InitSessionPool,0x8018B95C,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitCachePool.s,AudioHeap_InitCachePool,0x8018B9E0,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018BA64,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018BB28,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s,AudioHeap_AllocCached,0x8018BBEC,0x1E5 +asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s,AudioHeap_SearchCaches,0x8018C380,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_SearchRegularCaches.s,AudioHeap_SearchRegularCaches,0x8018C3D8,0x43 asm/non_matchings/code/audio_heap/func_8018C4E4.s,func_8018C4E4,0x8018C4E4,0xF5 -asm/non_matchings/code/audio_heap/func_8018C8B8.s,func_8018C8B8,0x8018C8B8,0xC -asm/non_matchings/code/audio_heap/func_8018C8E8.s,func_8018C8E8,0x8018C8E8,0x15 -asm/non_matchings/code/audio_heap/func_8018C93C.s,func_8018C93C,0x8018C93C,0x16 -asm/non_matchings/code/audio_heap/func_8018C994.s,func_8018C994,0x8018C994,0x77 -asm/non_matchings/code/audio_heap/func_8018CB70.s,func_8018CB70,0x8018CB70,0x2 -asm/non_matchings/code/audio_heap/func_8018CB78.s,func_8018CB78,0x8018CB78,0x31 -asm/non_matchings/code/audio_heap/func_8018CC3C.s,func_8018CC3C,0x8018CC3C,0x1B -asm/non_matchings/code/audio_heap/func_8018CCA8.s,func_8018CCA8,0x8018CCA8,0xC1 -asm/non_matchings/code/audio_heap/func_8018CFAC.s,func_8018CFAC,0x8018CFAC,0x174 -asm/non_matchings/code/audio_heap/func_8018D57C.s,func_8018D57C,0x8018D57C,0x16 -asm/non_matchings/code/audio_heap/func_8018D5D4.s,func_8018D5D4,0x8018D5D4,0x21 -asm/non_matchings/code/audio_heap/func_8018D658.s,func_8018D658,0x8018D658,0x1C -asm/non_matchings/code/audio_heap/func_8018D6C8.s,func_8018D6C8,0x8018D6C8,0x26 -asm/non_matchings/code/audio_heap/func_8018D760.s,func_8018D760,0x8018D760,0xBC -asm/non_matchings/code/audio_heap/func_8018DA50.s,func_8018DA50,0x8018DA50,0x5D -asm/non_matchings/code/audio_heap/func_8018DBC4.s,func_8018DBC4,0x8018DBC4,0x3C -asm/non_matchings/code/audio_heap/func_8018DCB4.s,func_8018DCB4,0x8018DCB4,0x11 -asm/non_matchings/code/audio_heap/func_8018DCF8.s,func_8018DCF8,0x8018DCF8,0x28 -asm/non_matchings/code/audio_heap/func_8018DD98.s,func_8018DD98,0x8018DD98,0xF -asm/non_matchings/code/audio_heap/func_8018DDD4.s,func_8018DDD4,0x8018DDD4,0x54 -asm/non_matchings/code/audio_heap/func_8018DF24.s,func_8018DF24,0x8018DF24,0x2F -asm/non_matchings/code/audio_heap/func_8018DFE0.s,func_8018DFE0,0x8018DFE0,0xB -asm/non_matchings/code/audio_heap/func_8018E00C.s,func_8018E00C,0x8018E00C,0xC -asm/non_matchings/code/audio_heap/func_8018E03C.s,func_8018E03C,0x8018E03C,0x9B -asm/non_matchings/code/audio_heap/func_8018E2A8.s,func_8018E2A8,0x8018E2A8,0x27 -asm/non_matchings/code/audio_heap/func_8018E344.s,func_8018E344,0x8018E344,0x161 -asm/non_matchings/code/audio_heap/func_8018E8C8.s,func_8018E8C8,0x8018E8C8,0xA6 -asm/non_matchings/code/audio_load/func_8018EB60.s,func_8018EB60,0x8018EB60,0x3B -asm/non_matchings/code/audio_load/func_8018EC4C.s,func_8018EC4C,0x8018EC4C,0xCF -asm/non_matchings/code/audio_load/func_8018EF88.s,func_8018EF88,0x8018EF88,0xA6 +asm/non_matchings/code/audio_heap/AudioHeap_ClearFilter.s,AudioHeap_ClearFilter,0x8018C8B8,0xC +asm/non_matchings/code/audio_heap/AudioHeap_LoadLowPassFilter.s,AudioHeap_LoadLowPassFilter,0x8018C8E8,0x15 +asm/non_matchings/code/audio_heap/AudioHeap_LoadHighPassFilter.s,AudioHeap_LoadHighPassFilter,0x8018C93C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_LoadFilter.s,AudioHeap_LoadFilter,0x8018C994,0x77 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverb.s,AudioHeap_UpdateReverb,0x8018CB70,0x2 +asm/non_matchings/code/audio_heap/AudioHeap_UpdateReverbs.s,AudioHeap_UpdateReverbs,0x8018CB78,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_ClearAiBuffers.s,AudioHeap_ClearAiBuffers,0x8018CC3C,0x1B +asm/non_matchings/code/audio_heap/AudioHeap_ResetStep.s,AudioHeap_ResetStep,0x8018CCA8,0xC1 +asm/non_matchings/code/audio_heap/AudioHeap_Init.s,AudioHeap_Init,0x8018CFAC,0x174 +asm/non_matchings/code/audio_heap/AudioHeap_SearchPermanentCache.s,AudioHeap_SearchPermanentCache,0x8018D57C,0x16 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPermanent.s,AudioHeap_AllocPermanent,0x8018D5D4,0x21 +asm/non_matchings/code/audio_heap/AudioHeap_AllocSampleCache.s,AudioHeap_AllocSampleCache,0x8018D658,0x1C +asm/non_matchings/code/audio_heap/AudioHeap_InitSampleCaches.s,AudioHeap_InitSampleCaches,0x8018D6C8,0x26 +asm/non_matchings/code/audio_heap/AudioHeap_AllocTemporarySampleCacheEntry.s,AudioHeap_AllocTemporarySampleCacheEntry,0x8018D760,0xBC +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCacheForFont.s,AudioHeap_UnapplySampleCacheForFont,0x8018DA50,0x5D +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheEntry.s,AudioHeap_DiscardSampleCacheEntry,0x8018DBC4,0x3C +asm/non_matchings/code/audio_heap/AudioHeap_UnapplySampleCache.s,AudioHeap_UnapplySampleCache,0x8018DCB4,0x11 +asm/non_matchings/code/audio_heap/AudioHeap_AllocPersistentSampleCacheEntry.s,AudioHeap_AllocPersistentSampleCacheEntry,0x8018DCF8,0x28 +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCacheForFont.s,AudioHeap_DiscardSampleCacheForFont,0x8018DD98,0xF +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleCaches.s,AudioHeap_DiscardSampleCaches,0x8018DDD4,0x54 +asm/non_matchings/code/audio_heap/AudioHeap_ChangeStorage.s,AudioHeap_ChangeStorage,0x8018DF24,0x2F +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBank.s,AudioHeap_DiscardSampleBank,0x8018DFE0,0xB +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCache.s,AudioHeap_ApplySampleBankCache,0x8018E00C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_ApplySampleBankCacheInternal.s,AudioHeap_ApplySampleBankCacheInternal,0x8018E03C,0x9B +asm/non_matchings/code/audio_heap/AudioHeap_DiscardSampleBanks.s,AudioHeap_DiscardSampleBanks,0x8018E2A8,0x27 +asm/non_matchings/code/audio_heap/AudioHeap_SetReverbData.s,AudioHeap_SetReverbData,0x8018E344,0x161 +asm/non_matchings/code/audio_heap/AudioHeap_InitReverb.s,AudioHeap_InitReverb,0x8018E8C8,0xA6 +asm/non_matchings/code/audio_load/AudioLoad_DecreaseSampleDmaTtls.s,AudioLoad_DecreaseSampleDmaTtls,0x8018EB60,0x3B +asm/non_matchings/code/audio_load/AudioLoad_DmaSampleData.s,AudioLoad_DmaSampleData,0x8018EC4C,0xCF +asm/non_matchings/code/audio_load/AudioLoad_InitSampleDmaBuffers.s,AudioLoad_InitSampleDmaBuffers,0x8018EF88,0xA6 asm/non_matchings/code/audio_load/AudioLoad_IsFontLoadComplete.s,AudioLoad_IsFontLoadComplete,0x8018F220,0x1E -asm/non_matchings/code/audio_load/func_8018F298.s,func_8018F298,0x8018F298,0x1E -asm/non_matchings/code/audio_load/func_8018F310.s,func_8018F310,0x8018F310,0x1E -asm/non_matchings/code/audio_load/func_8018F388.s,func_8018F388,0x8018F388,0xC -asm/non_matchings/code/audio_load/func_8018F3B8.s,func_8018F3B8,0x8018F3B8,0xC -asm/non_matchings/code/audio_load/func_8018F3E8.s,func_8018F3E8,0x8018F3E8,0x18 -asm/non_matchings/code/audio_load/func_8018F448.s,func_8018F448,0x8018F448,0xC -asm/non_matchings/code/audio_load/func_8018F478.s,func_8018F478,0x8018F478,0x18 -asm/non_matchings/code/audio_load/func_8018F4D8.s,func_8018F4D8,0x8018F4D8,0x2C -asm/non_matchings/code/audio_load/func_8018F588.s,func_8018F588,0x8018F588,0x1F -asm/non_matchings/code/audio_load/func_8018F604.s,func_8018F604,0x8018F604,0x3B -asm/non_matchings/code/audio_load/func_8018F6F0.s,func_8018F6F0,0x8018F6F0,0x34 -asm/non_matchings/code/audio_load/func_8018F7C0.s,func_8018F7C0,0x8018F7C0,0xE -asm/non_matchings/code/audio_load/func_8018F7F8.s,func_8018F7F8,0x8018F7F8,0x11 -asm/non_matchings/code/audio_load/func_8018F83C.s,func_8018F83C,0x8018F83C,0x11 -asm/non_matchings/code/audio_load/func_8018F880.s,func_8018F880,0x8018F880,0x11 -asm/non_matchings/code/audio_load/func_8018F8C4.s,func_8018F8C4,0x8018F8C4,0x11 -asm/non_matchings/code/audio_load/func_8018F908.s,func_8018F908,0x8018F908,0x2C -asm/non_matchings/code/audio_load/func_8018F9B8.s,func_8018F9B8,0x8018F9B8,0x2A +asm/non_matchings/code/audio_load/AudioLoad_IsSeqLoadComplete.s,AudioLoad_IsSeqLoadComplete,0x8018F298,0x1E +asm/non_matchings/code/audio_load/AudioLoad_IsSampleLoadComplete.s,AudioLoad_IsSampleLoadComplete,0x8018F310,0x1E +asm/non_matchings/code/audio_load/AudioLoad_SetFontLoadStatus.s,AudioLoad_SetFontLoadStatus,0x8018F388,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSeqLoadStatus.s,AudioLoad_SetSeqLoadStatus,0x8018F3B8,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatusAndApplyCaches.s,AudioLoad_SetSampleFontLoadStatusAndApplyCaches,0x8018F3E8,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SetSampleFontLoadStatus.s,AudioLoad_SetSampleFontLoadStatus,0x8018F448,0xC +asm/non_matchings/code/audio_load/AudioLoad_InitTable.s,AudioLoad_InitTable,0x8018F478,0x18 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqFonts.s,AudioLoad_SyncLoadSeqFonts,0x8018F4D8,0x2C +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeqParts.s,AudioLoad_SyncLoadSeqParts,0x8018F588,0x1F +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSample.s,AudioLoad_SyncLoadSample,0x8018F604,0x3B +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadInstrument.s,AudioLoad_SyncLoadInstrument,0x8018F6F0,0x34 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoad.s,AudioLoad_AsyncLoad,0x8018F7C0,0xE +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSeq.s,AudioLoad_AsyncLoadSeq,0x8018F7F8,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadSampleBank.s,AudioLoad_AsyncLoadSampleBank,0x8018F83C,0x11 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadFont.s,AudioLoad_AsyncLoadFont,0x8018F880,0x11 +asm/non_matchings/code/audio_load/AudioLoad_GetFontsForSequence.s,AudioLoad_GetFontsForSequence,0x8018F8C4,0x11 +asm/non_matchings/code/audio_load/AudioLoad_DiscardSeqFonts.s,AudioLoad_DiscardSeqFonts,0x8018F908,0x2C +asm/non_matchings/code/audio_load/AudioLoad_DiscardFont.s,AudioLoad_DiscardFont,0x8018F9B8,0x2A asm/non_matchings/code/audio_load/func_8018FA60.s,func_8018FA60,0x8018FA60,0x1C -asm/non_matchings/code/audio_load/func_8018FAD0.s,func_8018FAD0,0x8018FAD0,0x14 -asm/non_matchings/code/audio_load/func_8018FB20.s,func_8018FB20,0x8018FB20,0x16 -asm/non_matchings/code/audio_load/func_8018FB78.s,func_8018FB78,0x8018FB78,0x55 -asm/non_matchings/code/audio_load/func_8018FCCC.s,func_8018FCCC,0x8018FCCC,0x15 -asm/non_matchings/code/audio_load/func_8018FD20.s,func_8018FD20,0x8018FD20,0x8 -asm/non_matchings/code/audio_load/func_8018FD40.s,func_8018FD40,0x8018FD40,0x47 -asm/non_matchings/code/audio_load/func_8018FE5C.s,func_8018FE5C,0x8018FE5C,0x41 -asm/non_matchings/code/audio_load/func_8018FF60.s,func_8018FF60,0x8018FF60,0xA9 -asm/non_matchings/code/audio_load/func_80190204.s,func_80190204,0x80190204,0xF -asm/non_matchings/code/audio_load/func_80190240.s,func_80190240,0x80190240,0x15 -asm/non_matchings/code/audio_load/func_80190294.s,func_80190294,0x80190294,0x11 -asm/non_matchings/code/audio_load/func_801902D8.s,func_801902D8,0x801902D8,0x9B -asm/non_matchings/code/audio_load/func_80190544.s,func_80190544,0x80190544,0x49 -asm/non_matchings/code/audio_load/func_80190668.s,func_80190668,0x80190668,0x5 -asm/non_matchings/code/audio_load/func_8019067C.s,func_8019067C,0x8019067C,0x36 -asm/non_matchings/code/audio_load/func_80190754.s,func_80190754,0x80190754,0x2 -asm/non_matchings/code/audio_load/func_8019075C.s,func_8019075C,0x8019075C,0x8 -asm/non_matchings/code/audio_load/func_8019077C.s,func_8019077C,0x8019077C,0xE3 -asm/non_matchings/code/audio_load/func_80190B08.s,func_80190B08,0x80190B08,0xC -asm/non_matchings/code/audio_load/func_80190B38.s,func_80190B38,0x80190B38,0x3 -asm/non_matchings/code/audio_load/func_80190B44.s,func_80190B44,0x80190B44,0x3 -asm/non_matchings/code/audio_load/func_80190B50.s,func_80190B50,0x80190B50,0x18 -asm/non_matchings/code/audio_load/func_80190BB0.s,func_80190BB0,0x80190BB0,0xE8 -asm/non_matchings/code/audio_load/func_80190F50.s,func_80190F50,0x80190F50,0x5 -asm/non_matchings/code/audio_load/func_80190F64.s,func_80190F64,0x80190F64,0x74 -asm/non_matchings/code/audio_load/func_80191134.s,func_80191134,0x80191134,0x24 -asm/non_matchings/code/audio_load/func_801911C4.s,func_801911C4,0x801911C4,0x2 -asm/non_matchings/code/audio_load/func_801911CC.s,func_801911CC,0x801911CC,0x1D -asm/non_matchings/code/audio_load/func_80191240.s,func_80191240,0x80191240,0x62 -asm/non_matchings/code/audio_load/func_801913C8.s,func_801913C8,0x801913C8,0x21 -asm/non_matchings/code/audio_load/func_8019144C.s,func_8019144C,0x8019144C,0x5 -asm/non_matchings/code/audio_load/func_80191460.s,func_80191460,0x80191460,0x42 -asm/non_matchings/code/audio_load/func_80191568.s,func_80191568,0x80191568,0xC -asm/non_matchings/code/audio_load/func_80191598.s,func_80191598,0x80191598,0x21 -asm/non_matchings/code/audio_load/func_8019161C.s,func_8019161C,0x8019161C,0x49 -asm/non_matchings/code/audio_load/func_80191740.s,func_80191740,0x80191740,0x49 -asm/non_matchings/code/audio_load/func_80191864.s,func_80191864,0x80191864,0x3 -asm/non_matchings/code/audio_load/func_80191870.s,func_80191870,0x80191870,0x4F -asm/non_matchings/code/audio_load/func_801919AC.s,func_801919AC,0x801919AC,0x65 -asm/non_matchings/code/audio_load/func_80191B40.s,func_80191B40,0x80191B40,0x24 -asm/non_matchings/code/audio_load/func_80191BD0.s,func_80191BD0,0x80191BD0,0x1C -asm/non_matchings/code/audio_load/func_80191C40.s,func_80191C40,0x80191C40,0x5 -asm/non_matchings/code/audio_load/func_80191C54.s,func_80191C54,0x80191C54,0x50 -asm/non_matchings/code/audio_load/func_80191D94.s,func_80191D94,0x80191D94,0xFE -asm/non_matchings/code/audio_load/func_8019218C.s,func_8019218C,0x8019218C,0x6D -asm/non_matchings/code/audio_load/func_80192340.s,func_80192340,0x80192340,0x12 -asm/non_matchings/code/audio_load/func_80192388.s,func_80192388,0x80192388,0x4D -asm/non_matchings/code/audio_load/func_801924BC.s,func_801924BC,0x801924BC,0x16 -asm/non_matchings/code/audio_load/func_80192514.s,func_80192514,0x80192514,0x11F -asm/non_matchings/code/audio_load/func_80192990.s,func_80192990,0x80192990,0x50 -asm/non_matchings/code/audio_load/func_80192AD0.s,func_80192AD0,0x80192AD0,0x2 -asm/non_matchings/code/audio_load/func_80192AD8.s,func_80192AD8,0x80192AD8,0x2 -asm/non_matchings/code/audio_load/func_80192AE0.s,func_80192AE0,0x80192AE0,0x2 -asm/non_matchings/code/audio_load/func_80192AE8.s,func_80192AE8,0x80192AE8,0x1B -asm/non_matchings/code/audio_load/func_80192B54.s,func_80192B54,0x80192B54,0x16 -asm/non_matchings/code/audio_load/func_80192BAC.s,func_80192BAC,0x80192BAC,0xD +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayer.s,AudioLoad_SyncInitSeqPlayer,0x8018FAD0,0x14 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerSkipTicks.s,AudioLoad_SyncInitSeqPlayerSkipTicks,0x8018FB20,0x16 +asm/non_matchings/code/audio_load/AudioLoad_SyncInitSeqPlayerInternal.s,AudioLoad_SyncInitSeqPlayerInternal,0x8018FB78,0x55 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSeq.s,AudioLoad_SyncLoadSeq,0x8018FCCC,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetSampleBank.s,AudioLoad_GetSampleBank,0x8018FD20,0x8 +asm/non_matchings/code/audio_load/AudioLoad_TrySyncLoadSampleBank.s,AudioLoad_TrySyncLoadSampleBank,0x8018FD40,0x47 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadFont.s,AudioLoad_SyncLoadFont,0x8018FE5C,0x41 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoad.s,AudioLoad_SyncLoad,0x8018FF60,0xA9 +asm/non_matchings/code/audio_load/AudioLoad_GetRealTableIndex.s,AudioLoad_GetRealTableIndex,0x80190204,0xF +asm/non_matchings/code/audio_load/AudioLoad_SearchCaches.s,AudioLoad_SearchCaches,0x80190240,0x15 +asm/non_matchings/code/audio_load/AudioLoad_GetLoadTable.s,AudioLoad_GetLoadTable,0x80190294,0x11 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFont.s,AudioLoad_RelocateFont,0x801902D8,0x9B +asm/non_matchings/code/audio_load/AudioLoad_SyncDma.s,AudioLoad_SyncDma,0x80190544,0x49 +asm/non_matchings/code/audio_load/AudioLoad_SyncDmaUnkMedium.s,AudioLoad_SyncDmaUnkMedium,0x80190668,0x5 +asm/non_matchings/code/audio_load/AudioLoad_Dma.s,AudioLoad_Dma,0x8019067C,0x36 +asm/non_matchings/code/audio_load/AudioLoad_Unused1.s,AudioLoad_Unused1,0x80190754,0x2 +asm/non_matchings/code/audio_load/AudioLoad_SyncLoadSimple.s,AudioLoad_SyncLoadSimple,0x8019075C,0x8 +asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadInner.s,AudioLoad_AsyncLoadInner,0x8019077C,0xE3 +asm/non_matchings/code/audio_load/AudioLoad_ProcessLoads.s,AudioLoad_ProcessLoads,0x80190B08,0xC +asm/non_matchings/code/audio_load/AudioLoad_SetDmaHandler.s,AudioLoad_SetDmaHandler,0x80190B38,0x3 +asm/non_matchings/code/audio_load/AudioLoad_SetUnusedHandler.s,AudioLoad_SetUnusedHandler,0x80190B44,0x3 +asm/non_matchings/code/audio_load/AudioLoad_InitSoundFontMeta.s,AudioLoad_InitSoundFontMeta,0x80190B50,0x18 +asm/non_matchings/code/audio_load/AudioLoad_Init.s,AudioLoad_Init,0x80190BB0,0xE8 +asm/non_matchings/code/audio_load/AudioLoad_InitSlowLoads.s,AudioLoad_InitSlowLoads,0x80190F50,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSample.s,AudioLoad_SlowLoadSample,0x80190F64,0x74 +asm/non_matchings/code/audio_load/AudioLoad_GetFontSample.s,AudioLoad_GetFontSample,0x80191134,0x24 +asm/non_matchings/code/audio_load/AudioLoad_Unused2.s,AudioLoad_Unused2,0x801911C4,0x2 +asm/non_matchings/code/audio_load/AudioLoad_FinishSlowLoad.s,AudioLoad_FinishSlowLoad,0x801911CC,0x1D +asm/non_matchings/code/audio_load/AudioLoad_ProcessSlowLoads.s,AudioLoad_ProcessSlowLoads,0x80191240,0x62 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopy.s,AudioLoad_DmaSlowCopy,0x801913C8,0x21 +asm/non_matchings/code/audio_load/AudioLoad_DmaSlowCopyUnkMedium.s,AudioLoad_DmaSlowCopyUnkMedium,0x8019144C,0x5 +asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSeq.s,AudioLoad_SlowLoadSeq,0x80191460,0x42 +asm/non_matchings/code/audio_load/AudioLoad_InitAsyncLoads.s,AudioLoad_InitAsyncLoads,0x80191568,0xC +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoadUnkMedium.s,AudioLoad_StartAsyncLoadUnkMedium,0x80191598,0x21 +asm/non_matchings/code/audio_load/AudioLoad_StartAsyncLoad.s,AudioLoad_StartAsyncLoad,0x8019161C,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoads.s,AudioLoad_ProcessAsyncLoads,0x80191740,0x49 +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoadUnkMedium.s,AudioLoad_ProcessAsyncLoadUnkMedium,0x80191864,0x3 +asm/non_matchings/code/audio_load/AudioLoad_FinishAsyncLoad.s,AudioLoad_FinishAsyncLoad,0x80191870,0x4F +asm/non_matchings/code/audio_load/AudioLoad_ProcessAsyncLoad.s,AudioLoad_ProcessAsyncLoad,0x801919AC,0x65 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDma.s,AudioLoad_AsyncDma,0x80191B40,0x24 +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaRamUnloaded.s,AudioLoad_AsyncDmaRamUnloaded,0x80191BD0,0x1C +asm/non_matchings/code/audio_load/AudioLoad_AsyncDmaUnkMedium.s,AudioLoad_AsyncDmaUnkMedium,0x80191C40,0x5 +asm/non_matchings/code/audio_load/AudioLoad_RelocateSample.s,AudioLoad_RelocateSample,0x80191C54,0x50 +asm/non_matchings/code/audio_load/AudioLoad_RelocateFontAndPreloadSamples.s,AudioLoad_RelocateFontAndPreloadSamples,0x80191D94,0xFE +asm/non_matchings/code/audio_load/AudioLoad_ProcessSamplePreloads.s,AudioLoad_ProcessSamplePreloads,0x8019218C,0x6D +asm/non_matchings/code/audio_load/AudioLoad_AddToSampleSet.s,AudioLoad_AddToSampleSet,0x80192340,0x12 +asm/non_matchings/code/audio_load/AudioLoad_GetSamplesForFont.s,AudioLoad_GetSamplesForFont,0x80192388,0x4D +asm/non_matchings/code/audio_load/AudioLoad_AddUsedSample.s,AudioLoad_AddUsedSample,0x801924BC,0x16 +asm/non_matchings/code/audio_load/AudioLoad_PreloadSamplesForFont.s,AudioLoad_PreloadSamplesForFont,0x80192514,0x11F +asm/non_matchings/code/audio_load/AudioLoad_LoadPermanentSamples.s,AudioLoad_LoadPermanentSamples,0x80192990,0x50 +asm/non_matchings/code/audio_load/AudioLoad_Unused3.s,AudioLoad_Unused3,0x80192AD0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused4.s,AudioLoad_Unused4,0x80192AD8,0x2 +asm/non_matchings/code/audio_load/AudioLoad_Unused5.s,AudioLoad_Unused5,0x80192AE0,0x2 +asm/non_matchings/code/audio_load/AudioLoad_ScriptLoad.s,AudioLoad_ScriptLoad,0x80192AE8,0x1B +asm/non_matchings/code/audio_load/AudioLoad_ProcessScriptLoads.s,AudioLoad_ProcessScriptLoads,0x80192B54,0x16 +asm/non_matchings/code/audio_load/AudioLoad_InitScriptLoads.s,AudioLoad_InitScriptLoads,0x80192BAC,0xD asm/non_matchings/code/code_80192BE0/func_80192BE0.s,func_80192BE0,0x80192BE0,0x8 asm/non_matchings/code/code_80192BE0/func_80192C00.s,func_80192C00,0x80192C00,0x167 asm/non_matchings/code/code_80192BE0/func_8019319C.s,func_8019319C,0x8019319C,0x14F @@ -3207,7 +3205,7 @@ asm/non_matchings/code/code_80192BE0/func_80193774.s,func_80193774,0x80193774,0x asm/non_matchings/code/code_80192BE0/func_8019380C.s,func_8019380C,0x8019380C,0x13 asm/non_matchings/code/code_80192BE0/func_80193858.s,func_80193858,0x80193858,0x9 asm/non_matchings/code/code_80192BE0/func_8019387C.s,func_8019387C,0x8019387C,0x9 -asm/non_matchings/code/code_80192BE0/func_801938A0.s,func_801938A0,0x801938A0,0xC +asm/non_matchings/code/code_80192BE0/Audio_QueueCmdS8.s,Audio_QueueCmdS8,0x801938A0,0xC asm/non_matchings/code/code_80192BE0/func_801938D0.s,func_801938D0,0x801938D0,0xC asm/non_matchings/code/code_80192BE0/func_80193900.s,func_80193900,0x80193900,0x24 asm/non_matchings/code/code_80192BE0/func_80193990.s,func_80193990,0x80193990,0x6 @@ -3236,8 +3234,8 @@ asm/non_matchings/code/code_80192BE0/func_8019440C.s,func_8019440C,0x8019440C,0x asm/non_matchings/code/code_80192BE0/func_80194528.s,func_80194528,0x80194528,0x8 asm/non_matchings/code/code_80192BE0/func_80194548.s,func_80194548,0x80194548,0x8 asm/non_matchings/code/code_80192BE0/func_80194568.s,func_80194568,0x80194568,0x40 -asm/non_matchings/code/code_80192BE0/func_80194668.s,func_80194668,0x80194668,0x1F -asm/non_matchings/code/code_80192BE0/func_801946E4.s,func_801946E4,0x801946E4,0xB +asm/non_matchings/code/code_80192BE0/Audio_NextRandom.s,Audio_NextRandom,0x80194668,0x1F +asm/non_matchings/code/code_80192BE0/Audio_InitMesgQueues.s,Audio_InitMesgQueues,0x801946E4,0xB asm/non_matchings/code/code_80194710/Audio_InvalDCache.s,Audio_InvalDCache,0x80194710,0x10 asm/non_matchings/code/code_80194710/Audio_WritebackDCache.s,Audio_WritebackDCache,0x80194750,0x10 asm/non_matchings/code/code_80194710/func_80194790.s,func_80194790,0x80194790,0x1D @@ -3295,7 +3293,7 @@ asm/non_matchings/code/audio_seqplayer/AudioSeq_SequenceChannelDisable.s,AudioSe asm/non_matchings/code/audio_seqplayer/func_80197B14.s,func_80197B14,0x80197B14,0x3E asm/non_matchings/code/audio_seqplayer/func_80197C0C.s,func_80197C0C,0x80197C0C,0x20 asm/non_matchings/code/audio_seqplayer/func_80197C8C.s,func_80197C8C,0x80197C8C,0x26 -asm/non_matchings/code/audio_seqplayer/func_80197D24.s,func_80197D24,0x80197D24,0xA +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 @@ -3317,23 +3315,23 @@ asm/non_matchings/code/audio_seqplayer/func_80199268.s,func_80199268,0x80199268, asm/non_matchings/code/audio_seqplayer/func_8019A0BC.s,func_8019A0BC,0x8019A0BC,0x260 asm/non_matchings/code/audio_seqplayer/func_8019AA3C.s,func_8019AA3C,0x8019AA3C,0x2D asm/non_matchings/code/audio_seqplayer/func_8019AAF0.s,func_8019AAF0,0x8019AAF0,0x14 -asm/non_matchings/code/audio_seqplayer/func_8019AB40.s,func_8019AB40,0x8019AB40,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019AC10.s,func_8019AC10,0x8019AC10,0x37 +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/func_8019ACEC.s,func_8019ACEC,0x8019ACEC,0x34 -asm/non_matchings/code/audio_seqplayer/func_8019ADBC.s,func_8019ADBC,0x8019ADBC,0x21 +asm/non_matchings/code/audio_seqplayer/AudioSeq_InitSequencePlayers.s,AudioSeq_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/func_8019AF00.s,func_8019AF00,0x8019AF00,0x16 asm/non_matchings/code/code_8019AF00/func_8019AF58.s,func_8019AF58,0x8019AF58,0x24 asm/non_matchings/code/code_8019AF00/func_8019AFE8.s,func_8019AFE8,0x8019AFE8,0x11 asm/non_matchings/code/code_8019AF00/func_8019B02C.s,func_8019B02C,0x8019B02C,0x12 -asm/non_matchings/code/code_8019AF00/func_8019B074.s,func_8019B074,0x8019B074,0x34 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MapSongFromNotesToButtons.s,AudioOcarina_MapSongFromNotesToButtons,0x8019B074,0x34 asm/non_matchings/code/code_8019AF00/func_8019B144.s,func_8019B144,0x8019B144,0x8D asm/non_matchings/code/code_8019AF00/func_8019B378.s,func_8019B378,0x8019B378,0x5 asm/non_matchings/code/code_8019AF00/func_8019B38C.s,func_8019B38C,0x8019B38C,0x11 asm/non_matchings/code/code_8019AF00/func_8019B3D0.s,func_8019B3D0,0x8019B3D0,0x3A asm/non_matchings/code/code_8019AF00/func_8019B4B8.s,func_8019B4B8,0x8019B4B8,0x23 -asm/non_matchings/code/code_8019AF00/func_8019B544.s,func_8019B544,0x8019B544,0x9 +asm/non_matchings/code/code_8019AF00/AudioOcarina_StartDefault.s,AudioOcarina_StartDefault,0x8019B544,0x9 asm/non_matchings/code/code_8019AF00/func_8019B568.s,func_8019B568,0x8019B568,0x11 asm/non_matchings/code/code_8019AF00/func_8019B5AC.s,func_8019B5AC,0x8019B5AC,0x10 asm/non_matchings/code/code_8019AF00/func_8019B5EC.s,func_8019B5EC,0x8019B5EC,0xB @@ -3346,7 +3344,7 @@ asm/non_matchings/code/code_8019AF00/func_8019C1C0.s,func_8019C1C0,0x8019C1C0,0x asm/non_matchings/code/code_8019AF00/func_8019C1D0.s,func_8019C1D0,0x8019C1D0,0x26 asm/non_matchings/code/code_8019AF00/func_8019C268.s,func_8019C268,0x8019C268,0x1F asm/non_matchings/code/code_8019AF00/func_8019C2E4.s,func_8019C2E4,0x8019C2E4,0x7 -asm/non_matchings/code/code_8019AF00/func_8019C300.s,func_8019C300,0x8019C300,0x26 +asm/non_matchings/code/code_8019AF00/AudioOcarina_SetInstrumentId.s,AudioOcarina_SetInstrumentId,0x8019C300,0x26 asm/non_matchings/code/code_8019AF00/func_8019C398.s,func_8019C398,0x8019C398,0x82 asm/non_matchings/code/code_8019AF00/func_8019C5A0.s,func_8019C5A0,0x8019C5A0,0xCE asm/non_matchings/code/code_8019AF00/func_8019C8D8.s,func_8019C8D8,0x8019C8D8,0x10C @@ -3356,12 +3354,12 @@ asm/non_matchings/code/code_8019AF00/func_8019CE6C.s,func_8019CE6C,0x8019CE6C,0x asm/non_matchings/code/code_8019AF00/func_8019CEBC.s,func_8019CEBC,0x8019CEBC,0x2C asm/non_matchings/code/code_8019AF00/func_8019CF6C.s,func_8019CF6C,0x8019CF6C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CF78.s,func_8019CF78,0x8019CF78,0x9 -asm/non_matchings/code/code_8019AF00/func_8019CF9C.s,func_8019CF9C,0x8019CF9C,0x3 +asm/non_matchings/code/code_8019AF00/AudioOcarina_GetPlaybackStaff.s,AudioOcarina_GetPlaybackStaff,0x8019CF9C,0x3 asm/non_matchings/code/code_8019AF00/func_8019CFA8.s,func_8019CFA8,0x8019CFA8,0x63 -asm/non_matchings/code/code_8019AF00/func_8019D134.s,func_8019D134,0x8019D134,0x4E -asm/non_matchings/code/code_8019AF00/func_8019D26C.s,func_8019D26C,0x8019D26C,0x87 -asm/non_matchings/code/code_8019AF00/func_8019D488.s,func_8019D488,0x8019D488,0x1C -asm/non_matchings/code/code_8019AF00/func_8019D4F8.s,func_8019D4F8,0x8019D4F8,0x42 +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallValidateNotes.s,AudioOcarina_TerminaWallValidateNotes,0x8019D134,0x4E +asm/non_matchings/code/code_8019AF00/AudioOcarina_TerminaWallGenerateNotes.s,AudioOcarina_TerminaWallGenerateNotes,0x8019D26C,0x87 +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameSetNumNotes.s,AudioOcarina_MemoryGameSetNumNotes,0x8019D488,0x1C +asm/non_matchings/code/code_8019AF00/AudioOcarina_MemoryGameGenerateNotes.s,AudioOcarina_MemoryGameGenerateNotes,0x8019D4F8,0x42 asm/non_matchings/code/code_8019AF00/func_8019D600.s,func_8019D600,0x8019D600,0x56 asm/non_matchings/code/code_8019AF00/func_8019D758.s,func_8019D758,0x8019D758,0x43 asm/non_matchings/code/code_8019AF00/func_8019D864.s,func_8019D864,0x8019D864,0x14 @@ -3415,18 +3413,18 @@ asm/non_matchings/code/code_8019AF00/func_8019FE1C.s,func_8019FE1C,0x8019FE1C,0x asm/non_matchings/code/code_8019AF00/func_8019FE74.s,func_8019FE74,0x8019FE74,0x1A asm/non_matchings/code/code_8019AF00/func_8019FEDC.s,func_8019FEDC,0x8019FEDC,0x17 asm/non_matchings/code/code_8019AF00/func_8019FF38.s,func_8019FF38,0x8019FF38,0x19 -asm/non_matchings/code/code_8019AF00/func_8019FF9C.s,func_8019FF9C,0x8019FF9C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0048.s,func_801A0048,0x801A0048,0x29 -asm/non_matchings/code/code_8019AF00/func_801A00EC.s,func_801A00EC,0x801A00EC,0xE +asm/non_matchings/code/code_8019AF00/Audio_PlaySfxForRiver.s,Audio_PlaySfxForRiver,0x8019FF9C,0x2B +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/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/func_801A026C.s,func_801A026C,0x801A026C,0x2B -asm/non_matchings/code/code_8019AF00/func_801A0318.s,func_801A0318,0x801A0318,0x4E -asm/non_matchings/code/code_8019AF00/func_801A0450.s,func_801A0450,0x801A0450,0x7 -asm/non_matchings/code/code_8019AF00/func_801A046C.s,func_801A046C,0x801A046C,0x3A +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 +asm/non_matchings/code/code_8019AF00/Audio_UpdateRiverSoundVolumes.s,Audio_UpdateRiverSoundVolumes,0x801A046C,0x3A asm/non_matchings/code/code_8019AF00/func_801A0554.s,func_801A0554,0x801A0554,0x24 asm/non_matchings/code/code_8019AF00/func_801A05E4.s,func_801A05E4,0x801A05E4,0x3 asm/non_matchings/code/code_8019AF00/func_801A05F0.s,func_801A05F0,0x801A05F0,0x19 @@ -3434,9 +3432,9 @@ asm/non_matchings/code/code_8019AF00/func_801A0654.s,func_801A0654,0x801A0654,0x asm/non_matchings/code/code_8019AF00/func_801A0810.s,func_801A0810,0x801A0810,0x16 asm/non_matchings/code/code_8019AF00/func_801A0868.s,func_801A0868,0x801A0868,0x5B asm/non_matchings/code/code_8019AF00/func_801A09D4.s,func_801A09D4,0x801A09D4,0xA7 -asm/non_matchings/code/code_8019AF00/func_801A0C70.s,func_801A0C70,0x801A0C70,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0C90.s,func_801A0C90,0x801A0C90,0x8 -asm/non_matchings/code/code_8019AF00/func_801A0CB0.s,func_801A0CB0,0x801A0CB0,0x65 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm.s,Audio_ClearSariaBgm,0x801A0C70,0x8 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgmAtPos.s,Audio_ClearSariaBgmAtPos,0x801A0C90,0x8 +asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s,Audio_SplitBgmChannels,0x801A0CB0,0x65 asm/non_matchings/code/code_8019AF00/func_801A0E44.s,func_801A0E44,0x801A0E44,0x113 asm/non_matchings/code/code_8019AF00/func_801A1290.s,func_801A1290,0x801A1290,0x2E asm/non_matchings/code/code_8019AF00/func_801A1348.s,func_801A1348,0x801A1348,0x1D @@ -3453,8 +3451,8 @@ asm/non_matchings/code/code_8019AF00/func_801A1F00.s,func_801A1F00,0x801A1F00,0x asm/non_matchings/code/code_8019AF00/func_801A1F88.s,func_801A1F88,0x801A1F88,0xB asm/non_matchings/code/code_8019AF00/func_801A1FB4.s,func_801A1FB4,0x801A1FB4,0x37 asm/non_matchings/code/code_8019AF00/func_801A2090.s,func_801A2090,0x801A2090,0x5B -asm/non_matchings/code/code_8019AF00/func_801A21FC.s,func_801A21FC,0x801A21FC,0x99 -asm/non_matchings/code/code_8019AF00/func_801A2460.s,func_801A2460,0x801A2460,0x3 +asm/non_matchings/code/code_8019AF00/Audio_PlaySariaBgm.s,Audio_PlaySariaBgm,0x801A21FC,0x99 +asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm2.s,Audio_ClearSariaBgm2,0x801A2460,0x3 asm/non_matchings/code/code_8019AF00/func_801A246C.s,func_801A246C,0x801A246C,0x36 asm/non_matchings/code/code_8019AF00/func_801A2544.s,func_801A2544,0x801A2544,0xE asm/non_matchings/code/code_8019AF00/func_801A257C.s,func_801A257C,0x801A257C,0x1A @@ -3496,7 +3494,7 @@ asm/non_matchings/code/code_8019AF00/func_801A3D54.s,func_801A3D54,0x801A3D54,0x asm/non_matchings/code/code_8019AF00/func_801A3D98.s,func_801A3D98,0x801A3D98,0x28 asm/non_matchings/code/code_8019AF00/func_801A3E38.s,func_801A3E38,0x801A3E38,0x22 asm/non_matchings/code/code_8019AF00/func_801A3EC0.s,func_801A3EC0,0x801A3EC0,0x25 -asm/non_matchings/code/code_8019AF00/func_801A3F54.s,func_801A3F54,0x801A3F54,0x6 +asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s,Audio_SetCutsceneFlag,0x801A3F54,0x6 asm/non_matchings/code/code_8019AF00/func_801A3F6C.s,func_801A3F6C,0x801A3F6C,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FB4.s,func_801A3FB4,0x801A3FB4,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FFC.s,func_801A3FFC,0x801A3FFC,0x4 @@ -3568,7 +3566,7 @@ asm/non_matchings/code/code_801A5BD0/func_801A7720.s,func_801A7720,0x801A7720,0x asm/non_matchings/code/code_801A5BD0/func_801A7794.s,func_801A7794,0x801A7794,0x25 asm/non_matchings/code/code_801A5BD0/func_801A7828.s,func_801A7828,0x801A7828,0x15 asm/non_matchings/code/code_801A5BD0/func_801A787C.s,func_801A787C,0x801A787C,0x1A -asm/non_matchings/code/code_801A5BD0/func_801A78E4.s,func_801A78E4,0x801A78E4,0x1A +asm/non_matchings/code/code_801A5BD0/Audio_IsSfxPlaying.s,Audio_IsSfxPlaying,0x801A78E4,0x1A asm/non_matchings/code/code_801A5BD0/func_801A794C.s,func_801A794C,0x801A794C,0x71 asm/non_matchings/code/code_801A7B10/func_801A7B10.s,func_801A7B10,0x801A7B10,0x7D asm/non_matchings/code/code_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 @@ -3579,7 +3577,7 @@ asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x 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/func_801A8BD0.s,func_801A8BD0,0x801A8BD0,0x63 +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 diff --git a/tools/warnings_count/.gitignore b/tools/warnings_count/.gitignore index 5606ab0ef..eaf2f58b5 100644 --- a/tools/warnings_count/.gitignore +++ b/tools/warnings_count/.gitignore @@ -2,3 +2,4 @@ warnings_setup_new.txt warnings_disasm_new.txt warnings_build_new.txt +warnings_temp.txt diff --git a/undefined_syms.txt b/undefined_syms.txt index 30b7873fa..892c20e98 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -396,8 +396,6 @@ D_04020658 = 0x04020658; D_04020BB8 = 0x04020BB8; D_04020D00 = 0x04020D00; D_040221B8 = 0x040221B8; -D_04022B28 = 0x04022B28; -D_04023100 = 0x04023100; D_04023130 = 0x04023130; D_04023210 = 0x04023210; D_04023288 = 0x04023288; @@ -512,13 +510,10 @@ D_05006760 = 0x05006760; D_05007498 = 0x05007498; D_050078A0 = 0x050078A0; D_05007938 = 0x05007938; -D_05007E00 = 0x05007E00; -D_05008018 = 0x05008018; D_050085F0 = 0x050085F0; D_050089D0 = 0x050089D0; D_050182A8 = 0x050182A8; D_0501B370 = 0x0501B370; -D_0501B508 = 0x0501B508; D_0501BEE0 = 0x0501BEE0; D_0501BFB8 = 0x0501BFB8; D_0501C058 = 0x0501C058; @@ -550,25 +545,6 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// z_en_hy.c - -D_0600007C = 0x0600007C; -D_0600066C = 0x0600066C; -D_0600071C = 0x0600071C; -D_060008C0 = 0x060008C0; -D_06000AB0 = 0x06000AB0; -D_06000FDC = 0x06000FDC; -D_06001494 = 0x06001494; -D_06001908 = 0x06001908; -D_06001EE0 = 0x06001EE0; -D_06005DC4 = 0x06005DC4; -D_06005D9C = 0x06005D9C; -D_0600DED8 = 0x0600DED8; -D_0600F920 = 0x0600F920; -D_0600FC1C = 0x0600FC1C; -D_0600FEE4 = 0x0600FEE4; -D_06010330 = 0x06010330; - // ovl_Bg_Astr_Bombwall D_06002178 = 0x06002178; @@ -581,45 +557,16 @@ D_06002498 = 0x06002498; D_06000638 = 0x06000638; D_06001BD8 = 0x06001BD8; -// ovl_Bg_Breakwall - -D_06000A50 = 0x06000A50; -D_06000C98 = 0x06000C98; - // ovl_Bg_Crace_Movebg D_060003A0 = 0x060003A0; D_06000E00 = 0x06000E00; -// ovl_Bg_Dblue_Balance - -D_0600CD10 = 0x0600CD10; -D_0600CE00 = 0x0600CE00; -D_0600D110 = 0x0600D110; -D_0600D250 = 0x0600D250; - // ovl_Bg_Dblue_Elevator D_060002C8 = 0x060002C8; D_060005C4 = 0x060005C4; -// ovl_Bg_Dblue_Movebg - -D_06004848 = 0x06004848; -D_060052B8 = 0x060052B8; -D_06008778 = 0x06008778; -D_0600A528 = 0x0600A528; -D_0600CD10 = 0x0600CD10; -D_0600CE00 = 0x0600CE00; - -// ovl_Bg_Dblue_Waterfall - -D_06003250 = 0x06003250; -D_06003358 = 0x06003358; -D_06003770 = 0x06003770; -D_0600B280 = 0x0600B280; -D_0600B448 = 0x0600B448; - // ovl_Bg_Dkjail_Ivy D_06000080 = 0x06000080; @@ -633,22 +580,11 @@ D_0600D228 = 0x0600D228; D_0601C6F4 = 0x0601C6F4; D_0601C8B4 = 0x0601C8B4; -// ovl_Bg_F40_Block - -D_060043D0 = 0x060043D0; -D_06004640 = 0x06004640; - // ovl_Bg_F40_Flift D_06004038 = 0x06004038; D_06004240 = 0x06004240; -// ovl_Bg_F40_Switch - -D_06000118 = 0x06000118; -D_06000390 = 0x06000390; -D_06000438 = 0x06000438; - // ovl_Bg_F40_Swlift D_06003B08 = 0x06003B08; @@ -679,11 +615,6 @@ D_06009830 = 0x06009830; D_0600ACB8 = 0x0600ACB8; D_0600BF40 = 0x0600BF40; -// ovl_Bg_Hakugin_Switch - -D_06000268 = 0x06000268; -D_060005C8 = 0x060005C8; - // ovl_Bg_Icefloe D_060001E0 = 0x060001E0; @@ -709,14 +640,6 @@ D_06001AD8 = 0x06001AD8; D_06001E18 = 0x06001E18; D_06002358 = 0x06002358; -// ovl_Bg_Ikana_Rotaryroom - -D_06004710 = 0x06004710; -D_060048A0 = 0x060048A0; -D_06007360 = 0x06007360; -D_06007448 = 0x06007448; -D_06007B68 = 0x06007B68; - // ovl_Bg_Ikninside D_0600CC78 = 0x0600CC78; @@ -735,11 +658,6 @@ D_06012700 = 0x06012700; D_06012728 = 0x06012728; D_06012788 = 0x06012788; -// ovl_Bg_Ingate - -D_060006B0 = 0x060006B0; -D_060016DC = 0x060016DC; - // ovl_Bg_Keikoku_Saku D_06001640 = 0x06001640; @@ -761,15 +679,6 @@ D_06000798 = 0x06000798; D_06000098 = 0x06000098; -// ovl_Bg_Numa_Hana - -D_06000870 = 0x06000870; -D_06009FE0 = 0x06009FE0; -D_0600A740 = 0x0600A740; -D_0600AB88 = 0x0600AB88; -D_0600B928 = 0x0600B928; -D_0600BE58 = 0x0600BE58; - // ovl_Bg_Open_Shutter D_060003E8 = 0x060003E8; @@ -785,13 +694,6 @@ D_06002CE0 = 0x06002CE0; D_06000048 = 0x06000048; -// ovl_Bg_Spdweb - -D_06000060 = 0x06000060; -D_060011C0 = 0x060011C0; -D_060012F0 = 0x060012F0; -D_06002678 = 0x06002678; - // ovl_Bg_Spout_Fire D_06000040 = 0x06000040; @@ -838,26 +740,6 @@ D_06022118 = 0x06022118; D_060222D0 = 0x060222D0; D_06022550 = 0x06022550; -// ovl_Boss_02 - -D_060003A0 = 0x060003A0; -D_060041A0 = 0x060041A0; - -// ovl_Boss_03 - -D_06004260 = 0x06004260; -D_060042B0 = 0x060042B0; -D_060042F8 = 0x060042F8; -D_06007E50 = 0x06007E50; -D_06007EB0 = 0x06007EB0; -D_06007EC8 = 0x06007EC8; -D_060093A8 = 0x060093A8; -D_06009554 = 0x06009554; -D_060099D0 = 0x060099D0; -D_06009C14 = 0x06009C14; -D_06009CF8 = 0x06009CF8; -D_0600A6C8 = 0x0600A6C8; - // ovl_Boss_05 D_060006A4 = 0x060006A4; @@ -981,22 +863,6 @@ D_0600B5A0 = 0x0600B5A0; D_06010C40 = 0x06010C40; D_060129F0 = 0x060129F0; -// ovl_Demo_Syoten - -D_0600023C = 0x0600023C; -D_06001298 = 0x06001298; -D_06001328 = 0x06001328; -D_06001370 = 0x06001370; -D_06001448 = 0x06001448; -D_06001730 = 0x06001730; -D_060018B8 = 0x060018B8; -D_060018C0 = 0x060018C0; -D_06001DD0 = 0x06001DD0; -D_06002880 = 0x06002880; -D_06002A20 = 0x06002A20; -D_06002B88 = 0x06002B88; -D_06002B98 = 0x06002B98; - // ovl_Demo_Tre_Lgt D_06007D78 = 0x06007D78; @@ -1009,40 +875,12 @@ D_06009E70 = 0x06009E70; D_0600A0D8 = 0x0600A0D8; -// ovl_Dm_An - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Bal D_060005FC = 0x060005FC; D_06001804 = 0x06001804; D_0600A6D0 = 0x0600A6D0; -// ovl_Dm_Char01 - -D_06009928 = 0x06009928; -D_06009D70 = 0x06009D70; -D_06009E4C = 0x06009E4C; -D_0600A398 = 0x0600A398; -D_0600A5C0 = 0x0600A5C0; -D_0600A8F8 = 0x0600A8F8; -D_0600AA50 = 0x0600AA50; -D_0600AF98 = 0x0600AF98; -D_0600B1A0 = 0x0600B1A0; -D_0600DE50 = 0x0600DE50; -D_0600DF18 = 0x0600DF18; -D_0600F3C0 = 0x0600F3C0; -D_0600F768 = 0x0600F768; -D_0600FAE8 = 0x0600FAE8; -D_0600FE5C = 0x0600FE5C; -D_0600FE90 = 0x0600FE90; -D_06010C3C = 0x06010C3C; -D_06010EF0 = 0x06010EF0; -D_06010FD8 = 0x06010FD8; -D_060110B8 = 0x060110B8; - // ovl_Dm_Char02 D_0600AD68 = 0x0600AD68; @@ -1051,14 +889,6 @@ D_0600AD68 = 0x0600AD68; D_06020550 = 0x06020550; -// ovl_Dm_Char05 - -D_060001D0 = 0x060001D0; -D_060010B0 = 0x060010B0; -D_060013D0 = 0x060013D0; -D_06001E70 = 0x06001E70; -D_060042B0 = 0x060042B0; - // ovl_Dm_Char06 D_060013A8 = 0x060013A8; @@ -1076,11 +906,6 @@ D_0600E748 = 0x0600E748; D_0600005C = 0x0600005C; D_06001398 = 0x06001398; -// ovl_Dm_Gm - -D_06000E70 = 0x06000E70; -D_06012618 = 0x06012618; - // ovl_Dm_Opstage D_06000970 = 0x06000970; @@ -1112,10 +937,6 @@ D_060057D8 = 0x060057D8; D_060058C8 = 0x060058C8; D_06007238 = 0x06007238; -// ovl_Effect_En_Ice_Block - -D_06000A38 = 0x06000A38; - // ovl_Effect_Ss_D_Fire D_060098A0 = 0x060098A0; @@ -1154,21 +975,6 @@ D_06000180 = 0x06000180; D_060002A8 = 0x060002A8; D_06000F38 = 0x06000F38; -// ovl_En_Ah - -D_06009E70 = 0x06009E70; - -// ovl_En_Al - -D_0600A0D8 = 0x0600A0D8; - -// ovl_En_Am - -D_06000238 = 0x06000238; -D_0600033C = 0x0600033C; -D_06005948 = 0x06005948; -D_06005B3C = 0x06005B3C; - // ovl_En_An D_06000308 = 0x06000308; @@ -1193,11 +999,6 @@ D_060028A0 = 0x060028A0; D_06009220 = 0x06009220; D_06009D34 = 0x06009D34; -// ovl_En_Attack_Niw - -D_060000E8 = 0x060000E8; -D_06002530 = 0x06002530; - // ovl_En_Az D_06007438 = 0x06007438; @@ -1206,12 +1007,6 @@ D_06017990 = 0x06017990; D_0601ABF0 = 0x0601ABF0; D_0601AD00 = 0x0601AD00; -// ovl_En_Baba - -D_06005EF0 = 0x06005EF0; -D_06006B10 = 0x06006B10; -D_060092A0 = 0x060092A0; - // ovl_En_Bal D_060005FC = 0x060005FC; @@ -1226,16 +1021,6 @@ D_0600D530 = 0x0600D530; D_060000A0 = 0x060000A0; D_060000C8 = 0x060000C8; -// ovl_En_Bb - -D_06000184 = 0x06000184; -D_06000444 = 0x06000444; -D_06001A30 = 0x06001A30; - -// ovl_En_Bba_01 - -D_06005EF0 = 0x06005EF0; - // ovl_En_Bbfall D_06000184 = 0x06000184; @@ -1273,32 +1058,16 @@ D_06002390 = 0x06002390; D_06000A00 = 0x06000A00; D_06000D78 = 0x06000D78; -// ovl_En_Bombers - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Bombers2 D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; -// ovl_En_Bombf - -D_06000340 = 0x06000340; -D_06000408 = 0x06000408; -D_06000530 = 0x06000530; - // ovl_En_Bomjimb D_060064B8 = 0x060064B8; D_0600F82C = 0x0600F82C; -// ovl_En_Bom_Bowl_Man - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - // ovl_En_Box D_0600043C = 0x0600043C; @@ -1322,11 +1091,6 @@ D_0600C3E0 = 0x0600C3E0; D_06001000 = 0x06001000; -// ovl_En_Cne_01 - -D_060000F0 = 0x060000F0; -D_06001300 = 0x06001300; - // ovl_En_Crow D_060000F0 = 0x060000F0; @@ -1372,20 +1136,6 @@ D_0600D640 = 0x0600D640; D_06002950 = 0x06002950; -// ovl_En_Dno - -D_801C20C0 = 0x801C20C0; - -// ovl_En_Dragon - -D_06004398 = 0x06004398; -D_060048B8 = 0x060048B8; - -// ovl_En_Drs - -D_06000E70 = 0x06000E70; -D_06005A78 = 0x06005A78; - // ovl_En_Ds2n D_06008038 = 0x06008038; @@ -1437,24 +1187,11 @@ D_06003DC8 = 0x06003DC8; // ovl_En_Fishing +D_060029C0 = 0x060029C0; +D_0600007C = 0x0600007C; D_0600CFE0 = 0x0600CFE0; D_06011058 = 0x06011058; -// ovl_En_Fu_Kago - -D_060006A0 = 0x060006A0; -D_06000740 = 0x06000740; -D_060007E0 = 0x060007E0; -D_06000880 = 0x06000880; -D_06000920 = 0x06000920; -D_060009C0 = 0x060009C0; -D_060015C0 = 0x060015C0; - -// ovl_En_Fu_Mato - -D_060023D4 = 0x060023D4; -D_06002720 = 0x06002720; - // ovl_En_Ge1 D_06002B98 = 0x06002B98; @@ -1475,90 +1212,28 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Gg - -D_0600F578 = 0x0600F578; -D_0600F6C0 = 0x0600F6C0; - -// ovl_En_Gg2 - -D_0600F578 = 0x0600F578; -D_0600F6C0 = 0x0600F6C0; - -// ovl_En_Gk - -D_06006680 = 0x06006680; -D_06006688 = 0x06006688; -D_0600787C = 0x0600787C; -D_060079C0 = 0x060079C0; - -// ovl_En_Goron_Oyu - -D_06000988 = 0x06000988; - // ovl_En_Grasshopper D_06000F9C = 0x06000F9C; D_06003F00 = 0x06003F00; -// ovl_En_Guard_Nuts - -D_06002700 = 0x06002700; -D_06002848 = 0x06002848; -D_06002A08 = 0x06002A08; - // ovl_En_Hata D_060000C0 = 0x060000C0; D_06000444 = 0x06000444; D_06002FD0 = 0x06002FD0; -// ovl_En_Heishi - -D_06003BFC = 0x06003BFC; -D_0600D640 = 0x0600D640; - // ovl_En_Hgo D_0600B644 = 0x0600B644; D_0600F248 = 0x0600F248; D_06012A58 = 0x06012A58; -// ovl_En_Hidden_Nuts - -D_060023B8 = 0x060023B8; -D_060024CC = 0x060024CC; - -// ovl_En_Horse - -D_06008C68 = 0x06008C68; -D_0600A8DC = 0x0600A8DC; -D_0600AD08 = 0x0600AD08; -D_0600B3E0 = 0x0600B3E0; -D_0600BDE0 = 0x0600BDE0; -D_0600D178 = 0x0600D178; -D_0600D4E8 = 0x0600D4E8; -D_060150D8 = 0x060150D8; - -// ovl_En_Horse_Game_Check - -D_060013A0 = 0x060013A0; -D_060014B0 = 0x060014B0; -D_06002FB8 = 0x06002FB8; -D_06003030 = 0x06003030; -D_060030C0 = 0x060030C0; -D_06003918 = 0x06003918; - // ovl_En_Horse_Link_Child D_06002F98 = 0x06002F98; D_0600A480 = 0x0600A480; -// ovl_En_Hs - -D_060005C0 = 0x060005C0; -D_06006260 = 0x06006260; - // ovl_En_Ik D_06000CE8 = 0x06000CE8; @@ -1590,22 +1265,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Ja - -D_0600BA30 = 0x0600BA30; -D_0600BCC8 = 0x0600BCC8; -D_0600C240 = 0x0600C240; - -// ovl_En_Jg - -D_0601ADC0 = 0x0601ADC0; -D_0601AFF0 = 0x0601AFF0; - -// ovl_En_Jgame_Tsn - -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Js D_06010880 = 0x06010880; @@ -1636,26 +1295,6 @@ D_0600D828 = 0x0600D828; D_06000C30 = 0x06000C30; D_06001630 = 0x06001630; -// ovl_En_Karebaba - -D_060002B8 = 0x060002B8; -D_060010F0 = 0x060010F0; -D_06001828 = 0x06001828; -D_06002A40 = 0x06002A40; -D_06003070 = 0x06003070; - -// ovl_En_Kbt - -D_06004274 = 0x06004274; -D_0600DEE8 = 0x0600DEE8; - -// ovl_En_Kendo_Js - -D_0600016C = 0x0600016C; -D_060003DC = 0x060003DC; -D_06000F4C = 0x06000F4C; -D_06006990 = 0x06006990; - // ovl_En_Kitan D_06000CE8 = 0x06000CE8; @@ -1722,36 +1361,11 @@ D_06021E34 = 0x06021E34; D_06022728 = 0x06022728; D_06022CAC = 0x06022CAC; -// ovl_En_Kujiya - -D_06002A80 = 0x06002A80; -D_06003030 = 0x06003030; -D_06003248 = 0x06003248; -D_06003358 = 0x06003358; -D_060034A8 = 0x060034A8; -D_060035B8 = 0x060035B8; -D_060036B0 = 0x060036B0; -D_060037C0 = 0x060037C0; -D_06003C80 = 0x06003C80; -D_06003D58 = 0x06003D58; -D_06006198 = 0x06006198; - -// ovl_En_Kusa - -D_06000140 = 0x06000140; -D_060002E0 = 0x060002E0; - // ovl_En_Lift_Nuts D_060029E8 = 0x060029E8; D_0600AC70 = 0x0600AC70; -// ovl_En_Look_Nuts - -D_06000430 = 0x06000430; -D_06002848 = 0x06002848; -D_06002B6C = 0x06002B6C; - // ovl_En_Mag D_06000000 = 0x06000000; @@ -1763,20 +1377,6 @@ D_06011740 = 0x06011740; D_06011BC0 = 0x06011BC0; D_06011E48 = 0x06011E48; -// ovl_En_Maruta - -D_06002EC0 = 0x06002EC0; - -// ovl_En_Mk - -D_06001C38 = 0x06001C38; -D_06006CA0 = 0x06006CA0; - -// ovl_En_Mm3 - -D_060096E8 = 0x060096E8; -D_0600A4E0 = 0x0600A4E0; - // ovl_En_Mnk D_06003584 = 0x06003584; @@ -1818,15 +1418,6 @@ D_06003EE4 = 0x06003EE4; D_06004204 = 0x06004204; D_0600466C = 0x0600466C; -// ovl_En_Osk - -D_060000B8 = 0x060000B8; -D_060038F0 = 0x060038F0; -D_06006808 = 0x06006808; -D_06007B48 = 0x06007B48; -D_06009F00 = 0x06009F00; -D_0600B490 = 0x0600B490; - // ovl_En_Osn D_060192A0 = 0x060192A0; @@ -1851,32 +1442,16 @@ D_06009930 = 0x06009930; D_0600A844 = 0x0600A844; D_06012768 = 0x06012768; -// ovl_En_Pr - -D_060021E8 = 0x060021E8; -D_060038B8 = 0x060038B8; - // ovl_En_Pr2 D_06003904 = 0x06003904; D_06004188 = 0x06004188; D_06004340 = 0x06004340; -// ovl_En_Prz - -D_06004188 = 0x06004188; -D_06004340 = 0x06004340; - // ovl_En_Pst D_06001A80 = 0x06001A80; -// ovl_En_Racedog - -D_06000550 = 0x06000550; -D_06000618 = 0x06000618; -D_060080F0 = 0x060080F0; - // ovl_En_Raf D_06000108 = 0x06000108; @@ -1907,11 +1482,6 @@ D_0600D8D8 = 0x0600D8D8; D_060000F0 = 0x060000F0; D_060010C0 = 0x060010C0; -// ovl_En_Shn - -D_0600B738 = 0x0600B738; -D_0600E7D0 = 0x0600E7D0; - // ovl_En_Slime D_060004C0 = 0x060004C0; @@ -1941,11 +1511,6 @@ D_06001AA0 = 0x06001AA0; D_06000304 = 0x06000304; -// ovl_En_Sth - -D_060031F8 = 0x060031F8; -D_06005998 = 0x06005998; - // ovl_En_Sth2 D_060031F8 = 0x060031F8; @@ -1962,38 +1527,12 @@ D_0600D640 = 0x0600D640; D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_Syateki_Crow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - -// ovl_En_Syateki_Dekunuts - -D_06001E50 = 0x06001E50; -D_06002468 = 0x06002468; -D_06002A5C = 0x06002A5C; -D_06003180 = 0x06003180; - -// ovl_En_Syateki_Okuta - -D_060033D0 = 0x060033D0; -D_0600466C = 0x0600466C; - -// ovl_En_Syateki_Wf - -D_060095D0 = 0x060095D0; -D_0600A3CC = 0x0600A3CC; - // ovl_En_S_Goro D_060091A8 = 0x060091A8; D_06011AC8 = 0x06011AC8; D_06012DE0 = 0x06012DE0; -// ovl_En_Tab - -D_06007F78 = 0x06007F78; - // ovl_En_Takaraya D_06000968 = 0x06000968; @@ -2015,12 +1554,6 @@ D_06004550 = 0x06004550; D_06000168 = 0x06000168; D_06000E68 = 0x06000E68; -// ovl_En_Tanron5 - -D_06006FD0 = 0x06006FD0; -D_06007A88 = 0x06007A88; -D_06007D18 = 0x06007D18; - // ovl_En_Test3 D_0600CB60 = 0x0600CB60; @@ -2043,43 +1576,11 @@ D_06000A44 = 0x06000A44; D_0601A820 = 0x0601A820; D_0601A830 = 0x0601A830; -// ovl_En_Tru_Mt - -D_060004C8 = 0x060004C8; -D_0601AA60 = 0x0601AA60; - -// ovl_En_Tsn - -D_06000964 = 0x06000964; -D_06001198 = 0x06001198; -D_06008AB8 = 0x06008AB8; -D_060092FC = 0x060092FC; - // ovl_En_Twig D_060014C8 = 0x060014C8; D_06001C38 = 0x06001C38; -// ovl_En_Vm - -D_06000068 = 0x06000068; -D_06002728 = 0x06002728; -D_06003F60 = 0x06003F60; - -// ovl_En_Wallmas - -D_06000590 = 0x06000590; -D_06000EA4 = 0x06000EA4; -D_060019CC = 0x060019CC; -D_0600299C = 0x0600299C; -D_060041F4 = 0x060041F4; -D_06008688 = 0x06008688; -D_06008FB0 = 0x06008FB0; -D_06009244 = 0x06009244; -D_06009520 = 0x06009520; -D_06009DB0 = 0x06009DB0; -D_0600A054 = 0x0600A054; - // ovl_En_Wdhand D_060000F4 = 0x060000F4; @@ -2105,173 +1606,46 @@ D_06001690 = 0x06001690; D_06005870 = 0x06005870; D_06005C64 = 0x06005C64; -// ovl_En_Wood02 - -D_06000700 = 0x06000700; - -// ovl_En_Yb - -D_06000200 = 0x06000200; -D_06005F48 = 0x06005F48; - // ovl_En_Zl4 D_06013328 = 0x06013328; -// ovl_En_Zob - -D_06006998 = 0x06006998; -D_06010810 = 0x06010810; - // ovl_En_Zod D_06000D94 = 0x06000D94; D_06007650 = 0x06007650; D_0600D658 = 0x0600D658; -// ovl_En_Zoraegg - -D_060005D4 = 0x060005D4; -D_06001E08 = 0x06001E08; -D_06004C90 = 0x06004C90; -D_06004D20 = 0x06004D20; -D_06004E04 = 0x06004E04; -D_06004FE4 = 0x06004FE4; -D_06005098 = 0x06005098; -D_06005250 = 0x06005250; - -// ovl_En_Zov - -D_0600D3EC = 0x0600D3EC; -D_06016258 = 0x06016258; - -// ovl_En_Zow - -D_060029F0 = 0x060029F0; -D_06002A50 = 0x06002A50; -D_06002BA0 = 0x06002BA0; -D_06002C10 = 0x06002C10; -D_06003610 = 0x06003610; -D_06004248 = 0x06004248; -D_0600D208 = 0x0600D208; -D_0600D220 = 0x0600D220; -D_0600D288 = 0x0600D288; - -// ovl_Mir_Ray - -D_06000168 = 0x06000168; -D_060003F8 = 0x060003F8; -D_060004B0 = 0x060004B0; - // ovl_Mir_Ray3 D_06000168 = 0x06000168; D_060003F8 = 0x060003F8; D_060004B0 = 0x060004B0; -// ovl_Obj_Armos - -D_0600033C = 0x0600033C; -D_06005948 = 0x06005948; -D_06005CF8 = 0x06005CF8; - -// ovl_Obj_Bigicicle - -D_060009B0 = 0x060009B0; -D_060014F0 = 0x060014F0; - // ovl_Obj_Boat D_06007630 = 0x06007630; D_06009A88 = 0x06009A88; -// ovl_Obj_Bombiwa - -D_060009E0 = 0x060009E0; -D_06000AF0 = 0x06000AF0; -D_06004560 = 0x06004560; -D_06004688 = 0x06004688; -D_06005990 = 0x06005990; - -// ovl_Obj_Chan - -D_06000A10 = 0x06000A10; -D_06000AF0 = 0x06000AF0; -D_06001960 = 0x06001960; -D_06002358 = 0x06002358; - // ovl_Obj_Chikuwa D_06000D10 = 0x06000D10; D_06000F00 = 0x06000F00; -// ovl_Obj_Comb - -D_06000CB0 = 0x06000CB0; -D_06001040 = 0x06001040; - // ovl_Obj_Danpeilift D_06000180 = 0x06000180; D_06000BA0 = 0x06000BA0; -// ovl_Obj_Dhouse - -D_06004928 = 0x06004928; -D_06005A78 = 0x06005A78; -D_06008040 = 0x06008040; -D_060081D8 = 0x060081D8; - // ovl_Obj_Dora D_06003FD0 = 0x06003FD0; D_06004160 = 0x06004160; -// ovl_Obj_Driftice - -D_060016A0 = 0x060016A0; -D_06001AA8 = 0x06001AA8; - -// ovl_Obj_Entotu - -D_06000158 = 0x06000158; -D_06001C00 = 0x06001C00; - -// ovl_Obj_Hakaisi - -D_06001F10 = 0x06001F10; -D_060021B0 = 0x060021B0; -D_06002650 = 0x06002650; -D_060029C0 = 0x060029C0; -D_06002CC0 = 0x06002CC0; -D_06002FC4 = 0x06002FC4; - -// ovl_Obj_Hariko - -D_06000080 = 0x06000080; -D_06000110 = 0x06000110; - -// ovl_Obj_Hunsui - -D_06000220 = 0x06000220; -D_06000BF0 = 0x06000BF0; -D_06000C74 = 0x06000C74; -D_06000EC0 = 0x06000EC0; -D_06001888 = 0x06001888; - // ovl_Obj_Jgame_Light D_060003A0 = 0x060003A0; -// ovl_Obj_Jg_Gakki - -D_0601B1E8 = 0x0601B1E8; -D_0601B210 = 0x0601B210; - -// ovl_Obj_Kendo_Kanban - -D_06000180 = 0x06000180; - // ovl_Obj_Lift D_06000D10 = 0x06000D10; @@ -2302,19 +1676,6 @@ D_060048D0 = 0x060048D0; D_060011E0 = 0x060011E0; -// ovl_Obj_Smork - -D_06001C00 = 0x06001C00; - -// ovl_Obj_Snowball2 - -D_06008B90 = 0x06008B90; - -// ovl_Obj_Spinyroll - -D_06000460 = 0x06000460; -D_06000E68 = 0x06000E68; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; @@ -2359,21 +1720,11 @@ D_06000098 = 0x06000098; D_06000838 = 0x06000838; D_060022AC = 0x060022AC; -// ovl_Obj_Vspinyroll - -D_06000460 = 0x06000460; -D_06000F80 = 0x06000F80; - // ovl_Obj_Y2lift D_06001680 = 0x06001680; D_060019B0 = 0x060019B0; -// ovl_Obj_Yasi - -D_06000360 = 0x06000360; -D_06001428 = 0x06001428; - // ovl_player_actor D_06008860 = 0x06008860;